Loading...
Searching...
No Matches
gmp_float Class Reference

`#include <mpr_complex.h>`

## Public Member Functions

| gmp_float (const int v=0)
| gmp_float (const long v)
| gmp_float (const mprfloat v)
| gmp_float (const mpf_t v)
| gmp_float (const mpz_t v)
| gmp_float (const gmp_float &v)
| ~gmp_float ()
gmp_float & | operator= (const gmp_float &a)
gmp_float & | operator= (const mpz_t &a)
gmp_float & | operator= (const mprfloat a)
gmp_float & | operator= (const long a)
gmp_float & | operator+= (const gmp_float &a)
gmp_float & | operator-= (const gmp_float &a)
gmp_float & | operator*= (const gmp_float &a)
gmp_float & | operator/= (const gmp_float &a)
gmp_float & | neg ()
gmp_float | operator^ (const int exp) const
int | sign ()
bool | isZero () const
bool | isOne () const
bool | isMOne () const
void | setFromStr (const char *in)
const mpf_t * | mpfp () const
mpf_t * | _mpfp ()
| operator double ()
| operator double () const

## Data Fields

mpf_t | t

## Friends

gmp_float | operator+ (const gmp_float &a, const gmp_float &b)
gmp_float | operator- (const gmp_float &a, const gmp_float &b)
gmp_float | operator* (const gmp_float &a, const gmp_float &b)
gmp_float | operator/ (const gmp_float &a, const gmp_float &b)
bool | operator== (const gmp_float &a, const gmp_float &b)
bool | operator> (const gmp_float &a, const gmp_float &b)
bool | operator< (const gmp_float &a, const gmp_float &b)
bool | operator>= (const gmp_float &a, const gmp_float &b)
bool | operator<= (const gmp_float &a, const gmp_float &b)
gmp_float | operator- (const gmp_float &a)

## Detailed Description

Definition at line 31 of file mpr_complex.h.

## Constructor & Destructor Documentation

## gmp_float() [1/6]

gmp_float::gmp_float | ( | const int | v = 0 | ) |

inline

Definition at line 34 of file mpr_complex.h.

{
mpf_init_set_si( t, (long)v );
}
gmp_float::t
mpf_t t
Definition mpr_complex.h:153
v
const Variable & v
< [in] a sqrfree bivariate poly
Definition facBivar.h:39

## gmp_float() [2/6]

gmp_float::gmp_float | ( | const long | v | ) |

inline

Definition at line 38 of file mpr_complex.h.

{
mpf_init_set_si( t, v );
}

## gmp_float() [3/6]

gmp_float::gmp_float | ( | const mprfloat | v | ) |

inline

Definition at line 42 of file mpr_complex.h.

{
mpf_init_set_d( t, v );
}

## gmp_float() [4/6]

gmp_float::gmp_float | ( | const mpf_t | v | ) |

inline

Definition at line 46 of file mpr_complex.h.

{
mpf_init_set( t, v );
}

## gmp_float() [5/6]

gmp_float::gmp_float | ( | const mpz_t | v | ) |

inline

Definition at line 50 of file mpr_complex.h.

{
mpf_init( t );
mpf_set_z( t, v );
}

## gmp_float() [6/6]

gmp_float::gmp_float | ( | const gmp_float & | v | ) |

inline

Definition at line 55 of file mpr_complex.h.

{
mpf_init_set( t, v.t );
}

## ~gmp_float()

gmp_float::~gmp_float | ( |  | ) |

inline

Definition at line 60 of file mpr_complex.h.

{
mpf_clear( t );
}

## Member Function Documentation

## _mpfp()

mpf_t * gmp_float::_mpfp | ( |  | ) |

inline

Definition at line 136 of file mpr_complex.h.

{ return &t; };

## isMOne()

bool gmp_float::isMOne | ( |  | ) | const

Definition at line 273 of file mpr_complex.cc.

{
#ifdef VARIANTE_1
return (mpf_cmp_si( t , -1 ) == 0);
#else
if (mpf_sgn(t) >= 0)
return false;
mpf_add_ui(diff->t, t, 1);
mpf_abs(diff->t, diff->t);
if(mpf_cmp(diff->t, gmpRel->t) < 0)
return true;
else
return false;
#endif
}
gmpRel
STATIC_VAR gmp_float * gmpRel
Definition mpr_complex.cc:44
diff
STATIC_VAR gmp_float * diff
Definition mpr_complex.cc:45

## isOne()

bool gmp_float::isOne | ( |  | ) | const

Definition at line 257 of file mpr_complex.cc.

{
#ifdef VARIANTE_1
return (mpf_cmp_ui( t , 1 ) == 0);
#else
if (mpf_sgn(t) <= 0)
return false;
mpf_sub_ui(diff->t, t, 1);
mpf_abs(diff->t, diff->t);
if(mpf_cmp(diff->t, gmpRel->t) < 0)
return true;
else
return false;
#endif
}

## isZero()

bool gmp_float::isZero | ( |  | ) | const

Definition at line 252 of file mpr_complex.cc.

{
return (mpf_sgn( t ) == 0);
}

## mpfp()

const mpf_t * gmp_float::mpfp | ( |  | ) | const

inline

Definition at line 135 of file mpr_complex.h.

{ return &t; };

## neg()

gmp_float & gmp_float::neg | ( |  | ) |

inline

Definition at line 100 of file mpr_complex.h.

{ mpf_neg(t,t); return *this; };

## operator double() [1/2]

gmp_float::operator double | ( |  | ) |

inline

Definition at line 138 of file mpr_complex.h.

{ return mpf_get_d( t ); };

## operator double() [2/2]

gmp_float::operator double | ( |  | ) | const

inline

Definition at line 139 of file mpr_complex.h.

{ return mpf_get_d( t ); };

## operator*=()

gmp_float & gmp_float::operator*= | ( | const gmp_float & | a | ) |

inline

Definition at line 88 of file mpr_complex.h.

{
mpf_mul( t, t, a.t );
return *this;
};

## operator+=()

gmp_float & gmp_float::operator+= | ( | const gmp_float & | a | ) |

Definition at line 193 of file mpr_complex.cc.

{
if (mpf_sgn(t) != -(mpf_sgn(a.t)))
{
mpf_add( t, t, a.t);
return *this;
}
if((mpf_sgn(a.t)==0) && (mpf_sgn(t)==0))
{
mpf_set_d( t, 0.0);
return *this;
}
mpf_add( t, t, a.t );
mpf_set(diff->t, t);
mpf_set_prec(diff->t, 32);
mpf_div(diff->t, diff->t, a.t);
mpf_abs(diff->t, diff->t);
if(mpf_cmp(diff->t, gmpRel->t) < 0)
mpf_set_d( t, 0.0);
return *this;
}

## operator-=()

gmp_float & gmp_float::operator-= | ( | const gmp_float & | a | ) |

Definition at line 214 of file mpr_complex.cc.

{
if (mpf_sgn(t) != mpf_sgn(a.t))
{
mpf_sub( t, t, a.t);
return *this;
}
if((mpf_sgn(a.t)==0) && (mpf_sgn(t)==0))
{
mpf_set_d( t, 0.0);
return *this;
}
mpf_sub( t, t, a.t );
mpf_set(diff->t, t);
mpf_set_prec(diff->t, 32);
mpf_div(diff->t, diff->t, a.t);
mpf_abs(diff->t, diff->t);
if(mpf_cmp(diff->t, gmpRel->t) < 0)
mpf_set_d( t, 0.0);
return *this;
}

## operator/=()

gmp_float & gmp_float::operator/= | ( | const gmp_float & | a | ) |

inline

Definition at line 94 of file mpr_complex.h.

{
mpf_div( t, t, a.t );
return *this;
};

## operator=() [1/4]

gmp_float & gmp_float::operator= | ( | const gmp_float & | a | ) |

inline

Definition at line 65 of file mpr_complex.h.

{
mpf_set( t, a.t );
return *this;
};

## operator=() [2/4]

gmp_float & gmp_float::operator= | ( | const long | a | ) |

inline

Definition at line 80 of file mpr_complex.h.

{
mpf_set_d( t, (double) a );
return *this;
};

## operator=() [3/4]

gmp_float & gmp_float::operator= | ( | const mprfloat | a | ) |

inline

Definition at line 75 of file mpr_complex.h.

{
mpf_set_d( t, (double) a );
return *this;
};

## operator=() [4/4]

gmp_float & gmp_float::operator= | ( | const mpz_t & | a | ) |

inline

Definition at line 70 of file mpr_complex.h.

{
mpf_set_z( t, a );
return *this;
};

## operator^()

gmp_float gmp_float::operator^ | ( | const int | exp | ) | const

inline

Definition at line 107 of file mpr_complex.h.

{
mpf_t b;
mpf_init(b);
mpf_pow_ui( b, this->t, (unsigned long)exp );
gmp_float res=gmp_float(b);
mpf_clear(b);
return res;
};
b
CanonicalForm b
Definition cfModGcd.cc:4111
gmp_float::gmp_float
gmp_float(const int v=0)
Definition mpr_complex.h:34
res
CanonicalForm res
Definition facAbsFact.cc:60
exp
gmp_float exp(const gmp_float &)
Definition mpr_complex.cc:349

## setFromStr()

void gmp_float::setFromStr | ( | const char * | in | ) |

Definition at line 78 of file mpr_complex.cc.

{
BOOLEAN neg=false;
if (*in == '-') { in++; neg=TRUE; }
char *s;
if ((s=strchr((char *)in,'E')) !=NULL)
{
*s='e';
}
// gmp doesn't understand number which begin with "." -- it needs 0.
// so, insert the zero
if (*in == '.')
{
int len = strlen(in)+2;
char* c_in = (char*) omAlloc(len);
*c_in = '0';
strcpy(&(c_in[1]), in);
if(mpf_set_str( t, c_in, 10 )!=0) WerrorS("syntax error in GMP float");
omFreeSize((void*)c_in, len);
}
else
{
if(mpf_set_str( t, in, 10 )!=0) WerrorS("syntax error in GMP float");
}
if (neg) mpf_neg( t, t );
}
BOOLEAN
int BOOLEAN
Definition auxiliary.h:88
TRUE
#define TRUE
Definition auxiliary.h:101
gmp_float::neg
gmp_float & neg()
Definition mpr_complex.h:100
s
const CanonicalForm int s
Definition facAbsFact.cc:51
WerrorS
void WerrorS(const char *s)
Definition feFopen.cc:24
omFreeSize
#define omFreeSize(addr, size)
Definition omAllocDecl.h:260
omAlloc
#define omAlloc(size)
Definition omAllocDecl.h:210
NULL
#define NULL
Definition omList.c:12

## sign()

int gmp_float::sign | ( |  | ) |

inline

Definition at line 125 of file mpr_complex.h.

{ return mpf_sgn( t ); };

## Friends And Related Symbol Documentation

## operator*

gmp_float operator* | ( | const gmp_float & | a,
|  | const gmp_float & | b )

friend

Definition at line 179 of file mpr_complex.cc.

{
gmp_float tmp( a );
tmp *= b;
return tmp;
}

## operator+

gmp_float operator+ | ( | const gmp_float & | a,
|  | const gmp_float & | b )

friend

Definition at line 167 of file mpr_complex.cc.

{
gmp_float tmp( a );
tmp += b;
return tmp;
}

## operator- [1/2]

gmp_float operator- | ( | const gmp_float & | a | ) |

friend

Definition at line 306 of file mpr_complex.cc.

{
gmp_float tmp;
mpf_neg( *(tmp._mpfp()), *(a.mpfp()) );
return tmp;
}
gmp_float::_mpfp
mpf_t * _mpfp()
Definition mpr_complex.h:136
gmp_float::mpfp
const mpf_t * mpfp() const
Definition mpr_complex.h:135

## operator- [2/2]

gmp_float operator- | ( | const gmp_float & | a,
|  | const gmp_float & | b )

friend

Definition at line 173 of file mpr_complex.cc.

{
gmp_float tmp( a );
tmp -= b;
return tmp;
}

## operator/

gmp_float operator/ | ( | const gmp_float & | a,
|  | const gmp_float & | b )

friend

Definition at line 185 of file mpr_complex.cc.

{
gmp_float tmp( a );
tmp /= b;
return tmp;
}

## operator<

bool operator< | ( | const gmp_float & | a,
|  | const gmp_float & | b )

friend

Definition at line 292 of file mpr_complex.cc.

{
return mpf_cmp( a.t, b.t ) < 0;
}

## operator<=

bool operator<= | ( | const gmp_float & | a,
|  | const gmp_float & | b )

friend

Definition at line 300 of file mpr_complex.cc.

{
return mpf_cmp( a.t, b.t ) <= 0;
}

## operator==

bool operator== | ( | const gmp_float & | a,
|  | const gmp_float & | b )

friend

Definition at line 237 of file mpr_complex.cc.

{
if(mpf_sgn(a.t) != mpf_sgn(b.t))
return false;
if((mpf_sgn(a.t)==0) && (mpf_sgn(b.t)==0))
return true;
mpf_sub(diff->t, a.t, b.t);
mpf_div(diff->t, diff->t, a.t);
mpf_abs(diff->t, diff->t);
if(mpf_cmp(diff->t, gmpRel->t) < 0)
return true;
else
return false;
}

## operator>

bool operator> | ( | const gmp_float & | a,
|  | const gmp_float & | b )

friend

Definition at line 288 of file mpr_complex.cc.

{
return mpf_cmp( a.t, b.t ) > 0;
}

## operator>=

bool operator>= | ( | const gmp_float & | a,
|  | const gmp_float & | b )

friend

Definition at line 296 of file mpr_complex.cc.

{
return mpf_cmp( a.t, b.t ) >= 0;
}

## Field Documentation

## t

mpf_t gmp_float::t

Definition at line 153 of file mpr_complex.h.

The documentation for this class was generated from the following files:

- libpolys/coeffs/mpr_complex.h
- libpolys/coeffs/mpr_complex.cc