Z_NR< Z > Class Template Reference

Public Member Functions

 Z_NR ()
 
 Z_NR (const Z_NR< Z > &z)
 
 Z_NR (const Z &z)
 
 ~Z_NR ()
 
Z & get_data ()
 
const Z & get_data () const
 
double get_d () const
 
long get_si () const
 
void get_mpz (mpz_t r) const
 
long exponent () const
 
template<class F >
void get_f_exp (F &f, long &expo)
 
template<class F >
void set_f (const FP_NR< F > &f)
 
void set_str (const char *s)
 
int cmp (const Z_NR< Z > &m) const
 
int sgn () const
 
void operator= (const Z_NR< Z > &z)
 
void operator= (const mpz_t &z)
 
void operator= (long i)
 
bool operator< (const Z_NR< Z > &a) const
 
bool operator< (long a) const
 
bool operator> (const Z_NR< Z > &a) const
 
bool operator> (long a) const
 
bool operator<= (const Z_NR< Z > &a) const
 
bool operator<= (long a) const
 
bool operator>= (const Z_NR< Z > &a) const
 
bool operator>= (long a) const
 
bool operator== (const Z_NR< Z > &a) const
 
bool operator== (long a) const
 
bool operator!= (const Z_NR< Z > &a) const
 
bool operator!= (long a) const
 
Z_NRmax_z (Z_NR< Z > &b)
 
bool is_zero () const
 
void add (const Z_NR< Z > &a, const Z_NR< Z > &b)
 
void add_ui (const Z_NR< Z > &a, unsigned int b)
 
void sub (const Z_NR< Z > &a, const Z_NR< Z > &b)
 
void sub_ui (const Z_NR< Z > &a, unsigned int b)
 
void mod (const Z_NR< Z > &a, const Z_NR< Z > &b)
 
void neg (const Z_NR< Z > &a)
 
void mul (const Z_NR< Z > &a, const Z_NR< Z > &b)
 
void mul_si (const Z_NR< Z > &a, long b)
 
void mul_ui (const Z_NR< Z > &a, unsigned long b)
 
void mul_2si (const Z_NR< Z > &a, long b)
 
void div_2si (const Z_NR< Z > &a, long b)
 
void addmul (const Z_NR< Z > &a, const Z_NR< Z > &b)
 
void addmul_ui (const Z_NR< Z > &a, unsigned long b)
 
void addmul_si (const Z_NR< Z > &a, long b)
 
void submul (const Z_NR< Z > &a, const Z_NR< Z > &b)
 
void submul_ui (const Z_NR< Z > &a, unsigned long b)
 
void abs (const Z_NR< Z > &a)
 
void swap (Z_NR< Z > &a)
 
void randb (int bits)
 
void randb_si (int bits)
 
void randm (const Z_NR< Z > &max)
 
void randm_si (const Z_NR< Z > &max)
 
void nextprime (const Z_NR< Z > &nbr)
 

Detailed Description

template<class Z = mpz_t>
class Z_NR< Z >

Z_NR stores integers. This template provides a uniform interface for doing integer computations with several underlying types (long, double and mpz_t).

Constructor & Destructor Documentation

◆ Z_NR() [1/3]

template<class Z = mpz_t>
Z_NR< Z >::Z_NR ( )
inline

Constructors.

◆ Z_NR() [2/3]

template<class Z = mpz_t>
Z_NR< Z >::Z_NR ( const Z_NR< Z > &  z)
inline

◆ Z_NR() [3/3]

template<class Z = mpz_t>
Z_NR< Z >::Z_NR ( const Z &  z)
inline

◆ ~Z_NR()

template<class Z = mpz_t>
Z_NR< Z >::~Z_NR ( )
inline

Member Function Documentation

◆ abs()

template<class Z = mpz_t>
void Z_NR< Z >::abs ( const Z_NR< Z > &  a)
inline

value := absolute value of a.

◆ add()

template<class Z = mpz_t>
void Z_NR< Z >::add ( const Z_NR< Z > &  a,
const Z_NR< Z > &  b 
)
inline

arithmetic value := a + b.

◆ add_ui()

template<class Z = mpz_t>
void Z_NR< Z >::add_ui ( const Z_NR< Z > &  a,
unsigned int  b 
)
inline

◆ addmul()

template<class Z = mpz_t>
void Z_NR< Z >::addmul ( const Z_NR< Z > &  a,
const Z_NR< Z > &  b 
)
inline

value := value + a * b.

◆ addmul_si()

template<class Z = mpz_t>
void Z_NR< Z >::addmul_si ( const Z_NR< Z > &  a,
long  b 
)
inline

◆ addmul_ui()

template<class Z = mpz_t>
void Z_NR< Z >::addmul_ui ( const Z_NR< Z > &  a,
unsigned long  b 
)
inline

◆ cmp()

template<class Z = mpz_t>
int Z_NR< Z >::cmp ( const Z_NR< Z > &  m) const
inline

comparison 3-way comparison. Returns a positive number if *this > m, a negative number if *this < m or zero is *this == m.

◆ div_2si()

template<class Z = mpz_t>
void Z_NR< Z >::div_2si ( const Z_NR< Z > &  a,
long  b 
)
inline

value := a / 2^b. if Z=long and |b| >= size_in_bits(a), the result is undefined.

◆ exponent()

template<class Z = mpz_t>
long Z_NR< Z >::exponent ( ) const
inline

Returns the smallest non-negative expo such that |value| < 2^expo.

◆ get_d()

template<class Z = mpz_t>
double Z_NR< Z >::get_d ( ) const
inline

Converts this object to a double. If it does not fit in a double, the result is undefined.

◆ get_data() [1/2]

template<class Z = mpz_t>
Z & Z_NR< Z >::get_data ( )
inline

get data Returns the internal representation of the data.

◆ get_data() [2/2]

template<class Z = mpz_t>
const Z & Z_NR< Z >::get_data ( ) const
inline

Returns the internal representation of the data.

◆ get_f_exp()

template<class Z = mpz_t>
template<class F >
void Z_NR< Z >::get_f_exp ( F &  f,
long &  expo 
)
inline

Computes f and expo such that 0.5 <= f < 1 and value ~= 2^expo * f. The rounding direction is undefined. This function is implemented only for native floating-point types (double and long double), otherwise the behaviour is undefined.

◆ get_mpz()

template<class Z = mpz_t>
void Z_NR< Z >::get_mpz ( mpz_t  r) const
inline

Converts this object to a mpz.

◆ get_si()

template<class Z = mpz_t>
long Z_NR< Z >::get_si ( ) const
inline

Converts this object to a long double. If it does not fit in a long double, the result is undefined. Converts this object to a long. If it does not fit in a long, the result is undefined.

◆ is_zero()

template<class Z = mpz_t>
bool Z_NR< Z >::is_zero ( ) const
inline

Returns non-zero if the current value is zero, 0 otherwise.

◆ max_z()

template<class Z = mpz_t>
Z_NR & Z_NR< Z >::max_z ( Z_NR< Z > &  b)
inline

max between a and b

◆ mod()

template<class Z = mpz_t>
void Z_NR< Z >::mod ( const Z_NR< Z > &  a,
const Z_NR< Z > &  b 
)
inline

value := a mod b

◆ mul()

template<class Z = mpz_t>
void Z_NR< Z >::mul ( const Z_NR< Z > &  a,
const Z_NR< Z > &  b 
)
inline

value := a * b.

◆ mul_2si()

template<class Z = mpz_t>
void Z_NR< Z >::mul_2si ( const Z_NR< Z > &  a,
long  b 
)
inline

value := a * 2^b. if Z=long and |b| >= size_in_bits(a), the result is undefined.

◆ mul_si()

template<class Z = mpz_t>
void Z_NR< Z >::mul_si ( const Z_NR< Z > &  a,
long  b 
)
inline

value := a * b.

◆ mul_ui()

template<class Z = mpz_t>
void Z_NR< Z >::mul_ui ( const Z_NR< Z > &  a,
unsigned long  b 
)
inline

◆ neg()

template<class Z = mpz_t>
void Z_NR< Z >::neg ( const Z_NR< Z > &  a)
inline

value := -a.

◆ nextprime()

template<class Z = mpz_t>
void Z_NR< Z >::nextprime ( const Z_NR< Z > &  nbr)
inline

Generates smallest prime number above nbr

◆ operator!=() [1/2]

template<class Z = mpz_t>
bool Z_NR< Z >::operator!= ( const Z_NR< Z > &  a) const
inline

◆ operator!=() [2/2]

template<class Z = mpz_t>
bool Z_NR< Z >::operator!= ( long  a) const
inline

◆ operator<() [1/2]

template<class Z = mpz_t>
bool Z_NR< Z >::operator< ( const Z_NR< Z > &  a) const
inline

◆ operator<() [2/2]

template<class Z = mpz_t>
bool Z_NR< Z >::operator< ( long  a) const
inline

◆ operator<=() [1/2]

template<class Z = mpz_t>
bool Z_NR< Z >::operator<= ( const Z_NR< Z > &  a) const
inline

◆ operator<=() [2/2]

template<class Z = mpz_t>
bool Z_NR< Z >::operator<= ( long  a) const
inline

◆ operator=() [1/3]

template<class Z = mpz_t>
void Z_NR< Z >::operator= ( const mpz_t &  z)
inline

◆ operator=() [2/3]

template<class Z = mpz_t>
void Z_NR< Z >::operator= ( const Z_NR< Z > &  z)
inline

Operator

◆ operator=() [3/3]

template<class Z = mpz_t>
void Z_NR< Z >::operator= ( long  i)
inline

◆ operator==() [1/2]

template<class Z = mpz_t>
bool Z_NR< Z >::operator== ( const Z_NR< Z > &  a) const
inline

◆ operator==() [2/2]

template<class Z = mpz_t>
bool Z_NR< Z >::operator== ( long  a) const
inline

◆ operator>() [1/2]

template<class Z = mpz_t>
bool Z_NR< Z >::operator> ( const Z_NR< Z > &  a) const
inline

◆ operator>() [2/2]

template<class Z = mpz_t>
bool Z_NR< Z >::operator> ( long  a) const
inline

◆ operator>=() [1/2]

template<class Z = mpz_t>
bool Z_NR< Z >::operator>= ( const Z_NR< Z > &  a) const
inline

◆ operator>=() [2/2]

template<class Z = mpz_t>
bool Z_NR< Z >::operator>= ( long  a) const
inline

◆ randb()

template<class Z = mpz_t>
void Z_NR< Z >::randb ( int  bits)
inline

Generates random integer between 0 and 2^bits-1.

◆ randb_si()

template<class Z = mpz_t>
void Z_NR< Z >::randb_si ( int  bits)
inline

◆ randm()

template<class Z = mpz_t>
void Z_NR< Z >::randm ( const Z_NR< Z > &  max)
inline

Generates random integer between 0 and max - 1

◆ randm_si()

template<class Z = mpz_t>
void Z_NR< Z >::randm_si ( const Z_NR< Z > &  max)
inline

◆ set_f()

template<class Z = mpz_t>
template<class F >
void Z_NR< Z >::set_f ( const FP_NR< F > &  f)
inline

set data Sets the value to x. When FT=mpfr_t, x is rounded to the nearest integer and if the fractional part of x is 0.5, the even integer is chosen when. Otherwise, the rounding direction is undefined.

◆ set_str()

template<class Z = mpz_t>
void Z_NR< Z >::set_str ( const char *  s)
inline

Sets the value to s, signed integer in basis 10.

◆ sgn()

template<class Z = mpz_t>
int Z_NR< Z >::sgn ( ) const
inline

Sign. Returns a positive number, a negative number or zero if the value of this object is respectively positive, negative or null.

◆ sub()

template<class Z = mpz_t>
void Z_NR< Z >::sub ( const Z_NR< Z > &  a,
const Z_NR< Z > &  b 
)
inline

value := a - b.

◆ sub_ui()

template<class Z = mpz_t>
void Z_NR< Z >::sub_ui ( const Z_NR< Z > &  a,
unsigned int  b 
)
inline

◆ submul()

template<class Z = mpz_t>
void Z_NR< Z >::submul ( const Z_NR< Z > &  a,
const Z_NR< Z > &  b 
)
inline

value := value - a * b.

◆ submul_ui()

template<class Z = mpz_t>
void Z_NR< Z >::submul_ui ( const Z_NR< Z > &  a,
unsigned long  b 
)
inline

◆ swap()

template<class Z = mpz_t>
void Z_NR< Z >::swap ( Z_NR< Z > &  a)
inline

Efficiently swaps the values of two Z_NR.


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