Givaro
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | Friends
Rational Class Reference

Rationals. No doc. More...

#include <givrational.h>

+ Collaboration diagram for Rational:

Public Types

enum  ReduceFlag { Reduce = 0x1, NoReduce = 0x0 }
 

Public Member Functions

 Rational (Neutral n=Neutral::zero)
 
 Rational (int32_t n)
 
 Rational (uint32_t n)
 
 Rational (int64_t n)
 
 Rational (uint64_t n)
 
 Rational (int64_t n, int64_t d)
 
 Rational (uint64_t n, uint64_t d)
 
 Rational (int32_t n, int32_t d)
 
 Rational (uint32_t n, uint32_t d)
 
 Rational (double x)
 
 Rational (const char *s)
 
 Rational (const Integer &n)
 
 Rational (const Integer &n, const Integer &d, int red=1)
 
 Rational (const Integer &f, const Integer &m, const Integer &k, bool recurs=false)
 Rational number reconstruction. More...
 
 Rational (const Rational &)
 
Rationaloperator= (const Rational &)
 
Rationallogcpy (const Rational &)
 
Rationalcopy (const Rational &)
 
Rational operator+ (const Rational &r) const
 
Rational operator- (const Rational &r) const
 
Rational operator- () const
 
Rational operator+ () const
 
Rational operator* (const Rational &r) const
 
Rational operator/ (const Rational &r) const
 
Rationaloperator+= (const Rational &r)
 
Rationaloperator-= (const Rational &r)
 
Rationaloperator*= (const Rational &r)
 
Rationaloperator/= (const Rational &r)
 
Integer operator% (const Integer &r) const
 
const Integer nume () const
 
const Integer deno () const
 
std::ostream & print (std::ostream &o) const
 
Rational reduce (const Rational &R) const
 
 operator short () const
 
 operator uint16_t () const
 
 operator uint8_t () const
 
 operator uint32_t () const
 
 operator int () const
 
 operator signed char () const
 
 operator uint64_t () const
 
 operator int64_t () const
 
 operator std::string () const
 
 operator float () const
 
 operator double () const
 
 Rational (givNoInit)
 

Static Public Member Functions

static void SetReduce ()
 
static void SetNoReduce ()
 

Static Public Attributes

static const Rational zero
 
static const Rational one
 
static const Rational mOne
 
static GivModule Module
 

Protected Member Functions

Rationalreduce ()
 
bool ratrecon (const Integer &f, const Integer &m, const Integer &k, bool recurs=false)
 

Static Protected Member Functions

static void Init (int *argc, char ***argv)
 
static void End ()
 

Protected Attributes

Integer num
 
Integer den
 

Static Protected Attributes

static ReduceFlag flags = Rational::Reduce
 

Friends

class GivModule
 
class QField< Rational >
 
int compare (const Rational &a, const Rational &b)
 
int absCompare (const Rational &a, const Rational &b)
 
const Rational pow (const Rational &r, const int64_t l)
 
const Integer floor (const Rational &r)
 
const Integer ceil (const Rational &r)
 
const Integer round (const Rational &r)
 
const Integer trunc (const Rational &r)
 
const Rational abs (const Rational &r)
 
const Rational pow (const Rational &n, uint32_t l)
 
const Rational pow (const Rational &n, uint64_t l)
 
uint64_t length (const Rational &r)
 
int sign (const Rational &r)
 
int isZero (const Rational &r)
 
int isOne (const Rational &r)
 
int isMOne (const Rational &r)
 
int isInteger (const Rational &r)
 

Detailed Description

Rationals. No doc.

Examples:
examples/Rational/iratrecon.C.

Member Enumeration Documentation

enum ReduceFlag
Enumerator
Reduce 
NoReduce 

Constructor & Destructor Documentation

Rational ( int32_t  n)
Rational ( uint32_t  n)
Rational ( int64_t  n)
Rational ( uint64_t  n)
Rational ( int64_t  n,
int64_t  d 
)
Rational ( uint64_t  n,
uint64_t  d 
)
Rational ( int32_t  n,
int32_t  d 
)
Rational ( uint32_t  n,
uint32_t  d 
)
Rational ( double  x)
Rational ( const char *  s)
Rational ( const Integer n)
Rational ( const Integer n,
const Integer d,
int  red = 1 
)
Rational ( const Integer f,
const Integer m,
const Integer k,
bool  recurs = false 
)

Rational number reconstruction.

$ num/den \equiv f \mod m$, with $|num|<k$ and $0 < |den| \leq f/kf$

Bibliography:
  • von zur Gathen & Gerhard Modern Computer Algebra, 5.10, Cambridge Univ. Press 1999]
Rational ( const Rational r)

Member Function Documentation

Rational & operator= ( const Rational r)
Rational & logcpy ( const Rational r)
Rational & copy ( const Rational r)
Rational operator+ ( const Rational r) const
Rational operator- ( const Rational r) const
Rational operator- ( ) const
Rational operator+ ( ) const
inline
Rational operator* ( const Rational r) const
Rational operator/ ( const Rational r) const
Rational & operator+= ( const Rational r)
Rational & operator-= ( const Rational r)
Rational & operator*= ( const Rational r)
Rational & operator/= ( const Rational r)
Integer operator% ( const Integer r) const
const Integer nume ( ) const
inline
const Integer deno ( ) const
inline
std::ostream & print ( std::ostream &  o) const
Rational reduce ( const Rational R) const
inline
void SetReduce ( )
static
void SetNoReduce ( )
static
operator short ( ) const
inline
operator uint16_t ( ) const
inline
operator uint8_t ( ) const
inline
operator uint32_t ( ) const
inline
operator int ( ) const
inline
operator signed char ( ) const
inline
operator uint64_t ( ) const
inline
operator int64_t ( ) const
inline
operator std::string ( ) const
inline
operator float ( ) const
inline
operator double ( ) const
inline
Rational & reduce ( )
protected
void Init ( int *  argc,
char ***  argv 
)
staticprotected
void End ( )
staticprotected
bool ratrecon ( const Integer f,
const Integer m,
const Integer k,
bool  recurs = false 
)
protected

Friends And Related Function Documentation

friend class GivModule
friend
friend class QField< Rational >
friend
int compare ( const Rational a,
const Rational b 
)
friend
int absCompare ( const Rational a,
const Rational b 
)
friend
const Rational pow ( const Rational r,
const int64_t  l 
)
friend
const Integer floor ( const Rational r)
friend
const Integer ceil ( const Rational r)
friend
const Integer round ( const Rational r)
friend
const Integer trunc ( const Rational r)
friend
const Rational abs ( const Rational r)
friend
const Rational pow ( const Rational n,
uint32_t  l 
)
friend
const Rational pow ( const Rational n,
uint64_t  l 
)
friend
uint64_t length ( const Rational r)
friend
int sign ( const Rational r)
friend
int isZero ( const Rational r)
friend
int isOne ( const Rational r)
friend
int isMOne ( const Rational r)
friend
int isInteger ( const Rational r)
friend

Field Documentation

const Rational zero
static
const Rational one
static
const Rational mOne
static
Integer num
protected
Integer den
protected
Rational::ReduceFlag flags = Rational::Reduce
staticprotected
GivModule Module
static

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