15 #include <factory/factory.h> 32 # include <iostream.h> 44 while ( (temp !=
NULL) && (point < numMonoms) ) {
45 state=
pCmp( temp, monomials[point] );
49 if ( pretemp ==
NULL ) {
82 for ( k=
IDELEMS( source ) - 1; k >= 0; k-- ) {
88 if ( w[k] < w[best-1] ) {
97 poly p2 = (source->m)[best-1];
101 for ( i= (
currRing->N); i > 0; i-- )
115 number temp =
nDiv( n1, n2 );
123 *pptr=
pAdd( *pptr, p2 );
125 return ( (best > 0) );
133 while ( reduced ==
TRUE ) {
139 if ( temp !=
NULL ) {
143 while ( reduced ==
TRUE ) {
165 int basisMax = basisBS;
167 int * weights =
NULL;
168 int * lengthes =
NULL;
181 for ( k= 0; k < numMonoms; k++ ) {
192 #ifndef HAVE_EXPLICIT_CONSTR 198 #ifndef HAVE_EXPLICIT_CONSTR 209 for ( k= 0; k <
IDELEMS( source ); k++ ) {
210 poly temp= (source->m)[k];
212 while ( temp !=
NULL ) {
220 lengthes= (
int *)
omAlloc( numMonoms *
sizeof(
int ) );
221 order= (
int *)
omAlloc( numMonoms *
sizeof(
int ) );
224 for ( k= 0; k < numMonoms; k++ )
230 fglmReduce( & current, currV, m, numMonoms, source, weights );
233 while ( temp !=
NULL )
236 for ( b= 0; (b < basisSize) && (found ==
FALSE); b++ )
243 if ( found ==
FALSE )
245 if ( basisSize == basisMax )
254 basis[basisSize]=
pLmInit(temp);
261 #ifndef HAVE_EXPLICIT_CONSTR 262 mv[
k].mac_constr( currV );
269 for ( k= 0; k < numMonoms; k++ ) {
272 #ifndef HAVE_EXPLICIT_CONSTR 273 v[
k].mac_constr_i( basisSize );
278 while ( mon !=
NULL ) {
281 while ( found ==
FALSE ) {
301 for ( k= 0; k < basisSize; k++ )
310 for ( k= 0; k < numMonoms; k++ ) {
317 while ( (isZero ==
FALSE) && (act < numMonoms) ) {
319 for ( k= numMonoms - 1; k >= 0; k-- ) {
320 if ( lengthes[k] > 0 ) {
325 if ( lengthes[k] < lengthes[best-1] ) {
334 if ( ( isZero= gauss.
reduce( v[best-1] )) ==
TRUE ) {
342 #ifndef HAVE_EXPLICIT_CONSTR 343 v[best-1].clearelems();
349 if ( isZero ==
TRUE ) {
356 for ( k= 0; k < p.
size(); k++ ) {
370 for ( k= 1; k <= numMonoms; k++ ) {
372 if ( result ==
NULL ) {
373 result=
pCopy( m[k-1] );
377 sum->next=
pCopy( m[k-1] );
391 #ifndef HAVE_EXPLICIT_CONSTR 397 for ( k= 0; k < basisSize; k++ )
401 #ifndef HAVE_EXPLICIT_CONSTR 404 for ( k= 0; k < numMonoms; k++ )
409 for ( k= 0; k < numMonoms; k++ )
435 while ( temp !=
NULL ) {
449 for ( k= 0; k < numMonoms; k++ ) {
462 while ( sm !=
NULL ) {
465 for ( b= 0; (b < basisSize) && (found ==
FALSE); b++ )
467 if ( found ==
FALSE ) {
469 if ( basisSize == basisMax ) {
473 basis[basisSize]=
pHead( sm );
486 for ( k= 0; k < numMonoms; k++ ) {
487 #ifndef HAVE_EXPLICIT_CONSTR 488 v[
k].mac_constr_i( basisSize );
494 while ( mon !=
NULL ) {
497 while ( found ==
FALSE ) {
513 for ( k= 0; (k < numMonoms) && (isZero ==
FALSE); k++ ) {
515 if ( ( isZero= gauss.
reduce( v[k] )) ==
TRUE )
522 if ( isZero ==
TRUE ) {
527 for ( k= 1; k <= p.
size(); k++ ) {
531 comb=
pAdd( comb, temp );
538 for ( k= 0; k < numMonoms; k++ ) {
545 for ( k= numMonoms - 1; k >= 0; k-- ) v[k].~
fglmVector();
547 for ( k= 0; k < basisSize; k++ )
fglmVector(fglmVectorRep *rep)
Implementation of class fglmVector
poly kNF(ideal F, ideal Q, poly p, int syzComp, int lazyReduce)
Compatiblity layer for legacy polynomial operations (over currRing)
#define omFreeSize(addr, size)
static void fglmReduce(poly *pptr, fglmVector &v, polyset m, int numMonoms, ideal source, int *w)
#define pLmDelete(p)
assume p != NULL, deletes Lm(p)->coef and Lm(p)
#define pCmp(p1, p2)
pCmp: args may be NULL returns: (p2==NULL ? 1 : (p1 == NULL ? -1 : p_LmCmp(p1, p2))) ...
static FORCE_INLINE void n_Normalize(number &n, const coeffs r)
inplace-normalization of n; produces some canonical representation of n;
number getconstelem(int i) const
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy ...
static int pLength(poly a)
static poly fglmNewLinearCombination(ideal source, poly monset)
fglmVector getDependence()
#define omReallocSize(addr, o_size, size)
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
#define pGetExp(p, i)
Exponent.
int numNonZeroElems() const
#define pLmInit(p)
like pInit, except that expvector is initialized to that of p, p must be != NULL
static BOOLEAN fglmReductionStep(poly *pptr, ideal source, int *w)
BOOLEAN reduce(fglmVector v)
#define pHead(p)
returns newly allocated copy of Lm(p), coef is copied, next=NULL, p might be NULL ...
void p_Content(poly ph, const ring r)
static void fglmEliminateMonomials(poly *pptr, fglmVector &v, polyset monomials, int numMonoms)
const Variable & v
< [in] a sqrfree bivariate poly
#define pDivisibleBy(a, b)
returns TRUE, if leading monom of a divides leading monom of b i.e., if there exists a expvector c > ...
void setelem(int i, number &n)
bool isZero(const CFArray &A)
checks if entries of A are zero
static void pLmFree(poly p)
frees the space of the monomial m, assumes m != NULL coef is not freed, m is not advanced ...
#define pSetCoeff(p, n)
deletes old coeff before setting the new one
static poly fglmLinearCombination(ideal source, poly monset)
#define pCopy(p)
return a copy of the poly
#define STICKYPROT2(msg, arg)