## #498 SVDC in GDL 0.9.2 differs from IDL implementation

closed-wont-fix
nobody
None
2
2012-12-05
2012-11-12
ursus
No

Using the example data given at http://idlastro.gsfc.nasa.gov/idl_html_help/SVDC.html, the GDL and IDL implemtations appeart to deliver a different output for the same input:

<code>

; Define the array A:
A = [[1.0, 2.0, -1.0, 2.5], $[1.5, 3.3, -0.5, 2.0],$
[3.1, 0.7, 2.2, 0.0], $[0.0, 0.3, -2.0, 5.3],$
[2.1, 1.0, 4.3, 2.2], \$
[0.0, 5.5, 3.8, 0.2]]

; Compute the Singular Value Decomposition:
SVDC, A, W, U, V

; Print the singular values:
PRINT, W

; IDL prints:
; 8.81973 2.65502 4.30598 6.84484

</code>

However, GDL prints:
8.81973 6.84484 4.30598 2.65502

Note that the second and forth values are interchanged.

## Discussion

• ursus - 2012-11-12

SVDC application example taken from IDL documentation

• Alain C. - 2012-11-12

OK, what is really the problem ?

What seems to be important for me is that the final check is OK, isn't it ?

(nevertheless we welcome suggestions !)

The GDL provided the outputs ordered following modulus:
http://www.gnu.org/software/gsl/manual/html_node/Singular-Value-Decomposition.html
"The singular values \sigma_i = S_{ii} are all non-negative and are generally chosen to form a non-increasing sequence \sigma_1 >= \sigma_2 >= ... >= \sigma_N >= 0. "

• Alain C. - 2012-11-12
• priority: 5 --> 2

• Marc Schellens - 2012-12-05
• status: open --> closed-wont-fix

• Marc Schellens - 2012-12-05

To resemble the exact IDL behavior here would be a lot of effort. And the ordered result is usually prefered anyway (e. g. https://groups.google.com/forum/?fromgroups=#!topic/comp.lang.idl-pvwave/JwmLRGcsNwM\). We gain for maximum IDL compatibility, but I think this is not a game breaker as IDL does not seem to have any order in the results. So no sensible code will rely on a specific order and hence run fine on GDL as well.