15 #include "factory/factory.h" 31 # include <iostream.h> 43 while ( (temp !=
NULL) && (point < numMonoms) ) {
44 state=
pCmp( temp, monomials[point] );
48 if ( pretemp ==
NULL ) {
81 for ( k=
IDELEMS( source ) - 1; k >= 0; k-- ) {
87 if ( w[k] < w[best-1] ) {
96 poly p2 = (source->m)[best-1];
100 for ( i= (
currRing->N); i > 0; i-- )
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 * lengthes =
NULL;
179 for ( k= 0; k < numMonoms; k++ ) {
190 #ifndef HAVE_EXPLICIT_CONSTR 196 #ifndef HAVE_EXPLICIT_CONSTR 207 for ( k= 0; k <
IDELEMS( source ); k++ ) {
208 poly temp= (source->m)[k];
210 while ( temp !=
NULL ) {
218 lengthes= (
int *)
omAlloc( numMonoms *
sizeof(
int ) );
219 order= (
int *)
omAlloc( numMonoms *
sizeof(
int ) );
222 for ( k= 0; k < numMonoms; k++ )
225 poly current =
pCopy( m[k] );
228 fglmReduce( & current, currV, m, numMonoms, source, weights );
231 while ( temp !=
NULL )
234 for ( b= 0; (b < basisSize) && (found ==
FALSE); b++ )
241 if ( found ==
FALSE )
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 );
276 while ( mon !=
NULL ) {
279 while ( found ==
FALSE ) {
299 for ( k= 0; k < basisSize; k++ )
308 for ( k= 0; k < numMonoms; k++ ) {
315 while ( (isZero ==
FALSE) && (act < numMonoms) ) {
317 for ( k= numMonoms - 1; k >= 0; k-- ) {
318 if ( lengthes[k] > 0 ) {
323 if ( lengthes[k] < lengthes[best-1] ) {
332 if ( ( isZero= gauss.
reduce( v[best-1] )) ==
TRUE ) {
340 #ifndef HAVE_EXPLICIT_CONSTR 341 v[best-1].clearelems();
347 if ( isZero ==
TRUE ) {
354 for ( k= 0; k < p.
size(); k++ ) {
368 for ( k= 1; k <= numMonoms; k++ ) {
370 if ( result ==
NULL ) {
371 result=
pCopy( m[k-1] );
375 sum->next=
pCopy( m[k-1] );
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 ) {
461 for ( b= 0; (b < basisSize) && (found ==
FALSE); b++ )
463 if ( found ==
FALSE ) {
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 );
490 while ( mon !=
NULL ) {
493 while ( found ==
FALSE ) {
509 for ( k= 0; (k < numMonoms) && (isZero ==
FALSE); k++ ) {
511 if ( ( isZero= gauss.
reduce( v[k] )) ==
TRUE )
518 if ( isZero ==
TRUE ) {
523 for ( k= 1; k <= p.
size(); k++ ) {
525 poly temp =
pCopy( m[k-1] );
527 comb=
pAdd( comb, temp );
534 for ( k= 0; k < numMonoms; k++ ) {
541 for ( k= numMonoms - 1; k >= 0; k-- ) v[k].~
fglmVector();
543 for ( k= 0; k < basisSize; k++ )
int numNonZeroElems() const
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)
number getconstelem(int i) const
poly fglmLinearCombination(ideal source, poly monset)
#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))) ...
poly fglmNewLinearCombination(ideal source, poly monset)
static FORCE_INLINE void n_Normalize(number &n, const coeffs r)
inplace-normalization of n; produces some canonical representation of n;
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy ...
fglmVector getDependence()
#define omReallocSize(addr, o_size, size)
#define pGetExp(p, i)
Exponent.
#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)
static unsigned pLength(poly a)
#define pHead(p)
returns newly allocated copy of Lm(p), coef is copied, next=NULL, p might be NULL ...
static void fglmEliminateMonomials(poly *pptr, fglmVector &v, polyset monomials, int numMonoms)
const Variable & v
< [in] a sqrfree bivariate poly
#define __p_Mult_nn(p, n, r)
#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
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
static void pLmFree(poly p)
frees the space of the monomial m, assumes m != NULL coef is not freed, m is not advanced ...
poly p_Cleardenom(poly p, const ring r)
#define pSetCoeff(p, n)
deletes old coeff before setting the new one
#define pCopy(p)
return a copy of the poly
#define STICKYPROT2(msg, arg)