Loading...
Searching...
No Matches
int_rat.h
Go to the documentation of this file.
/* emacs edit mode for this file is -*- C++ -*- */
#ifndef INCL_INT_RAT_H
#define INCL_INT_RAT_H
/**
* @file int_rat.h
*
* Factory's internal rationals
**/
// #include "config.h"
#ifndef NOSTREAMIO
#ifdef HAVE_IOSTREAM
#include <iostream>
#define OSTREAM std::ostream
#elif defined(HAVE_IOSTREAM_H)
#include <iostream.h>
#define OSTREAM ostream
#endif
#endif /* NOSTREAMIO */
#include "cf_assert.h"
#include "canonicalform.h"
#include "int_cf.h"
#include "imm.h"
#ifdef HAVE_FLINT
#ifdef __cplusplus
extern "C"
{
#endif
#ifndef __GMP_BITS_PER_MP_LIMB
#define __GMP_BITS_PER_MP_LIMB GMP_LIMB_BITS
#endif
#include <flint/fmpz.h>
#include <flint/fmpq.h>
#ifdef __cplusplus
}
#endif
#endif
/**
* factory's class for rationals
*
* a rational is represented as two mpz_t's _num, _den
*
* Note: If you want to compute over Q make sure that SW_RATIONAL is set to 1!
*
* @sa InternalInteger
**/
class InternalRational : public InternalCF
{
private:
mpz_t _num;
mpz_t _den;
STATIC_VAR int initialized;
static mpz_ptr MPQNUM( const InternalCF * const c );
static mpz_ptr MPQDEN( const InternalCF * const c );
static void normalize( const mpz_ptr, const mpz_ptr, mpz_ptr, mpz_ptr );
public:
InternalRational();
InternalRational( const InternalCF& )
{
ASSERT( 0, "ups there is something wrong in your code" );
}
InternalRational( const int i );
InternalRational( const int n, const int d );
InternalRational( const long i );
InternalRational( const long n, const long d );
InternalRational( const char * str );
InternalRational( const mpz_ptr );
InternalRational( const mpz_ptr , const mpz_ptr );
~InternalRational();
InternalCF* deepCopyObject() const;
const char * classname() const { return "InternalRational"; }
#ifndef NOSTREAMIO
void print( OSTREAM&, char* );
#endif /* NOSTREAMIO */
InternalCF* genZero();
InternalCF* genOne();
bool is_imm() const;
int levelcoeff() const { return RationalDomain; }
InternalCF* num();
InternalCF* den();
InternalCF* neg();
int comparesame( InternalCF* );
InternalCF* addsame( InternalCF* );
InternalCF* subsame( InternalCF* );
InternalCF* mulsame( InternalCF* );
InternalCF* dividesame( InternalCF* );
InternalCF* modulosame( InternalCF* );
InternalCF* divsame( InternalCF* );
InternalCF* modsame( InternalCF* );
void divremsame( InternalCF*, InternalCF*&, InternalCF*& );
bool divremsamet( InternalCF*, InternalCF*&, InternalCF*& );
int comparecoeff( InternalCF* );
InternalCF* addcoeff( InternalCF* );
InternalCF* subcoeff( InternalCF*, bool );
InternalCF* mulcoeff( InternalCF* );
InternalCF* dividecoeff( InternalCF*, bool );
InternalCF* modulocoeff( InternalCF*, bool );
InternalCF* divcoeff( InternalCF*, bool );
InternalCF* modcoeff( InternalCF*, bool );
void divremcoeff( InternalCF*, InternalCF*&, InternalCF*&, bool );
bool divremcoefft( InternalCF*, InternalCF*&, InternalCF*&, bool );
InternalCF * bgcdsame ( const InternalCF * const ) const;
InternalCF * bgcdcoeff ( const InternalCF * const );
InternalCF * bextgcdsame ( InternalCF *, CanonicalForm &, CanonicalForm & );
InternalCF * bextgcdcoeff ( InternalCF *, CanonicalForm &, CanonicalForm & );
long intval() const;
int sign() const;
InternalCF * normalize_myself();
friend class InternalInteger;
friend void gmp_numerator ( const CanonicalForm & f, mpz_ptr result );
friend void gmp_denominator ( const CanonicalForm & f, mpz_ptr result );
friend CanonicalForm make_cf ( const mpz_ptr n, const mpz_ptr d );
#ifdef HAVE_FLINT
friend void convertCF2Fmpq(fmpq_t result, const CanonicalForm& f);
#endif
};
inline mpz_ptr InternalRational::MPQNUM( const InternalCF * const c )
{
return (((InternalRational*)c)->_num);
}
inline mpz_ptr InternalRational::MPQDEN( const InternalCF * const c )
{
return (((InternalRational*)c)->_den);
}
#endif /* ! INCL_INT_RAT_H */
canonicalform.h
Header for factory's main class CanonicalForm.
OSTREAM
#define OSTREAM
Definition canonicalform.h:16
i
int i
Definition cfEzgcd.cc:132
cf_assert.h
assertions for Factory
ASSERT
#define ASSERT(expression, message)
Definition cf_assert.h:99
RationalDomain
#define RationalDomain
Definition cf_defs.h:20
f
FILE * f
Definition checklibs.c:9
CanonicalForm
factory's main class
Definition canonicalform.h:86
InternalCF
virtual class for internal CanonicalForm's
Definition int_cf.h:47
InternalCF::InternalCF
InternalCF()
Definition int_cf.h:55
InternalRational::divremcoeff
void divremcoeff(InternalCF *, InternalCF *&, InternalCF *&, bool)
Definition int_rat.cc:805
InternalRational::divsame
InternalCF * divsame(InternalCF *)
Definition int_rat.cc:473
InternalRational::_num
mpz_t _num
Definition int_rat.h:57
InternalRational::initialized
STATIC_VAR int initialized
Definition int_rat.h:59
InternalRational::bextgcdcoeff
InternalCF * bextgcdcoeff(InternalCF *, CanonicalForm &, CanonicalForm &)
Definition int_rat.cc:850
InternalRational::subcoeff
InternalCF * subcoeff(InternalCF *, bool)
Definition int_rat.cc:597
InternalRational::normalize_myself
InternalCF * normalize_myself()
reduce InternalRational to lowest terms
Definition int_rat.cc:859
InternalRational::comparesame
int comparesame(InternalCF *)
comparesame(), comparecoeff() - compare with an InternalRational.
Definition int_rat.cc:516
InternalRational::gmp_denominator
friend void gmp_denominator(const CanonicalForm &f, mpz_ptr result)
Definition singext.cc:40
InternalRational::InternalRational
InternalRational()
Definition int_rat.cc:34
InternalRational::InternalInteger
friend class InternalInteger
Definition int_rat.h:129
InternalRational::intval
long intval() const
Definition int_rat.cc:897
InternalRational::levelcoeff
int levelcoeff() const
Definition int_rat.h:86
InternalRational::modsame
InternalCF * modsame(InternalCF *)
Definition int_rat.cc:483
InternalRational::genOne
InternalCF * genOne()
Definition int_rat.cc:167
InternalRational::is_imm
bool is_imm() const
Definition int_rat.cc:154
InternalRational::sign
int sign() const
Definition int_rat.cc:909
InternalRational::_den
mpz_t _den
Definition int_rat.h:58
InternalRational::addsame
InternalCF * addsame(InternalCF *)
Definition int_rat.cc:234
InternalRational::bgcdcoeff
InternalCF * bgcdcoeff(const InternalCF *const)
Definition int_rat.cc:831
InternalRational::num
InternalCF * num()
Definition int_rat.cc:178
InternalRational::genZero
InternalCF * genZero()
Definition int_rat.cc:159
InternalRational::divremcoefft
bool divremcoefft(InternalCF *, InternalCF *&, InternalCF *&, bool)
Definition int_rat.cc:812
InternalRational::divremsamet
bool divremsamet(InternalCF *, InternalCF *&, InternalCF *&)
Definition int_rat.cc:496
InternalRational::bextgcdsame
InternalCF * bextgcdsame(InternalCF *, CanonicalForm &, CanonicalForm &)
Definition int_rat.cc:840
InternalRational::bgcdsame
InternalCF * bgcdsame(const InternalCF *const) const
Definition int_rat.cc:822
InternalRational::mulsame
InternalCF * mulsame(InternalCF *)
Definition int_rat.cc:348
InternalRational::modcoeff
InternalCF * modcoeff(InternalCF *, bool)
Definition int_rat.cc:797
InternalRational::make_cf
friend CanonicalForm make_cf(const mpz_ptr n, const mpz_ptr d)
InternalRational::deepCopyObject
InternalCF * deepCopyObject() const
Definition int_rat.cc:131
InternalRational::divremsame
void divremsame(InternalCF *, InternalCF *&, InternalCF *&)
Definition int_rat.cc:489
InternalRational::divcoeff
InternalCF * divcoeff(InternalCF *, bool)
Definition int_rat.cc:787
InternalRational::dividecoeff
InternalCF * dividecoeff(InternalCF *, bool)
Definition int_rat.cc:707
InternalRational::dividesame
InternalCF * dividesame(InternalCF *)
Definition int_rat.cc:408
InternalRational::convertCF2Fmpq
friend void convertCF2Fmpq(fmpq_t result, const CanonicalForm &f)
conversion of a factory rationals to fmpq_t
Definition FLINTconvert.cc:220
InternalRational::den
InternalCF * den()
Definition int_rat.cc:196
InternalRational::neg
InternalCF * neg()
InternalCF * InternalRational::neg ().
Definition int_rat.cc:215
InternalRational::addcoeff
InternalCF * addcoeff(InternalCF *)
Definition int_rat.cc:560
InternalRational::~InternalRational
~InternalRational()
Definition int_rat.cc:125
InternalRational::gmp_numerator
friend void gmp_numerator(const CanonicalForm &f, mpz_ptr result)
Definition singext.cc:20
InternalRational::MPQDEN
static mpz_ptr MPQDEN(const InternalCF *const c)
Definition int_rat.h:143
InternalRational::modulosame
InternalCF * modulosame(InternalCF *)
Definition int_rat.cc:478
InternalRational::print
void print(OSTREAM &, char *)
Definition int_rat.cc:141
InternalRational::classname
const char * classname() const
Definition int_rat.h:78
InternalRational::comparecoeff
int comparecoeff(InternalCF *)
comparecoeff() compares the CO=a/b and the integer c using the equivalence a/b < c iff a < c*b.
Definition int_rat.cc:536
InternalRational::InternalRational
InternalRational(const InternalCF &)
Definition int_rat.h:65
InternalRational::subsame
InternalCF * subsame(InternalCF *)
Definition int_rat.cc:292
InternalRational::normalize
static void normalize(const mpz_ptr, const mpz_ptr, mpz_ptr, mpz_ptr)
InternalRational::MPQNUM
static mpz_ptr MPQNUM(const InternalCF *const c)
Definition int_rat.h:138
InternalRational::modulocoeff
InternalCF * modulocoeff(InternalCF *, bool)
Definition int_rat.cc:792
InternalRational::mulcoeff
InternalCF * mulcoeff(InternalCF *)
Definition int_rat.cc:654
result
return result
Definition facAbsBiFact.cc:76
STATIC_VAR
#define STATIC_VAR
Definition globaldefs.h:7
imm.h
operations on immediates, that is elements of F_p, GF, Z, Q that fit into intrinsic int,...
int_cf.h
Factory's internal CanonicalForm's.