My Project
|
#include "config.h"
#include "cf_assert.h"
#include "cf_factory.h"
#include "cf_defs.h"
#include "cf_globals.h"
#include "canonicalform.h"
#include "cf_iter.h"
#include "int_cf.h"
#include "cf_algorithm.h"
#include "imm.h"
#include "int_pp.h"
#include "gfops.h"
#include "facMul.h"
#include "facAlgFuncUtil.h"
#include "FLINTconvert.h"
#include "cf_binom.h"
Go to the source code of this file.
CanonicalForm bextgcd | ( | const CanonicalForm & | f, |
const CanonicalForm & | g, | ||
CanonicalForm & | a, | ||
CanonicalForm & | b | ||
) |
CanonicalForm bextgcd ( const CanonicalForm & f, const CanonicalForm & g, CanonicalForm & a, CanonicalForm & b )
bextgcd() - return base coefficient extended gcd.
Definition at line 1722 of file canonicalform.cc.
CanonicalForm bgcd | ( | const CanonicalForm & | f, |
const CanonicalForm & | g | ||
) |
CanonicalForm bgcd ( const CanonicalForm & f, const CanonicalForm & g )
bgcd() - return base coefficient gcd.
If both f and g are integers and ‘SW_RATIONAL’ is off the positive greatest common divisor of f and g is returned. Otherwise, if ‘SW_RATIONAL’ is on or one of f and g is not an integer, the greatest common divisor is trivial: either zero if f and g equal zero or one (both from the current domain).
f and g should come from one base domain which should be not the prime power domain.
Implementation:
CanonicalForm::bgcd() handles the immediate case with a standard euclidean algorithm. For the non-immediate cases ‘InternalCF::bgcdsame()’ or ‘InternalCF::bgcdcoeff()’, resp. are called following the usual level/levelcoeff approach.
InternalCF::bgcdsame() and InternalCF::bgcdcoeff() throw an assertion ("not implemented")
InternalInteger::bgcdsame() is a wrapper around ‘mpz_gcd()’ which takes some care about immediate results and the sign of the result InternalInteger::bgcdcoeff() is a wrapper around ‘mpz_gcd_ui()’ which takes some care about the sign of the result
InternalRational::bgcdsame() and InternalRational::bgcdcoeff() always return one
Definition at line 1648 of file canonicalform.cc.
CanonicalForm blcm | ( | const CanonicalForm & | f, |
const CanonicalForm & | g | ||
) |
Definition at line 1816 of file canonicalform.cc.
void divrem | ( | const CanonicalForm & | f, |
const CanonicalForm & | g, | ||
CanonicalForm & | q, | ||
CanonicalForm & | r | ||
) |
Definition at line 1032 of file canonicalform.cc.
bool divremt | ( | const CanonicalForm & | f, |
const CanonicalForm & | g, | ||
CanonicalForm & | q, | ||
CanonicalForm & | r | ||
) |
Definition at line 1066 of file canonicalform.cc.
bool isOn | ( | int | sw | ) |
switches
Definition at line 1971 of file canonicalform.cc.
void Off | ( | int | sw | ) |
void On | ( | int | sw | ) |
bool operator!= | ( | const CanonicalForm & | lhs, |
const CanonicalForm & | rhs | ||
) |
operator !=() returns true iff lhs does not equal rhs.
Definition at line 1492 of file canonicalform.cc.
bool operator< | ( | const CanonicalForm & | lhs, |
const CanonicalForm & | rhs | ||
) |
Definition at line 1585 of file canonicalform.cc.
bool operator== | ( | const CanonicalForm & | lhs, |
const CanonicalForm & | rhs | ||
) |
operator ==() - compare canonical forms on (in)equality.
operator ==() returns true iff lhs equals rhs.
This is the point in factory where we essentially use that CanonicalForms in fact are canonical. There must not be two different representations of the same mathematical object, otherwise, such (in)equality will not be recognized by these operators. In other word, we rely on the fact that structural different factory objects in any case represent different mathematical objects.
So we use the following procedure to test on equality (and analogously on inequality). First, we check whether lhs.value equals rhs.value. If so we are ready and return true. Second, if one of the operands is immediate, but the other one not, we return false. Third, if the operand's levels differ we return false. Fourth, if the operand's levelcoeffs differ we return false. At last, we call the corresponding internal method to compare both operands.
Both operands should have coefficients from the same base domain.
Note: To compare with the zero or the unit of the current domain, you better use the methods ‘CanonicalForm::isZero()’ or ‘CanonicalForm::isOne()’, resp., than something like ‘f == 0’, since the latter is quite a lot slower.
Definition at line 1467 of file canonicalform.cc.
bool operator> | ( | const CanonicalForm & | lhs, |
const CanonicalForm & | rhs | ||
) |
operator >() - compare canonical forms.
on size or level.
The most common and most useful application of these operators is to compare two integers or rationals, of course. However, these operators are defined on all other base domains and on polynomials, too. From a mathematical point of view this may seem meaningless, since there is no ordering on finite fields or on polynomials respecting the algebraic structure. Nevertheless, from a programmer's point of view it may be sensible to order these objects, e.g. to sort them.
Therefore, the ordering defined by these operators in any case is a total ordering which fulfills the law of trichotomy.
It is clear how this is done in the case of the integers and the rationals. For finite fields, all you can say is that zero is the minimal element w.r.t. the ordering, the other elements are ordered in an arbitrary (but total!) way. For polynomials, you have an ordering derived from the lexicographical ordering of monomials. E.g. if lm(f) < lm(g) w.r.t. lexicographic ordering, then f < g. For more details, refer to the documentation of ‘InternalPoly::operator <()’.
Both operands should have coefficients from the same base domain.
The scheme how both operators are implemented is allmost the same as for the assignment operators (check for immediates, then check levels, then check levelcoeffs, then call the appropriate internal comparesame()/comparecoeff() method). For more information, confer to the overview for the arithmetic operators.
Definition at line 1555 of file canonicalform.cc.
CanonicalForm power | ( | const CanonicalForm & | f, |
int | n | ||
) |
exponentiation
Definition at line 1896 of file canonicalform.cc.
CanonicalForm power | ( | const Variable & | v, |
int | n | ||
) |
exponentiation
Definition at line 1939 of file canonicalform.cc.
bool tryDivremt | ( | const CanonicalForm & | f, |
const CanonicalForm & | g, | ||
CanonicalForm & | q, | ||
CanonicalForm & | r, | ||
const CanonicalForm & | M, | ||
bool & | fail | ||
) |
same as divremt but handles zero divisors in case we are in Z_p[x]/(f) where f is not irreducible
Definition at line 1108 of file canonicalform.cc.