164 if (this->
isZero())
return true;
170 int cdeg = -2, dummy;
171 for (
i = *
this;
i.hasTerms();
i++ )
173 if (!(
i.coeff().isHomogeneous()))
return false;
176 if (cdeg == -2) cdeg = dummy;
186 for (
i=termlist;
i.hasItem();
i++ )
232 ASSERT( 0,
"illegal domain" );
442 coeffdeg =
i.coeff().degree(
v );
612 else if ( what ==
GFMARK )
654 else if ( what ==
GFMARK )
696 else if ( what ==
GFMARK )
708 #if (HAVE_NTL && HAVE_FLINT && __FLINT_RELEASE >= 20400)
750 else if ( what ==
GFMARK )
762 #if (HAVE_NTL && HAVE_FLINT && __FLINT_RELEASE >= 20400)
804 else if ( what ==
GFMARK )
850 else if ( what ==
GFMARK )
890 else if ( what ==
GFMARK )
932 else if ( what ==
GFMARK )
975 else if ( what ==
GFMARK )
981 g.value->divremcoeff(
f.value, qq, rr,
true );
982 else if ( (what=
is_imm(
g.value )) )
983 f.value->divremcoeff(
g.value, qq, rr,
false );
984 else if (
f.value->level() ==
g.value->level() )
985 if (
f.value->levelcoeff() ==
g.value->levelcoeff() )
986 f.value->divremsame(
g.value, qq, rr );
987 else if (
f.value->levelcoeff() >
g.value->levelcoeff() )
988 f.value->divremcoeff(
g.value, qq, rr,
false );
990 g.value->divremcoeff(
f.value, qq, rr,
true );
991 else if (
f.value->level() >
g.value->level() )
992 f.value->divremcoeff(
g.value, qq, rr,
false );
994 g.value->divremcoeff(
f.value, qq, rr,
true );
995 ASSERT( qq != 0 && rr != 0,
"error in divrem" );
1010 else if ( what ==
GFMARK )
1016 result =
g.value->divremcoefft(
f.value, qq, rr,
true );
1017 else if ( (what=
is_imm(
g.value )) )
1018 result =
f.value->divremcoefft(
g.value, qq, rr,
false );
1019 else if (
f.value->level() ==
g.value->level() )
1020 if (
f.value->levelcoeff() ==
g.value->levelcoeff() )
1021 result =
f.value->divremsamet(
g.value, qq, rr );
1022 else if (
f.value->levelcoeff() >
g.value->levelcoeff() )
1023 result =
f.value->divremcoefft(
g.value, qq, rr,
false );
1025 result =
g.value->divremcoefft(
f.value, qq, rr,
true );
1026 else if (
f.value->level() >
g.value->level() )
1027 result =
f.value->divremcoefft(
g.value, qq, rr,
false );
1029 result =
g.value->divremcoefft(
f.value, qq, rr,
true );
1031 ASSERT( qq != 0 && rr != 0,
"error in divrem" );
1055 else if ( what ==
GFMARK )
1059 result =
g.value->tryDivremcoefft(
f.value, qq, rr,
true,
M, fail );
1060 else if ( (what=
is_imm(
g.value )) )
1061 result =
f.value->tryDivremcoefft(
g.value, qq, rr,
false,
M, fail );
1062 else if (
f.value->level() ==
g.value->level() )
1063 if (
f.value->levelcoeff() ==
g.value->levelcoeff() )
1064 result =
f.value->tryDivremsamet(
g.value, qq, rr,
M, fail );
1065 else if (
f.value->levelcoeff() >
g.value->levelcoeff() )
1066 result =
f.value->tryDivremcoefft(
g.value, qq, rr,
false,
M, fail );
1068 result =
g.value->tryDivremcoefft(
f.value, qq, rr,
true,
M, fail );
1069 else if (
f.value->level() >
g.value->level() )
1070 result =
f.value->tryDivremcoefft(
g.value, qq, rr,
false,
M, fail );
1072 result =
g.value->tryDivremcoefft(
f.value, qq, rr,
true,
M, fail );
1080 ASSERT( qq != 0 && rr != 0,
"error in divrem" );
1111 int lastExp =
i.exp();
1114 while (
i.hasTerms() ) {
1115 if ( (lastExp -
i.exp()) == 1 )
1127 int lastExp =
i.exp();
1130 while (
i.hasTerms() )
1133 if ( (lastExp - i_exp ) == 1 )
1165 return (*
this)(
f );
1214 ASSERT(
i >= 0,
"index to operator [] less than zero" );
1257 ASSERT(
x.
level() > 0,
"cannot derive with respect to algebraic variables" );
1323 ASSERT( n >= 0,
"arg to sqrt() less than zero" );
1324 if ( n == 0 || n == 1 )
1332 y = (
unsigned long)(
x + n/
x)/2;
1358 ASSERT( a > 0,
"arg to ilog2() less or equal zero" );
1416 "incompatible operands" );
1441 "incompatible operands" );
1505 else if ( what ==
FFMARK )
1536 else if ( what ==
FFMARK )
1595 ASSERT( ! what || (what ==
is_imm(
f.value )),
"incompatible operands" );
1597 return g.value->bgcdcoeff(
f.value );
1605 if ( fInt < 0 ) fInt = -fInt;
1619 long r = fInt %
gInt;
1632 return f.value->bgcdcoeff(
g.value );
1634 int fLevel =
f.value->level();
1635 int gLevel =
g.value->level();
1638 if ( fLevel == gLevel )
1640 fLevel =
f.value->levelcoeff();
1641 gLevel =
g.value->levelcoeff();
1644 if ( fLevel == gLevel )
1645 return f.value->bgcdsame(
g.value );
1646 else if ( fLevel < gLevel )
1647 return g.value->bgcdcoeff(
f.value );
1649 return f.value->bgcdcoeff(
g.value );
1651 else if ( fLevel < gLevel )
1652 return g.value->bgcdcoeff(
f.value );
1654 return f.value->bgcdcoeff(
g.value );
1668 ASSERT( ! what || (what ==
is_imm(
f.value )),
"incompatible operands" );
1670 return g.value->bextgcdcoeff(
f.value,
b, a );
1680 if ( fInt < 0 ) fInt = -fInt;
1683 if (
gInt > fInt ) {
1689 long u = 1;
long v = 0;
1690 long uNext = 0;
long vNext = 1;
1698 long r = fInt %
gInt;
1699 long q = fInt /
gInt;
1700 long uSwap = u - q * uNext;
1701 long vSwap =
v - q * vNext;
1706 u = uNext;
v = vNext;
1707 uNext = uSwap; vNext = vSwap;
1713 if ( gTest > fTest ) {
1718 if ( fTest < 0 ) a = -a;
1719 if ( gTest < 0 )
b = -
b;
1723 if ( !
f.isZero() ) {
1725 }
else if ( !
g.isZero() ) {
1732 return f.value->bextgcdcoeff(
g.value, a,
b );
1734 int fLevel =
f.value->level();
1735 int gLevel =
g.value->level();
1738 if ( fLevel == gLevel ) {
1739 fLevel =
f.value->levelcoeff();
1740 gLevel =
g.value->levelcoeff();
1743 if ( fLevel == gLevel )
1744 return f.value->bextgcdsame(
g.value, a,
b );
1745 else if ( fLevel < gLevel )
1746 return g.value->bextgcdcoeff(
f.value,
b, a );
1748 return f.value->bextgcdcoeff(
g.value, a,
b );
1750 else if ( fLevel < gLevel )
1751 return g.value->bextgcdcoeff(
f.value,
b, a );
1753 return f.value->bextgcdcoeff(
g.value, a,
b );
1759 if (
f.isZero() ||
g.isZero() )
1813 else if ( what ==
GFMARK )
1827 else if ( what ==
GFMARK )
1839 ASSERT( n >= 0,
"illegal exponent" );
1842 else if (
f.isOne() )
This file defines functions for conversion to FLINT (www.flintlib.org) and back.
declarations of higher level algorithms.
CFList get_Terms(const CanonicalForm &f)
#define ASSERT(expression, message)
#define FiniteFieldDomain
static const int SW_RATIONAL
set to 1 for computations over Q
#define GaloisFieldDomain
void getmpi(InternalCF *value, mpz_t mpi)
Interface to generate InternalCF's over various domains from intrinsic types or mpz_t's.
Iterators for CanonicalForm's.
CFSwitches cf_glob_switches
CFSwitches cf_glob_switches;.
static InternalCF * basic(long value)
class to iterate through CanonicalForm's
void On(int s)
switch 's' on
void Off(int s)
switch 's' off
bool isOn(int s) const
check if 's' is on
virtual class for internal CanonicalForm's
virtual InternalCF * modulosame(InternalCF *) PVIRT_INTCF("modulosame")
virtual int intmod(int) const
virtual InternalCF * mulsame(InternalCF *) PVIRT_INTCF("mulsame")
virtual CanonicalForm Lc()
virtual InternalCF * divcoeff(InternalCF *, bool) PVIRT_INTCF("divcoeff")
virtual InternalCF * tryDivcoeff(InternalCF *, bool, const CanonicalForm &, bool &)
virtual InternalCF * modulocoeff(InternalCF *, bool) PVIRT_INTCF("dividecoeff")
virtual InternalCF * subsame(InternalCF *) PVIRT_INTCF("subsame")
virtual CanonicalForm tailcoeff()
CanonicalForm InternalCF::tailcoeff (), int InternalCF::taildegree ()
virtual bool inPolyDomain() const
virtual CanonicalForm lc()
CanonicalForm InternalCF::lc (), Lc (), LC ()
virtual long intval() const
virtual InternalCF * genOne() PVIRT_INTCF("genOne")
virtual InternalCF * dividesame(InternalCF *) PVIRT_INTCF("dividesame")
virtual bool inExtension() const
virtual void print(OSTREAM &, char *) PVIRT_VOID("print")
virtual int levelcoeff() const
virtual int degree()
int InternalCF::degree ()
virtual InternalCF * addcoeff(InternalCF *) PVIRT_INTCF("addcoeff")
virtual InternalCF * modsame(InternalCF *) PVIRT_INTCF("modsame")
virtual int ilog2()
int InternalCF::ilog2 ()
virtual int comparesame(InternalCF *) PVIRT_INT("comparesame")
virtual bool inCoeffDomain() const
virtual CanonicalForm LC()
virtual InternalCF * num()
InternalCF * InternalCF::num (), den ()
virtual int comparecoeff(InternalCF *) PVIRT_INT("comparecoeff")
virtual InternalCF * den()
virtual Variable variable() const
virtual InternalCF * sqrt()
InternalCF * InternalCF::sqrt ()
virtual int sign() const PVIRT_INT("sign")
virtual bool inBaseDomain() const
virtual InternalCF * genZero() PVIRT_INTCF("genZero")
virtual InternalCF * tryDivsame(InternalCF *, const CanonicalForm &, bool &)
virtual InternalCF * addsame(InternalCF *) PVIRT_INTCF("addsame")
virtual InternalCF * subcoeff(InternalCF *, bool) PVIRT_INTCF("subcoeff")
virtual CanonicalForm coeff(int i)
CanonicalForm InternalCF::coeff ( int i )
virtual int level() const
virtual InternalCF * modcoeff(InternalCF *, bool) PVIRT_INTCF("modcoeff")
InternalCF * copyObject()
virtual bool isUnivariate() const
virtual bool inQuotDomain() const
virtual InternalCF * dividecoeff(InternalCF *, bool) PVIRT_INTCF("dividecoeff")
virtual InternalCF * deepCopyObject() const PVIRT_INTCF("deepCopyObject")
virtual InternalCF * mulcoeff(InternalCF *) PVIRT_INTCF("mulcoeff")
virtual InternalCF * divsame(InternalCF *) PVIRT_INTCF("divsame")
factory's class for variables
const CanonicalForm int const CFList const Variable & y
const Variable & v
< [in] a sqrfree bivariate poly
CanonicalForm mulNTL(const CanonicalForm &F, const CanonicalForm &G, const modpk &b)
multiplication of univariate polys using FLINT/NTL over F_p, F_q, Z/p^k, Z/p^k[t]/(f),...
CanonicalForm divNTL(const CanonicalForm &F, const CanonicalForm &G, const modpk &b)
division of univariate polys using FLINT/NTL over F_p, F_q, Z/p^k, Z/p^k[t]/(f), Z,...
This file defines functions for fast multiplication and division with remainder.
bool hasMipo(const Variable &alpha)
int ff_symmetric(const int a)
static long gInt(number &a, const coeffs)
Operations in GF, where GF is a finite field of size less than 2^16 represented by a root of Conway p...
operations on immediates, that is elements of F_p, GF, Z, Q that fit into intrinsic int,...
InternalCF * int2imm_p(long i)
void imm_divrem_gf(const InternalCF *const lhs, const InternalCF *const rhs, InternalCF *&q, InternalCF *&r)
InternalCF * imm_sub_p(const InternalCF *const lhs, const InternalCF *const rhs)
InternalCF * imm_mul_p(const InternalCF *const lhs, const InternalCF *const rhs)
static long imm2int(const InternalCF *const imm)
InternalCF * imm_add(const InternalCF *const lhs, const InternalCF *const rhs)
InternalCF * imm_mod_p(const InternalCF *const, const InternalCF *const)
InternalCF * imm_div(const InternalCF *const lhs, const InternalCF *const rhs)
InternalCF * imm_sub(const InternalCF *const lhs, const InternalCF *const rhs)
int imm_sign(const InternalCF *const op)
imm_sign() - return sign of immediate object.
InternalCF * imm_add_gf(const InternalCF *const lhs, const InternalCF *const rhs)
int imm_cmp_p(const InternalCF *const lhs, const InternalCF *const rhs)
InternalCF * imm_divrat(const InternalCF *const lhs, const InternalCF *const rhs)
InternalCF * imm_div_p(const InternalCF *const lhs, const InternalCF *const rhs)
int imm_cmp_gf(const InternalCF *const lhs, const InternalCF *const rhs)
InternalCF * imm_div_gf(const InternalCF *const lhs, const InternalCF *const rhs)
int imm_iszero(const InternalCF *const ptr)
int imm_iszero_gf(const InternalCF *const ptr)
void imm_print(OSTREAM &os, const InternalCF *const op, const char *const str)
long imm_intval(const InternalCF *const op)
static InternalCF * int2imm(long i)
int imm_iszero_p(const InternalCF *const ptr)
InternalCF * imm_mul_gf(const InternalCF *const lhs, const InternalCF *const rhs)
InternalCF * imm_mod_gf(const InternalCF *const, const InternalCF *const)
InternalCF * imm_mod(const InternalCF *const lhs, const InternalCF *const rhs)
int imm_cmp(const InternalCF *const lhs, const InternalCF *const rhs)
imm_cmp(), imm_cmp_p(), imm_cmp_gf() - compare immediate objects.
InternalCF * int2imm_gf(long i)
void imm_divrem_p(const InternalCF *const lhs, const InternalCF *const rhs, InternalCF *&q, InternalCF *&r)
InternalCF * imm_add_p(const InternalCF *const lhs, const InternalCF *const rhs)
InternalCF * imm_mul(InternalCF *lhs, InternalCF *rhs)
void imm_divrem(const InternalCF *const lhs, const InternalCF *const rhs, InternalCF *&q, InternalCF *&r)
InternalCF * imm_sub_gf(const InternalCF *const lhs, const InternalCF *const rhs)
Factory's internal CanonicalForm's.
bool getReduce(const Variable &alpha)