bugGNU Octave - Bugs: bug #29997, legendre can not process column...

 
 

bug #29997: legendre can not process column vectors

Submitted by:  Qianqian Fang <fangq>
Submitted on:  Sun 30 May 2010 06:28:27 PM UTC  
 
Category: InterpreterSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Incorrect Result
Status: FixedAssigned to: None
Originator Name: Qianqian FangOpen/Closed: Closed
Release: devOperating 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 31 May 2010 09:40:34 PM UTC, comment #2:

Thanks for catching this. I patched the dev code (changeset 10672:1cd7c39a96ee).

I used

if (rows (x) != 1)
x = x';
endif

which avoids reshaping the vector when it is unnecessary.

Incidentally,
x' is complex conjugate transpose
x.' is transpose

I used the more familiar transpose since x is guaranteed to be real thanks to the validation checks at the start of the code.

Rik <rik5>
Project Administrator
Sun 30 May 2010 06:50:15 PM UTC, comment #1:

patch revised. Add fix to an additional issue: Legendre Polynomial is only defined for real x. However, the
if (! isvector (x) || any (x < -1 || x > 1))
statement does not catch complex inputs, it was changed to
if (! isvector (x) || !isreal(x) || any (x < -1 || x > 1))

the x=x(:)' statement was changed to
x=reshape(x(:),1,prod(size(x)));
since it does not make x conjugate when x is complex, although combined with the above fix, it should not an issue anymore, but still look more robust.

(file #20656)

Qianqian Fang <fangq>
Sun 30 May 2010 06:28:27 PM UTC, original submission:

when giving a column vector to legendre(), it will raise a "nonconformant" error and quit, like this:

octave:6> dat=legendre(1,cos((0:10)'))
error: product: nonconformant arguments (op1 is 11x1, op2 is 1x11)
error: called from:
error: octave/scripts/specfun/legendre.m at line 156, column 10

Matlab legendre() can handle vertical vectors, which yields identical solutions to a row vector.

The following simple patch enables octave to do the same.

Qianqian Fang <fangq>

 

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

Attach File(s):
   
   
Comment:
   

Attached Files
file #20656:  legendre_column_vector.patch added by fangq (571B - text/x-patch - Restrict legendre to real numbers, transpose column vectors to row vectors)
file #20655:  legendre_column_vector.patch added by fangq (358B - text/x-patch - patch to allow )

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by rik5 (Posted a comment)
  • -unavailable- added by fangq (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 31 May 2010 09:40:34 PM UTCrik5StatusNone=>Fixed
      Open/ClosedOpen=>Closed
    Sun 30 May 2010 06:50:15 PM UTCfangqAttached File-=>Added legendre_column_vector.patch, #20656
    Sun 30 May 2010 06:28:27 PM UTCfangqAttached File-=>Added legendre_column_vector.patch, #20655

    Back to the top


    Powered by Savane 3.1-cleanup1