40#define SM_MIN_LENGTH_BUCKET MIN_LENGTH_BUCKET - 5
42#define SM_MIN_LENGTH_BUCKET MAX_INT_VAL
45typedef struct smprec sm_prec;
60static void sm_ExpMultDiv(poly,
const poly,
const poly,
const ring);
61static void sm_PolyDivN(poly,
const number,
const ring);
64static void sm_FindRef(poly *, poly *, poly,
const ring);
86 p =
currRing->p_Procs->pp_Mult_Coeff_mm_DivSelectMult(
p,
m, a,
b,
196 al = di*
sizeof(long);
198 bl = ra*
sizeof(long);
200 for (
i=di-1;
i>=0;
i--)
253 for (
i=pos;
i<d;
i++) c[
i] = c[
i+1];
263 int *block0=(
int*)
omAlloc0(3*
sizeof(
int));
264 int *block1=(
int*)
omAlloc0(3*
sizeof(
int));
273 tmpR->bitmask = 2*
bound;
274 tmpR->wvhdl = (
int **)
omAlloc0((3) *
sizeof(
int*));
280 if (origR->qideal!=
NULL)
285 Print(
"[%ld:%d]", (
long) tmpR->bitmask, tmpR->ExpL_Size);
292 for(
int i=r->N-1;
i>=0;
i--)
omFree(r->names[
i]);
304 if (I->ncols != I->rank)
306 Werror(
"det of %ld x %d module (matrix)",I->rank,I->ncols);
468 for (
i=
v->rows()-1;
i>=0;
i--)
660 if ((wr<0.25) || (wc<0.25))
701 float wc, wp,
w, hp =
piv->f;
739 float wopt = 1.0e30, hp =
piv->f;
742 int i, copt, ropt,
f, e =
crd;
761 if ((wr<0.25) || (wc<0.25))
838 else if (a->pos >
b->pos)
925 else if (a->pos >
b->pos)
1008 }
while (r !=
NULL);
1037 }
while (a->pos <
rpiv);
1053 if ((a ==
NULL) || (a->pos >
rpiv))
1065 else if (a->pos ==
rpiv)
1142 if (
i >
act)
return;
1172 if (
i >
act)
return;
1217 }
while ((a !=
NULL) && (a->pos <=
tored));
1233 if ((a ==
NULL) || (a->pos >
tored))
break;
1236 if ((
k >
i) && (a->pos <=
tored))
1243 }
while ((a !=
NULL) && (a->pos <=
tored));
1253 while ((a !=
NULL) && (a->pos <=
tored))
1406 }
while (a !=
NULL);
1425 }
while (a !=
NULL);
1446 }
while (a !=
NULL);
1486 }
while (a !=
NULL);
1560void sm_PolyDiv(poly a, poly
b,
const ring
R)
1581 }
while (a !=
NULL);
1605 }
while (t !=
NULL);
1620poly smMultDiv(poly a, poly b, const poly c)
1626 if ((c == NULL) || pLmIsConstantComp(c))
1628 return pp_Mult_qq(a, b);
1631 pqLength(a, b, la, lb, SM_MIN_LENGTH_BUCKET);
1633 // we iter over b, so, make sure b is the shortest
1634 // such that we minimize our iterations
1649 pSetCoeff0(e,pGetCoeff(b));
1650 if (smIsNegQuot(e, b, c))
1652 lead = pLmDivisibleByNoComp(e, a);
1653 r = smSelectCopy_ExpMultDiv(a, e, b, c);
1658 r = pp_Mult__mm(a, e);
1664 smFindRef(&pa, &res, r);
1674 res = p_Add_q(res, r);
1683 if (!TEST_OPT_NOT_BUCKETS && lb >= SM_MIN_LENGTH_BUCKET)
1685 // use buckets if minimum length is smaller than threshold
1688 // find the last monomial before pa
1692 pNext(append) = res;
1697 while (pNext(append) != pa)
1699 assume(pNext(append) != NULL);
1703 kBucket_pt bucket = kBucketCreate(currRing);
1704 kBucketInit(bucket, pNext(append), 0);
1707 pSetCoeff0(e,pGetCoeff(b));
1708 if (smIsNegQuot(e, b, c))
1711 r = pp_Mult_Coeff_mm_DivSelect_MultDiv(a, lr, e, b, c);
1712 if (pLmDivisibleByNoComp(e, a))
1713 append = kBucket_ExtractLarger_Add_q(bucket, append, r, &lr);
1715 kBucket_Add_q(bucket, r, &lr);
1719 r = pp_Mult__mm(a, e);
1720 append = kBucket_ExtractLarger_Add_q(bucket, append, r, &la);
1723 } while (b != NULL);
1724 pNext(append) = kBucketClear(bucket);
1725 kBucketDestroy(&bucket);
1733 pSetCoeff0(e,pGetCoeff(b));
1734 if (smIsNegQuot(e, b, c))
1736 r = smSelectCopy_ExpMultDiv(a, e, b, c);
1737 if (pLmDivisibleByNoComp(e, a))
1738 smCombineChain(&pa, r);
1744 r = pp_Mult__mm(a, e);
1745 smCombineChain(&pa, r);
1748 } while (b != NULL);
1829 }
while (
b !=
NULL);
1959 }
while (a !=
NULL);
2088 memcpy(r, a,
sizeof(
smprec));
2200 return res+(float)
i;
2235 if (!sw)
return res;
2256typedef struct smnrec sm_nrec;
2324 WerrorS(
"symbol in equation");
2340 WerrorS(
"singular problem for linsolv");
2402 if (
sing != 0)
return;
2413 if (
sing != 0)
return;
2607 }
while (
b !=
NULL);
2610 if (a->pos <
b->pos)
2615 else if (a->pos >
b->pos)
2647 }
while (r !=
NULL);
2676 }
while (a->pos <
rpiv);
2692 if ((a ==
NULL) || (a->pos >
rpiv))
2704 else if (a->pos ==
rpiv)
2837 memcpy(r, a,
sizeof(
smnrec));
2891 if ((
i == 0) || (
i != I->rank-1))
2893 WerrorS(
"wrong dimensions for linsolv");
2898 if(I->m[
i-1] ==
NULL)
2900 WerrorS(
"singular input for linsolv");
static int si_max(const int a, const int b)
static CanonicalForm bound(const CFMatrix &M)
sparse_mat(ideal, const ring)
void smToIntvec(intvec *)
void smNewBareiss(int, int)
sparse_number_mat(ideal, const ring)
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 number n_Copy(number n, const coeffs r)
return a copy of 'n'
static FORCE_INLINE number n_Add(number a, number b, const coeffs r)
return the sum of 'a' and 'b', i.e., a+b
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 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 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 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 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 int n_Size(number n, const coeffs r)
return a non-negative measure for the complexity of n; return 0 only when n represents zero; (used fo...
static FORCE_INLINE number n_Sub(number a, number b, const coeffs r)
return the difference of 'a' and 'b', i.e., a-b
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
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 BOOLEAN n_Equal(number a, number b, const coeffs r)
TRUE iff 'a' and 'b' represent the same number; they may have different representations.
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 pa(leftv res, leftv args)
static BOOLEAN pb(leftv res, leftv args)
const CanonicalForm int s
const CanonicalForm int const CFList const Variable & y
const Variable & v
< [in] a sqrfree bivariate poly
void WerrorS(const char *s)
void kBucketDestroy(kBucket_pt *bucket_pt)
void kBucketInit(kBucket_pt bucket, poly lm, int length)
poly kBucketExtractLm(kBucket_pt bucket)
kBucket_pt kBucketCreate(const ring bucket_ring)
Creation/Destruction of buckets.
void kBucket_Add_q(kBucket_pt bucket, poly q, int *l)
Add to Bucket a poly ,i.e. Bpoly == q+Bpoly.
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy
#define omFreeSize(addr, size)
#define omFreeBin(addr, bin)
#define omGetSpecBin(size)
#define TEST_OPT_NOT_BUCKETS
void p_Normalize(poly p, const ring r)
poly p_Cleardenom(poly p, 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 void p_LmDelete(poly p, const ring r)
static void p_ExpVectorAdd(poly p1, poly p2, const ring r)
static long p_SubExp(poly p, int v, long ee, ring r)
static poly pp_Mult_mm(poly p, poly m, const ring r)
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)
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
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 int p_LmCmp(poly p, poly q, 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_LmDivisibleByNoComp(poly a, poly b, const ring r)
static poly p_New(const ring, omBin bin)
static long p_MaxComp(poly p, ring lmRing, ring tailRing)
static poly p_Mult_nn(poly p, number n, 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 void p_LmFree(poly p, ring)
static poly p_Init(const ring r, omBin bin)
static poly pp_Mult_Coeff_mm_DivSelect(poly p, const poly m, const ring r)
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
poly prMoveR(poly &p, ring src_r, ring dest_r)
ideal idrMoveR(ideal &id, ring src_r, ring dest_r)
ideal idrCopyR(ideal id, ring src_r, ring dest_r)
ideal idrCopyR_NoSort(ideal id, ring src_r, ring dest_r)
void PrintS(const char *s)
void Werror(const char *fmt,...)
BOOLEAN rComplete(ring r, int force)
this needs to be called whenever a new ring is created: new fields in ring are created (like VarOffse...
void rKillModifiedRing(ring r)
ring rCopy0(const ring r, BOOLEAN copy_qideal, BOOLEAN copy_ordering)
static BOOLEAN rOrd_is_Comp_dp(const ring r)
static short rVar(const ring r)
#define rVar(r) (r->N)
ideal idInit(int idsize, int rank)
initialise an ideal / module
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
BOOLEAN id_IsConstant(ideal id, const ring r)
test if the ideal has only constant polynomials NOTE: zero ideal/module is also constant
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s
STATIC_VAR omBin smnrec_bin
static void sm_ElemDelete(smpoly *, const ring)
static smnumber sm_Poly2Smnumber(poly, const ring)
static void smMinSelect(long *, int, int)
poly sm_MultDiv(poly a, poly b, const poly c, const ring R)
static BOOLEAN sm_HaveDenom(poly, const ring)
#define SM_MIN_LENGTH_BUCKET
long sm_ExpBound(ideal m, int di, int ra, int t, const ring currRing)
static void sm_CombineChain(poly *, poly, const ring)
poly sm_CallDet(ideal I, const ring R)
static poly pp_Mult_Coeff_mm_DivSelect_MultDiv(poly p, int &lp, poly m, poly a, poly b, const ring currRing)
static void sm_NumberDelete(smnumber *, const ring R)
void sm_CallBareiss(ideal I, int x, int y, ideal &M, intvec **iv, const ring R)
static float sm_PolyWeight(smpoly, const ring)
static BOOLEAN smSmaller(poly, poly)
ideal sm_CallSolv(ideal I, const ring R)
static smnumber smNumberCopy(smnumber)
static poly sm_Smpoly2Poly(smpoly, const ring)
static smpoly smElemCopy(smpoly)
static number sm_Cleardenom(ideal, const ring)
static poly sm_SelectCopy_ExpMultDiv(poly p, poly m, poly a, poly b, const ring currRing)
static void sm_ExpMultDiv(poly, const poly, const poly, const ring)
ring sm_RingChange(const ring origR, long bound)
static BOOLEAN smCheckSolv(ideal)
void sm_SpecialPolyDiv(poly a, poly b, const ring R)
static BOOLEAN sm_IsNegQuot(poly, const poly, const poly, const ring)
static void sm_ExactPolyDiv(poly, poly, const ring)
static void sm_FindRef(poly *, poly *, poly, const ring)
void sm_KillModifiedRing(ring r)
static smpoly sm_Poly2Smpoly(poly, const ring)
static void sm_PolyDivN(poly, const number, const ring)
static poly sm_Smnumber2Poly(number, const ring)