154{
158
161 int basisSize = 0;
162 int basisBS = 16;
163 int basisMax = basisBS;
164
165 int * weights =
NULL;
166 int * lengths =
NULL;
168
169 int numMonoms = 0;
171
172
175
176
178 poly temp= monset;
179 for (
k= 0;
k < numMonoms;
k++ ) {
180
181
182
186 }
187
189
190#ifndef HAVE_EXPLICIT_CONSTR
192#else
194#endif
195
196#ifndef HAVE_EXPLICIT_CONSTR
198#else
200#endif
201
202 basisMax= basisBS;
204
208 poly temp= (source->m)[
k];
210 while ( temp !=
NULL ) {
213 }
216 }
218 lengths= (
int *)
omAlloc( numMonoms *
sizeof(
int ) );
219 order= (
int *)
omAlloc( numMonoms *
sizeof(
int ) );
220
221
222 for (
k= 0;
k < numMonoms;
k++ )
223 {
227
228 fglmReduce( & current, currV,
m, numMonoms, source, weights );
229 poly temp = current;
231 while ( temp !=
NULL )
232 {
235 {
237 {
239 }
240 }
242 {
243 if ( basisSize == basisMax )
244 {
245
246 basis= (
polyset)
omReallocSize( basis, basisMax *
sizeof( poly ), (basisMax + basisBS ) *
sizeof( poly ) );
247 basisMax+= basisBS;
248 }
249
250
251
252 basis[basisSize]=
pLmInit(temp);
254 basisSize++;
255 }
257 }
259#ifndef HAVE_EXPLICIT_CONSTR
260 mv[
k].mac_constr( currV );
261#else
263#endif
265 }
266
267 for (
k= 0;
k < numMonoms;
k++ ) {
269
270#ifndef HAVE_EXPLICIT_CONSTR
271 v[
k].mac_constr_i( basisSize );
272#else
273 v[
k].fglmVector( basisSize );
274#endif
276 while ( mon !=
NULL ) {
282 }
283 else {
285 }
286 }
288 v[
k].setelem(
b+1, coeff );
290 }
292 }
293
296
299 for (
k= 0;
k < basisSize;
k++ )
302
306
308 for (
k= 0;
k < numMonoms;
k++ ) {
309 lengths[
k]=
v[
k].numNonZeroElems();
311 }
313
316 int best = 0;
317 for (
k= numMonoms - 1;
k >= 0;
k-- ) {
318 if ( lengths[
k] > 0 ) {
319 if ( best == 0 ) {
321 }
322 else {
323 if ( lengths[
k] < lengths[best-1] ) {
325 }
326 }
327 }
328 }
329 lengths[best-1]= 0;
332 if ( (
isZero= gauss.reduce(
v[best-1] )) ==
TRUE ) {
333 p= gauss.getDependence();
334 }
335 else {
337 gauss.store();
339 }
340#ifndef HAVE_EXPLICIT_CONSTR
341 v[best-1].clearelems();
342#else
343 v[best-1].~fglmVector();
344#endif
345 }
348 number
gcd =
p.gcd();
351 }
354 for (
k= 0;
k <
p.size();
k++ ) {
355 if ( !
p.elemIsZero(
k+1 ) ) {
356 temp+=
p.getconstelem(
k+1 ) * mv[order[
k]];
357 }
358 }
364 }
366
368 for (
k= 1;
k <= numMonoms;
k++ ) {
369 if ( ! temp.elemIsZero(
k ) ) {
373 }
374 else {
377 }
379 }
380 }
382 }
383
386
387
388#ifndef HAVE_EXPLICIT_CONSTR
390#else
392#endif
393
394 for (
k= 0;
k < basisSize;
k++ )
397
398#ifndef HAVE_EXPLICIT_CONSTR
399 delete [] mv;
400#else
401 for (
k= 0;
k < numMonoms;
k++ )
404#endif
405
406 for (
k= 0;
k < numMonoms;
k++ )
409
412}
fglmVector(fglmVectorRep *rep)
static void fglmReduce(poly *pptr, fglmVector &v, polyset m, int numMonoms, ideal source, int *w)
poly p_Cleardenom(poly p, const ring r)
static int pLength(poly a)
#define pLmInit(p)
like pInit, except that expvector is initialized to that of p, p must be != NULL