[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: Setting precision in Ruby-GSL calculations ?

Yoshiki TSUNESADA

8/4/2006 3:43:00 AM

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


1 Answer

M. Edward (Ed) Borasky

8/4/2006 3:54:00 AM

0

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.