39 return value->copyObject();
109 return value->inBaseDomain();
118 return value->inExtension();
127 return value->inCoeffDomain();
136 return value->inPolyDomain();
145 return value->inQuotDomain();
160 return value->isUnivariate();
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++ )
205 return value->intval();
228 else if (
value->inBaseDomain() )
266 ASSERT( 0,
"illegal domain" );
425 return value->degree();
451 else if (
value->inBaseDomain() )
452 return value->degree();
459 case 0:
if (
value->inBaseDomain() )
460 return value->degree();
467 return value->degree();
475 coeffdeg =
i.coeff().degree(
v );
503 return value->tailcoeff();
527 return value->tailcoeff();
563 return value->taildegree();
581 return value->level();
598 return value->variable();
647 else if ( what ==
GFMARK )
658 else if ( (lv=
value->level()) == (cf_lv=
cf.value->level()) )
660 if (
value->levelcoeff() ==
cf.value->levelcoeff() )
662 else if (
value->levelcoeff() >
cf.value->levelcoeff() )
672 else if ( lv > cf_lv )
692 else if ( what ==
GFMARK )
703 else if (
value->level() ==
cf.value->level() ) {
704 if (
value->levelcoeff() ==
cf.value->levelcoeff() )
706 else if (
value->levelcoeff() >
cf.value->levelcoeff() )
715 else if (
level() >
cf.level() )
734 else if ( what ==
GFMARK )
745 else if (
value->level() ==
cf.value->level() ) {
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);
774 if (
value->levelcoeff() ==
cf.value->levelcoeff() &&
cf.isUnivariate() && (*this).isUnivariate())
781 else if (
value->levelcoeff() ==
cf.value->levelcoeff() && (!
cf.isUnivariate() || !(*this).isUnivariate()))
784 if (
value->levelcoeff() ==
cf.value->levelcoeff() )
787 else if (
value->levelcoeff() >
cf.value->levelcoeff() )
796 else if (
level() >
cf.level() )
815 else if ( what ==
GFMARK )
826 else if (
value->level() ==
cf.value->level() ) {
827#if (HAVE_NTL && HAVE_FLINT && __FLINT_RELEASE >= 20400)
828 if (
value->levelcoeff() ==
cf.value->levelcoeff() && (*this).isUnivariate() &&
cf.isUnivariate())
835 else if (
value->levelcoeff() ==
cf.value->levelcoeff() && (!
cf.isUnivariate() || !(*this).isUnivariate()))
838 if (
value->levelcoeff() ==
cf.value->levelcoeff() )
841 else if (
value->levelcoeff() >
cf.value->levelcoeff() )
850 else if (
level() >
cf.level() )
869 else if ( what ==
GFMARK )
880 else if (
value->level() ==
cf.value->level() ) {
881 if (
value->levelcoeff() ==
cf.value->levelcoeff() )
883 else if (
value->levelcoeff() >
cf.value->levelcoeff() )
892 else if (
level() >
cf.level() )
915 else if ( what ==
GFMARK )
924 else if (
value->level() ==
cf.value->level() ) {
925 if (
value->levelcoeff() ==
cf.value->levelcoeff() )
927 else if (
value->levelcoeff() >
cf.value->levelcoeff() )
936 else if (
level() >
cf.level() )
955 else if ( what ==
GFMARK )
966 else if (
value->level() ==
cf.value->level() ) {
967 if (
value->levelcoeff() ==
cf.value->levelcoeff() )
969 else if (
value->levelcoeff() >
cf.value->levelcoeff() )
978 else if (
level() >
cf.level() )
997 else if ( what ==
GFMARK )
1008 else if (
value->level() ==
cf.value->level() ) {
1009 if (
value->levelcoeff() ==
cf.value->levelcoeff() )
1011 else if (
value->levelcoeff() >
cf.value->levelcoeff() )
1020 else if (
level() >
cf.level() )
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" );
1286 return value->coeff(
i );
1322 ASSERT(
x.level() > 0,
"cannot derive with respect to algebraic variables" );
1365 return value->sign();
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" );
1427 return value->ilog2();
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() )
1838 value->print( os, str );
1847 value->print( os,
"" );
1872 else if ( what ==
GFMARK )
1886 else if ( what ==
GFMARK )
1898 ASSERT( n >= 0,
"illegal exponent" );
1901 else if (
f.isOne() )
1946 else if ((
v.level() < 0 ) && (
hasMipo(
v)))
This file defines functions for conversion to FLINT (www.flintlib.org) and back.
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 InternalCF * addcoeff(InternalCF *) PVIRT_INTCF("addcoeff")
virtual InternalCF * tryDivcoeff(InternalCF *, bool, const CanonicalForm &, bool &)
virtual InternalCF * mulcoeff(InternalCF *) PVIRT_INTCF("mulcoeff")
virtual InternalCF * divcoeff(InternalCF *, bool) PVIRT_INTCF("divcoeff")
virtual InternalCF * subcoeff(InternalCF *, bool) PVIRT_INTCF("subcoeff")
virtual InternalCF * dividecoeff(InternalCF *, bool) PVIRT_INTCF("dividecoeff")
virtual int levelcoeff() const
virtual int comparesame(InternalCF *) PVIRT_INT("comparesame")
virtual int comparecoeff(InternalCF *) PVIRT_INT("comparecoeff")
virtual InternalCF * modulocoeff(InternalCF *, bool) PVIRT_INTCF("dividecoeff")
virtual int level() const
virtual InternalCF * modcoeff(InternalCF *, bool) PVIRT_INTCF("modcoeff")
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)
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)
void imm_print(OSTREAM &os, const InternalCF *const op, const char *const str)
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)
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)
static const int SW_RATIONAL
set to 1 for computations over Q
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
List< CanonicalForm > CFList
int FACTORY_PUBLIC getCharacteristic()
Factory's internal CanonicalForm's.
static int SI_LOG2_LONG(long v)
bool getReduce(const Variable &alpha)