# Re: Setting precision in Ruby-GSL calculations?

**URL:** <https://www.ruby-forum.com/t/re-setting-precision-in-ruby-gsl-calculations/101312>\
**Category:** Ruby\
**Created:** [August 4, 2006, 5:43am UTC](https://www.ruby-forum.com/t/re-setting-precision-in-ruby-gsl-calculations/101312 "2006-08-04T05:43:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [August 4, 2006, 5:43am UTC](https://www.ruby-forum.com/t/re-setting-precision-in-ruby-gsl-calculations/101312/1 "2006-08-04T05:43:45Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [August 4, 2006, 5:55am UTC](https://www.ruby-forum.com/t/re-setting-precision-in-ruby-gsl-calculations/101312/2 "2006-08-04T05:55:45Z")

</div>

removed\_email\_address@domain.invalid wrote:

> > values to higher precision …  
> > 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.
