bugGNU Octave - Bugs: bug #48807, gsvd function needs matlab...

 
 

bug #48807: gsvd function needs matlab compatible interface

Submitter:  Rik <rik5>
Submitted:  Wed 17 Aug 2016 03:25:07 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Confirmed Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Mon 24 Oct 2016 08:20:29 PM UTC, comment #27: 

I connected the templated code for gsvd in liboctave to the gsvd function in libinterp/corefcn so that inputs of single type will now call the appropriate code in liboctave and return a FloatMatrix or FloatComplexMatrix (http://hg.savannah.gnu.org/hgweb/octave/rev/f1bb2f0bcfec).

I removed the warning about using matrices of single type since it is okay now, and also added BIST tests to check this.

There is still the principal problem that the outputs produced by liboctave need to be manipulated before they produce Matlab compatible results.  That manipulation can either be in liboctave, or in libinterp/corefcn/gsvd.cc.

Rik <rik5>
Group administrator
Wed 05 Oct 2016 03:24:06 PM UTC, comment #26: 

Thanks, I had to run "make maintainer-clean".

Guillaume <gyom>
Wed 05 Oct 2016 02:36:46 PM UTC, comment #25: 

I had to re-clone

Dmitri.




Dmitri A. Sergatskov <dasergatskov>
Wed 05 Oct 2016 10:34:48 AM UTC, comment #24: 

Compiling with the current tip (e22906126af5), I get this error:


libinterp/.libs/liboctinterp.so: undefined reference to `Fgsvd(octave_value_list const&, int)'


Do I have to do something extra for a successful compilation?

Guillaume <gyom>
Tue 04 Oct 2016 06:20:41 PM UTC, comment #23: 

All done. I updated the list of unimplemented and merged to stable again. I also moved gsvd in the default branch to a new section of the NEWS file.

Carnë Draug <carandraug>
Group Member
Mon 03 Oct 2016 07:57:58 PM UTC, comment #22: 

@Carnë: Could you do a merge of stable on to default?  I just tried to do that to pick up a bunch of patches for gnuplot, but Mercurial wanted to delete gsvd on the default branch which was confusing.

Rik <rik5>
Group administrator
Mon 03 Oct 2016 07:29:14 PM UTC, comment #21: 

No, just the unimplemented list.  The spellchecker exception is so minor we can just leave it be.

Rik <rik5>
Group administrator
Mon 03 Oct 2016 06:40:15 PM UTC, comment #20: 


> In this case, we don't have gsvd in Octave or in Octave Forge anymore.


The linear-algebra package hasn't been released in more than a year. The last release still has gsvd.  Still, I reverted the removal of the function http://hg.code.sf.net/p/octave/linear-algebra

> There are still bits of gsvd left on the stable branch that need to be cleaned up. Also, it should go back on to the unimplemented list.


I can put it back on the unimplemented list. About the other bits left behind, I only see the exception to the spellchecker. Are you referring to that or am I missing something else?

Carnë Draug <carandraug>
Group Member
Sun 02 Oct 2016 03:40:23 PM UTC, comment #19: 

I pushed a cset on the dev branch that prepares the gsvd function for implementation.  It updates the docstring to refer to the API that will be implemented, not the existing one.  I added input validation for a third input, for when "economy-sized" decompositions are implemented.  The code was very old in using the deprecated error_state variable so I got rid of that in favor of the new xmatrix_value call.  I added FIXME notes where more work has to be done.  For example, I added a warning if the user has inputs of type single.  Eventually that part of the code can be deleted when the connection to the single gsvd class is made.  I added a simple BIST test taken from the examples in the Matlab documentation.  All of the BIST tests are now tagged with the 48807 bug number so they won't cause failures to show up in 'make check'.  See http://hg.savannah.gnu.org/hgweb/octave/rev/98eeed41f372.

Rik <rik5>
Group administrator
Sun 02 Oct 2016 03:32:10 PM UTC, comment #18: 

Re-titling report back to the original issue which is that the results are not Matlab compatible.

Rik <rik5>
Group administrator
Sun 02 Oct 2016 01:11:39 AM UTC, comment #17: 

I don't think it's necessary to remove gsvd, as I stated.  It's better in my opinion to have 75% of something rather than 100% of nothing.  In this case, we don't have gsvd in Octave or in Octave Forge anymore.

But if you're keen to keep it in development for another cycle, okay.  There are still bits of gsvd left on the stable branch that need to be cleaned up.  Also, it should go back on to the unimplemented list.


Rik <rik5>
Group administrator
Sat 01 Oct 2016 10:59:16 PM UTC, comment #16: 

Yes, it is usable but this is not the right fix. I think that if we didn't had the incomplete gsvd already in the repository and someone submitted as it is, we wouldn't accept it and would ask the submitter to do it correctly without those issues. But we still don't have to accept it. gsvd has not been released in any Octave version yet so we can just revert the changes and do it properly later.

This was my mistake, I should have tested gsvd better and check Matlab compatibility before merging. If it was not in the repo, and I were to add it now to core in this state, would it really be accepted?

Carnë Draug <carandraug>
Group Member
Sat 01 Oct 2016 07:46:12 PM UTC, comment #15: 

The example cases and reference results in comments #6 and #7 above can be used for updated BISTs.

Nir Krakauer <nir_krakauer>
Sat 01 Oct 2016 07:29:10 PM UTC, comment #14: 

I also think like Rik that gsvd should not be removed.

The double/single issue can be treated with input validation until a proper fix will be made. But the commented out BISTs should be fixed before 4.2 release.

Avinoam Kalma <avinoam>
Group Member
Sat 01 Oct 2016 04:29:03 PM UTC, comment #13: 

Why remove it?  I think it's usable as is.  The difference between single and double is something that could be taken care of in a bug fix release, 4.2.1.  Or just add an input validation check to the m-file that emits an error if any of the inputs is single.

As for testing, the m-file approach passes the examples listed in the Matlab documentation.  That's at least 4 tests.

I don't think anyone is going to start picking up the gsvd C++ code right away.  In fact, I'm not sure that anybody really builds their own applications that link directly to liboctave, even though we have made it a possibility.

Rik <rik5>
Group administrator
Sat 01 Oct 2016 04:17:20 PM UTC, comment #12: 

Three issues with this m-file wrapper:

1. the function still does not work properly if matrices are of class single (it's converting to double behind the scenes and returning the double).
2. there is still no tests to check that this fix actually fixes the issue.
3. the right fix would be in gsvd c++ class. If we delay the fix for 4.4, we will then have to deal with backwards compatibility on the gsvd class.

No one has been asking for this function, we just thought it would be a quick exercise for Barbara during GSOC so I don't think there's a big issue with delaying it until release 4.4 when it's done properly.

Now that default was merged into stable, I'm revertinf the m-file change on stable, merge that to default, and then removed gsvd completely for the 4.2 release.

Carnë Draug <carandraug>
Group Member
Wed 28 Sep 2016 06:50:20 PM UTC, comment #11: 

I wrote an m-file wrapper for the C++ gsvd function so that it returns Matlab-compatible results (except for ordering of singular values which I wasn't too worried about).  See this cset http://hg.savannah.gnu.org/hgweb/octave/rev/73a85c6cacd1.

Ideally, we need someone to translate the m-file hack into C++ code after the 4.2.0 release.  Also, I commented out all of the BIST tests since they were based on the old behavior.  Those need to be updated too.

The good news, though, is that 4.2.0 release can happen with gsvd included.

Rik <rik5>
Group administrator
Mon 26 Sep 2016 09:59:24 PM UTC, comment #10: 

though if we remove gsvd, it should be restored to the linear-algebra package version intended for 4.2

Nir Krakauer <nir_krakauer>
Mon 26 Sep 2016 07:11:26 PM UTC, comment #9: 

I think jwe is going to release from the development branch, and then merge dev to stable.  Given that, it would be best to remove it from the development branch and then reverse that after the release.

Rik <rik5>
Group administrator
Mon 26 Sep 2016 06:47:14 PM UTC, comment #8: 

How are we dealing with this for the next release? I can push a commit that removes this code on the default branch and then revert it once 4.2 has been released. Or if the default branch is merged into stable for the release candidates, this could be undone only on the stable branch.

Carnë Draug <carandraug>
Group Member
Sun 11 Sep 2016 10:33:32 PM UTC, comment #7: 

I won’t have time for it, I am overwhelmed with school.
Here is the result of Nir’s test cases in Matlab R2016a:



U =

    0.3543   -0.0173   -0.2850    0.0600   -0.8885
    0.2046    0.7223   -0.2563    0.5788    0.1888
   -0.1743    0.3803   -0.5843   -0.6925    0.0638
   -0.7213   -0.2709   -0.4691    0.4190   -0.1036
    0.5310   -0.5099   -0.5400    0.0789    0.4002


V =

   -0.0970   -0.3533   -0.9305
   -0.3868    0.8748   -0.2918
    0.9171    0.3316   -0.2215


X =

   -0.1910   -0.9067  -14.2176
   -1.5229    4.4906   -8.9171
    7.2221    3.4042  -13.5371


C =

    0.8614         0         0
         0    0.9210         0
         0         0    0.9979
         0         0         0
         0         0         0


S =

    0.5079         0         0
         0    0.3896         0
         0         0    0.0654


U =

    0.3360   -0.2309   -0.2020    0.0600   -0.8885
    0.4064    0.4572   -0.5051    0.5788    0.1888
   -0.0529    0.1163   -0.7071   -0.6925    0.0638
   -0.7657   -0.2534   -0.4041    0.4190   -0.1036
    0.3645   -0.8123   -0.2020    0.0789    0.4002


V =

   -0.1721   -0.9851         0
         0         0   -1.0000
    0.9851   -0.1721         0


X =

   -0.3491   -6.9642  -12.4249
    0.0000   -0.0000   -9.8995
    7.9914   -4.8681  -12.6269


C =

    0.8700         0         0
         0    0.9899         0
         0         0    1.0000
         0         0         0
         0         0         0


S =

    0.4931         0         0
         0    0.1414         0
         0         0         0


U =

    0.9423    0.0959    0.2797    0.1523    0.0381
   -0.0552   -0.6561    0.2234    0.1693    0.6985
   -0.0226   -0.4322    0.5711   -0.5206   -0.4643
   -0.2644    0.0638    0.4914    0.7693   -0.3046
   -0.1965    0.6078    0.5516   -0.2922    0.4498


V =

   -0.4082    0.0997    0.9074
    0.4082   -0.8691    0.2791
    0.8165    0.4844    0.3141


X =

   -0.4082    0.2843   14.2391
    0.8165   -4.9584    8.7606
    3.2660    5.5270   19.7176


C =

    0.0000         0         0
         0    0.9365         0
         0         0    0.9980
         0         0         0
         0         0         0


S =

    1.0000         0         0
         0    0.3506         0
         0         0    0.0637


U =

    0.9459    0.2159   -0.2020    0.0410    0.1270
   -0.0991   -0.4746   -0.5051    0.1126    0.7051
   -0.0357   -0.1139   -0.7071   -0.4719   -0.5129
   -0.1539    0.2869   -0.4041    0.8179   -0.2485
   -0.2654    0.7955   -0.2020   -0.3065    0.4024


V =

   -0.4472    0.8944         0
         0         0    1.0000
    0.8944    0.4472         0


X =

   -0.4472    6.9586  -12.4249
    0.0000   -0.0000   -9.8995
    3.5777   13.9172  -14.9503


C =

    0.0000         0         0
         0    0.9917         0
         0         0    1.0000
         0         0         0
         0         0         0


S =

    1.0000         0         0
         0    0.1285         0
         0         0         0


U =

    0.7739    0.3779    0.5082
    0.1992   -0.9070    0.3711
   -0.6011    0.1860    0.7772


V =

   -0.1405         0   -0.1032    0.5726    0.8011
   -0.0050    0.2483   -0.4079   -0.7392    0.4750
    0.1911   -0.5776    0.6363   -0.3236    0.3468
   -0.3115    0.6916    0.6431   -0.0701    0.0783
    0.9201    0.3555    0.0676    0.1269    0.0794


X =

   -0.1405         0   -0.1527    0.9947    7.4811
   -0.0101    0.4965   -1.2074   -2.5678    8.8714
    0.7644   -2.3106    3.7667   -2.2483   12.9551
   -2.4921    5.5330    7.6142   -0.9747    5.8523
   14.7223    5.6875    1.6004    3.5255   11.8707


C =

         0         0    0.7372         0         0
         0         0         0    0.8177         0
         0         0         0         0    0.9943


S =

    1.0000         0         0         0         0
         0    1.0000         0         0         0
         0         0    0.6757         0         0
         0         0         0    0.5757         0
         0         0         0         0    0.1071


U =

    0.6014   -0.7279    0.3293
    0.5054    0.6658    0.5488
   -0.6188   -0.1636    0.7683


V =

    0.1405         0   -0.2595   -0.9555    0.0000
    0.0000   -0.0000   -0.0000    0.0000    1.0000
   -0.1919   -0.5963    0.7446   -0.2305    0.0000
    0.3124    0.7140    0.6148   -0.1210    0.0000
   -0.9197    0.3670    0.0139   -0.1390    0.0000


X =

    0.1405         0   -0.3937   -2.7342    7.0249
   -0.0000    0.0000    0.0000   -0.0000    9.1104
   -0.7675   -2.3852    4.5195   -2.6379   12.6229
    2.4995    5.7118    7.4628   -2.7705    5.2687
  -14.7149    5.8713    0.3366   -6.3658   10.6471


C =

         0         0    0.7521         0         0
         0         0         0    0.9370         0
         0         0         0         0    1.0000


S =

    1.0000         0         0         0         0
         0    1.0000         0         0         0
         0         0    0.6591         0         0
         0         0         0    0.3495         0
         0         0         0         0    0.0000


U =

   -0.8165   -0.1587    0.5551
    0.4082   -0.8386    0.3607
    0.4082    0.5211    0.7495


V =

         0         0   -0.3748    0.3498    0.8586
   -0.1524    0.2224   -0.2735   -0.8907    0.2434
    0.4535   -0.3630    0.6610   -0.2630    0.3956
   -0.8643   -0.0672    0.4612    0.0400    0.1850
    0.1557    0.9023    0.3677    0.1167    0.1129


X =

         0         0   -0.3748    0.8864    7.4882
   -0.3047    0.4449   -0.5470   -4.5144    4.2462
    1.8139   -1.4521    2.6438   -2.6665   13.8022
   -6.9140   -0.5374    3.6898    0.8113   12.9087
    2.4905   14.4375    5.8825    4.7323   15.7593


C =

         0         0    0.0000         0         0
         0         0         0    0.9189         0
         0         0         0         0    0.9934


S =

    1.0000         0         0         0         0
         0    1.0000         0         0         0
         0         0    1.0000         0         0
         0         0         0    0.3946         0
         0         0         0         0    0.1147


U =

    0.8165    0.2760   -0.5071
   -0.4082   -0.3450   -0.8452
   -0.4082    0.8971   -0.1690


V =

   -0.3909         0         0    0.9204   -0.0000
         0   -0.0000    0.0000    0.0000    1.0000
    0.7354    0.0778   -0.5963    0.3123    0.0000
    0.4451   -0.6725    0.5602    0.1890    0.0000
    0.3290    0.7360    0.5750    0.1397    0.0000


X =

   -0.3909         0         0    5.8692   -4.7329
    0.0000   -0.0000   -0.0000    0.0000   -5.9161
    2.9417    0.3112   -2.3852    7.9653  -11.4941
    3.5610   -5.3802    4.4817    9.6422   -8.6206
    5.2641   11.7755    9.1994   14.2537   -8.1135


C =

         0         0    0.0000         0         0
         0         0         0    0.9876         0
         0         0         0         0    1.0000


S =

    1.0000         0         0         0         0
         0    1.0000         0         0         0
         0         0    1.0000         0         0
         0         0         0    0.1568         0
         0         0         0         0    0.0000


U =

  -0.1877 - 0.3070i   0.4753 + 0.0466i  -0.2641 - 0.3132i  -0.0933 + 0.1440i  -0.5564 + 0.3682i
   0.4052 - 0.1938i   0.3613 - 0.0659i  -0.3539 - 0.3671i   0.2043 - 0.3926i   0.4437 - 0.1032i
   0.1339 + 0.6023i   0.0137 + 0.1258i  -0.4644 - 0.1888i  -0.5334 + 0.2264i   0.0396 - 0.1208i
  -0.1375 + 0.1399i  -0.3661 - 0.2989i  -0.2937 - 0.3701i   0.5520 + 0.1651i  -0.2829 - 0.3208i
  -0.2368 - 0.4399i  -0.3615 + 0.5167i  -0.2961 - 0.0994i   0.0020 + 0.3269i   0.3798 + 0.0633i


V =

  -0.1917 - 0.7668i  -0.0732 - 0.2996i  -0.1737 - 0.4999i
   0.4058 - 0.2691i  -0.3851 - 0.3369i  -0.3257 + 0.6286i
   0.1545 - 0.3381i   0.3856 + 0.7031i  -0.4472 + 0.1369i


X =

  -6.0682 + 0.0000i  -3.5326 - 0.0184i -19.6366 + 1.7611i
   2.5130 + 0.5091i  -0.2678 - 4.0118i -17.2430 + 5.4717i
   1.7805 - 2.2304i   2.3320 + 8.8857i -17.3965 + 0.9078i


C =

    0.8435         0         0
         0    0.9330         0
         0         0    0.9939
         0         0         0
         0         0         0


S =

    0.5371         0         0
         0    0.3599         0
         0         0    0.1107


U =

  -0.1143 - 0.4457i  -0.1728 - 0.2915i  -0.2150 - 0.3906i  -0.0933 + 0.1440i  -0.5564 + 0.3682i
   0.4080 - 0.2901i  -0.1890 - 0.0185i  -0.3856 - 0.4015i   0.2043 - 0.3926i   0.4437 - 0.1032i
   0.1101 + 0.5686i   0.0087 - 0.1610i  -0.4626 - 0.2693i  -0.5334 + 0.2264i   0.0396 - 0.1208i
  -0.2493 + 0.1652i   0.2181 + 0.3975i  -0.3058 - 0.3108i   0.5520 + 0.1651i  -0.2829 - 0.3208i
  -0.1150 - 0.3155i   0.7368 - 0.2730i  -0.1184 - 0.0247i   0.0020 + 0.3269i   0.3798 + 0.0633i


V =

  -0.2105 - 0.8419i   0.3143 + 0.3849i   0.0000 - 0.0000i
   0.0000 + 0.0000i   0.0000 + 0.0000i  -0.9801 - 0.1984i
   0.3224 - 0.3782i   0.2282 - 0.8372i  -0.0000 - 0.0000i


X =

  -7.2017 + 0.0000i   6.2171 - 2.9257i -18.3733 + 1.1600i
  -0.0000 + 0.0000i  -0.0000 + 0.0000i -17.8805 + 4.7211i
   3.3570 - 2.3961i   5.8681 -10.4649i -15.3251 - 0.4278i


C =

    0.8679         0         0
         0    0.9545         0
         0         0    1.0000
         0         0         0
         0         0         0


S =

    0.4968         0         0
         0    0.2982         0
         0         0    0.0000


U =

  -0.7534 - 0.4308i   0.0808 + 0.0493i  -0.3792 - 0.2306i   0.0428 + 0.0529i  -0.1893 - 0.0201i
   0.1107 + 0.1359i   0.4536 - 0.2682i  -0.3753 - 0.2605i  -0.2151 - 0.3541i   0.3419 - 0.4407i
   0.2890 - 0.0906i   0.4701 + 0.3482i  -0.4055 + 0.1593i  -0.3018 + 0.3594i  -0.0438 + 0.3924i
   0.3374 + 0.0750i  -0.0916 - 0.0430i  -0.4884 - 0.1547i   0.7485 + 0.0605i  -0.2079 - 0.0281i
  -0.0089 - 0.0692i  -0.5920 + 0.1017i  -0.3738 + 0.0482i  -0.1147 + 0.1625i   0.6716 + 0.0414i


V =

  -0.2074 - 0.8296i  -0.0282 - 0.1129i  -0.3613 - 0.3532i
   0.2074 - 0.2074i  -0.0856 - 0.7268i  -0.0105 + 0.6151i
   0.4148 - 0.1037i  -0.4319 + 0.5142i  -0.4832 + 0.3644i


X =

  -3.5256 + 0.0000i  -1.7105 + 0.0000i -17.5087 +10.7746i
   0.8296 - 0.0000i   4.5724 - 5.7936i -12.3464 +11.9334i
   1.7628 + 0.0000i  -7.9935 + 5.7936i -22.6709 + 9.6157i


C =

    0.0000         0         0
         0    0.9599         0
         0         0    0.9949
         0         0         0
         0         0         0


S =

    1.0000         0         0
         0    0.2805         0
         0         0    0.1013


U =

  -0.7085 - 0.4745i   0.0555 + 0.0633i  -0.3202 - 0.3104i   0.0330 + 0.1017i  -0.2336 + 0.0312i
   0.0374 + 0.1179i  -0.3996 + 0.1297i  -0.4865 - 0.2707i  -0.1817 - 0.3676i   0.3694 - 0.4401i
   0.3338 - 0.0367i  -0.0207 - 0.4951i  -0.5213 - 0.1217i  -0.3354 + 0.3396i  -0.0529 + 0.3529i
   0.3545 + 0.0821i   0.1924 + 0.2137i  -0.3835 - 0.2074i   0.7379 + 0.0581i  -0.2132 - 0.0403i
   0.0024 - 0.1114i   0.6461 + 0.2659i  -0.1204 + 0.0111i  -0.1141 + 0.1783i   0.6619 + 0.0422i


V =

  -0.2169 - 0.8677i   0.1085 + 0.4339i  -0.0000 + 0.0000i
   0.0000 + 0.0000i   0.0000 - 0.0000i  -0.8765 - 0.4815i
   0.4339 - 0.1085i   0.8677 - 0.2169i   0.0000 + 0.0000i


X =

  -3.6878 + 0.0000i   9.2453 + 0.0000i -17.2242 + 6.5001i
  -0.0000 + 0.0000i  -0.0000 + 0.0000i -15.7082 + 9.7598i
   1.8439 + 0.0000i  18.4906 + 0.0000i -18.7402 + 3.2404i


C =

    0.0000         0         0
         0    0.9799         0
         0         0    1.0000
         0         0         0
         0         0         0


S =

    1.0000         0         0
         0    0.1994         0
         0         0    0.0000


U =

  -0.4786 - 0.1352i  -0.3389 - 0.5403i   0.3316 - 0.4858i
   0.7548 + 0.1801i   0.0448 - 0.0718i   0.2566 - 0.5700i
  -0.2504 - 0.2965i   0.1296 + 0.7545i   0.3886 - 0.3351i


V =

   0.0000 + 0.0000i  -0.1076 + 0.5382i  -0.1031 + 0.5155i   0.0920 - 0.4601i   0.0882 - 0.4409i
   0.1713 + 0.0300i   0.0353 + 0.4758i   0.2121 + 0.3590i   0.0168 + 0.4181i   0.2735 + 0.5643i
  -0.2368 + 0.2390i  -0.2108 - 0.2638i   0.1805 + 0.3275i  -0.2844 + 0.5136i   0.2505 - 0.4749i
   0.4171 + 0.4911i  -0.2923 - 0.1409i   0.3583 - 0.1351i  -0.2228 - 0.4277i   0.2946 + 0.1164i
  -0.3226 + 0.5808i   0.2315 + 0.4452i  -0.2709 - 0.4357i  -0.1390 + 0.0906i   0.1109 - 0.0606i


X =

   0.0000 + 0.0000i  -2.7986 + 0.0000i  -3.3268 + 0.0000i   4.3674 + 0.0000i  13.1540 + 0.0000i
   0.4627 - 0.6250i   1.9737 + 0.8106i   2.3085 - 0.1620i   3.1140 + 1.4036i  16.0867 + 0.1976i
  -1.6644 + 0.2457i  -0.0517 - 1.6874i  -0.3235 + 2.2975i  -4.8890 + 2.1928i  13.9221 - 6.5878i
   4.3188 + 3.0946i  -2.6205 - 0.5423i   3.2214 - 2.2309i  -4.8159 - 5.4329i  14.8561 + 1.9605i
  -5.7417 + 8.9709i   3.2592 + 7.3551i  -4.8380 - 8.9880i  -4.2252 + 2.3919i  10.5276 - 4.9235i


C =

         0         0    0.5922         0         0
         0         0         0    0.8366         0
         0         0         0         0    0.9847


S =

    1.0000         0         0         0         0
         0    1.0000         0         0         0
         0         0    0.8058         0         0
         0         0         0    0.5478         0
         0         0         0         0    0.1743


U =

  -0.3776 - 0.0930i  -0.0718 + 0.7062i  -0.2040 + 0.5507i
   0.6992 + 0.3049i   0.0372 - 0.1030i  -0.3277 + 0.5466i
  -0.3039 - 0.4178i   0.5083 - 0.4751i  -0.4412 + 0.2332i


V =

   0.1230 - 0.6152i   0.0000 + 0.0000i  -0.1494 + 0.7468i  -0.0319 + 0.1593i  -0.0000 + 0.0000i
   0.0000 + 0.0000i  -0.0000 + 0.0000i   0.0000 + 0.0000i   0.0000 - 0.0000i  -0.9899 - 0.1420i
   0.2693 + 0.3183i   0.3029 + 0.1581i   0.0530 + 0.2762i   0.7913 - 0.0656i   0.0000 - 0.0000i
   0.3707 + 0.1097i   0.3514 - 0.5519i   0.3408 - 0.0221i  -0.1660 + 0.5275i  -0.0000 + 0.0000i
  -0.2019 - 0.4923i   0.6602 + 0.1388i  -0.2001 - 0.4292i   0.1586 + 0.1109i   0.0000 - 0.0000i


X =

   3.1991 + 0.0000i   0.0000 + 0.0000i  -5.0400 + 0.0000i  -1.7254 + 0.0000i -13.1296 + 0.0000i
  -0.0000 - 0.0000i   0.0000 + 0.0000i  -0.0000 + 0.0000i  -0.0000 - 0.0000i -16.1467 - 0.5331i
   0.1223 + 2.0808i   0.7373 + 1.5412i  -0.7999 + 1.6403i   7.0024 + 4.3984i -12.9980 + 5.3924i
   3.1854 + 0.1363i   1.7078 - 5.1178i   3.4816 - 1.1144i  -0.5686 + 9.4815i -13.5096 - 1.6228i
  -2.7376 - 8.0783i  10.4249 + 2.8816i  -3.5990 - 9.1728i   5.0552 + 4.0262i  -9.6226 + 4.4511i


C =

         0         0    0.6375         0         0
         0         0         0    0.8772         0
         0         0         0         0    1.0000


S =

    1.0000         0         0         0         0
         0    1.0000         0         0         0
         0         0    0.7705         0         0
         0         0         0    0.4801         0
         0         0         0         0    0.0000


U =

  -0.5176 + 0.6315i  -0.0123 - 0.0869i  -0.2537 + 0.5111i
   0.2588 - 0.3157i   0.6012 - 0.4216i  -0.1468 + 0.5221i
   0.2588 - 0.3157i  -0.6258 + 0.2478i  -0.3607 + 0.5001i


V =

   0.0000 + 0.0000i  -0.1688 + 0.8438i   0.0000 + 0.0000i  -0.0106 + 0.0531i  -0.0993 + 0.4966i
  -0.1044 - 0.3616i   0.0763 + 0.3004i   0.0104 + 0.1580i   0.5134 + 0.3704i  -0.1845 - 0.5500i
   0.2510 + 0.0888i  -0.0635 - 0.3103i  -0.3138 + 0.0031i   0.6150 + 0.3289i   0.0422 + 0.4921i
   0.7749 - 0.1209i   0.2280 + 0.0100i   0.0777 + 0.3919i  -0.1377 - 0.1240i  -0.3727 - 0.0037i
  -0.3449 - 0.2312i   0.0855 - 0.0609i  -0.6890 + 0.4920i  -0.2749 - 0.0040i  -0.1158 + 0.1039i


X =

   0.0000 + 0.0000i  -4.3880 + 0.0000i   0.0000 + 0.0000i  -0.5855 + 0.0000i -15.9500 + 0.0000i
  -1.6553 - 0.3055i   1.3540 + 0.2957i   0.6528 + 0.2741i   5.3183 - 2.7831i -15.8655 - 2.2362i
   0.7377 + 1.1081i   0.6768 - 1.4317i  -1.2646 - 0.9292i   3.1237 + 6.7010i  -8.0751 +12.9379i
   5.9573 - 2.5168i   1.8439 - 0.3763i   1.4055 + 2.9796i  -2.8621 - 1.5193i -18.4586 + 4.4226i
  -5.2865 - 4.0444i   1.4284 - 0.8887i -11.5167 + 7.1825i  -9.3163 - 0.7191i -12.0886 + 9.5499i


C =

         0         0    0.0000         0         0
         0         0         0    0.8818         0
         0         0         0         0    0.9868


S =

    1.0000         0         0         0         0
         0    1.0000         0         0         0
         0         0    1.0000         0         0
         0         0         0    0.4717         0
         0         0         0         0    0.1619


U =

  -0.2068 + 0.7899i  -0.0373 + 0.0906i   0.2568 - 0.5077i
   0.1034 - 0.3949i   0.6579 + 0.1385i   0.3755 - 0.4902i
   0.1034 - 0.3949i  -0.7325 + 0.0426i   0.1381 - 0.5252i


V =

  -0.0000 + 0.0000i  -0.1794 + 0.8971i   0.0000 + 0.0000i  -0.0792 + 0.3959i   0.0000 - 0.0000i
  -0.0000 + 0.0000i   0.0000 + 0.0000i   0.0000 - 0.0000i   0.0000 - 0.0000i   0.7866 - 0.6175i
  -0.0244 - 0.4246i  -0.1237 - 0.3405i  -0.0092 - 0.1164i   0.2804 + 0.7718i  -0.0000 + 0.0000i
  -0.6944 - 0.5001i   0.1358 + 0.0481i   0.3192 + 0.1964i  -0.3077 - 0.1089i  -0.0000 - 0.0000i
  -0.2705 - 0.1173i   0.1042 + 0.0094i  -0.8709 - 0.2958i  -0.2362 - 0.0214i   0.0000 + 0.0000i


X =

  -0.0000 + 0.0000i  -4.6650 + 0.0000i   0.0000 + 0.0000i  -5.7808 + 0.0000i  14.7926 + 0.0000i
   0.0000 - 0.0000i  -0.0000 - 0.0000i  -0.0000 + 0.0000i  -0.0000 + 0.0000i  16.4948 + 2.4337i
   1.1760 - 1.7717i   0.5267 - 1.7333i   0.3124 - 0.4930i  -3.3522 +11.0313i   7.2387 -10.0264i
  -6.5550 - 2.6119i   1.1824 + 0.1129i   2.9467 + 0.9331i  -7.5253 - 0.7183i  16.9013 - 4.8420i
  -4.2103 - 2.1479i   1.6581 + 0.2553i -13.6379 - 5.6034i -10.5525 - 1.6248i   9.3786 -10.5595i


C =

         0         0    0.0000         0         0
         0         0         0    0.9345         0
         0         0         0         0    1.0000


S =

    1.0000         0         0         0         0
         0    1.0000         0         0         0
         0         0    1.0000         0         0
         0         0         0    0.3561         0
         0         0         0         0    0.0000


Barbara Lócsi <bumi>
Sun 11 Sep 2016 08:39:12 PM UTC, comment #6: 

Can someone please run the following test cases in Matlab?


A = [4 2 6; 3 5 7; 8 7 8; 7 4 1; 8 2 9];
A1 = [4 2 6; 3 5 1; 8 7 9; 7 4 10; 8 2 14];
[U, V, X, C, S] = gsvd(A, diag([1 2 4]))
[U, V, X, C, S] = gsvd(A, diag([1 0 4]))
[U, V, X, C, S] = gsvd(A1, diag([1 2 4]))
[U, V, X, C, S] = gsvd(A1, diag([1 0 4]))
[U, V, X, C, S] = gsvd(A', diag([1 2 4 8 16]))
[U, V, X, C, S] = gsvd(A', diag([1 0 4 8 16]))
[U, V, X, C, S] = gsvd(A1', diag([1 2 4 8 16]))
[U, V, X, C, S] = gsvd(A1', diag([1 0 4 8 16]))
Z = A + i*[8 8 1; 9 9 4; 1 7 5; 8 7 9; 3 1 5];
Z1 = A1 + i*[8 8 8; 9 9 9; 1 7 -5; 8 7 9; 3 1 5];
[U, V, X, C, S] = gsvd(Z, diag([1 2 4])+i*diag([4 -2 -1]))
[U, V, X, C, S] = gsvd(Z, diag([1 0 4])+i*diag([4 0 -1]))
[U, V, X, C, S] = gsvd(Z1, diag([1 2 4])+i*diag([4 -2 -1]))
[U, V, X, C, S] = gsvd(Z1, diag([1 0 4])+i*diag([4 0 -1]))
[U, V, X, C, S] = gsvd(Z', diag([1 2 4 8 16])+i*diag([-5 4 -3 2 -1]))
[U, V, X, C, S] = gsvd(Z', diag([1 0 4 8 16])+i*diag([-5 0 -3 2 -1]))
[U, V, X, C, S] = gsvd(Z1', diag([1 2 4 8 16])+i*diag([-5 4 -3 2 -1]))
[U, V, X, C, S] = gsvd(Z1', diag([1 0 4 8 16])+i*diag([-5 0 -3 2 -1]))


Nir Krakauer <nir_krakauer>
Sun 04 Sep 2016 04:55:14 PM UTC, comment #5: 

I have changed the order of the arguments to match what we would expect from Matlab (and reducing code duplication)

http://hg.savannah.gnu.org/hgweb/octave/rev/de24ca103c21

added support for float to liboctave gsvd (but did not make an interface to it on libinterp)

http://hg.savannah.gnu.org/hgweb/octave/rev/09005ac7d56c

and moved the class into the octave namespace as discussed some weeks ago on the mailing list

http://hg.savannah.gnu.org/hgweb/octave/rev/0aee8b620864

It's still needed:

  • X, C, and S must be Matlab compatible (and the tests adjusted);
  • support for class single from the Octave interpreter (with tests)


Nir or Barbara, can you do it? Without these very soon, I will remove them from the next 4.2 release.

Carnë Draug <carandraug>
Group Member
Wed 17 Aug 2016 05:14:21 PM UTC, comment #4: 

It looks like there are differences between Matlab and LAPACK in how GSVD is defined. This is alluded to vaguely in both Matlab's [1] and Octave's [2] documentation.

An interface to LAPACK's GSVD routines is good to have available, regardless of what Matlab is doing.

As far as recovering Matlab's form, we can do that (up to the ordering of singular values and vectors, which seems to be consistently the opposite) for at least their Examples 1 and 2 with


[U, V, C, S, X, R] = gsvd (A, B);
X = (R / X)';
[m, n] = size(A);
if m > n
  C = [C; zeros(m-n, n)];
elseif m < n
  C = [C zeros(m, n-m)];
  S0 = S; S = eye(n); S(1:m, 1:m) = S0;
endif



[1] cf. https://groups.google.com/forum/#!topic/comp.soft-sys.matlab/aBgSZNTBcxU
[2] "Other authors, like S. Van Huffel, define this transformation as the simulatenous diagonalisation of the input matrices, this can be achieved by multiplying x by the inverse of [I 0; 0 r]."

Nir Krakauer <nir_krakauer>
Wed 17 Aug 2016 03:49:32 PM UTC, comment #3: 

Check the Matlab documentation (http://www.mathworks.com/help/matlab/ref/gsvd.html).  They have a description of each output, and I simply tried Example 1 that was listed there.

Rik <rik5>
Group administrator
Wed 17 Aug 2016 03:40:36 PM UTC, comment #2: 

There may be different definitions in use of the GSVD outputs. Can you post results from both Matlab and Octave for some cases, such as the examples in the documentation?

Nir Krakauer <nir_krakauer>
Wed 17 Aug 2016 03:31:37 PM UTC, comment #1: 

I assumed that the function in the linear-algebra package was compatible and it was only a matter of adjusting to fit into core build system.

From the docs, it would seem that it's only the order of the output values that is incorrect. Nir and Barbara should comment on this. The place to start would be making tests for those issues with Matlab that are failing now.

Carnë Draug <carandraug>
Group Member
Wed 17 Aug 2016 03:25:07 PM UTC, original submission:  

The newly introduced gsvd function in Octave has a different syntax and produces different results than Matlab (http://www.mathworks.com/help/matlab/ref/gsvd.html).

Rik <rik5>
Group administrator

 

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

Attach Files:
   
   
Comment:
   

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 dasergatskov (Posted a comment)
  • -email is unavailable- added by gyom (Posted a comment)
  • -email is unavailable- added by avinoam (Posted a comment)
  • -email is unavailable- added by bumi (Posted a comment)
  • -email is unavailable- added by nir_krakauer (Posted a comment)
  • -email is unavailable- added by carandraug (Barbara and Nir - GSOC student and mentor)
  • -email is unavailable- added by carandraug (Barbara and Nir - GSOC student and mentor)
  • -email is unavailable- added by rik5 (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-10-02 rik5 Summarygsvd function needs BIST tests updated gsvd function needs matlab compatible interface
    2016-09-28 rik5 Severity4 - Important 3 - Normal
        StatusNone Confirmed
        Summarynew gsvd function is incompatible w/Matlab gsvd function needs BIST tests updated
    2016-08-17 carandraug Carbon-Copy- Added -email is unavailable-
        Carbon-Copy- Added -email is unavailable-

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code