My Project  debian-1:4.1.1-p2+ds-4build4
Data Structures | Macros | Functions
fglmzero.cc File Reference
#include "kernel/mod2.h"
#include "factory/factory.h"
#include "factory/templates/ftmpl_list.h"
#include "factory/templates/ftmpl_list.cc"
#include "omalloc/omalloc.h"
#include "misc/options.h"
#include "misc/intvec.h"
#include "polys/monomials/maps.h"
#include "polys/monomials/ring.h"
#include "kernel/polys.h"
#include "kernel/ideals.h"
#include "kernel/GBEngine/kstd1.h"
#include "fglm.h"
#include "fglmvec.h"
#include "fglmgauss.h"

Go to the source code of this file.

Data Structures

struct  matElem
 The idealFunctionals. More...
 
struct  matHeader
 
class  idealFunctionals
 
class  borderElem
 The old basis. More...
 
class  fglmSdata
 
class  oldGaussElem
 
class  fglmDdata
 

Macros

#define PROT(msg)
 
#define STICKYPROT(msg)   if (BTEST1(OPT_PROT)) Print(msg)
 
#define PROT2(msg, arg)
 
#define STICKYPROT2(msg, arg)   if (BTEST1(OPT_PROT)) Print(msg,arg)
 
#define fglmASSERT(ignore1, ignore2)
 

Functions

void internalCalculateFunctionals (const ideal, idealFunctionals &l, fglmSdata &data)
 
static BOOLEAN CalculateFunctionals (const ideal &theIdeal, idealFunctionals &l)
 
static BOOLEAN CalculateFunctionals (const ideal &theIdeal, idealFunctionals &l, poly &p, fglmVector &v)
 
static ideal GroebnerViaFunctionals (const idealFunctionals &l, fglmVector iv=fglmVector())
 
static ideal FindUnivariatePolys (const idealFunctionals &l)
 
BOOLEAN fglmzero (ring sourceRing, ideal &sourceIdeal, ring destRing, ideal &destIdeal, BOOLEAN switchBack, BOOLEAN deleteIdeal)
 
BOOLEAN fglmquot (ideal sourceIdeal, poly quot, ideal &destIdeal)
 
BOOLEAN FindUnivariateWrapper (ideal source, ideal &destIdeal)
 

Data Structure Documentation

◆ matElem

struct matElem

The idealFunctionals.

Definition at line 63 of file fglmzero.cc.

Data Fields
number elem
int row

◆ matHeader

struct matHeader

Definition at line 69 of file fglmzero.cc.

Data Fields
matElem * elems
BOOLEAN owner
int size

Macro Definition Documentation

◆ fglmASSERT

#define fglmASSERT (   ignore1,
  ignore2 
)

Definition at line 54 of file fglmzero.cc.

◆ PROT

#define PROT (   msg)

Definition at line 50 of file fglmzero.cc.

◆ PROT2

#define PROT2 (   msg,
  arg 
)

Definition at line 52 of file fglmzero.cc.

◆ STICKYPROT

#define STICKYPROT (   msg)    if (BTEST1(OPT_PROT)) Print(msg)

Definition at line 51 of file fglmzero.cc.

◆ STICKYPROT2

#define STICKYPROT2 (   msg,
  arg 
)    if (BTEST1(OPT_PROT)) Print(msg,arg)

Definition at line 53 of file fglmzero.cc.

Function Documentation

◆ CalculateFunctionals() [1/2]

static BOOLEAN CalculateFunctionals ( const ideal &  theIdeal,
idealFunctionals l 
)
static

Definition at line 675 of file fglmzero.cc.

676 {
677  fglmSdata data( theIdeal );
678  internalCalculateFunctionals( theIdeal, l, data );
679  return ( data.state() );
680 }
int l
Definition: cfEzgcd.cc:93
void internalCalculateFunctionals(const ideal, idealFunctionals &l, fglmSdata &data)
Definition: fglmzero.cc:611

◆ CalculateFunctionals() [2/2]

static BOOLEAN CalculateFunctionals ( const ideal &  theIdeal,
idealFunctionals l,
poly &  p,
fglmVector v 
)
static

Definition at line 683 of file fglmzero.cc.

685 {
686  fglmSdata data( theIdeal );
687  internalCalculateFunctionals( theIdeal, l, data );
688  // STICKYPROT("Calculating vector rep\n");
689  v = data.getVectorRep( p );
690  // if ( v.isZero() )
691  // STICKYPROT("vectorrep is 0\n");
692  return ( data.state() );
693 }
int p
Definition: cfModGcd.cc:4019
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37

◆ fglmquot()

BOOLEAN fglmquot ( ideal  sourceIdeal,
poly  quot,
ideal &  destIdeal 
)

Definition at line 1220 of file fglmzero.cc.

1221 {
1222  BOOLEAN fglmok;
1223  fglmVector v;
1224 
1225  idealFunctionals L( 100, (currRing->N) );
1226  // STICKYPROT("calculating normal form\n");
1227  // poly p = kNF( sourceIdeal, currRing->qideal, quot );
1228  // STICKYPROT("calculating functionals\n");
1229  fglmok = CalculateFunctionals( sourceIdeal, L, quot, v );
1230  if ( fglmok == TRUE ) {
1231  // STICKYPROT("calculating groebner basis\n");
1232  destIdeal= GroebnerViaFunctionals( L, v );
1233  }
1234  return fglmok;
1235 }
int BOOLEAN
Definition: auxiliary.h:85
#define TRUE
Definition: auxiliary.h:98
static BOOLEAN CalculateFunctionals(const ideal &theIdeal, idealFunctionals &l)
Definition: fglmzero.cc:675
static ideal GroebnerViaFunctionals(const idealFunctionals &l, fglmVector iv=fglmVector())
Definition: fglmzero.cc:1048
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13

◆ fglmzero()

BOOLEAN fglmzero ( ring  sourceRing,
ideal &  sourceIdeal,
ring  destRing,
ideal &  destIdeal,
BOOLEAN  switchBack,
BOOLEAN  deleteIdeal 
)

Definition at line 1195 of file fglmzero.cc.

1196 {
1197  ring initialRing = currRing;
1198  BOOLEAN fglmok;
1199 
1200  if ( currRing != sourceRing )
1201  {
1202  rChangeCurrRing( sourceRing );
1203  }
1204  idealFunctionals L( 100, rVar(currRing) );
1205  fglmok = CalculateFunctionals( sourceIdeal, L );
1206  if ( deleteIdeal == TRUE )
1207  idDelete( & sourceIdeal );
1208  rChangeCurrRing( destRing );
1209  if ( fglmok == TRUE )
1210  {
1211  L.map( sourceRing );
1212  destIdeal= GroebnerViaFunctionals( L );
1213  }
1214  if ( (switchBack) && (currRing != initialRing) )
1215  rChangeCurrRing( initialRing );
1216  return fglmok;
1217 }
#define idDelete(H)
delete an ideal
Definition: ideals.h:29
void rChangeCurrRing(ring r)
Definition: polys.cc:15
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:583

◆ FindUnivariatePolys()

static ideal FindUnivariatePolys ( const idealFunctionals l)
static

Definition at line 1120 of file fglmzero.cc.

1121 {
1122  fglmVector v;
1123  fglmVector p;
1124  ideal destIdeal = idInit( (currRing->N), 1 );
1125 
1126  int i;
1127  BOOLEAN isZero;
1128  int *varpermutation = (int*)omAlloc( ((currRing->N)+1)*sizeof(int) );
1129  ideal perm = idMaxIdeal(1);
1130  intvec *iv = idSort(perm,TRUE);
1131  idDelete(&perm);
1132  for(i = (currRing->N); i > 0; i--) varpermutation[(currRing->N)+1-i] = (*iv)[i-1];
1133  delete iv;
1134 
1135  for (i= 1; i <= (currRing->N); i++ )
1136  {
1137  // main loop
1138  STICKYPROT2( "(%i)", i /*varpermutation[i]*/);
1139  gaussReducer gauss( l.dimen() );
1140  isZero= FALSE;
1141  v= fglmVector( l.dimen(), 1 );
1142  while ( !isZero )
1143  {
1144  if ( (isZero= gauss.reduce( v )))
1145  {
1146  STICKYPROT( "+" );
1147  p= gauss.getDependence();
1148  number gcd= p.gcd();
1149  if ( ! nIsOne( gcd ) )
1150  {
1151  p /= gcd;
1152  }
1153  nDelete( & gcd );
1154  int k;
1155  poly temp = NULL;
1156  poly result=NULL;
1157  for ( k= p.size(); k > 0; k-- )
1158  {
1159  number n = nCopy( p.getconstelem( k ) );
1160  if ( ! nIsZero( n ) )
1161  {
1162  if ( temp == NULL )
1163  {
1164  result= pOne();
1165  temp= result;
1166  }
1167  else
1168  {
1169  temp->next= pOne();
1170  pIter( temp );
1171  }
1172  pSetCoeff( temp, n );
1173  pSetExp( temp, i /*varpermutation[i]*/, k-1 );
1174  pSetm( temp );
1175  }
1176  }
1177  if ( ! nGreaterZero( pGetCoeff( result ) ) ) result= pNeg( result );
1178  (destIdeal->m)[i-1]= result;
1179  }
1180  else
1181  {
1182  STICKYPROT( "." );
1183  gauss.store();
1184  v= l.multiply( v, i /*varpermutation[i]*/ );
1185  }
1186  }
1187  }
1188  STICKYPROT( "\n" );
1189  omFreeSize( (ADDRESS)varpermutation, ((currRing->N)+1)*sizeof(int) );
1190  return destIdeal;
1191 }
#define FALSE
Definition: auxiliary.h:94
void * ADDRESS
Definition: auxiliary.h:133
int i
Definition: cfEzgcd.cc:125
int k
Definition: cfEzgcd.cc:92
Definition: intvec.h:21
return result
Definition: facAbsBiFact.cc:76
bool isZero(const CFArray &A)
checks if entries of A are zero
#define STICKYPROT2(msg, arg)
Definition: fglmzero.cc:53
#define STICKYPROT(msg)
Definition: fglmzero.cc:51
static intvec * idSort(ideal id, BOOLEAN nolex=TRUE)
Definition: ideals.h:186
#define idMaxIdeal(D)
initialise the maximal ideal (at 0)
Definition: ideals.h:33
#define pIter(p)
Definition: monomials.h:44
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 nDelete(n)
Definition: numbers.h:17
#define nIsZero(n)
Definition: numbers.h:20
#define nCopy(n)
Definition: numbers.h:16
#define nGreaterZero(n)
Definition: numbers.h:28
#define nIsOne(n)
Definition: numbers.h:26
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
#define omAlloc(size)
Definition: omAllocDecl.h:210
#define NULL
Definition: omList.c:10
#define pSetm(p)
Definition: polys.h:257
#define pNeg(p)
Definition: polys.h:185
#define pSetCoeff(p, n)
deletes old coeff before setting the new one
Definition: polys.h:31
#define pSetExp(p, i, v)
Definition: polys.h:42
#define pOne()
Definition: polys.h:301
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:37
int gcd(int a, int b)
Definition: walkSupport.cc:836

◆ FindUnivariateWrapper()

BOOLEAN FindUnivariateWrapper ( ideal  source,
ideal &  destIdeal 
)

Definition at line 1238 of file fglmzero.cc.

1239 {
1240  BOOLEAN fglmok;
1241 
1242  idealFunctionals L( 100, (currRing->N) );
1243  fglmok = CalculateFunctionals( source, L );
1244  if ( fglmok == TRUE ) {
1245  destIdeal= FindUnivariatePolys( L );
1246  return TRUE;
1247  }
1248  else
1249  return FALSE;
1250 }
static ideal FindUnivariatePolys(const idealFunctionals &l)
Definition: fglmzero.cc:1120

◆ GroebnerViaFunctionals()

static ideal GroebnerViaFunctionals ( const idealFunctionals l,
fglmVector  iv = fglmVector() 
)
static

Definition at line 1048 of file fglmzero.cc.

1056 {
1057  fglmDdata data( l.dimen() );
1058 
1059  // insert pOne() and update workinglist according to iv:
1060  fglmVector initv;
1061  if ( iv.isZero() ) {
1062  // STICKYPROT("initv is zero\n");
1063  initv = fglmVector( l.dimen(), 1 );
1064  }
1065  else {
1066  // STICKYPROT("initv is not zero\n");
1067  initv = iv;
1068  }
1069 
1070  poly one = pOne();
1071  data.updateCandidates( one, initv );
1072  number nOne = nInit( 1 );
1073  data.newBasisElem( one, initv, fglmVector( 1, 1 ), nOne );
1074  STICKYPROT( "." );
1075  while ( data.candidatesLeft() == TRUE ) {
1076  fglmDelem candidate = data.nextCandidate();
1077  if ( candidate.isBasisOrEdge() == TRUE ) {
1078  // Now we have the chance to find a new groebner polynomial
1079 
1080  // v is the vector-representation of candidate.monom
1081  // some elements of v are zeroed in data.gaussreduce(). Which
1082  // ones and how this was done is stored in p.
1083  // originalV containes the unchanged v, which is later inserted
1084  // into the working list (via data.updateCandidates().
1085  fglmVector v = l.multiply( candidate.v, candidate.var );
1086  fglmVector originalV = v;
1087  fglmVector p( data.getBasisSize()+1, data.getBasisSize()+1 );
1088  number pdenom = NULL;
1089  data.gaussreduce( v, p, pdenom );
1090  if ( v.isZero() ) {
1091  // Now v is linear dependend to the already found basis elements.
1092  // This means that v (rsp. candidate.monom) is the leading
1093  // monomial of the next groebner-basis polynomial.
1094  data.newGroebnerPoly( p, candidate.monom );
1095  nDelete( & pdenom );
1096  STICKYPROT( "+" );
1097  }
1098  else {
1099  // no linear dependence could be found, so v ( rsp. monom )
1100  // is a basis monomial. We store the zeroed version ( i.e. v
1101  // and not originalV ) as well as p, the denomiator and all
1102  // the other stuff.
1103  // erst updateCandidates, dann newBasisELem!!!
1104  data.updateCandidates( candidate.monom, originalV );
1105  data.newBasisElem( candidate.monom, v, p, pdenom );
1106  STICKYPROT( "." );
1107  }
1108  }
1109  else {
1110  STICKYPROT( "-" );
1111  candidate.cleanup();
1112  }
1113  } //. while data.candidatesLeft()
1114  STICKYPROT( "\n" );
1115  return ( data.buildIdeal() );
1116 }
Definition: fglm.h:47
fglmVector v
Definition: fglm.h:50
poly monom
Definition: fglm.h:49
int var
Definition: fglm.h:52
void cleanup()
Definition: fglmzero.cc:715
BOOLEAN isBasisOrEdge() const
Definition: fglm.h:56
int isZero()
Definition: fglmvec.cc:296
#define nInit(i)
Definition: numbers.h:25

◆ internalCalculateFunctionals()

void internalCalculateFunctionals ( const  ideal,
idealFunctionals l,
fglmSdata data 
)

Definition at line 611 of file fglmzero.cc.

613 {
614 
615  // insert pOne() into basis and update the workingList:
616  poly one = pOne();
617  data.newBasisElem( one );
618  data.updateCandidates();
619 
620  STICKYPROT(".");
621  while ( data.candidatesLeft() == TRUE ) {
622  fglmSelem candidate = data.nextCandidate();
623  if ( candidate.isBasisOrEdge() == TRUE ) {
624  int edge = data.getEdgeNumber( candidate.monom );
625  if ( edge != 0 )
626  {
627  // now candidate is an edge, i.e. we know its normalform:
628  // NF(p) = - ( tail(p)/LC(p) )
629  poly nf = data.getSpanPoly( edge );
630  pNorm( nf );
631  pLmDelete(&nf); //. deletes the leadingmonomial
632  nf= pNeg( nf );
633  fglmVector nfv = data.getVectorRep( nf );
634  l.insertCols( candidate.divisors, nfv );
635  data.newBorderElem( candidate.monom, nfv );
636  pDelete( &nf );
637  STICKYPROT( "+" );
638  }
639  else
640  {
641  int basis= data.newBasisElem( candidate.monom );
642  data.updateCandidates();
643  l.insertCols( candidate.divisors, basis );
644  STICKYPROT( "." );
645  }
646  }
647  else {
648  int var = 0;
649  fglmVector temp = data.getBorderDiv( candidate.monom, var );
650  fglmASSERT( var > 0, "this should never happen" );
651  fglmVector nfv = l.addCols( var, data.getBasisSize(), temp );
652  data.newBorderElem( candidate.monom, nfv );
653  l.insertCols( candidate.divisors, nfv );
654  STICKYPROT( "-" );
655  }
656  candidate.cleanup();
657  } //. while ( data.candidatesLeft() == TRUE )
658  l.endofConstruction();
659  STICKYPROT2( "\nvdim= %i\n", data.getBasisSize() );
660  return;
661 }
BOOLEAN candidatesLeft() const
Definition: fglmzero.cc:365
void newBorderElem(poly &m, fglmVector v)
Definition: fglmzero.cc:443
poly getSpanPoly(int number) const
Definition: fglmzero.cc:369
int newBasisElem(poly &p)
Definition: fglmzero.cc:426
fglmVector getVectorRep(const poly m)
Definition: fglmzero.cc:545
fglmSelem nextCandidate()
Definition: fglmzero.cc:469
fglmVector getBorderDiv(const poly m, int &var) const
Definition: fglmzero.cc:580
int getBasisSize() const
Definition: fglmzero.cc:362
int getEdgeNumber(const poly m) const
Definition: fglmzero.cc:531
void updateCandidates()
Definition: fglmzero.cc:481
Definition: fglm.h:28
poly monom
Definition: fglm.h:31
void cleanup()
Definition: fglmzero.cc:332
int * divisors
Definition: fglm.h:30
BOOLEAN isBasisOrEdge() const
Definition: fglm.h:36
#define fglmASSERT(ignore1, ignore2)
Definition: fglmzero.cc:54
#define pDelete(p_ptr)
Definition: polys.h:173
#define pLmDelete(p)
assume p != NULL, deletes Lm(p)->coef and Lm(p)
Definition: polys.h:76
void pNorm(poly p, const ring R=currRing)
Definition: polys.h:349
Definition: gnumpfl.cc:28