My Project
Loading...
Searching...
No Matches
Functions
fglm.h File Reference
#include "kernel/mod2.h"
#include "kernel/ideals.h"
#include "kernel/structs.h"

Go to the source code of this file.

Functions

BOOLEAN fglmProc (leftv result, leftv first, leftv second)
 
BOOLEAN fglmQuotProc (leftv result, leftv first, leftv second)
 
ideal fglmQuot (ideal first, poly second)
 
BOOLEAN FindUnivariateWrapper (ideal source, ideal &dest)
 
BOOLEAN findUniProc (leftv result, leftv first)
 
ideal findUni (ideal first)
 
ideal fglmhomProc (leftv first, leftv second)
 

Function Documentation

◆ fglmhomProc()

ideal fglmhomProc ( leftv  first,
leftv  second 
)

◆ fglmProc()

BOOLEAN fglmProc ( leftv  result,
leftv  first,
leftv  second 
)

Definition at line 277 of file fglm.cc.

278{
279 FglmState state = FglmOk;
280
281 ring destRing = currRing;
282 // ring destRing = currRing;
283 ideal destIdeal = NULL;
284 ring sourceRing = (ring)first->Data();
285 rChangeCurrRing( sourceRing );
286 // ring sourceRing = currRing;
287
288 int * vperm = (int *)omAlloc0( (sourceRing->N+1)*sizeof( int ) );
289 state= fglmConsistency( sourceRing, destRing, vperm );
290 omFreeSize( (ADDRESS)vperm, (sourceRing->N+1)*sizeof(int) );
291
292 if ( state == FglmOk )
293 {
294 idhdl ih = sourceRing->idroot->get( second->Name(), myynest );
295 if ( (ih != NULL) && (IDTYP(ih)==IDEAL_CMD) )
296 {
297 ideal sourceIdeal;
298 if ( sourceRing->qideal != NULL )
299 sourceIdeal= fglmUpdatesource( IDIDEAL( ih ) );
300 else
301 sourceIdeal = IDIDEAL( ih );
302 state= fglmIdealcheck( sourceIdeal );
303 if ( state == FglmOk )
304 {
305 // Now the settings are compatible with FGLM
306 assumeStdFlag( (leftv)ih );
307 if ( fglmzero( sourceRing, sourceIdeal, destRing, destIdeal, FALSE, (currRing->qideal != NULL) ) == FALSE )
308 state= FglmNotReduced;
309 }
310 } else state= FglmNoIdeal;
311 }
312 if ( currRing != destRing )
313 rChangeCurrRing( destRing );
314 switch (state)
315 {
316 case FglmOk:
317 if ( currRing->qideal != NULL ) fglmUpdateresult( destIdeal );
318 break;
319 case FglmHasOne:
320 destIdeal= idInit(1,1);
321 (destIdeal->m)[0]= pOne();
322 state= FglmOk;
323 break;
325 WerrorS( "source ring and current ring are incompatible" );
326 destIdeal= NULL;
327 break;
328 case FglmNoIdeal:
329 Werror( "Can't find ideal %s in source ring", second->Name() );
330 destIdeal= NULL;
331 break;
332 case FglmNotZeroDim:
333 Werror( "The ideal %s has to be 0-dimensional", second->Name() );
334 destIdeal= NULL;
335 break;
336 case FglmNotReduced:
337 Werror( "The ideal %s has to be given by a reduced SB", second->Name() );
338 destIdeal= NULL;
339 break;
340 default:
341 destIdeal= idInit(1,1);
342 }
343
344 result->rtyp = IDEAL_CMD;
345 result->data= (void *)destIdeal;
347 return (state != FglmOk);
348}
#define FALSE
Definition: auxiliary.h:96
void * ADDRESS
Definition: auxiliary.h:119
Definition: idrec.h:35
idhdl get(const char *s, int lev)
Definition: ipid.cc:72
Class used for (list of) interpreter objects.
Definition: subexpr.h:83
void * Data()
Definition: subexpr.cc:1162
const char * Name()
Definition: subexpr.h:120
return result
Definition: facAbsBiFact.cc:75
void WerrorS(const char *s)
Definition: feFopen.cc:24
VAR int myynest
Definition: febase.cc:41
FglmState fglmConsistency(ring sring, ring dring, int *vperm)
Definition: fglm.cc:121
FglmState fglmIdealcheck(const ideal theIdeal)
Definition: fglm.cc:240
ideal fglmUpdatesource(const ideal sourceIdeal)
Definition: fglm.cc:57
void fglmUpdateresult(ideal &result)
Definition: fglm.cc:89
FglmState
Definition: fglm.cc:39
@ FglmOk
Definition: fglm.cc:40
@ FglmNotReduced
Definition: fglm.cc:43
@ FglmHasOne
Definition: fglm.cc:41
@ FglmNotZeroDim
Definition: fglm.cc:44
@ FglmIncompatibleRings
Definition: fglm.cc:45
@ FglmNoIdeal
Definition: fglm.cc:42
@ IDEAL_CMD
Definition: grammar.cc:284
#define setFlag(A, F)
Definition: ipid.h:113
#define IDIDEAL(a)
Definition: ipid.h:133
#define IDTYP(a)
Definition: ipid.h:119
#define FLAG_STD
Definition: ipid.h:106
BOOLEAN fglmzero(ring sourceRing, ideal &sourceIdeal, ring destRing, ideal &destideal, BOOLEAN switchBack=TRUE, BOOLEAN deleteIdeal=FALSE)
Definition: fglmzero.cc:1193
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
#define omAlloc0(size)
Definition: omAllocDecl.h:211
#define NULL
Definition: omList.c:12
void rChangeCurrRing(ring r)
Definition: polys.cc:15
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
#define pOne()
Definition: polys.h:315
void Werror(const char *fmt,...)
Definition: reporter.cc:189
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:35
BOOLEAN assumeStdFlag(leftv h)
Definition: subexpr.cc:1544

◆ fglmQuot()

ideal fglmQuot ( ideal  first,
poly  second 
)

Definition at line 350 of file fglm.cc.

351{
352 FglmState state = FglmOk;
353
354 ideal sourceIdeal = first;
355 poly quot = second;
356 ideal destIdeal = NULL;
357
358 state = fglmIdealcheck( sourceIdeal );
359 if ( state == FglmOk )
360 {
361 if ( quot == NULL ) state= FglmPolyIsZero;
362 else if ( pIsConstant( quot ) ) state= FglmPolyIsOne;
363 }
364
365 if ( state == FglmOk )
366 {
367 if ( fglmquot( sourceIdeal, quot, destIdeal ) == FALSE )
368 state= FglmNotReduced;
369 }
370
371 switch (state)
372 {
373 case FglmOk:
374 break;
375 case FglmHasOne:
376 destIdeal= idInit(1,1);
377 (destIdeal->m)[0]= pOne();
378 state= FglmOk;
379 break;
380 case FglmNotZeroDim:
381 WerrorS( "The ideal has to be 0-dimensional" );
382 destIdeal= idInit(1,1);
383 break;
384 case FglmNotReduced:
385 WerrorS( "The poly has to be reduced" );
386 destIdeal= idInit(1,1);
387 break;
388 case FglmPolyIsOne:
389 int k;
390 destIdeal= idInit( IDELEMS(sourceIdeal), 1 );
391 for ( k= IDELEMS( sourceIdeal )-1; k >=0; k-- )
392 (destIdeal->m)[k]= pCopy( (sourceIdeal->m)[k] );
393 state= FglmOk;
394 break;
395 case FglmPolyIsZero:
396 destIdeal= idInit(1,1);
397 (destIdeal->m)[0]= pOne();
398 state= FglmOk;
399 break;
400 default:
401 destIdeal= idInit(1,1);
402 }
403
404 return destIdeal;
405}
int k
Definition: cfEzgcd.cc:99
@ FglmPolyIsOne
Definition: fglm.cc:47
@ FglmPolyIsZero
Definition: fglm.cc:48
BOOLEAN fglmquot(ideal sourceIdeal, poly quot, ideal &destIdeal)
Definition: fglmzero.cc:1218
#define pIsConstant(p)
like above, except that Comp must be 0
Definition: polys.h:238
#define pCopy(p)
return a copy of the poly
Definition: polys.h:185
#define IDELEMS(i)
Definition: simpleideals.h:23

◆ fglmQuotProc()

BOOLEAN fglmQuotProc ( leftv  result,
leftv  first,
leftv  second 
)

Definition at line 411 of file fglm.cc.

412{
413 FglmState state = FglmOk;
414
415 // STICKYPROT("quotstart\n");
416 ideal sourceIdeal = (ideal)first->Data();
417 poly quot = (poly)second->Data();
418 ideal destIdeal = NULL;
419
420 state = fglmIdealcheck( sourceIdeal );
421 if ( state == FglmOk )
422 {
423 if ( quot == NULL ) state= FglmPolyIsZero;
424 else if ( pIsConstant( quot ) ) state= FglmPolyIsOne;
425 }
426
427 if ( state == FglmOk )
428 {
429 assumeStdFlag( first );
430 if ( fglmquot( sourceIdeal, quot, destIdeal ) == FALSE )
431 state= FglmNotReduced;
432 }
433
434 switch (state)
435 {
436 case FglmOk:
437 break;
438 case FglmHasOne:
439 destIdeal= idInit(1,1);
440 (destIdeal->m)[0]= pOne();
441 state= FglmOk;
442 break;
443 case FglmNotZeroDim:
444 Werror( "The ideal %s has to be 0-dimensional", first->Name() );
445 destIdeal= NULL;
446 break;
447 case FglmNotReduced:
448 Werror( "The poly %s has to be reduced", second->Name() );
449 destIdeal= NULL;
450 break;
451 case FglmPolyIsOne:
452 int k;
453 destIdeal= idInit( IDELEMS(sourceIdeal), 1 );
454 for ( k= IDELEMS( sourceIdeal )-1; k >=0; k-- )
455 (destIdeal->m)[k]= pCopy( (sourceIdeal->m)[k] );
456 state= FglmOk;
457 break;
458 case FglmPolyIsZero:
459 destIdeal= idInit(1,1);
460 (destIdeal->m)[0]= pOne();
461 state= FglmOk;
462 break;
463 default:
464 destIdeal= idInit(1,1);
465 }
466
467 result->rtyp = IDEAL_CMD;
468 result->data= (void *)destIdeal;
470 // STICKYPROT("quotend\n");
471 return (state != FglmOk);
472} // fglmQuotProt

◆ findUni()

ideal findUni ( ideal  first)

Definition at line 474 of file fglm.cc.

475{
476 ideal sourceIdeal;
477 ideal destIdeal = NULL;
478 FglmState state;
479
480 sourceIdeal = first;
481
482 state= fglmIdealcheck( sourceIdeal );
483 if ( state == FglmOk )
484 {
485 // check for special cases: if the input contains
486 // univariate polys, try to reduce the problem
487 int i,k;
488 int count=0;
489 BOOLEAN * purePowers = (BOOLEAN *)omAlloc0( currRing->N*sizeof( BOOLEAN ) );
490 for ( k= IDELEMS( sourceIdeal ) - 1; k >= 0; k-- )
491 {
492 if((i=pIsUnivariate(sourceIdeal->m[k]))>0)
493 {
494 if (purePowers[i-1]==0)
495 {
496 purePowers[i-1]=k;
497 count++;
498 if (count==currRing->N) break;
499 }
500 }
501 }
502 if (count==currRing->N)
503 {
504 destIdeal=idInit(currRing->N,1);
505 for(k=currRing->N-1; k>=0; k--) destIdeal->m[k]=pCopy(sourceIdeal->m[purePowers[k]]);
506 }
507 omFreeSize((ADDRESS)purePowers, currRing->N*sizeof( BOOLEAN ) );
508 if (destIdeal!=NULL)
509 state = FglmOk;
510 else if ( FindUnivariateWrapper( sourceIdeal, destIdeal ) == FALSE )
511 state = FglmNotReduced;
512 }
513 switch (state)
514 {
515 case FglmOk:
516 break;
517 case FglmHasOne:
518 destIdeal= idInit(1,1);
519 (destIdeal->m)[0]= pOne();
520 state= FglmOk;
521 break;
522 case FglmNotZeroDim:
523 WerrorS( "The ideal has to be 0-dimensional" );
524 destIdeal= idInit(1,1);
525 break;
526 case FglmNotReduced:
527 Werror( "The ideal has to be reduced" );
528 destIdeal= idInit(1,1);
529 break;
530 default:
531 destIdeal= idInit(1,1);
532 }
533
534 return destIdeal;
535}
int BOOLEAN
Definition: auxiliary.h:87
int i
Definition: cfEzgcd.cc:132
BOOLEAN FindUnivariateWrapper(ideal source, ideal &destIdeal)
Definition: fglmzero.cc:1236
#define pIsUnivariate(p)
Definition: polys.h:249
int status int void size_t count
Definition: si_signals.h:59

◆ findUniProc()

BOOLEAN findUniProc ( leftv  result,
leftv  first 
)

Definition at line 541 of file fglm.cc.

542{
543 ideal sourceIdeal;
544 ideal destIdeal = NULL;
545 FglmState state;
546
547 sourceIdeal = (ideal)first->Data();
548
549 assumeStdFlag( first );
550 state= fglmIdealcheck( sourceIdeal );
551 if ( state == FglmOk )
552 {
553 // check for special cases: if the input contains
554 // univariate polys, try to reduce the problem
555 int i,k;
556 int count=0;
557 BOOLEAN * purePowers = (BOOLEAN *)omAlloc0( currRing->N*sizeof( BOOLEAN ) );
558 for ( k= IDELEMS( sourceIdeal ) - 1; k >= 0; k-- )
559 {
560 if((i=pIsUnivariate(sourceIdeal->m[k]))>0)
561 {
562 if (purePowers[i-1]==0)
563 {
564 purePowers[i-1]=k;
565 count++;
566 if (count==currRing->N) break;
567 }
568 }
569 }
570 if (count==currRing->N)
571 {
572 destIdeal=idInit(currRing->N,1);
573 for(k=currRing->N-1; k>=0; k--) destIdeal->m[k]=pCopy(sourceIdeal->m[purePowers[k]]);
574 }
575 omFreeSize((ADDRESS)purePowers, currRing->N*sizeof( BOOLEAN ) );
576 if (destIdeal!=NULL)
577 state = FglmOk;
578 else if ( FindUnivariateWrapper( sourceIdeal, destIdeal ) == FALSE )
579 state = FglmNotReduced;
580 }
581 switch (state)
582 {
583 case FglmOk:
584 break;
585 case FglmHasOne:
586 destIdeal= idInit(1,1);
587 (destIdeal->m)[0]= pOne();
588 state= FglmOk;
589 break;
590 case FglmNotZeroDim:
591 Werror( "The ideal %s has to be 0-dimensional", first->Name() );
592 destIdeal= NULL;
593 break;
594 case FglmNotReduced:
595 Werror( "The ideal %s has to be reduced", first->Name() );
596 destIdeal= NULL;
597 break;
598 default:
599 destIdeal= idInit(1,1);
600 }
601
602 result->rtyp = IDEAL_CMD;
603 result->data= (void *)destIdeal;
604
605 return FALSE;
606}

◆ FindUnivariateWrapper()

BOOLEAN FindUnivariateWrapper ( ideal  source,
ideal &  dest 
)

Definition at line 1236 of file fglmzero.cc.

1237{
1238 BOOLEAN fglmok;
1239
1240 idealFunctionals L( 100, (currRing->N) );
1241 fglmok = CalculateFunctionals( source, L );
1242 if ( fglmok == TRUE ) {
1243 destIdeal= FindUnivariatePolys( L );
1244 return TRUE;
1245 }
1246 else
1247 return FALSE;
1248}
#define TRUE
Definition: auxiliary.h:100
static ideal FindUnivariatePolys(const idealFunctionals &l)
Definition: fglmzero.cc:1118
static BOOLEAN CalculateFunctionals(const ideal &theIdeal, idealFunctionals &l)
Definition: fglmzero.cc:673