octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #30847] Matrix transpose bug


From: anonymous
Subject: [Octave-bug-tracker] [bug #30847] Matrix transpose bug
Date: Mon, 23 Aug 2010 09:10:41 +0000
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.9pre) Gecko/20100822 Ubuntu/8.04 (hardy) Namoroka/3.6.9pre

URL:
  <http://savannah.gnu.org/bugs/?30847>

                 Summary: Matrix transpose bug
                 Project: GNU Octave
            Submitted by: None
            Submitted on: Mon 23 Aug 2010 09:10:40 AM UTC
                Category: None
                Severity: 3 - Normal
              Item Group: Incorrect Result
                  Status: None
             Assigned to: None
         Originator Name: Hannes Nickisch
        Originator Email: address@hidden
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 3.2.4
        Operating System: GNU/Linux

    _______________________________________________________

Details:

First of all, let me express my gratitude and respect for making Octave a
true "Matlab challenger".

I'm using version 3.2.4 on i686-pc-linux-gnu. I have some numerical code that
should run for dense and sparse matrices as well as for linear operators
specified through the Octave OOP facilities. The matrix class 'mat' [2] does
not properly handle the overloaded transpose operator.

The code calling the 'mat' class [2]
m = 3; n = 5; A = mat(m,n); y = randn(m,1);
z1 = [A']*y; % => OK
z2 = (A')*y; % => error [1]
z3 = A'*y;   % => error [1]

yields the error [1] on Octave but works fine for Matlab. Only putting []
around the transposed operator seems to work.

Thanks for you help
Hannes Nickisch


[1]
error: T& Array<T>::checkelem (2): range error
error: called from:
error: mat_bug.m at line 3, column 4


[2]
The matrix class consists of 4 files located in @mat:

1) mat.m
  function A = mat(m,n)
  sz = [m,n];
  A.mat = randn(sz);
  A.sz = sz; A.ctransp = 0;
  A = class(A,mfilename);

2) size.m
  function [sz1,sz2] = size(A,id)
  sz = A.sz; if A.ctransp, sz = sz([2,1]); end
  if nargin==1
    if nargout==2, sz1 = sz(1); sz2 = sz(2); else sz1 = sz; end
  elseif nargin==2
    if nargout>1, error('too many output arguments'), end
    if id(1)>numel(sz), sz1 = 1; else sz1 = sz(id); end
  else
    error('wrong number of input arguments')
  end

3) ctranspose.m
  function A = ctranspose(A), A.ctransp = xor(A.ctransp,1);

4) mtimes.m
  function y = mtimes(A,x), if A.ctransp, y = A.mat'*x; else y = A.mat*x; end





    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?30847>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]