float lower limit at given precision

Thomas D. Dean tomdean at speakeasy.org
Thu Feb 23 23:38:49 CET 2012

On 02/23/12 13:15, Jacopo Nespolo wrote:
> Hello everyone,
> this is my first message here: I'm a student in theoretical physics at
> University of Pisa, Italy.
> I have just started my thesis, and I need to diagonalise a matrix with
> great precision. Unfortunately, after some research, I didn't find any
> suitable option ready to use, so I'm translating a couple of routines
> of the GNU Scientific Library from double to mpf_t.
> In one routine, I need to chop off the small elements from a vector of
> mpf_t. The problem is I cannot understand what small means in this
> case.  For those familiar with GSL, I need the equivalent of
> Hopefully some of you will know.

I assume by small, you mean close to zero? You want to do
    if abs(n) < epsilon then n = 0"

Look at
    mpf_eq (mpf_t OP1, mpf_t OP2, mp_bitcnt_t op3)
where mp_bitcnt is your needed precision.

I used mpq_t for a large problem and at an intermediate point, set all n 
< value to zero.

Tom Dean

More information about the gmp-discuss mailing list