33#define TRANSEXT_PRIVATES
37#include "factory/factory.h"
61#define ADD_COMPLEXITY 1
62#define MULT_COMPLEXITY 2
63#define DIFF_COMPLEXITY 2
64#define BOUND_COMPLEXITY 10
67#define NUMIS1(f) (p_IsOne(NUM(f), cf->extRing))
69#define COM(f) (f)->complexity
76#define ntTest(a) n_Test(a, cf)
80#define ntRing cf->extRing
86#define ntCoeffs cf->extRing->cf
158 Print(
"ERROR in %s:%d: non-integer Q coeff in num. poly\n",
f,
l);
173 Print(
"ERROR in %s:%d: non-integer Q coeff in den. poly\n",
f,
l);
182 Print(
"ERROR in %s:%d: constant den. poly / Zp\n",
f,
l);
190 Print(
"ERROR in %s:%d: non-monic den. poly / Zp\n",
f,
l);
204 Print(
"ERROR in %s:%d: 1 != GCD between num. & den. poly\n",
f,
l);
222 Print(
"negative sign of DEN. of a fraction in %s:%d\n",
f,
l);
255 Print(
"rational coeff in num: %s:%d\n",
f,
l);
266 Print(
"rational coeff in den.:%s:%d\n",
f,
l);
300 cf =
cf->extRing->cf;
334 if (a ==
b)
return TRUE;
777 if (
IS0(a))
return 0;
869 const int P =
rVar(
A);
912 WerrorS(
"expected differentiation by a variable");
918 WerrorS(
"expected differentiation by a variable");
1094 const poly db =
DEN(
fb);
1160 const poly db =
DEN(
fb);
1491 if (
COM(
f)==0)
return;
1906 if (
IS0(a))
return 0;
1935 assume(src->rep ==
dst->extRing->cf->rep);
1973 int n =
n_Int(a, src);
2153 int n =
n_Int(a, src);
2202 if (
h != 1)
return NULL;
2213 for (
int i = 0;
i <
rVar(src->extRing);
i++)
2219 if (src->extRing->cf==
dst->extRing->cf)
2226 if (src->extRing->cf==
dst->extRing->cf)
2253 if (
cf->extRing->ref < 0)
2280 if (
IS0(a))
return -1;
2282 return cf->extRing->pFDeg(
NUM(
fa),
cf->extRing);
2575 poly *P=(poly*)
omAlloc(
rl*
sizeof(poly*));
2664 cf->factoryVarOffset =
R->cf->factoryVarOffset +
rVar(
R);
2720 cf->iNumberOfParameters =
rVar(
R);
2721 cf->pParameterNames = (
const char**)
R->names;
2723 cf->has_simple_Inverse=
FALSE;
Rational pow(const Rational &a, int e)
Concrete implementation of enumerators over polynomials.
char * naCoeffName(const coeffs r)
const CanonicalForm CFMap CFMap & N
const CanonicalForm const CanonicalForm const CanonicalForm const CanonicalForm & cand
CanonicalForm convSingPFactoryP(poly p, const ring r)
poly convFactoryPSingP(const CanonicalForm &f, const ring r)
poly singclap_pdivide(poly f, poly g, const ring r)
poly singclap_gcd_and_divide(poly &f, poly &g, const ring r)
clears denominators of f and g, divides by gcd(f,g)
poly singclap_gcd_r(poly f, poly g, const ring r)
This is a polynomial enumerator for simple iteration over coefficients of polynomials.
Coefficient rings, fields and other domains suitable for Singular polynomials.
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of 'a' and 'b', i.e., a*b
static FORCE_INLINE long n_Int(number &n, const coeffs r)
conversion of n to an int; 0 if not possible in Z/pZ: the representing int lying in (-p/2 ....
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of 'n'
static FORCE_INLINE number n_NormalizeHelper(number a, number b, const coeffs r)
assume that r is a quotient field (otherwise, return 1) for arguments (a1/a2,b1/b2) return (lcm(a1,...
static FORCE_INLINE number n_GetDenom(number &n, const coeffs r)
return the denominator of n (if elements of r are by nature not fractional, result is 1)
static FORCE_INLINE void n_CoeffWrite(const coeffs r, BOOLEAN details=TRUE)
output the coeff description
static FORCE_INLINE BOOLEAN nCoeff_is_Z(const coeffs r)
static FORCE_INLINE BOOLEAN nCoeff_is_Extension(const coeffs r)
#define n_Test(a, r)
BOOLEAN n_Test(number a, const coeffs r)
@ n_Q
rational (GMP) numbers
@ n_transExt
used for all transcendental extensions, i.e., the top-most extension in an extension tower is transce...
static FORCE_INLINE number n_Gcd(number a, number b, const coeffs r)
in Z: return the gcd of 'a' and 'b' in Z/nZ, Z/2^kZ: computed as in the case Z in Z/pZ,...
static FORCE_INLINE number n_Invers(number a, const coeffs r)
return the multiplicative inverse of 'a'; raise an error if 'a' is not invertible
static FORCE_INLINE BOOLEAN n_GreaterZero(number n, const coeffs r)
ordered fields: TRUE iff 'n' is positive; in Z/pZ: TRUE iff 0 < m <= roundedBelow(p/2),...
static FORCE_INLINE void n_MPZ(mpz_t result, number &n, const coeffs r)
conversion of n to a GMP integer; 0 if not possible
static FORCE_INLINE BOOLEAN n_IsMOne(number n, const coeffs r)
TRUE iff 'n' represents the additive inverse of the one element, i.e. -1.
static FORCE_INLINE nMapFunc n_SetMap(const coeffs src, const coeffs dst)
set the mapping function pointers for translating numbers from src to dst
static FORCE_INLINE number n_InpNeg(number n, const coeffs r)
in-place negation of n MUST BE USED: n = n_InpNeg(n) (no copy is returned)
static FORCE_INLINE BOOLEAN nCoeff_has_simple_inverse(const coeffs r)
TRUE, if the computation of the inverse is fast, i.e. prefer leading coeff. 1 over content.
static FORCE_INLINE number n_Div(number a, number b, const coeffs r)
return the quotient of 'a' and 'b', i.e., a/b; raises an error if 'b' is not invertible in r exceptio...
static FORCE_INLINE BOOLEAN nCoeff_is_Q(const coeffs r)
static FORCE_INLINE BOOLEAN n_Greater(number a, number b, const coeffs r)
ordered fields: TRUE iff 'a' is larger than 'b'; in Z/pZ: TRUE iff la > lb, where la and lb are the l...
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
static FORCE_INLINE void n_ClearDenominators(ICoeffsEnumerator &numberCollectionEnumerator, number &d, const coeffs r)
(inplace) Clears denominators on a collection of numbers number d is the LCM of all the coefficient d...
static FORCE_INLINE BOOLEAN nCoeff_is_Q_or_BI(const coeffs r)
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
static FORCE_INLINE BOOLEAN nCoeff_is_Zn(const coeffs r)
static FORCE_INLINE number n_InitMPZ(mpz_t n, const coeffs r)
conversion of a GMP integer to number
static FORCE_INLINE BOOLEAN nCoeff_is_Zp(const coeffs r)
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
static FORCE_INLINE void n_ClearContent(ICoeffsEnumerator &numberCollectionEnumerator, number &c, const coeffs r)
Computes the content and (inplace) divides it out on a collection of numbers number c is the content ...
static FORCE_INLINE number n_GetNumerator(number &n, const coeffs r)
return the numerator of n (if elements of r are by nature not fractional, result is n)
@ n_rep_gap_rat
(number), see longrat.h
@ n_rep_gap_gmp
(), see rinteger.h, new impl.
@ n_rep_gmp
(mpz_ptr), see rmodulon,h
@ n_rep_rat_fct
(fraction), see transext.h
static FORCE_INLINE number n_SubringGcd(number a, number b, const coeffs r)
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
static FORCE_INLINE void n_Normalize(number &n, const coeffs r)
inplace-normalization of n; produces some canonical representation of n;
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff 'n' represents the one element.
static BOOLEAN fa(leftv res, leftv args)
static BOOLEAN pa(leftv res, leftv args)
static BOOLEAN fb(leftv res, leftv args)
static BOOLEAN pb(leftv res, leftv args)
const CanonicalForm int s
void WerrorS(const char *s)
poly p_ChineseRemainder(poly *xx, mpz_ptr *x, mpz_ptr *q, int rl, mpz_ptr *C, const ring R)
number nlModP(number q, const coeffs, const coeffs Zp)
static FORCE_INLINE BOOLEAN nlIsInteger(number q, const coeffs r)
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy
gmp_float exp(const gmp_float &a)
The main handler for Singular numbers which are suitable for Singular polynomials.
const char *const nDivBy0
#define omFreeSize(addr, size)
#define omFreeBin(addr, bin)
#define omGetSpecBin(size)
poly p_Diff(poly a, int k, const ring r)
poly p_Farey(poly p, number N, const ring r)
poly p_ISet(long i, const ring r)
returns the poly representing the integer i
poly p_Div_nn(poly p, const number n, const ring r)
void p_Normalize(poly p, const ring r)
void p_Norm(poly p1, const ring r)
poly p_Cleardenom(poly p, const ring r)
int p_Var(poly m, const ring r)
poly p_Sub(poly p1, poly p2, const ring r)
poly p_NSet(number n, const ring r)
returns the poly representing the number n, destroys n
const char * p_Read(const char *st, poly &rc, const ring r)
BOOLEAN p_EqualPolys(poly p1, poly p2, const ring r)
static poly p_Neg(poly p, const ring r)
static int pLength(poly a)
static poly p_Add_q(poly p, poly q, const ring r)
static poly p_Mult_q(poly p, poly q, const ring r)
void p_Write(poly p, ring lmRing, ring tailRing)
static unsigned long p_SetExp(poly p, const unsigned long e, const unsigned long iBitmask, const int VarOffset)
set a single variable exponent @Note: VarOffset encodes the position in p->exp
static void p_ExpVectorDiff(poly pr, poly p1, poly p2, const ring r)
void p_String0Long(const poly p, ring lmRing, ring tailRing)
print p in a long way
void p_String0Short(const poly p, ring lmRing, ring tailRing)
print p in a short way, if possible
static void p_Setm(poly p, const ring r)
static number p_SetCoeff(poly p, number n, ring r)
static BOOLEAN p_LmIsConstantComp(const poly p, const ring r)
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent @Note: the integer VarOffset encodes:
static BOOLEAN p_LmIsConstant(const poly p, const ring r)
static BOOLEAN p_IsOne(const poly p, const ring R)
either poly(1) or gen(k)?!
static BOOLEAN p_IsConstant(const poly p, const ring r)
static void p_Delete(poly *p, const ring r)
static poly pp_Mult_qq(poly p, poly q, const ring r)
static poly p_LmFreeAndNext(poly p, ring)
static poly p_Copy(poly p, const ring r)
returns a copy of p
static long p_Totaldegree(poly p, const ring r)
#define __p_Mult_nn(p, n, r)
void p_wrp(poly p, ring lmRing, ring tailRing)
poly prMapR(poly src, nMapFunc nMap, ring src_r, ring dest_r)
poly prCopyR(poly p, ring src_r, ring dest_r)
void StringAppendS(const char *st)
void PrintS(const char *s)
void rDelete(ring r)
unconditionally deletes fields in r
BOOLEAN rEqual(ring r1, ring r2, BOOLEAN qr)
returns TRUE, if r1 equals r2 FALSE, otherwise Equality is determined componentwise,...
static ring rIncRefCnt(ring r)
static char * rRingVar(short i, const ring r)
static void rDecRefCnt(ring r)
static BOOLEAN rCanShortOut(const ring r)
static short rVar(const ring r)
#define rVar(r) (r->N)
static poly convert(const number &n)
static int ntSize(number a, const coeffs cf)
static BOOLEAN ntDBTest(number a, const char *f, const int l, const coeffs r)
static number ntParameter(const int iParameter, const coeffs cf)
return the specified parameter as a number in the given trans.ext.
static void ntWriteLong(number a, const coeffs cf)
static BOOLEAN ntCoeffIsEqual(const coeffs cf, n_coeffType n, void *param)
static void heuristicGcdCancellation(number a, const coeffs cf)
forward declarations
static const char * ntRead(const char *s, number *a, const coeffs cf)
number ntDiff(number a, number d, const coeffs cf)
nMapFunc ntSetMap(const coeffs src, const coeffs dst)
Get a mapping function from src into the domain of this type (n_transExt)
static number ntSub(number a, number b, const coeffs cf)
static number ntCopyAlg(number a, const coeffs cf, const coeffs dst)
static long ntInt(number &a, const coeffs cf)
static number ntMapPP(number a, const coeffs src, const coeffs dst)
static void ntDelete(number *a, const coeffs cf)
static BOOLEAN ntIsOne(number a, const coeffs cf)
static void ntNormalizeDen(fraction result, const ring R)
poly gcd_over_Q(poly f, poly g, const ring r)
helper routine for calling singclap_gcd_r
BOOLEAN ntInitChar(coeffs cf, void *infoStruct)
Initialize the coeffs object.
static BOOLEAN ntIsZero(number a, const coeffs cf)
static number ntGetNumerator(number &a, const coeffs cf)
TODO: normalization of a!?
static CanonicalForm ntConvSingNFactoryN(number n, BOOLEAN, const coeffs cf)
static void ntClearDenominators(ICoeffsEnumerator &numberCollectionEnumerator, number &c, const coeffs cf)
static BOOLEAN ntIsMOne(number a, const coeffs cf)
static number ntMapZ0(number a, const coeffs src, const coeffs dst)
static void ntMPZ(mpz_t m, number &n, const coeffs r)
static void ntCoeffWrite(const coeffs cf, BOOLEAN details)
static number ntMap0P(number a, const coeffs src, const coeffs dst)
#define NUMIS1(f)
TRUE iff num. represents 1.
static number ntGcd(number a, number b, const coeffs cf)
static number ntConvFactoryNSingN(const CanonicalForm n, const coeffs cf)
static void ntClearContent(ICoeffsEnumerator &numberCollectionEnumerator, number &c, const coeffs cf)
static number ntInvers(number a, const coeffs cf)
static number ntNormalizeHelper(number a, number b, const coeffs cf)
static void ntPower(number a, int exp, number *b, const coeffs cf)
number ntInit(long i, const coeffs cf)
static number ntMapP0(number a, const coeffs src, const coeffs dst)
static number ntGetDenom(number &a, const coeffs cf)
TODO: normalization of a!?
static number ntMapUP(number a, const coeffs src, const coeffs dst)
static void ntInpMult(number &a, number b, const coeffs cf)
#define MULT_COMPLEXITY
complexity increase due to * and /
static void ntKillChar(coeffs cf)
static void ntInpAdd(number &a, number b, const coeffs cf)
static void ntWriteShort(number a, const coeffs cf)
static number ntDiv(number a, number b, const coeffs cf)
static number ntCopy(number a, const coeffs cf)
static int ntParDeg(number a, const coeffs cf)
static BOOLEAN ntGreaterZero(number a, const coeffs cf)
static number ntChineseRemainder(number *x, number *q, int rl, BOOLEAN, CFArray &inv_cache, const coeffs cf)
static number ntGenMap(number a, const coeffs cf, const coeffs dst)
int ntIsParam(number m, const coeffs cf)
if m == var(i)/1 => return i,
static number ntMap00(number a, const coeffs src, const coeffs dst)
static number ntMult(number a, number b, const coeffs cf)
#define ADD_COMPLEXITY
complexity increase due to + and -
static number ntGenAlg(number a, const coeffs cf, const coeffs dst)
static number ntNeg(number a, const coeffs cf)
this is in-place, modifies a
static void definiteGcdCancellation(number a, const coeffs cf, BOOLEAN simpleTestsHaveAlreadyBeenPerformed)
modifies a
static number ntAdd(number a, number b, const coeffs cf)
static number ntFarey(number p, number n, const coeffs cf)
static number ntCopyMap(number a, const coeffs cf, const coeffs dst)
static void ntNormalize(number &a, const coeffs cf)
static BOOLEAN ntEqual(number a, number b, const coeffs cf)
VAR omBin fractionObjectBin
static coeffs nCoeff_bottom(const coeffs r, int &height)
#define DIFF_COMPLEXITY
complexity increase due to diff
static BOOLEAN ntGreater(number a, number b, const coeffs cf)
static void handleNestedFractionsOverQ(fraction f, const coeffs cf)
static number ntExactDiv(number a, number b, const coeffs cf)
#define BOUND_COMPLEXITY
maximum complexity of a number
static number ntInitMPZ(mpz_t m, const coeffs r)
struct for passing initialization parameters to naInitChar