167 if (this->
isZero())
return true;
173 int cdeg = -2, dummy;
174 for (
i = *
this;
i.hasTerms();
i++ )
176 if (!(
i.coeff().isHomogeneous()))
return false;
179 if (cdeg == -2) cdeg = dummy;
189 for (
i=termlist;
i.hasItem();
i++ )
266 ASSERT( 0,
"illegal domain" );
475 coeffdeg =
i.coeff().degree(
v );
647 else if ( what ==
GFMARK )
672 else if ( lv > cf_lv )
692 else if ( what ==
GFMARK )
734 else if ( what ==
GFMARK )
746#if (HAVE_NTL && HAVE_FLINT && __FLINT_RELEASE >= 20400)
747#if (__FLINT_RELEASE >= 20503)
758 *
this=mulFlintMP_Zp(*
this,l_this,
cf,l_cf,
m);
769 *
this=mulFlintMP_QQ(*
this,l_this,
cf,l_cf,
m);
815 else if ( what ==
GFMARK )
827#if (HAVE_NTL && HAVE_FLINT && __FLINT_RELEASE >= 20400)
869 else if ( what ==
GFMARK )
915 else if ( what ==
GFMARK )
955 else if ( what ==
GFMARK )
997 else if ( what ==
GFMARK )
1039 imm_divrem_p(
f.value,
g.value, qq, rr );
1040 else if ( what ==
GFMARK )
1041 imm_divrem_gf(
f.value,
g.value, qq, rr );
1043 imm_divrem(
f.value,
g.value, qq, rr );
1046 g.value->divremcoeff(
f.value, qq, rr,
true );
1047 else if ( (what=
is_imm(
g.value )) )
1048 f.value->divremcoeff(
g.value, qq, rr,
false );
1049 else if (
f.value->level() ==
g.value->level() )
1050 if (
f.value->levelcoeff() ==
g.value->levelcoeff() )
1051 f.value->divremsame(
g.value, qq, rr );
1052 else if (
f.value->levelcoeff() >
g.value->levelcoeff() )
1053 f.value->divremcoeff(
g.value, qq, rr,
false );
1055 g.value->divremcoeff(
f.value, qq, rr,
true );
1056 else if (
f.value->level() >
g.value->level() )
1057 f.value->divremcoeff(
g.value, qq, rr,
false );
1059 g.value->divremcoeff(
f.value, qq, rr,
true );
1060 ASSERT( qq != 0 && rr != 0,
"error in divrem" );
1074 imm_divrem_p(
f.value,
g.value, qq, rr );
1075 else if ( what ==
GFMARK )
1076 imm_divrem_gf(
f.value,
g.value, qq, rr );
1078 imm_divrem(
f.value,
g.value, qq, rr );
1081 result =
g.value->divremcoefft(
f.value, qq, rr,
true );
1082 else if ( (what=
is_imm(
g.value )) )
1083 result =
f.value->divremcoefft(
g.value, qq, rr,
false );
1084 else if (
f.value->level() ==
g.value->level() )
1085 if (
f.value->levelcoeff() ==
g.value->levelcoeff() )
1086 result =
f.value->divremsamet(
g.value, qq, rr );
1087 else if (
f.value->levelcoeff() >
g.value->levelcoeff() )
1088 result =
f.value->divremcoefft(
g.value, qq, rr,
false );
1090 result =
g.value->divremcoefft(
f.value, qq, rr,
true );
1091 else if (
f.value->level() >
g.value->level() )
1092 result =
f.value->divremcoefft(
g.value, qq, rr,
false );
1094 result =
g.value->divremcoefft(
f.value, qq, rr,
true );
1096 ASSERT( qq != 0 && rr != 0,
"error in divrem" );
1119 imm_divrem_p(
f.value,
g.value, qq, rr );
1120 else if ( what ==
GFMARK )
1121 imm_divrem_gf(
f.value,
g.value, qq, rr );
1124 result =
g.value->tryDivremcoefft(
f.value, qq, rr,
true,
M, fail );
1125 else if ( (what=
is_imm(
g.value )) )
1126 result =
f.value->tryDivremcoefft(
g.value, qq, rr,
false,
M, fail );
1127 else if (
f.value->level() ==
g.value->level() )
1128 if (
f.value->levelcoeff() ==
g.value->levelcoeff() )
1129 result =
f.value->tryDivremsamet(
g.value, qq, rr,
M, fail );
1130 else if (
f.value->levelcoeff() >
g.value->levelcoeff() )
1131 result =
f.value->tryDivremcoefft(
g.value, qq, rr,
false,
M, fail );
1133 result =
g.value->tryDivremcoefft(
f.value, qq, rr,
true,
M, fail );
1134 else if (
f.value->level() >
g.value->level() )
1135 result =
f.value->tryDivremcoefft(
g.value, qq, rr,
false,
M, fail );
1137 result =
g.value->tryDivremcoefft(
f.value, qq, rr,
true,
M, fail );
1145 ASSERT( qq != 0 && rr != 0,
"error in divrem" );
1176 int lastExp =
i.exp();
1179 while (
i.hasTerms() ) {
1180 if ( (lastExp -
i.exp()) == 1 )
1192 int lastExp =
i.exp();
1195 while (
i.hasTerms() )
1198 if ( (lastExp - i_exp ) == 1 )
1230 return (*
this)(
f );
1279 ASSERT(
i >= 0,
"index to operator [] less than zero" );
1322 ASSERT(
x.
level() > 0,
"cannot derive with respect to algebraic variables" );
1387 long n = imm2int(
value );
1388 ASSERT( n >= 0,
"arg to sqrt() less than zero" );
1389 if ( n == 0 || n == 1 )
1397 y = (
unsigned long)(
x + n/
x)/2;
1422 long a = imm2int(
value );
1423 ASSERT( a > 0,
"arg to ilog2() less or equal zero" );
1424 return SI_LOG2_LONG(a);
1475 "incompatible operands" );
1500 "incompatible operands" );
1564 else if ( what ==
FFMARK )
1565 return imm_cmp_p( lhs.
value, rhs.
value ) > 0;
1567 return imm_cmp_gf( lhs.
value, rhs.
value ) > 0;
1595 else if ( what ==
FFMARK )
1596 return imm_cmp_p( lhs.
value, rhs.
value ) < 0;
1598 return imm_cmp_gf( lhs.
value, rhs.
value ) < 0;
1654 ASSERT( ! what || (what ==
is_imm(
f.value )),
"incompatible operands" );
1656 return g.value->bgcdcoeff(
f.value );
1661 long fInt = imm2int(
f.value );
1662 long gInt = imm2int(
g.value );
1664 if ( fInt < 0 ) fInt = -fInt;
1665 if ( gInt < 0 ) gInt = -gInt;
1678 long r = fInt % gInt;
1691 return f.value->bgcdcoeff(
g.value );
1693 int fLevel =
f.value->level();
1694 int gLevel =
g.value->level();
1697 if ( fLevel == gLevel )
1699 fLevel =
f.value->levelcoeff();
1700 gLevel =
g.value->levelcoeff();
1703 if ( fLevel == gLevel )
1704 return f.value->bgcdsame(
g.value );
1705 else if ( fLevel < gLevel )
1706 return g.value->bgcdcoeff(
f.value );
1708 return f.value->bgcdcoeff(
g.value );
1710 else if ( fLevel < gLevel )
1711 return g.value->bgcdcoeff(
f.value );
1713 return f.value->bgcdcoeff(
g.value );
1727 ASSERT( ! what || (what ==
is_imm(
f.value )),
"incompatible operands" );
1729 return g.value->bextgcdcoeff(
f.value,
b, a );
1733 long fInt = imm2int(
f.value );
1734 long gInt = imm2int(
g.value );
1739 if ( fInt < 0 ) fInt = -fInt;
1740 if ( gInt < 0 ) gInt = -gInt;
1742 if ( gInt > fInt ) {
1748 long u = 1;
long v = 0;
1749 long uNext = 0;
long vNext = 1;
1757 long r = fInt % gInt;
1758 long q = fInt / gInt;
1759 long uSwap = u - q * uNext;
1760 long vSwap =
v - q * vNext;
1765 u = uNext;
v = vNext;
1766 uNext = uSwap; vNext = vSwap;
1770 long fTest = imm2int(
f.value );
1771 long gTest = imm2int(
g.value );
1772 if ( gTest > fTest ) {
1777 if ( fTest < 0 ) a = -a;
1778 if ( gTest < 0 )
b = -
b;
1782 if ( !
f.isZero() ) {
1784 }
else if ( !
g.isZero() ) {
1791 return f.value->bextgcdcoeff(
g.value, a,
b );
1793 int fLevel =
f.value->level();
1794 int gLevel =
g.value->level();
1797 if ( fLevel == gLevel ) {
1798 fLevel =
f.value->levelcoeff();
1799 gLevel =
g.value->levelcoeff();
1802 if ( fLevel == gLevel )
1803 return f.value->bextgcdsame(
g.value, a,
b );
1804 else if ( fLevel < gLevel )
1805 return g.value->bextgcdcoeff(
f.value,
b, a );
1807 return f.value->bextgcdcoeff(
g.value, a,
b );
1809 else if ( fLevel < gLevel )
1810 return g.value->bextgcdcoeff(
f.value,
b, a );
1812 return f.value->bextgcdcoeff(
g.value, a,
b );
1818 if (
f.isZero() ||
g.isZero() )
1836 imm_print( os,
value, str );
1845 imm_print( os,
value,
"" );
1872 else if ( what ==
GFMARK )
1886 else if ( what ==
GFMARK )
1898 ASSERT( n >= 0,
"illegal exponent" );
1901 else if (
f.isOne() )
This file defines functions for conversion to FLINT (www.flintlib.org) and back.
bool operator==(const Rational &a, const Rational &b)
bool operator>(const Rational &a, const Rational &b)
declarations of higher level algorithms.
#define ASSERT(expression, message)
#define FiniteFieldDomain
#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.
INST_VAR CFSwitches cf_glob_switches
static InternalCF * basic(int value)
virtual class for internal CanonicalForm's
virtual int intmod(int) const
virtual InternalCF * addcoeff(InternalCF *) PVIRT_INTCF("addcoeff")
InternalCF * copyObject()
virtual CanonicalForm Lc()
virtual InternalCF * tryDivcoeff(InternalCF *, bool, const CanonicalForm &, bool &)
virtual InternalCF * modulosame(InternalCF *) PVIRT_INTCF("modulosame")
virtual InternalCF * addsame(InternalCF *) PVIRT_INTCF("addsame")
virtual CanonicalForm tailcoeff()
CanonicalForm InternalCF::tailcoeff (), int InternalCF::taildegree ().
virtual InternalCF * divsame(InternalCF *) PVIRT_INTCF("divsame")
virtual bool inPolyDomain() const
virtual CanonicalForm lc()
CanonicalForm InternalCF::lc (), Lc (), LC ().
virtual InternalCF * mulcoeff(InternalCF *) PVIRT_INTCF("mulcoeff")
virtual InternalCF * subsame(InternalCF *) PVIRT_INTCF("subsame")
virtual InternalCF * divcoeff(InternalCF *, bool) PVIRT_INTCF("divcoeff")
virtual InternalCF * subcoeff(InternalCF *, bool) PVIRT_INTCF("subcoeff")
virtual long intval() const
virtual InternalCF * dividecoeff(InternalCF *, bool) PVIRT_INTCF("dividecoeff")
virtual bool inExtension() const
virtual InternalCF * genOne() PVIRT_INTCF("genOne")
virtual void print(OSTREAM &, char *) PVIRT_VOID("print")
virtual int levelcoeff() const
virtual int degree()
int InternalCF::degree ()
virtual int ilog2()
int InternalCF::ilog2 ()
virtual int comparesame(InternalCF *) PVIRT_INT("comparesame")
virtual bool inCoeffDomain() const
virtual CanonicalForm LC()
virtual InternalCF * modsame(InternalCF *) PVIRT_INTCF("modsame")
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 * dividesame(InternalCF *) PVIRT_INTCF("dividesame")
virtual InternalCF * deepCopyObject() const PVIRT_INTCF("deepCopyObject")
virtual InternalCF * modulocoeff(InternalCF *, bool) PVIRT_INTCF("dividecoeff")
virtual InternalCF * tryDivsame(InternalCF *, const CanonicalForm &, bool &)
virtual CanonicalForm coeff(int i)
CanonicalForm InternalCF::coeff ( int i ).
virtual int level() const
virtual bool isUnivariate() const
virtual bool inQuotDomain() const
virtual InternalCF * modcoeff(InternalCF *, bool) PVIRT_INTCF("modcoeff")
virtual InternalCF * genZero() PVIRT_INTCF("genZero")
virtual InternalCF * mulsame(InternalCF *) PVIRT_INTCF("mulsame")
STATIC_VAR mpz_t primepowhalf
STATIC_VAR mpz_t primepow
factory's class for variables
const CanonicalForm int const CFList const Variable & y
int hasAlgVar(const CanonicalForm &f, const Variable &v)
Utility functions for factorization over algebraic function fields.
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)
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)
int imm_sign(const InternalCF *const op)
imm_sign() - return sign of immediate object.
int imm_iszero(const InternalCF *const ptr)
int imm_iszero_gf(const InternalCF *const ptr)
long imm_intval(const InternalCF *const op)
int imm_iszero_p(const InternalCF *const ptr)
InternalCF * int2imm_gf(long i)
int size(const CanonicalForm &f, const Variable &v)
int size ( const CanonicalForm & f, const Variable & v )
CFList get_Terms(const CanonicalForm &f)
int size_maxexp(const CanonicalForm &f, int &maxexp)
int is_imm(const InternalCF *const ptr)
CanonicalForm FACTORY_PUBLIC swapvar(const CanonicalForm &, const Variable &, const Variable &)
swapvar() - swap variables x1 and x2 in f.
ListIterator< CanonicalForm > CFListIterator
int totaldegree(const CanonicalForm &f)
int totaldegree ( const CanonicalForm & f )
CanonicalForm FACTORY_PUBLIC power(const CanonicalForm &f, int n)
exponentiation
CanonicalForm reduce(const CanonicalForm &f, const CanonicalForm &M)
polynomials in M.mvar() are considered coefficients M univariate monic polynomial the coefficients of...
List< CanonicalForm > CFList
int FACTORY_PUBLIC getCharacteristic()
Factory's internal CanonicalForm's.
bool getReduce(const Variable &alpha)