15#include "factory/factory.h"
43 while ( (temp !=
NULL) && (point < numMonoms) ) {
44 state=
pCmp( temp, monomials[point] );
48 if ( pretemp ==
NULL ) {
59 number newelem =
nAdd(
pGetCoeff( todelete ),
v.getconstelem( point+1 ) );
60 v.setelem( point+1, newelem );
81 for (
k=
IDELEMS( source ) - 1;
k >= 0;
k-- ) {
87 if (
w[
k] <
w[best-1] ) {
96 poly p2 = (source->m)[best-1];
114 number temp =
nDiv( n1, n2 );
122 *pptr=
pAdd( *pptr, p2 );
124 return ( (best > 0) );
132 while ( reduced ==
TRUE ) {
138 if ( temp !=
NULL ) {
142 while ( reduced ==
TRUE ) {
163 int basisMax = basisBS;
165 int * weights =
NULL;
166 int * lengths =
NULL;
179 for (
k= 0;
k < numMonoms;
k++ ) {
190#ifndef HAVE_EXPLICIT_CONSTR
196#ifndef HAVE_EXPLICIT_CONSTR
208 poly temp= (source->m)[
k];
210 while ( temp !=
NULL ) {
218 lengths= (
int *)
omAlloc( numMonoms *
sizeof(
int ) );
219 order= (
int *)
omAlloc( numMonoms *
sizeof(
int ) );
222 for (
k= 0;
k < numMonoms;
k++ )
228 fglmReduce( & current, currV,
m, numMonoms, source, weights );
231 while ( temp !=
NULL )
243 if ( basisSize == basisMax )
246 basis= (
polyset)
omReallocSize( basis, basisMax *
sizeof( poly ), (basisMax + basisBS ) *
sizeof( poly ) );
252 basis[basisSize]=
pLmInit(temp);
259#ifndef HAVE_EXPLICIT_CONSTR
260 mv[
k].mac_constr( currV );
267 for (
k= 0;
k < numMonoms;
k++ ) {
270#ifndef HAVE_EXPLICIT_CONSTR
271 v[
k].mac_constr_i( basisSize );
273 v[
k].fglmVector( basisSize );
276 while ( mon !=
NULL ) {
288 v[
k].setelem(
b+1, coeff );
299 for (
k= 0;
k < basisSize;
k++ )
308 for (
k= 0;
k < numMonoms;
k++ ) {
309 lengths[
k]=
v[
k].numNonZeroElems();
317 for (
k= numMonoms - 1;
k >= 0;
k-- ) {
318 if ( lengths[
k] > 0 ) {
323 if ( lengths[
k] < lengths[best-1] ) {
340#ifndef HAVE_EXPLICIT_CONSTR
341 v[best-1].clearelems();
343 v[best-1].~fglmVector();
348 number
gcd =
p.gcd();
354 for (
k= 0;
k <
p.size();
k++ ) {
355 if ( !
p.elemIsZero(
k+1 ) ) {
356 temp+=
p.getconstelem(
k+1 ) * mv[order[
k]];
368 for (
k= 1;
k <= numMonoms;
k++ ) {
388#ifndef HAVE_EXPLICIT_CONSTR
394 for (
k= 0;
k < basisSize;
k++ )
398#ifndef HAVE_EXPLICIT_CONSTR
401 for (
k= 0;
k < numMonoms;
k++ )
406 for (
k= 0;
k < numMonoms;
k++ )
431 while ( temp !=
NULL ) {
445 for (
k= 0;
k < numMonoms;
k++ ) {
446 poly mon=
pHead( temp );
458 while ( sm !=
NULL ) {
465 if ( basisSize == basisMax ) {
466 basis= (
polyset)
omReallocSize( basis, basisMax *
sizeof( poly ), (basisMax + basisBS ) *
sizeof( poly ) );
469 basis[basisSize]=
pHead( sm );
482 for (
k= 0;
k < numMonoms;
k++ ) {
483#ifndef HAVE_EXPLICIT_CONSTR
484 v[
k].mac_constr_i( basisSize );
486 v[
k].fglmVector( basisSize );
490 while ( mon !=
NULL ) {
500 v[
k].setelem(
b+1, coeff );
519 number
gcd =
p.gcd();
523 for (
k= 1;
k <=
p.size();
k++ ) {
524 if ( !
p.elemIsZero(
k ) ) {
527 comb=
pAdd( comb, temp );
534 for (
k= 0;
k < numMonoms;
k++ ) {
543 for (
k= 0;
k < basisSize;
k++ )
number getconstelem(int i) const
fglmVector(fglmVectorRep *rep)
BOOLEAN reduce(fglmVector v)
fglmVector getDependence()
static FORCE_INLINE void n_Normalize(number &n, const coeffs r)
inplace-normalization of n; produces some canonical representation of n;
const Variable & v
< [in] a sqrfree bivariate poly
bool isZero(const CFArray &A)
checks if entries of A are zero
static void fglmReduce(poly *pptr, fglmVector &v, polyset m, int numMonoms, ideal source, int *w)
poly fglmLinearCombination(ideal source, poly monset)
static void fglmEliminateMonomials(poly *pptr, fglmVector &v, polyset monomials, int numMonoms)
poly fglmNewLinearCombination(ideal source, poly monset)
static BOOLEAN fglmReductionStep(poly *pptr, ideal source, int *w)
#define STICKYPROT2(msg, arg)
poly kNF(ideal F, ideal Q, poly p, int syzComp, int lazyReduce)
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy
STATIC_VAR gmp_float * diff
#define omFreeSize(addr, size)
#define omReallocSize(addr, o_size, size)
poly p_Cleardenom(poly p, const ring r)
static int pLength(poly a)
#define __p_Mult_nn(p, n, r)
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Compatibility layer for legacy polynomial operations (over currRing)
#define pHead(p)
returns newly allocated copy of Lm(p), coef is copied, next=NULL, p might be NULL
#define pSetCoeff(p, n)
deletes old coeff before setting the new one
#define pCmp(p1, p2)
pCmp: args may be NULL returns: (p2==NULL ? 1 : (p1 == NULL ? -1 : p_LmCmp(p1, p2)))
#define pLmInit(p)
like pInit, except that expvector is initialized to that of p, p must be != NULL
#define pLmDelete(p)
assume p != NULL, deletes Lm(p)->coef and Lm(p)
static void pLmFree(poly p)
frees the space of the monomial m, assumes m != NULL coef is not freed, m is not advanced
#define pGetExp(p, i)
Exponent.
#define pDivisibleBy(a, b)
returns TRUE, if leading monom of a divides leading monom of b i.e., if there exists a expvector c > ...
#define pCopy(p)
return a copy of the poly