166 if (this->
isZero())
return true;
172 int cdeg = -2, dummy;
173 for (
i = *
this;
i.hasTerms();
i++ )
175 if (!(
i.coeff().isHomogeneous()))
return false;
178 if (cdeg == -2) cdeg = dummy;
188 for (
i=termlist;
i.hasItem();
i++ )
234 ASSERT( 0,
"illegal domain" );
444 coeffdeg =
i.coeff().degree(
v );
614 else if ( what ==
GFMARK )
656 else if ( what ==
GFMARK )
698 else if ( what ==
GFMARK )
710 #if (HAVE_NTL && HAVE_FLINT && __FLINT_RELEASE >= 20400) 752 else if ( what ==
GFMARK )
764 #if (HAVE_NTL && HAVE_FLINT && __FLINT_RELEASE >= 20400) 806 else if ( what ==
GFMARK )
852 else if ( what ==
GFMARK )
892 else if ( what ==
GFMARK )
934 else if ( what ==
GFMARK )
977 else if ( what ==
GFMARK )
983 g.value->divremcoeff(
f.value, qq, rr,
true );
984 else if ( (what=
is_imm(
g.value )) )
985 f.value->divremcoeff(
g.value, qq, rr,
false );
986 else if (
f.value->level() ==
g.value->level() )
987 if (
f.value->levelcoeff() ==
g.value->levelcoeff() )
988 f.value->divremsame(
g.value, qq, rr );
989 else if (
f.value->levelcoeff() >
g.value->levelcoeff() )
990 f.value->divremcoeff(
g.value, qq, rr,
false );
992 g.value->divremcoeff(
f.value, qq, rr,
true );
993 else if (
f.value->level() >
g.value->level() )
994 f.value->divremcoeff(
g.value, qq, rr,
false );
996 g.value->divremcoeff(
f.value, qq, rr,
true );
997 ASSERT( qq != 0 && rr != 0,
"error in divrem" );
1012 else if ( what ==
GFMARK )
1018 result =
g.value->divremcoefft(
f.value, qq, rr,
true );
1019 else if ( (what=
is_imm(
g.value )) )
1020 result =
f.value->divremcoefft(
g.value, qq, rr,
false );
1021 else if (
f.value->level() ==
g.value->level() )
1022 if (
f.value->levelcoeff() ==
g.value->levelcoeff() )
1023 result =
f.value->divremsamet(
g.value, qq, rr );
1024 else if (
f.value->levelcoeff() >
g.value->levelcoeff() )
1025 result =
f.value->divremcoefft(
g.value, qq, rr,
false );
1027 result =
g.value->divremcoefft(
f.value, qq, rr,
true );
1028 else if (
f.value->level() >
g.value->level() )
1029 result =
f.value->divremcoefft(
g.value, qq, rr,
false );
1031 result =
g.value->divremcoefft(
f.value, qq, rr,
true );
1033 ASSERT( qq != 0 && rr != 0,
"error in divrem" );
1057 else if ( what ==
GFMARK )
1061 result =
g.value->tryDivremcoefft(
f.value, qq, rr,
true,
M, fail );
1062 else if ( (what=
is_imm(
g.value )) )
1063 result =
f.value->tryDivremcoefft(
g.value, qq, rr,
false,
M, fail );
1064 else if (
f.value->level() ==
g.value->level() )
1065 if (
f.value->levelcoeff() ==
g.value->levelcoeff() )
1066 result =
f.value->tryDivremsamet(
g.value, qq, rr,
M, fail );
1067 else if (
f.value->levelcoeff() >
g.value->levelcoeff() )
1068 result =
f.value->tryDivremcoefft(
g.value, qq, rr,
false,
M, fail );
1070 result =
g.value->tryDivremcoefft(
f.value, qq, rr,
true,
M, fail );
1071 else if (
f.value->level() >
g.value->level() )
1072 result =
f.value->tryDivremcoefft(
g.value, qq, rr,
false,
M, fail );
1074 result =
g.value->tryDivremcoefft(
f.value, qq, rr,
true,
M, fail );
1082 ASSERT( qq != 0 && rr != 0,
"error in divrem" );
1113 int lastExp =
i.exp();
1116 while (
i.hasTerms() ) {
1117 if ( (lastExp -
i.exp()) == 1 )
1129 int lastExp =
i.exp();
1132 while (
i.hasTerms() )
1135 if ( (lastExp - i_exp ) == 1 )
1167 return (*
this)(
f );
1216 ASSERT(
i >= 0,
"index to operator [] less than zero" );
1259 ASSERT(
x.
level() > 0,
"cannot derive with respect to algebraic variables" );
1325 ASSERT( n >= 0,
"arg to sqrt() less than zero" );
1326 if ( n == 0 || n == 1 )
1334 y = (
unsigned long)(
x + n/
x)/2;
1360 ASSERT(
a > 0,
"arg to ilog2() less or equal zero" );
1418 "incompatible operands" );
1443 "incompatible operands" );
1507 else if ( what ==
FFMARK )
1538 else if ( what ==
FFMARK )
1597 ASSERT( ! what || (what ==
is_imm(
f.value )),
"incompatible operands" );
1599 return g.value->bgcdcoeff(
f.value );
1607 if ( fInt < 0 ) fInt = -fInt;
1608 if ( gInt < 0 ) gInt = -gInt;
1621 long r = fInt % gInt;
1634 return f.value->bgcdcoeff(
g.value );
1636 int fLevel =
f.value->level();
1637 int gLevel =
g.value->level();
1640 if ( fLevel == gLevel )
1642 fLevel =
f.value->levelcoeff();
1643 gLevel =
g.value->levelcoeff();
1646 if ( fLevel == gLevel )
1647 return f.value->bgcdsame(
g.value );
1648 else if ( fLevel < gLevel )
1649 return g.value->bgcdcoeff(
f.value );
1651 return f.value->bgcdcoeff(
g.value );
1653 else if ( fLevel < gLevel )
1654 return g.value->bgcdcoeff(
f.value );
1656 return f.value->bgcdcoeff(
g.value );
1670 ASSERT( ! what || (what ==
is_imm(
f.value )),
"incompatible operands" );
1672 return g.value->bextgcdcoeff(
f.value,
b,
a );
1682 if ( fInt < 0 ) fInt = -fInt;
1683 if ( gInt < 0 ) gInt = -gInt;
1685 if ( gInt > fInt ) {
1691 long u = 1;
long v = 0;
1692 long uNext = 0;
long vNext = 1;
1700 long r = fInt % gInt;
1701 long q = fInt / gInt;
1702 long uSwap = u - q * uNext;
1703 long vSwap =
v - q * vNext;
1708 u = uNext;
v = vNext;
1709 uNext = uSwap; vNext = vSwap;
1715 if ( gTest > fTest ) {
1720 if ( fTest < 0 )
a = -
a;
1721 if ( gTest < 0 )
b = -
b;
1725 if ( !
f.isZero() ) {
1727 }
else if ( !
g.isZero() ) {
1734 return f.value->bextgcdcoeff(
g.value,
a,
b );
1736 int fLevel =
f.value->level();
1737 int gLevel =
g.value->level();
1740 if ( fLevel == gLevel ) {
1741 fLevel =
f.value->levelcoeff();
1742 gLevel =
g.value->levelcoeff();
1745 if ( fLevel == gLevel )
1746 return f.value->bextgcdsame(
g.value,
a,
b );
1747 else if ( fLevel < gLevel )
1748 return g.value->bextgcdcoeff(
f.value,
b,
a );
1750 return f.value->bextgcdcoeff(
g.value,
a,
b );
1752 else if ( fLevel < gLevel )
1753 return g.value->bextgcdcoeff(
f.value,
b,
a );
1755 return f.value->bextgcdcoeff(
g.value,
a,
b );
1761 if (
f.isZero() ||
g.isZero() )
1815 else if ( what ==
GFMARK )
1829 else if ( what ==
GFMARK )
1841 ASSERT( n >= 0,
"illegal exponent" );
1844 else if (
f.isOne() )
int imm_iszero_p(const InternalCF *const ptr)
const CanonicalForm int const CFList const Variable & y
InternalCF * imm_sub(const InternalCF *const lhs, const InternalCF *const rhs)
This file defines functions for conversion to FLINT (www.flintlib.org) and back.
InternalCF * imm_mod(const InternalCF *const lhs, const InternalCF *const rhs)
virtual int degree()
int InternalCF::degree ()
InternalCF * int2imm(long i)
factory's class for variables
InternalCF * imm_mul_gf(const InternalCF *const lhs, const InternalCF *const rhs)
InternalCF * imm_add_gf(const InternalCF *const lhs, const InternalCF *const rhs)
virtual CanonicalForm LC()
virtual bool inCoeffDomain() const
InternalCF * copyObject()
InternalCF * imm_div_p(const InternalCF *const lhs, const InternalCF *const rhs)
virtual InternalCF * divsame(InternalCF *) PVIRT_INTCF("divsame")
int imm_cmp_p(const InternalCF *const lhs, const InternalCF *const rhs)
virtual bool isUnivariate() const
virtual InternalCF * addsame(InternalCF *) PVIRT_INTCF("addsame")
InternalCF * int2imm_p(long i)
InternalCF * imm_div_gf(const InternalCF *const lhs, const InternalCF *const rhs)
virtual int comparesame(InternalCF *) PVIRT_INT("comparesame")
virtual InternalCF * tryDivsame(InternalCF *, const CanonicalForm &, bool &)
virtual long intval() const
int imm_cmp(const InternalCF *const lhs, const InternalCF *const rhs)
imm_cmp(), imm_cmp_p(), imm_cmp_gf() - compare immediate objects.
virtual class for internal CanonicalForm's
virtual int comparecoeff(InternalCF *) PVIRT_INT("comparecoeff")
virtual int levelcoeff() const
virtual InternalCF * subsame(InternalCF *) PVIRT_INTCF("subsame")
virtual InternalCF * modulosame(InternalCF *) PVIRT_INTCF("modulosame")
virtual int level() const
void imm_divrem(const InternalCF *const lhs, const InternalCF *const rhs, InternalCF *&q, InternalCF *&r)
InternalCF * imm_mod_p(const InternalCF *const, const InternalCF *const)
virtual InternalCF * genOne() PVIRT_INTCF("genOne")
void imm_divrem_gf(const InternalCF *const lhs, const InternalCF *const rhs, InternalCF *&q, InternalCF *&r)
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), Z, Q, Q(a), if we are in GF factory's default multiplication is used. If b!= 0 and getCharacteristic() == 0 the input will be considered as elements over Z/p^k or Z/p^k[t]/(f).
int imm_iszero_gf(const InternalCF *const ptr)
Operations in GF, where GF is a finite field of size less than 2^16 represented by a root of Conway p...
virtual InternalCF * subcoeff(InternalCF *, bool) PVIRT_INTCF("subcoeff")
virtual InternalCF * divcoeff(InternalCF *, bool) PVIRT_INTCF("divcoeff")
virtual InternalCF * sqrt()
InternalCF * InternalCF::sqrt ()
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, Q, Q(a), if we are in GF factory's default multiplication is used. If b!= 0 and getCharacteristic() == 0 the input will be considered as elements over Z/p^k or Z/p^k[t]/(f); in this case invertiblity of Lc(G) is not checked
virtual void print(OSTREAM &, char *) PVIRT_VOID("print")
CFList get_Terms(const CanonicalForm &f)
InternalCF * imm_div(const InternalCF *const lhs, const InternalCF *const rhs)
int imm_iszero(const InternalCF *const ptr)
This file defines functions for fast multiplication and division with remainder.
virtual CanonicalForm coeff(int i)
CanonicalForm InternalCF::coeff ( int i )
Interface to generate InternalCF's over various domains from intrinsic types or mpz_t's.
bool getReduce(const Variable &alpha)
void getmpi(InternalCF *value, mpz_t mpi)
long imm_intval(const InternalCF *const op)
virtual CanonicalForm Lc()
static const int SW_RATIONAL
set to 1 for computations over Q
virtual InternalCF * dividesame(InternalCF *) PVIRT_INTCF("dividesame")
InternalCF * int2imm_gf(long i)
Iterators for CanonicalForm's.
virtual CanonicalForm tailcoeff()
CanonicalForm InternalCF::tailcoeff (), int InternalCF::taildegree ()
virtual InternalCF * dividecoeff(InternalCF *, bool) PVIRT_INTCF("dividecoeff")
static InternalCF * basic(long value)
virtual InternalCF * tryDivcoeff(InternalCF *, bool, const CanonicalForm &, bool &)
InternalCF * imm_sub_gf(const InternalCF *const lhs, const InternalCF *const rhs)
virtual int sign() const PVIRT_INT("sign")
declarations of higher level algorithms.
virtual int intmod(int) const
InternalCF * imm_mul(InternalCF *lhs, InternalCF *rhs)
virtual InternalCF * modsame(InternalCF *) PVIRT_INTCF("modsame")
virtual InternalCF * den()
InternalCF * imm_sub_p(const InternalCF *const lhs, const InternalCF *const rhs)
virtual InternalCF * deepCopyObject() const PVIRT_INTCF("deepCopyObject")
class to iterate through CanonicalForm's
void imm_print(OSTREAM &os, const InternalCF *const op, const char *const str)
virtual InternalCF * num()
InternalCF * InternalCF::num (), den ()
const Variable & v
< [in] a sqrfree bivariate poly
virtual bool inExtension() const
long imm2int(const InternalCF *const imm)
InternalCF * imm_mul_p(const InternalCF *const lhs, const InternalCF *const rhs)
virtual bool inPolyDomain() const
InternalCF * imm_divrat(const InternalCF *const lhs, const InternalCF *const rhs)
int imm_sign(const InternalCF *const op)
imm_sign() - return sign of immediate object.
virtual InternalCF * addcoeff(InternalCF *) PVIRT_INTCF("addcoeff")
void imm_divrem_p(const InternalCF *const lhs, const InternalCF *const rhs, InternalCF *&q, InternalCF *&r)
operations on immediates, that is elements of F_p, GF, Z, Q that fit into intrinsic int...
virtual int ilog2()
int InternalCF::ilog2 ()
#define GaloisFieldDomain
InternalCF * imm_add(const InternalCF *const lhs, const InternalCF *const rhs)
#define cf_glob_switches
CFSwitches cf_glob_switches;.
Factory's internal CanonicalForm's.
InternalCF * imm_add_p(const InternalCF *const lhs, const InternalCF *const rhs)
bool hasMipo(const Variable &alpha)
virtual InternalCF * mulcoeff(InternalCF *) PVIRT_INTCF("mulcoeff")
virtual InternalCF * modulocoeff(InternalCF *, bool) PVIRT_INTCF("dividecoeff")
#define ASSERT(expression, message)
int imm_cmp_gf(const InternalCF *const lhs, const InternalCF *const rhs)
virtual CanonicalForm lc()
CanonicalForm InternalCF::lc (), Lc (), LC ()
virtual InternalCF * modcoeff(InternalCF *, bool) PVIRT_INTCF("modcoeff")
virtual InternalCF * mulsame(InternalCF *) PVIRT_INTCF("mulsame")
virtual InternalCF * genZero() PVIRT_INTCF("genZero")
virtual bool inBaseDomain() const
InternalCF * imm_mod_gf(const InternalCF *const, const InternalCF *const)
virtual Variable variable() const
virtual bool inQuotDomain() const
#define FiniteFieldDomain
int ff_symmetric(const int a)