From: "M. Edward (Ed) Borasky" Date: 2006-08-04T12:53:41+09:00 Subject: Re: Setting precision in Ruby-GSL calculations ? yoshiki9@mac.com wrote: > Hi Axel, sorry for late reply. > >> Ruby-Gsl defines these as M= U S V^tr, >> where U can have uneven dimensions, but many >> authors require U to >> be square (and softwares, eg. Mathematica) > > This is because GSL can do so. > >> I still don't know why I don't get singular >> values to higher precision ... >> does one have to convert to Float or something ? > > All the values in Ruby/GSL including elements > in a GSL::Vector object are calculated in double > precision. But when you use e.g. > irb> p v or > irb> v.print > only 4 digits of each element are displayed using > printf() with the format "%4.3e". This does not > mean the precision of 4 significant digits. If you > need to "see" vector elements, you can obtain > them as Ruby Float by accessing with indices as > v[0], v[1]. > > If you really need more higher precision better > than double, I have no idea. > > Yoshiki You shouldn't need more than 64-bit (double) arithmetic for a singular value decomposition. It's a very stable process ... in fact, it's so stable it's the method of choice for solving least squares problems, rather than the cross-multiply / Cholesky decomposition that was commonly used in the "old days". Cross-multiply / Cholesky is faster, but much less stable.