bugGNU Octave - Bugs: bug #49232, Complex pinv giving incorrect...


bug #49232: Complex pinv giving incorrect results

Submitted by:  Ceral Paquet <octavebugs>
Submitted on:  Fri 30 Sep 2016 04:33:50 PM UTC  
Category:  Libraries Severity:  5 - Blocker
Priority:  5 - Normal Item Group:  Regression
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  Closed
Release:  4.2.0-rc2 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.


( Jump to the original submission)

Thu 06 Oct 2016 06:28:25 AM UTC, comment #8: 

Sorry for the noise (svd.cc not having changed). Seems that my tortoise-hg misled me here...

Thanks for the patch.

Hartmut <hardy>
Thu 06 Oct 2016 03:41:26 AM UTC, comment #7: 

I checked in the following changeset:


Closing report as fixed.

John W. Eaton <jwe>
Project Administrator
Thu 06 Oct 2016 03:05:28 AM UTC, comment #6: 

Hartmut, are you sure you are looking at the 4.0.3 sources?  In that version, there are four *SVD.cc files, one each for float, float complex, double, and double complex.  In the complex versions, hermitian was used.  This looks like a problem that I introduced when I converted these to use templates.  Always using hermitian should be fine in the new template version.

John W. Eaton <jwe>
Project Administrator
Wed 05 Oct 2016 09:45:12 PM UTC, comment #5: 

So why did this work correctly in Octave-4.0.3? This older version has the very same two lines of code, using "transpose()", doesn't it?

Has the functionality of "transpose" changed inbetween Octave 4.0.3 and 4.2.0-rc2? Could this have even wider effects?

Hartmut <hardy>
Wed 05 Oct 2016 08:00:46 PM UTC, comment #4: 

In ./octave-4.2.0-rc2/liboctave/numeric/svd.cc

Line 401-402:

      if (! (jobv == 'N' || jobv == 'O'))
        right_sm = right_sm.transpose ();

Replace with:

      if (! (jobv == 'N' || jobv == 'O'))
        right_sm = right_sm.hermitian ();

That seems to fix it.

Ceral Paquet <octavebugs>
Wed 05 Oct 2016 07:26:45 PM UTC, comment #3: 

It looks like the root cause is that V is being wrongly conjugated in svd in Octave.

[U S V] = svd(A);


>> U * S * conj(V)'

ans =

   1.00000000000000 + 5.00000000000000i   2.00000000000000 + 6.00000000000000i
   3.00000000000000 + 7.00000000000000i   4.00000000000000 + 8.00000000000000i


>> U * S * V'

ans =

  0.999999999999999 + 5.000000000000000i  1.999999999999999 + 6.000000000000004i
  2.999999999999998 + 7.000000000000000i  3.999999999999998 + 8.000000000000002i

Ceral Paquet <octavebugs>
Fri 30 Sep 2016 10:09:51 PM UTC, comment #2: 

I can confirm the results in the original submission. With 4.0.3 I get the first answer (only 0.5s) twice. With 4.2.0-rc2 I get the incorrect second answer for the pinv command. My compilation was on Ubuntu 14.04 with standard options (only --disable-docs).

Hartmut <hardy>
Fri 30 Sep 2016 06:29:46 PM UTC, comment #1: 

Compiled it again with ./configure and I get the same result.

Ceral Paquet <octavebugs>
Fri 30 Sep 2016 04:33:50 PM UTC, original submission:  

I just compiled 4.2-rc2 with enable-64 and OpenBLAS-0.2.16

./configure LD_LIBRARY_PATH=/opt/OpenBLAS/lib CPPFLAGS=-I/opt/OpenBLAS/include LDFLAGS=-L/opt/OpenBLAS/lib --enable-64

It seems that complex svd is broken.

>> A=[1 2;3 4]+i*[5 6;7 8];
>> b=[1;1];
>> A\b

ans =

  -0.50000 + 0.50000i
   0.50000 - 0.50000i

>> pinv(A)*b

ans =

  -0.50000 + 0.50000i
   0.41415 - 0.57313i

Sorry I haven't had a chance to recompile with other setups but this was all working under Octave 4.0.1... which I unfortunately deleted after 4.2 compiled.

Ceral Paquet <octavebugs>


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

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by hardy (Posted a comment)
  • -email is unavailable- added by octavebugs (Submitted the item)

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

    Only project members can vote.




    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-10-06 jwe StatusNone => Fixed
        Open/ClosedOpen => Closed
    2016-10-06 jwe CategoryNone => Libraries
        Severity3 - Normal => 5 - Blocker
        Item GroupNone => Regression

    Back to the top

    Powered by Savane 3.5