changeset 22592:ee0df00e12d6 stable

fix complex svd (bug #49232) * liboctave/numeric/svd.cc (svd<T>::svd): Use hermitian, not transpose. * libinterp/corefcn/svd.cc: New test for complex svd.
author John W. Eaton <jwe@octave.org>
date Wed, 05 Oct 2016 23:09:31 -0400
parents 1213b3f0602c
children dba5074bdc79
files libinterp/corefcn/svd.cc liboctave/numeric/svd.cc
diffstat 2 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/svd.cc	Wed Oct 05 22:13:14 2016 +0200
+++ b/libinterp/corefcn/svd.cc	Wed Oct 05 23:09:31 2016 -0400
@@ -251,6 +251,12 @@
 %!assert (svd ([1, 2; 2, 1]), [3; 1], sqrt (eps))
 
 %!test
+a = [1, 2; 3, 4] + [5, 6; 7, 8]*i;
+[u,s,v] = svd (a);
+assert (a, u * s * v', 128 * eps);
+
+
+%!test
 %! [u, s, v] = svd ([1, 2; 2, 1]);
 %! x = 1 / sqrt (2);
 %! assert (u, [-x, -x; -x, x], sqrt (eps));
--- a/liboctave/numeric/svd.cc	Wed Oct 05 22:13:14 2016 +0200
+++ b/liboctave/numeric/svd.cc	Wed Oct 05 23:09:31 2016 -0400
@@ -399,7 +399,7 @@
         abort ();
 
       if (! (jobv == 'N' || jobv == 'O'))
-        right_sm = right_sm.transpose ();
+        right_sm = right_sm.hermitian ();
     }
 
     // Instantiations we need.