Functions
fglmcomb.cc File Reference
#include <kernel/mod2.h>
#include <factory/factory.h>
#include <misc/options.h>
#include <kernel/polys.h>
#include <kernel/ideals.h>
#include <polys/monomials/ring.h>
#include <polys/monomials/maps.h>
#include <omalloc/omalloc.h>
#include "fglmvec.h"
#include "fglmgauss.h"
#include <kernel/GBEngine/kstd1.h>
#include "fglm.h"
#include <iostream>

Go to the source code of this file.

Functions

static void fglmEliminateMonomials (poly *pptr, fglmVector &v, polyset monomials, int numMonoms)
 
static BOOLEAN fglmReductionStep (poly *pptr, ideal source, int *w)
 
static void fglmReduce (poly *pptr, fglmVector &v, polyset m, int numMonoms, ideal source, int *w)
 
static poly fglmNewLinearCombination (ideal source, poly monset)
 
static poly fglmLinearCombination (ideal source, poly monset)
 

Function Documentation

static void fglmEliminateMonomials ( poly pptr,
fglmVector v,
polyset  monomials,
int  numMonoms 
)
static

Definition at line 37 of file fglmcomb.cc.

38 {
39  poly temp = *pptr;
40  poly pretemp = NULL;
41  int point = 0;
42  int state;
43 
44  while ( (temp != NULL) && (point < numMonoms) ) {
45  state= pCmp( temp, monomials[point] );
46  if ( state == 0 ) {
47  // Eliminate this monomial
48  poly todelete;
49  if ( pretemp == NULL ) {
50  todelete = temp;
51  pIter( *pptr );
52  temp= *pptr;
53  }
54  else {
55  todelete= temp;
56  pIter( temp );
57  pretemp->next= temp;
58  }
59  pGetCoeff( todelete )= nInpNeg( pGetCoeff( todelete ) );
60  number newelem = nAdd( pGetCoeff( todelete ), v.getconstelem( point+1 ) );
61  v.setelem( point+1, newelem );
62  nDelete( & pGetCoeff( todelete ) );
63  pLmFree( todelete );
64  point++;
65  }
66  else if ( state < 0 )
67  point++;
68  else {
69  pretemp= temp;
70  pIter( temp );
71  }
72  }
73 }
#define pCmp(p1, p2)
pCmp: args may be NULL returns: (p2==NULL ? 1 : (p1 == NULL ? -1 : p_LmCmp(p1, p2))) ...
Definition: polys.h:115
number getconstelem(int i) const
Definition: fglmvec.cc:443
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy ...
Definition: monomials.h:51
#define pIter(p)
Definition: monomials.h:44
#define nInpNeg(n)
Definition: numbers.h:21
#define nDelete(n)
Definition: numbers.h:16
#define NULL
Definition: omList.c:10
void setelem(int i, number &n)
Definition: fglmvec.cc:448
static void pLmFree(poly p)
frees the space of the monomial m, assumes m != NULL coef is not freed, m is not advanced ...
Definition: polys.h:70
polyrec * poly
Definition: hilb.h:10
#define nAdd(n1, n2)
Definition: numbers.h:18
static poly fglmLinearCombination ( ideal  source,
poly  monset 
)
static

Definition at line 419 of file fglmcomb.cc.

420 {
421  int k;
422  poly temp;
423 
424  polyset m;
425  polyset nf;
426  fglmVector * v;
427 
428  polyset basis;
429  int basisSize = 0;
430  int basisBS = 16;
431  int basisMax;
432  // get number of monomials in monset
433  int numMonoms = 0;
434  temp = monset;
435  while ( temp != NULL ) {
436  numMonoms++;
437  pIter( temp );
438  }
439  // Allocate Memory
440  m= (polyset)omAlloc( numMonoms * sizeof( poly ) );
441  nf= (polyset)omAlloc( numMonoms * sizeof( poly ) );
442  // Warning: The fglmVectors in v are yet not initialized
443  v= (fglmVector *)omAlloc( numMonoms * sizeof( fglmVector ) );
444  basisMax= basisBS;
445  basis= (polyset)omAlloc( basisMax * sizeof( poly ) );
446 
447  // get the NormalForm and the basis monomials
448  temp= monset;
449  for ( k= 0; k < numMonoms; k++ ) {
450  poly mon= pHead( temp );
451  if ( ! nIsOne( pGetCoeff( mon ) ) ) {
452  nDelete( & pGetCoeff( mon ) );
453  pSetCoeff( mon, nInit( 1 ) );
454  }
455  STICKYPROT( "(" );
456  nf[k]= kNF( source, currRing->qideal, mon );
457  STICKYPROT( ")" );
458 
459  // search through basis
460  STICKYPROT( "[" );
461  poly sm = nf[k];
462  while ( sm != NULL ) {
463  BOOLEAN found = FALSE;
464  int b;
465  for ( b= 0; (b < basisSize) && (found == FALSE); b++ )
466  if ( pLmEqual( sm, basis[b] ) ) found= TRUE;
467  if ( found == FALSE ) {
468  // Expand the basis
469  if ( basisSize == basisMax ) {
470  basis= (polyset)omReallocSize( basis, basisMax * sizeof( poly ), (basisMax + basisBS ) * sizeof( poly ) );
471  basisMax+= basisBS;
472  }
473  basis[basisSize]= pHead( sm );
474  nDelete( & pGetCoeff( basis[basisSize] ) );
475  pSetCoeff( basis[basisSize], nInit( 1 ) );
476  basisSize++;
477  }
478  pIter( sm );
479  }
480  STICKYPROT( "]" );
481  m[k]= mon;
482  pIter( temp );
483  }
484  // get the vector representation
485  STICKYPROT2( "(%i)", basisSize );
486  for ( k= 0; k < numMonoms; k++ ) {
487 #ifndef HAVE_EXPLICIT_CONSTR
488  v[k].mac_constr_i( basisSize );
489 #else
490  v[k].fglmVector( basisSize );
491 #endif
492  STICKYPROT( "(+" );
493  poly mon= nf[k];
494  while ( mon != NULL ) {
495  BOOLEAN found = FALSE;
496  int b= 0;
497  while ( found == FALSE ) {
498  if ( pLmEqual( mon, basis[b] ) )
499  found= TRUE;
500  else
501  b++;
502  }
503  number coeff = nCopy( pGetCoeff( mon ) );
504  v[k].setelem( b+1, coeff );
505  pIter( mon );
506  }
507  STICKYPROT( ")" );
508  }
509  // gauss reduce
510  gaussReducer gauss( basisSize );
511  BOOLEAN isZero = FALSE;
512  fglmVector p;
513  for ( k= 0; (k < numMonoms) && (isZero == FALSE); k++ ) {
514  STICKYPROT( "(-" );
515  if ( ( isZero= gauss.reduce( v[k] )) == TRUE )
516  p= gauss.getDependence();
517  else
518  gauss.store();
519  STICKYPROT( ")" );
520  }
521  poly comb = NULL;
522  if ( isZero == TRUE ) {
523  number gcd = p.gcd();
524  if ( ! nIsZero( gcd ) && ! ( nIsOne( gcd ) ) )
525  p/= gcd;
526  nDelete( & gcd );
527  for ( k= 1; k <= p.size(); k++ ) {
528  if ( ! p.elemIsZero( k ) ) {
529  poly temp = pCopy( m[k-1] );
530  pSetCoeff( temp, nCopy( p.getconstelem( k ) ) );
531  comb= pAdd( comb, temp );
532  }
533  }
534  if ( ! nGreaterZero( pGetCoeff( comb ) ) ) comb= pNeg( comb );
535  }
536 
537  // Free Memory
538  for ( k= 0; k < numMonoms; k++ ) {
539  pDelete( m + k );
540  pDelete( nf + k );
541  }
542  omFreeSize( (ADDRESS)m, numMonoms * sizeof( poly ) );
543  omFreeSize( (ADDRESS)nf, numMonoms * sizeof( poly ) );
544  // Warning: At this point all Vectors in v have to be initialized
545  for ( k= numMonoms - 1; k >= 0; k-- ) v[k].~fglmVector();
546  omFreeSize( (ADDRESS)v, numMonoms * sizeof( fglmVector ) );
547  for ( k= 0; k < basisSize; k++ )
548  pDelete( basis + k );
549  omFreeSize( (ADDRESS)basis, basisMax * sizeof( poly ) );
550  STICKYPROT( "\n" );
551  return comb;
552 }
fglmVector(fglmVectorRep *rep)
Implementation of class fglmVector
Definition: fglmvec.cc:149
number gcd() const
Definition: fglmvec.cc:455
poly kNF(ideal F, ideal Q, poly p, int syzComp, int lazyReduce)
Definition: kstd1.cc:2815
#define pAdd(p, q)
Definition: polys.h:174
#define FALSE
Definition: auxiliary.h:140
return P p
Definition: myNF.cc:203
int size() const
Definition: fglmvec.cc:204
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
#define pNeg(p)
Definition: polys.h:169
#define TRUE
Definition: auxiliary.h:144
#define nIsOne(n)
Definition: numbers.h:25
void * ADDRESS
Definition: auxiliary.h:161
number getconstelem(int i) const
Definition: fglmvec.cc:443
int k
Definition: cfEzgcd.cc:93
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy ...
Definition: monomials.h:51
#define omAlloc(size)
Definition: omAllocDecl.h:210
bool found
Definition: facFactorize.cc:56
Definition: gnumpfl.cc:60
#define pIter(p)
Definition: monomials.h:44
#define omReallocSize(addr, o_size, size)
Definition: omAllocDecl.h:220
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
#define STICKYPROT(msg)
Definition: fglm.h:20
int elemIsZero(int i)
Definition: fglmvec.cc:297
#define nGreaterZero(n)
Definition: numbers.h:27
int m
Definition: cfEzgcd.cc:119
#define pHead(p)
returns newly allocated copy of Lm(p), coef is copied, next=NULL, p might be NULL ...
Definition: polys.h:67
#define nDelete(n)
Definition: numbers.h:16
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
#define nIsZero(n)
Definition: numbers.h:19
#define NULL
Definition: omList.c:10
poly * polyset
Definition: hutil.h:17
void setelem(int i, number &n)
Definition: fglmvec.cc:448
int gcd(int a, int b)
Definition: walkSupport.cc:839
#define pDelete(p_ptr)
Definition: polys.h:157
#define nCopy(n)
Definition: numbers.h:15
bool isZero(const CFArray &A)
checks if entries of A are zero
polyrec * poly
Definition: hilb.h:10
#define nInit(i)
Definition: numbers.h:24
int BOOLEAN
Definition: auxiliary.h:131
const poly b
Definition: syzextra.cc:213
#define pSetCoeff(p, n)
deletes old coeff before setting the new one
Definition: polys.h:31
#define pLmEqual(p1, p2)
Definition: polys.h:111
#define pCopy(p)
return a copy of the poly
Definition: polys.h:156
#define STICKYPROT2(msg, arg)
Definition: fglm.h:22
static poly fglmNewLinearCombination ( ideal  source,
poly  monset 
)
static

Definition at line 155 of file fglmcomb.cc.

156 {
157  polyset m = NULL;
158  polyset nf = NULL;
159  fglmVector * mv = NULL;
160 
161  fglmVector * v = NULL;
162  polyset basis = NULL;
163  int basisSize = 0;
164  int basisBS = 16;
165  int basisMax = basisBS;
166 
167  int * weights = NULL;
168  int * lengthes = NULL;
169  int * order = NULL;
170 
171  int numMonoms = 0;
172  int k;
173 
174  // get number of monoms
175  numMonoms= pLength( monset );
176  STICKYPROT2( "%i monoms\n", numMonoms );
177 
178  // Allcoate Memory and initialize sets
179  m= (polyset)omAlloc( numMonoms * sizeof( poly ) );
180  poly temp= monset;
181  for ( k= 0; k < numMonoms; k++ ) {
182 // m[k]= pOne();
183 // pSetExpV( m[k], temp->exp );
184 // pSetm( m[k] );
185  m[k]=pLmInit(temp);
186  pSetCoeff( m[k], nInit(1) );
187  pIter( temp );
188  }
189 
190  nf= (polyset)omAlloc( numMonoms * sizeof( poly ) );
191 
192 #ifndef HAVE_EXPLICIT_CONSTR
193  mv= new fglmVector[ numMonoms ];
194 #else
195  mv= (fglmVector *)omAlloc( numMonoms * sizeof( fglmVector ) );
196 #endif
197 
198 #ifndef HAVE_EXPLICIT_CONSTR
199  v= new fglmVector[ numMonoms ];
200 #else
201  v= (fglmVector *)omAlloc( numMonoms * sizeof( fglmVector ) );
202 #endif
203 
204  basisMax= basisBS;
205  basis= (polyset)omAlloc( basisMax * sizeof( poly ) );
206 
207  weights= (int *)omAlloc( IDELEMS( source ) * sizeof( int ) );
208  STICKYPROT( "weights: " );
209  for ( k= 0; k < IDELEMS( source ); k++ ) {
210  poly temp= (source->m)[k];
211  int w = 0;
212  while ( temp != NULL ) {
213  w+= nSize( pGetCoeff( temp ) );
214  pIter( temp );
215  }
216  weights[k]= w;
217  STICKYPROT2( "%i ", w );
218  }
219  STICKYPROT( "\n" );
220  lengthes= (int *)omAlloc( numMonoms * sizeof( int ) );
221  order= (int *)omAlloc( numMonoms * sizeof( int ) );
222 
223  // calculate the NormalForm in a special way
224  for ( k= 0; k < numMonoms; k++ )
225  {
226  STICKYPROT( "#" );
227  poly current = pCopy( m[k] );
228  fglmVector currV( numMonoms, k+1 );
229 
230  fglmReduce( & current, currV, m, numMonoms, source, weights );
231  poly temp = current;
232  int b;
233  while ( temp != NULL )
234  {
235  BOOLEAN found = FALSE;
236  for ( b= 0; (b < basisSize) && (found == FALSE); b++ )
237  {
238  if ( pLmEqual( temp, basis[b] ) )
239  {
240  found= TRUE;
241  }
242  }
243  if ( found == FALSE )
244  {
245  if ( basisSize == basisMax )
246  {
247  // Expand the basis
248  basis= (polyset)omReallocSize( basis, basisMax * sizeof( poly ), (basisMax + basisBS ) * sizeof( poly ) );
249  basisMax+= basisBS;
250  }
251 // basis[basisSize]= pOne();
252 // pSetExpV( basis[basisSize], temp->exp );
253 // pSetm( basis[basisSize] );
254  basis[basisSize]=pLmInit(temp);
255  pSetCoeff( basis[basisSize], nInit(1) );
256  basisSize++;
257  }
258  pIter( temp );
259  }
260  nf[k]= current;
261 #ifndef HAVE_EXPLICIT_CONSTR
262  mv[k].mac_constr( currV );
263 #else
264  mv[k].fglmVector( currV );
265 #endif
266  STICKYPROT( "\n" );
267  }
268  // get the vector representation
269  for ( k= 0; k < numMonoms; k++ ) {
270  STICKYPROT( "." );
271 
272 #ifndef HAVE_EXPLICIT_CONSTR
273  v[k].mac_constr_i( basisSize );
274 #else
275  v[k].fglmVector( basisSize );
276 #endif
277  poly mon= nf[k];
278  while ( mon != NULL ) {
279  BOOLEAN found = FALSE;
280  int b= 0;
281  while ( found == FALSE ) {
282  if ( pLmEqual( mon, basis[b] ) ) {
283  found= TRUE;
284  }
285  else {
286  b++;
287  }
288  }
289  number coeff = nCopy( pGetCoeff( mon ) );
290  v[k].setelem( b+1, coeff );
291  pIter( mon );
292  }
293  pDelete( nf + k );
294  }
295  // Free Memory not needed anymore
296  omFreeSize( (ADDRESS)nf, numMonoms * sizeof( poly ) );
297  omFreeSize( (ADDRESS)weights, IDELEMS( source ) * sizeof( int ) );
298 
299  STICKYPROT2( "\nbasis size: %i\n", basisSize );
300  STICKYPROT( "(clear basis" );
301  for ( k= 0; k < basisSize; k++ )
302  pDelete( basis + k );
303  STICKYPROT( ")\n" );
304  // gauss reduce
305  gaussReducer gauss( basisSize );
306  BOOLEAN isZero = FALSE;
307  fglmVector p;
308 
309  STICKYPROT( "sizes: " );
310  for ( k= 0; k < numMonoms; k++ ) {
311  lengthes[k]= v[k].numNonZeroElems();
312  STICKYPROT2( "%i ", lengthes[k] );
313  }
314  STICKYPROT( "\n" );
315 
316  int act = 0;
317  while ( (isZero == FALSE) && (act < numMonoms) ) {
318  int best = 0;
319  for ( k= numMonoms - 1; k >= 0; k-- ) {
320  if ( lengthes[k] > 0 ) {
321  if ( best == 0 ) {
322  best= k+1;
323  }
324  else {
325  if ( lengthes[k] < lengthes[best-1] ) {
326  best= k+1;
327  }
328  }
329  }
330  }
331  lengthes[best-1]= 0;
332  order[act]= best-1;
333  STICKYPROT2( " (%i) ", best );
334  if ( ( isZero= gauss.reduce( v[best-1] )) == TRUE ) {
335  p= gauss.getDependence();
336  }
337  else {
338  STICKYPROT( "+" );
339  gauss.store();
340  act++;
341  }
342 #ifndef HAVE_EXPLICIT_CONSTR
343  v[best-1].clearelems();
344 #else
345  v[best-1].~fglmVector();
346 #endif
347  }
348  poly result = NULL;
349  if ( isZero == TRUE ) {
350  number gcd = p.gcd();
351  if ( ! nIsZero( gcd ) && ! ( nIsOne( gcd ) ) ) {
352  p/= gcd;
353  }
354  nDelete( & gcd );
355  fglmVector temp( numMonoms );
356  for ( k= 0; k < p.size(); k++ ) {
357  if ( ! p.elemIsZero( k+1 ) ) {
358  temp+= p.getconstelem( k+1 ) * mv[order[k]];
359  }
360  }
361  number denom = temp.clearDenom();
362  nDelete( & denom );
363  gcd = temp.gcd();
364  if ( ! nIsZero( gcd ) && ! nIsOne( gcd ) ) {
365  temp/= gcd;
366  }
367  nDelete( & gcd );
368 
369  poly sum = NULL;
370  for ( k= 1; k <= numMonoms; k++ ) {
371  if ( ! temp.elemIsZero( k ) ) {
372  if ( result == NULL ) {
373  result= pCopy( m[k-1] );
374  sum= result;
375  }
376  else {
377  sum->next= pCopy( m[k-1] );
378  pIter( sum );
379  }
380  pSetCoeff( sum, nCopy( temp.getconstelem( k ) ) );
381  }
382  }
383  p_Content( result, currRing );
384  if ( ! nGreaterZero( pGetCoeff( result ) ) ) result= pNeg( result );
385  }
386  // Free Memory
387  omFreeSize( (ADDRESS)lengthes, numMonoms * sizeof( int ) );
388  omFreeSize( (ADDRESS)order, numMonoms * sizeof( int ) );
389 // for ( k= 0; k < numMonoms; k++ )
390 // v[k].~fglmVector();
391 #ifndef HAVE_EXPLICIT_CONSTR
392  delete [] v;
393 #else
394  omFreeSize( (ADDRESS)v, numMonoms * sizeof( fglmVector ) );
395 #endif
396 
397  for ( k= 0; k < basisSize; k++ )
398  pDelete( basis + k );
399  omFreeSize( (ADDRESS)basis, basisMax * sizeof( poly ) );
400 
401 #ifndef HAVE_EXPLICIT_CONSTR
402  delete [] mv;
403 #else
404  for ( k= 0; k < numMonoms; k++ )
405  mv[k].~fglmVector();
406  omFreeSize( (ADDRESS)mv, numMonoms * sizeof( fglmVector ) );
407 #endif
408 
409  for ( k= 0; k < numMonoms; k++ )
410  pDelete( m + k );
411  omFreeSize( (ADDRESS)m, numMonoms * sizeof( poly ) );
412 
413  STICKYPROT( "\n" );
414  return result;
415 }
fglmVector(fglmVectorRep *rep)
Implementation of class fglmVector
Definition: fglmvec.cc:149
number gcd() const
Definition: fglmvec.cc:455
#define FALSE
Definition: auxiliary.h:140
return P p
Definition: myNF.cc:203
int size() const
Definition: fglmvec.cc:204
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
static void fglmReduce(poly *pptr, fglmVector &v, polyset m, int numMonoms, ideal source, int *w)
Definition: fglmcomb.cc:129
#define pNeg(p)
Definition: polys.h:169
#define TRUE
Definition: auxiliary.h:144
#define nIsOne(n)
Definition: numbers.h:25
~fglmVector()
Definition: fglmvec.cc:171
void * ADDRESS
Definition: auxiliary.h:161
number getconstelem(int i) const
Definition: fglmvec.cc:443
int k
Definition: cfEzgcd.cc:93
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy ...
Definition: monomials.h:51
#define omAlloc(size)
Definition: omAllocDecl.h:210
static int pLength(poly a)
Definition: p_polys.h:189
bool found
Definition: facFactorize.cc:56
Definition: gnumpfl.cc:60
#define pIter(p)
Definition: monomials.h:44
#define omReallocSize(addr, o_size, size)
Definition: omAllocDecl.h:220
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
#define STICKYPROT(msg)
Definition: fglm.h:20
int elemIsZero(int i)
Definition: fglmvec.cc:297
int numNonZeroElems() const
Definition: fglmvec.cc:209
#define nGreaterZero(n)
Definition: numbers.h:27
number clearDenom()
Definition: fglmvec.cc:499
#define pLmInit(p)
like pInit, except that expvector is initialized to that of p, p must be != NULL
Definition: polys.h:64
int m
Definition: cfEzgcd.cc:119
void p_Content(poly ph, const ring r)
Definition: p_polys.cc:2182
#define IDELEMS(i)
Definition: simpleideals.h:24
#define nDelete(n)
Definition: numbers.h:16
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
#define nIsZero(n)
Definition: numbers.h:19
#define NULL
Definition: omList.c:10
poly * polyset
Definition: hutil.h:17
void setelem(int i, number &n)
Definition: fglmvec.cc:448
int gcd(int a, int b)
Definition: walkSupport.cc:839
const CanonicalForm & w
Definition: facAbsFact.cc:55
#define pDelete(p_ptr)
Definition: polys.h:157
#define nSize(n)
Definition: numbers.h:39
#define nCopy(n)
Definition: numbers.h:15
bool isZero(const CFArray &A)
checks if entries of A are zero
static scmon act
Definition: hdegree.cc:1076
polyrec * poly
Definition: hilb.h:10
#define nInit(i)
Definition: numbers.h:24
int BOOLEAN
Definition: auxiliary.h:131
const poly b
Definition: syzextra.cc:213
#define pSetCoeff(p, n)
deletes old coeff before setting the new one
Definition: polys.h:31
#define pLmEqual(p1, p2)
Definition: polys.h:111
return result
Definition: facAbsBiFact.cc:76
#define pCopy(p)
return a copy of the poly
Definition: polys.h:156
#define STICKYPROT2(msg, arg)
Definition: fglm.h:22
static void fglmReduce ( poly pptr,
fglmVector v,
polyset  m,
int  numMonoms,
ideal  source,
int *  w 
)
static

Definition at line 129 of file fglmcomb.cc.

130 {
131  BOOLEAN reduced = FALSE;
132  reduced= fglmReductionStep( pptr, source, w );
133  while ( reduced == TRUE ) {
134  fglmEliminateMonomials( pptr, v, m, numMonoms );
135  reduced= fglmReductionStep( pptr, source, w );
136  }
137  STICKYPROT( "<" );
138  poly temp = * pptr;
139  if ( temp != NULL ) {
140  while ( pNext( temp ) != NULL ) {
141  STICKYPROT( ">" );
142  reduced= fglmReductionStep( & pNext( temp ), source, w );
143  while ( reduced == TRUE ) {
144  fglmEliminateMonomials( & pNext( temp ), v, m, numMonoms );
145  reduced= fglmReductionStep( & pNext( temp ), source, w );
146  }
147  if ( pNext( temp ) != NULL ) {
148  pIter( temp );
149  }
150  }
151  }
152 }
#define FALSE
Definition: auxiliary.h:140
#define TRUE
Definition: auxiliary.h:144
#define pIter(p)
Definition: monomials.h:44
#define STICKYPROT(msg)
Definition: fglm.h:20
int m
Definition: cfEzgcd.cc:119
static BOOLEAN fglmReductionStep(poly *pptr, ideal source, int *w)
Definition: fglmcomb.cc:76
static void fglmEliminateMonomials(poly *pptr, fglmVector &v, polyset monomials, int numMonoms)
Definition: fglmcomb.cc:37
#define NULL
Definition: omList.c:10
const CanonicalForm & w
Definition: facAbsFact.cc:55
#define pNext(p)
Definition: monomials.h:43
polyrec * poly
Definition: hilb.h:10
int BOOLEAN
Definition: auxiliary.h:131
static BOOLEAN fglmReductionStep ( poly pptr,
ideal  source,
int *  w 
)
static

Definition at line 76 of file fglmcomb.cc.

77 {
78 // returns TRUE if the leading monomial was reduced
79  if ( *pptr == NULL ) return FALSE;
80  int k;
81  int best = 0;
82  for ( k= IDELEMS( source ) - 1; k >= 0; k-- ) {
83  if ( pDivisibleBy( (source->m)[k], *pptr ) ) {
84  if ( best == 0 ) {
85  best= k + 1;
86  }
87  else {
88  if ( w[k] < w[best-1] ) {
89  best= k + 1;
90  }
91  }
92  }
93  }
94  if ( best > 0 )
95  {
96  // OwnSPoly
97  poly p2 = (source->m)[best-1];
98  int i, diff;
99 
100  poly m = pOne();
101  for ( i= (currRing->N); i > 0; i-- )
102  {
103  diff= pGetExp( *pptr, i ) - pGetExp( p2, i );
104  pSetExp( m, i, diff );
105  }
106  pSetm( m );
107  number n1 = nCopy( pGetCoeff( *pptr ) );
108  number n2 = pGetCoeff( p2 );
109 
110  p2= pCopy( p2 );
111  pLmDelete(pptr);
112  pLmDelete( & p2 );
113  p2= pMult( m, p2 );
114 
115  number temp = nDiv( n1, n2 );
116  n_Normalize( temp, currRing );
117  nDelete( & n1 );
118  n1= temp;
119  n1= nInpNeg( n1 );
120  pMult_nn( p2, n1 );
121 // pNormalize( p2 );
122  nDelete( & n1 );
123  *pptr= pAdd( *pptr, p2 );
124  }
125  return ( (best > 0) );
126 }
#define pSetm(p)
Definition: polys.h:241
static gmp_float * diff
Definition: mpr_complex.cc:47
#define pAdd(p, q)
Definition: polys.h:174
#define pSetExp(p, i, v)
Definition: polys.h:42
#define FALSE
Definition: auxiliary.h:140
#define pLmDelete(p)
assume p != NULL, deletes Lm(p)->coef and Lm(p)
Definition: polys.h:76
static FORCE_INLINE void n_Normalize(number &n, const coeffs r)
inplace-normalization of n; produces some canonical representation of n;
Definition: coeffs.h:579
int k
Definition: cfEzgcd.cc:93
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy ...
Definition: monomials.h:51
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
#define pGetExp(p, i)
Exponent.
Definition: polys.h:41
#define nInpNeg(n)
Definition: numbers.h:21
int m
Definition: cfEzgcd.cc:119
#define pMult_nn(p, n)
Definition: polys.h:171
int i
Definition: cfEzgcd.cc:123
#define pOne()
Definition: polys.h:286
#define IDELEMS(i)
Definition: simpleideals.h:24
#define nDelete(n)
Definition: numbers.h:16
#define nDiv(a, b)
Definition: numbers.h:32
#define NULL
Definition: omList.c:10
#define pDivisibleBy(a, b)
returns TRUE, if leading monom of a divides leading monom of b i.e., if there exists a expvector c > ...
Definition: polys.h:126
#define pMult(p, q)
Definition: polys.h:178
const CanonicalForm & w
Definition: facAbsFact.cc:55
#define nCopy(n)
Definition: numbers.h:15
END_NAMESPACE const void * p2
Definition: syzextra.cc:202
polyrec * poly
Definition: hilb.h:10
#define pCopy(p)
return a copy of the poly
Definition: polys.h:156