Hi, > I'd like to use ruby-gsl for some singular value decompositions, i.e. Which library do you use? There are two extensions, ruby-gsl and rb-gsl(Ruby/GSL). ruby-gsl http://ruby-gsl.sourceforge.net/ rb-gsl (Ruby/GSL) http://rubyforge.org/projects/rb-gsl/ > but these are printed out and apparently also calculated only to three > decimal digits If you use Ruby/GSL, this is just because matrices are displayed with the printf format %4.3e, not because of precision. You can get more significant figures by displaying elements as m[0][1]. > by the command > > eigval, eigvec = Eigen::symmv(m*m.transposed). > > This causes the matrix u, which is constructed from the values > eigval, > to have quite strange values for its determinant (I get values of > 1.06, > 0.96 for u*u.transpose.det, but u is unitary by definition, i.e., > u*u.transpose.det=1). Is it unitary? Isn't it an orthogonal matrix? > > Then, of course, m isn't remotely equal to u*s*v.transposed .... The following is rb-gsl(Ruby/GSL) outputs. irb(main):001:0> require("gsl") => true irb(main):002:0> m = GSL::Matrix[[10, 5, -10], [2, -11, 10]].trans => GSL::Matrix [ 1.000e+01 2.000e+00 5.000e+00 -1.100e+01 -1.000e+01 1.000e+01 ] irb(main):003:0> u, v, s = m.SV_decomp => [GSL::Linalg::SV::UMatrix [ -2.981e-01 8.944e-01 -5.963e-01 -4.472e-01 7.454e-01 5.356e-17 ], GSL::Linalg::SV::VMatrix [ -7.071e-01 7.071e-01 7.071e-01 7.071e-01 ], GSL::Linalg::SV::SingularValues [ 1.897e+01 9.487e+00 ]] irb(main):004:0> u.trans*u (U is orthogonal) => GSL::Matrix [ 1.000e+00 1.408e-16 1.408e-16 1.000e+00 ] irb(main):005:0> v*v.trans (V is also orthogonal) => GSL::Matrix [ 1.000e+00 -1.015e-17 -1.015e-17 1.000e+00 ] irb(main):006:0> u*Matrix.diagonal(s)*v.trans => GSL::Matrix (Reconstruct m) [ 1.000e+01 2.000e+00 5.000e+00 -1.100e+01 -1.000e+01 1.000e+01 ] Is this what you expect? Yoshiki