linbox
GMPRationalField Class Reference

#include <gmp-rational.h>

+ Inheritance diagram for GMPRationalField:

Public Member Functions

Object Management

x <- convert (y)

 GMPRationalField (const GMPRationalField &)
 Copy constructor.
 
 ~GMPRationalField (void)
 Destructor.
 
GMPRationalFieldoperator= (const GMPRationalField &)
 Assignment operator.
 
Elementinit (Element &x, const integer &y=0) const
 Initialization of field element from an integer.
 
Elementinit (Element &x, const integer &num, const integer &den) const
 Copy constructor.
 
Elementinit (Element &x, const int64_t &y) const
 Copy constructor.
 
Elementinit (Element &x, const uint64_t &y) const
 Copy constructor.
 
integerconvert (integer &x, const Element &y=0) const
 Conversion of field element to an integer.
 
Elementassign (Element &x, const Element &y) const
 Assignment of one field element to another.
 
integercardinality (integer &c) const
 is infinite (signified by -1 here)
 
integercharacteristic (integer &c) const
 of the rationals is 0.
 
integer cardinality () const
 Copy constructor.
 
integer characteristic () const
 Copy constructor.
 
Arithmetic Operations

x <- y op z; x <- op y These operations require all elements, including x, to be initialized before the operation is called.

Uninitialized field elements will give undefined results.

bool areEqual (const Element &x, const Element &y) const
 Equality of two elements.
 
Elementadd (Element &x, const Element &y, const Element &z) const
 Addition.
 
Elementsub (Element &x, const Element &y, const Element &z) const
 Subtraction.
 
Elementmul (Element &x, const Element &y, const Element &z) const
 Multiplication.
 
Elementdiv (Element &x, const Element &y, const Element &z) const
 Division.
 
Elementneg (Element &x, const Element &y) const
 Additive Inverse (Negation).
 
Elementinv (Element &x, const Element &y) const
 Multiplicative Inverse.
 
Inplace Arithmetic Operations

x <- x op y; x <- op x These operations require all elements, including x, to be initialized before the operation is called.

Uninitialized field elements will give undefined results.

bool isZero (const Element &x) const
 Zero equality.
 
bool isOne (const Element &x) const
 One equality.
 
bool isMOne (const Element &x) const
 MOne equality.
 
bool isUnit (const Element &x) const
 Zero equality.
 
Elementaddin (Element &x, const Element &y) const
 Inplace Addition.
 
Elementsubin (Element &x, const Element &y) const
 Inplace Subtraction.
 
Elementmulin (Element &x, const Element &y) const
 Inplace Multiplication.
 
Elementaxpy (Element &r, const Element &a, const Element &x, const Element &y) const
 axpy.
 
Elementaxpyin (Element &r, const Element &a, const Element &x) const
 axpyin.
 
Elementdivin (Element &x, const Element &y) const
 Inplace Division.
 
Elementnegin (Element &x) const
 Inplace Additive Inverse (Inplace Negation).
 
Elementinvin (Element &x) const
 Inplace Multiplicative Inverse.
 

Common Object Interface for a LinBox Field.

These methods are required of all LinBox fields.

typedef GMPRationalElement Element
 element type.
 
typedef GMPRationalElementElement_ptr
 pointer to element type.
 
typedef const Element_ptr ConstElement_ptr
 const pointer to element type.
 
typedef GMPRationalRandIter RandIter
 Random iterator generator type.
 
const Element zero
 element type.
 
const Element one
 element type.
 
const Element mOne
 element type.
 

Input/Output Operations

std::ostream & write (std::ostream &os) const
 Print field.
 
std::istream & read (std::istream &is)
 Read field.
 
std::ostream & write (std::ostream &os, const Element &x) const
 Print field element.
 
std::istream & read (std::istream &is, Element &x) const
 Read field element.
 
 GMPRationalField (int p=0, int exp=1)
 Print field.
 
integerget_num (integer &x, const Element &y) const
 get numerator.
 
integerget_den (integer &x, const Element &y) const
 get denominator.
 
int sign (const Element &x) const
 sign.
 
integerbitsize (integer &bs, const Element &q) const
 Bitsize as sum of bitsizes of numerator and denominator.
 
static int maxCardinality ()
 max modulus.
 

Member Typedef Documentation

◆ Element

element type.

◆ Element_ptr

pointer to element type.

◆ ConstElement_ptr

const pointer to element type.

◆ RandIter

Random iterator generator type.

Constructor & Destructor Documentation

◆ GMPRationalField() [1/2]

GMPRationalField ( const GMPRationalField & )
inline

Copy constructor.

Vacuous, since this field is unparametric so there is no need to construct multiple field objects

◆ ~GMPRationalField()

~GMPRationalField ( void )
inline

Destructor.

Also vacuous, since there is no de-initialization system

◆ GMPRationalField() [2/2]

GMPRationalField ( int p = 0,
int exp = 1 )
inline

Print field.

Returns
output stream to which field is written.
Parameters
osoutput stream to which field is written.

This does not do much...

Member Function Documentation

◆ operator=()

GMPRationalField & operator= ( const GMPRationalField & )
inline

Assignment operator.

Also vacuous

◆ init() [1/4]

Element & init ( Element & x,
const integer & y = 0 ) const
inline

Initialization of field element from an integer.

Behaves like C++ allocator construct. This function assumes the output field element x has already been constructed, but that it is not necessarily already initialized. In this implementation, this means the _elem_ptr of x exists, but that it may be the null pointer.

Returns
reference to field element.
Parameters
xfield element to contain output (reference returned).
yconstant reference to integer.

◆ init() [2/4]

Element & init ( Element & x,
const integer & num,
const integer & den ) const
inline

Copy constructor.

Vacuous, since this field is unparametric so there is no need to construct multiple field objects

◆ init() [3/4]

Element & init ( Element & x,
const int64_t & y ) const
inline

Copy constructor.

Vacuous, since this field is unparametric so there is no need to construct multiple field objects

◆ init() [4/4]

Element & init ( Element & x,
const uint64_t & y ) const
inline

Copy constructor.

Vacuous, since this field is unparametric so there is no need to construct multiple field objects

◆ convert()

integer & convert ( integer & x,
const Element & y = 0 ) const
inline

Conversion of field element to an integer.

This function assumes the output field element x has already been constructed, but that it is not already initialized. In this implementation, this means the _elem_ptr of y exists, and that it is not the null pointer.

Returns floor (numerator (y) / denominator (y))

Returns
reference to integer.
Parameters
xreference to integer to contain output (reference returned).
yconstant reference to field element.

◆ assign()

Element & assign ( Element & x,
const Element & y ) const
inline

Assignment of one field element to another.

This function assumes both field elements have already been constructed and initialized. In this implementation, this means for both x and y, _elem_ptr exists and does not point to null.

Returns
reference to x
Parameters
xfield element (reference returned).
yfield element.

FIXME: Is this x := y? I am assuming so.

◆ cardinality() [1/2]

integer & cardinality ( integer & c) const
inline

is infinite (signified by -1 here)

◆ characteristic() [1/2]

integer & characteristic ( integer & c) const
inline

of the rationals is 0.

◆ cardinality() [2/2]

integer cardinality ( ) const
inline

Copy constructor.

Vacuous, since this field is unparametric so there is no need to construct multiple field objects

◆ characteristic() [2/2]

integer characteristic ( ) const
inline

Copy constructor.

Vacuous, since this field is unparametric so there is no need to construct multiple field objects

◆ areEqual()

bool areEqual ( const Element & x,
const Element & y ) const
inline

Equality of two elements.

This function assumes both field elements have already been constructed and initialized. In this implementation, this means for both x and y, _elem_ptr exists and does not point to null.

Returns
boolean true if equal, false if not.
Parameters
xfield element
yfield element

◆ add()

Element & add ( Element & x,
const Element & y,
const Element & z ) const
inline

Addition.

x = y + z This function assumes all the field elements have already been constructed and initialized. In this implementation, this means for x, y, and z, _elem_ptr exists and does not point to null.

Returns
reference to x.
Parameters
xfield element (reference returned).
yfield element.
zfield element.

◆ sub()

Element & sub ( Element & x,
const Element & y,
const Element & z ) const
inline

Subtraction.

x = y - z This function assumes all the field elements have already been constructed and initialized. In this implementation, this means for x, y, and z, _elem_ptr exists and does not point to null.

Returns
reference to x.
Parameters
xfield element (reference returned).
yfield element.
zfield element.

◆ mul()

Element & mul ( Element & x,
const Element & y,
const Element & z ) const
inline

Multiplication.

x = y * z This function assumes all the field elements have already been constructed and initialized. In this implementation, this means for x, y, and z, _elem_ptr exists and does not point to null.

Returns
reference to x.
Parameters
xfield element (reference returned).
yfield element.
zfield element.

◆ div()

Element & div ( Element & x,
const Element & y,
const Element & z ) const
inline

Division.

x = y / z This function assumes all the field elements have already been constructed and initialized. In this implementation, this means for x, y, and z, _elem_ptr exists and does not point to null.

Returns
reference to x.
Parameters
xfield element (reference returned).
yfield element.
zfield element.

◆ neg()

Element & neg ( Element & x,
const Element & y ) const
inline

Additive Inverse (Negation).

x = - y This function assumes both field elements have already been constructed and initialized. In this implementation, this means for both x and y _elem_ptr exists and does not point to null.

Returns
reference to x.
Parameters
xfield element (reference returned).
yfield element.

◆ inv()

Element & inv ( Element & x,
const Element & y ) const
inline

Multiplicative Inverse.

x = 1 / y This function assumes both field elements have already been constructed and initialized. In this implementation, this means for both x and y _elem_ptr exists and does not point to null.

Returns
reference to x.
Parameters
xfield element (reference returned).
yfield element.

◆ isZero()

bool isZero ( const Element & x) const
inline

Zero equality.

Test if field element is equal to zero. This function assumes the field element has already been constructed and initialized. In this implementation, this means the _elem_ptr of x exists and does not point to null.

Returns
boolean true if equals zero, false if not.
Parameters
xfield element.

◆ isOne()

bool isOne ( const Element & x) const
inline

One equality.

Test if field element is equal to one. This function assumes the field element has already been constructed and initialized. In this implementation, this means the _elem_ptr of x exists and does not point to null.

Returns
boolean true if equals one, false if not.
Parameters
xfield element.

◆ isMOne()

bool isMOne ( const Element & x) const
inline

MOne equality.

Test if field element is equal to one. This function assumes the field element has already been constructed and initialized. In this implementation, this means the _elem_ptr of x exists and does not point to null.

Returns
boolean true if equals one, false if not.
Parameters
xfield element.

◆ isUnit()

bool isUnit ( const Element & x) const
inline

Zero equality.

Test if field element is equal to zero. This function assumes the field element has already been constructed and initialized. In this implementation, this means the _elem_ptr of x exists and does not point to null.

Returns
boolean true if equals zero, false if not.
Parameters
xfield element.

◆ addin()

Element & addin ( Element & x,
const Element & y ) const
inline

Inplace Addition.

x += y This function assumes both field elements have already been constructed and initialized. In this implementation, this means for both x and y _elem_ptr exists and does not point to null.

Returns
reference to x.
Parameters
xfield element (reference returned).
yfield element.

◆ subin()

Element & subin ( Element & x,
const Element & y ) const
inline

Inplace Subtraction.

x -= y This function assumes both field elements have already been constructed and initialized. In this implementation, this means for both x and y _elem_ptr exists and does not point to null.

Returns
reference to x.
Parameters
xfield element (reference returned).
yfield element.

◆ mulin()

Element & mulin ( Element & x,
const Element & y ) const
inline

Inplace Multiplication.

x *= y This function assumes both field elements have already been constructed and initialized. In this implementation, this means for both x and y _elem_ptr exists and does not point to null.

Returns
reference to x.
Parameters
xfield element (reference returned).
yfield element.

◆ axpy()

Element & axpy ( Element & r,
const Element & a,
const Element & x,
const Element & y ) const
inline

axpy.

r = a*x + y

Parameters
r
a
x
y

◆ axpyin()

Element & axpyin ( Element & r,
const Element & a,
const Element & x ) const
inline

axpyin.

r += a*x

Parameters
r
a
x

◆ divin()

Element & divin ( Element & x,
const Element & y ) const
inline

Inplace Division.

x /= y This function assumes both field elements have already been constructed and initialized. In this implementation, this means for both x and y _elem_ptr exists and does not point to null.

Returns
reference to x.
Parameters
xfield element (reference returned).
yfield element.

◆ negin()

Element & negin ( Element & x) const
inline

Inplace Additive Inverse (Inplace Negation).

x = - x This function assumes the field element has already been constructed and initialized. In this implementation, this means the _elem_ptr of x exists and does not point to null.

Returns
reference to x.
Parameters
xfield element (reference returned).

◆ invin()

Element & invin ( Element & x) const
inline

Inplace Multiplicative Inverse.

x = 1 / x This function assumes the field elementhas already been constructed and initialized. In this implementation, this means the _elem_ptr of x exists and does not point to null.

Returns
reference to x.
Parameters
xfield element (reference returned).

◆ write() [1/2]

std::ostream & write ( std::ostream & os) const
inline

Print field.

Returns
output stream to which field is written.
Parameters
osoutput stream to which field is written.

This does not do much...

◆ read() [1/2]

std::istream & read ( std::istream & is)
inline

Read field.

Returns
input stream from which field is read.
Parameters
isinput stream from which field is read.

This does not do much either...

FIXME: Read the same thing written above, and throw an exception if the strings do not match.

◆ write() [2/2]

std::ostream & write ( std::ostream & os,
const Element & x ) const
inline

Print field element.

This function assumes the field element has already been constructed and initialized. In this implementation, this means for the _elem_ptr for x exists and does not point to null.

Returns
output stream to which field element is written.
Parameters
osoutput stream to which field element is written.
xfield element.

◆ read() [2/2]

std::istream & read ( std::istream & is,
Element & x ) const
inline

Read field element.

This function assumes the field element has already been constructed and initialized. In this implementation, this means for the _elem_ptr for x exists and does not point to null.

Returns
input stream from which field element is read.
Parameters
isinput stream from which field element is read.
xfield element.

FIXME: Avoid the magical limit on size here FIXME: Right now it skips over everything until it finds something that looks like a number. Is this really the correct policy?

aniau.nosp@m.@ast.nosp@m.ronet.nosp@m..pl: 06/2009: supports scientific E/e notation for decimal fractions

◆ maxCardinality()

static int maxCardinality ( )
inlinestatic

max modulus.

◆ get_num()

integer & get_num ( integer & x,
const Element & y ) const
inline

get numerator.

Parameters
xnumerator of y
y

◆ get_den()

integer & get_den ( integer & x,
const Element & y ) const
inline

get denominator.

Parameters
xdenominator of y
y

◆ sign()

int sign ( const Element & x) const
inline

sign.

Parameters
x
Returns
sign of x

◆ bitsize()

integer & bitsize ( integer & bs,
const Element & q ) const
inline

Bitsize as sum of bitsizes of numerator and denominator.

Parameters
bs
q
Returns
bs

Field Documentation

◆ zero

const Element zero

element type.

◆ one

const Element one

element type.

◆ mOne

const Element mOne

element type.


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