bugGNU Octave - Bugs: bug #30847, Matrix transpose bug

 
 

bug #30847: Matrix transpose bug

Submitted by:  None
Submitted on:  Mon 23 Aug 2010 09:10:40 AM UTC  
 
Category: InterpreterSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Incorrect Result
Status: FixedAssigned to: Jaroslav Hajek <highegg>
Originator Name: Hannes NickischOriginator Email: -unavailable-
Open/Closed: ClosedRelease: 3.2.4
Operating System: GNU/Linux

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Mon 23 Aug 2010 09:16:56 AM UTC, comment #1:

This has been already fixed earlier this year:
http://hg.savannah.gnu.org/hgweb/octave/rev/4217a5402b7e

see

http://octave.1599824.n4.nabble.com/objecets-vs-compound-transpose-and-multiply-ops-td1658871.html#a1658871

Jaroslav Hajek <highegg>In charge of this item.
Mon 23 Aug 2010 09:10:40 AM UTC, original submission:

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.matx; end

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by highegg (Posted a comment)
  • -unavailable- added by None (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 4 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Mon 23 Aug 2010 09:16:56 AM UTChigheggCategoryNone=>Interpreter
      StatusNone=>Fixed
      Assigned toNone=>highegg
      Open/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1