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 )
1040 else if ( what ==
GFMARK )
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" );
1075 else if ( what ==
GFMARK )
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" );
1120 else if ( what ==
GFMARK )
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" );
1388 ASSERT( n >= 0,
"arg to sqrt() less than zero" );
1389 if ( n == 0 || n == 1 )
1397 y = (
unsigned long)(
x + n/
x)/2;
1423 ASSERT( a > 0,
"arg to ilog2() less or equal zero" );
1475 "incompatible operands" );
1500 "incompatible operands" );
1564 else if ( what ==
FFMARK )
1595 else if ( what ==
FFMARK )
1654 ASSERT( ! what || (what ==
is_imm(
f.value )),
"incompatible operands" );
1656 return g.value->bgcdcoeff(
f.value );
1664 if ( fInt < 0 ) fInt = -fInt;
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 );
1739 if ( fInt < 0 ) fInt = -fInt;
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;
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() )
1833CanonicalForm::print(
OSTREAM & os,
char * str )
const
1836 imm_print( os,
value, str );
1842CanonicalForm::print(
OSTREAM & os )
const
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.
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.
INST_VAR CFSwitches cf_glob_switches
static InternalCF * basic(int 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 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.
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 * imm_div_p(const InternalCF *const lhs, const InternalCF *const rhs)
void imm_divrem_gf(const InternalCF *const lhs, const InternalCF *const rhs, InternalCF *&q, InternalCF *&r)
static long imm2int(const InternalCF *const imm)
InternalCF * imm_div(const InternalCF *const lhs, const InternalCF *const rhs)
InternalCF * imm_add_gf(const InternalCF *const lhs, const InternalCF *const rhs)
InternalCF * imm_mod(const InternalCF *const lhs, const InternalCF *const rhs)
InternalCF * imm_mod_p(const InternalCF *const, const InternalCF *const)
InternalCF * int2imm_p(long i)
int imm_sign(const InternalCF *const op)
imm_sign() - return sign of immediate object.
int imm_cmp_p(const InternalCF *const lhs, const InternalCF *const rhs)
int imm_cmp_gf(const InternalCF *const lhs, const InternalCF *const rhs)
InternalCF * imm_mul_p(const InternalCF *const lhs, const InternalCF *const rhs)
InternalCF * imm_add_p(const InternalCF *const lhs, const InternalCF *const rhs)
int imm_iszero(const InternalCF *const ptr)
int imm_iszero_gf(const InternalCF *const ptr)
InternalCF * imm_mul_gf(const InternalCF *const lhs, const InternalCF *const rhs)
InternalCF * imm_add(const InternalCF *const lhs, const InternalCF *const rhs)
long imm_intval(const InternalCF *const op)
InternalCF * imm_div_gf(const InternalCF *const lhs, const InternalCF *const rhs)
int imm_iszero_p(const InternalCF *const ptr)
InternalCF * imm_sub_p(const InternalCF *const lhs, const InternalCF *const rhs)
InternalCF * int2imm_gf(long i)
int imm_cmp(const InternalCF *const lhs, const InternalCF *const rhs)
imm_cmp(), imm_cmp_p(), imm_cmp_gf() - compare immediate objects.
static InternalCF * int2imm(long i)
void imm_divrem_p(const InternalCF *const lhs, const InternalCF *const rhs, InternalCF *&q, InternalCF *&r)
InternalCF * imm_sub_gf(const InternalCF *const lhs, const InternalCF *const rhs)
InternalCF * imm_sub(const InternalCF *const lhs, const InternalCF *const rhs)
InternalCF * imm_divrat(const InternalCF *const lhs, const InternalCF *const rhs)
InternalCF * imm_mod_gf(const InternalCF *const, const InternalCF *const)
InternalCF * imm_mul(InternalCF *lhs, InternalCF *rhs)
void imm_divrem(const InternalCF *const lhs, const InternalCF *const rhs, InternalCF *&q, InternalCF *&r)
Factory's internal CanonicalForm's.
ostream & operator<<(ostream &s, const spectrum &spec)
static int SI_LOG2_LONG(long v)
bool getReduce(const Variable &alpha)
bool hasMipo(const Variable &alpha)