29 #include "factory/factory.h" 49 #define STICKYPROT(msg) if (BTEST1(OPT_PROT)) Print(msg) 50 #define PROT2(msg,arg) 51 #define STICKYPROT2(msg,arg) if (BTEST1(OPT_PROT)) Print(msg,arg) 52 #define fglmASSERT(ignore1,ignore2) 89 void endofConstruction();
90 void map( ring source );
91 void insertCols(
int * divisors,
int to );
92 void insertCols(
int * divisors,
const fglmVector to );
106 currentSize= (
int *)
omAlloc0( _nfunc*
sizeof(
int ) );
111 for ( k= _nfunc-1; k >= 0; k-- )
122 for ( k= _nfunc-1; k >= 0; k-- ) {
123 for ( l= _size-1, colp= func[k]; l >= 0; l--, colp++ ) {
125 for ( row= colp->
size-1, elemp= colp->
elems; row >= 0; row--, elemp++ )
139 _size= currentSize[0];
151 int * perm = (
int *)
omAlloc0( (_nfunc+1)*
sizeof( int ) );
157 for ( var= 0; var < _nfunc; var ++ ) {
158 for ( col= 0, colp= func[var]; col < _size; col++, colp++ ) {
160 for ( row= colp->
size-1, elemp= colp->
elems; row >= 0;
165 elemp->
elem= newelem;
169 temp[ perm[var+1]-1 ]= func[var];
179 if ( currentSize[var-1] == _max ) {
181 for ( k= _nfunc; k > 0; k-- )
185 currentSize[var-1]++;
186 return func[var-1] + currentSize[var-1] - 1;
192 fglmASSERT( 0 < divisors[0] && divisors[0] <= _nfunc,
"wrong number of divisors" );
198 for ( k= divisors[0]; k > 0; k-- ) {
199 fglmASSERT( 0 < divisors[k] && divisors[k] <= _nfunc,
"wrong divisor" );
213 fglmASSERT( 0 < divisors[0] && divisors[0] <= _nfunc,
"wrong number of divisors" );
219 if ( numElems > 0 ) {
221 for ( k= 1, l= 1, elemp= elems; k <= numElems; k++, elemp++ ) {
230 for ( k= divisors[0]; k > 0; k-- ) {
231 fglmASSERT( 0 < divisors[k] && divisors[k] <= _nfunc,
"wrong divisor" );
233 colp->
size= numElems;
248 int vsize = v.
size();
250 fglmASSERT( currentSize[var-1]+1 >= vsize,
"wrong v.size()" );
251 for ( k= 1, colp= func[var-1]; k <= vsize; k++, colp++ ) {
254 for ( l= colp->
size-1, elemp= colp->
elems; l >= 0; l--, elemp++ ) {
275 for ( k= 1, colp= func[var-1]; k <= _size; k++, colp++ ) {
278 for ( l= colp->
size-1, elemp= colp->
elems; l >= 0; l--, elemp++ ) {
280 number newelem=
nAdd( result.getconstelem( elemp->
row ), temp );
283 result.setelem( elemp->
row, newelem );
307 #ifndef HAVE_EXPLICIT_CONSTR 361 int newBasisElem( poly &
p );
365 void updateCandidates();
366 int getEdgeNumber(
const poly m )
const;
369 fglmVector getBorderDiv(
const poly m,
int & var )
const;
394 #ifndef HAVE_EXPLICIT_CONSTR 406 for (
int k = basisSize;
k > 0;
k-- )
409 #ifndef HAVE_EXPLICIT_CONSTR 412 for (
int l = borderSize;
l > 0;
l-- )
427 if ( basisSize == basisMax ) {
428 basis= (
polyset)
omReallocSize( basis, basisMax*
sizeof( poly ), (basisMax + basisBS)*
sizeof( poly ) );
444 if ( borderSize == borderMax ) {
445 #ifndef HAVE_EXPLICIT_CONSTR 447 for (
int k = 0;
k < borderMax;
k++ ) {
448 tempborder[
k]= border[
k];
456 borderMax+= borderBS;
458 #ifndef HAVE_EXPLICIT_CONSTR 459 border[borderSize].insertElem( m, v );
461 border[borderSize].borderElem( m, v );
482 fglmASSERT( basisSize > 0 && basisSize < basisMax,
"Error(1) in fglmSdata::updateCandidates - wrong bassSize" );
483 poly
m = basis[basisSize];
484 poly newmonom =
NULL;
490 newmonom =
pCopy( m );
491 pIncrExp( newmonom, varpermutation[k] );
494 while ( list.
hasItem() && (!done) )
502 nlist.append(
fglmSelem( newmonom, varpermutation[k] ) );
518 newmonom=
pCopy( m );
519 pIncrExp( newmonom, varpermutation[k] );
521 nlist.append(
fglmSelem( newmonom, varpermutation[k] ) );
531 for (
int k = idelems;
k > 0;
k-- )
548 while ( m !=
NULL ) {
551 fglmASSERT( num > 0,
"Error(1) in fglmSdata::getVectorRep" );
592 int num = borderSize;
594 poly temp = border[
num].monom;
599 return border[num].
nf;
648 fglmASSERT( var > 0,
"this should never happen" );
677 return ( data.
state() );
690 return ( data.
state() );
729 #ifndef HAVE_EXPLICIT_CONSTR 738 #ifndef HAVE_EXPLICIT_CONSTR 739 void insertElem(
const fglmVector newv,
const fglmVector newp, number & newpdenom, number & newfac )
783 void updateCandidates( poly m,
const fglmVector v );
784 void newGroebnerPoly(
fglmVector & v, poly & p );
799 #ifndef HAVE_EXPLICIT_CONSTR 805 for ( k= dimen; k > 0; k-- ) isPivot[k]=
FALSE;
806 perm= (
int *)
omAlloc( (dimen+1)*
sizeof( int ) );
818 destId=
idInit( groebnerBS, 1 );
827 #ifndef HAVE_EXPLICIT_CONSTR 831 for ( k= basisSize; k > 0; k-- )
839 for ( k= basisSize; k > 0; k-- )
865 fglmASSERT( k <= dimen,
"Error(1) in fglmDdata::pivot-search");
869 while ( k <= dimen ) {
879 isPivot[ pivotcol ]=
TRUE;
880 perm[basisSize]= pivotcol;
883 #ifndef HAVE_EXPLICIT_CONSTR 884 gauss[basisSize].insertElem( v, p, denom, pivot );
886 gauss[basisSize].oldGaussElem( v, p, denom, pivot );
894 poly newmonom =
NULL;
900 newmonom =
pCopy( m );
901 pIncrExp( newmonom, varpermutation[k] );
904 while ( list.
hasItem() && (!done) )
912 nlist.append(
fglmDelem( newmonom, v, k ) );
928 newmonom=
pCopy( m );
929 pIncrExp( newmonom, varpermutation[k] );
931 nlist.append(
fglmDelem( newmonom, v, k ) );
943 fglmASSERT( p.
size() == basisSize+1,
"GP::newGroebnerPoly: p has wrong size" );
961 for ( k= basisSize; k > 0; k-- ) {
963 temp->next=
pCopy( basis[k] );
970 if ( groebnerSize ==
IDELEMS( destId ) ) {
972 IDELEMS( destId )+= groebnerBS;
974 (destId->m)[groebnerSize]= result;
984 fglmASSERT( pdenom ==
NULL,
"pdenom in gaussreduce should be NULL" );
996 number temp=
nMult( pdenom, gcd );
1002 for ( k= 1; k <= basisSize; k++ ) {
1007 v.
nihilate( fac1, fac2, gauss[k].v );
1008 fac1=
nMult( fac1, gauss[k].pdenom );
1009 temp=
nMult( fac2, pdenom );
1012 p.
nihilate( fac1, fac2, gauss[k].p );
1013 temp=
nMult( pdenom, gauss[k].pdenom );
1019 number gcd = v.gcd();
1023 number temp=
nMult( pdenom, gcd );
1035 temp=
nDiv( pdenom, gcd );
1059 if ( iv.isZero() ) {
1069 data.updateCandidates( one, initv );
1070 number nOne =
nInit( 1 );
1071 data.newBasisElem( one, initv,
fglmVector( 1, 1 ), nOne );
1073 while ( data.candidatesLeft() ==
TRUE ) {
1074 fglmDelem candidate = data.nextCandidate();
1085 fglmVector p( data.getBasisSize()+1, data.getBasisSize()+1 );
1086 number pdenom =
NULL;
1087 data.gaussreduce( v,
p, pdenom );
1092 data.newGroebnerPoly(
p, candidate.
monom );
1102 data.updateCandidates( candidate.
monom, originalV );
1103 data.newBasisElem( candidate.
monom, v,
p, pdenom );
1113 return ( data.buildIdeal() );
1130 for(i = (
currRing->N); i > 0; i--) varpermutation[(
currRing->N)+1-i] = (*iv)[i-1];
1133 for (i= 1; i <= (
currRing->N); i++ )
1142 if ( (isZero= gauss.reduce( v )))
1145 p= gauss.getDependence();
1155 for ( k= p.
size(); k > 0; k-- )
1176 (destIdeal->m)[i-1]= result;
1204 if ( deleteIdeal ==
TRUE )
1207 if ( fglmok ==
TRUE )
1209 L.
map( sourceRing );
1212 if ( (switchBack) && (
currRing != initialRing) )
1218 fglmquot( ideal sourceIdeal, poly quot, ideal & destIdeal)
1228 if ( fglmok ==
TRUE ) {
1242 if ( fglmok ==
TRUE ) {
int numNonZeroElems() const
fglmDelem(poly &m, fglmVector mv, int v)
The new basis.
CanonicalForm map(const CanonicalForm &primElem, const Variable &alpha, const CanonicalForm &F, const Variable &beta)
map from to such that is mapped onto
#define idMaxIdeal(D)
initialise the maximal ideal (at 0)
fglmDelem nextCandidate()
#define idDelete(H)
delete an ideal
void internalCalculateFunctionals(const ideal, idealFunctionals &l, fglmSdata &data)
Compatiblity layer for legacy polynomial operations (over currRing)
number getconstelem(int i) const
#define omFreeSize(addr, size)
void gaussreduce(fglmVector &v, fglmVector &p, number &denom)
void newBasisElem(poly &m, fglmVector v, fglmVector p, number &denom)
static short rVar(const ring r)
#define rVar(r) (r->N)
fglmSelem nextCandidate()
#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))) ...
bool pivot(const matrix aMat, const int r1, const int r2, const int c1, const int c2, int *bestR, int *bestC, const ring R)
This code computes a score for each non-zero matrix entry in aMat[r1..r2, c1..c2].
static ideal GroebnerViaFunctionals(const idealFunctionals &l, fglmVector iv=fglmVector())
BOOLEAN isBasisOrEdge() const
#define STICKYPROT2(msg, arg)
static intvec * idSort(ideal id, BOOLEAN nolex=TRUE)
void insertCols(int *divisors, int to)
fglmSdata(const ideal thisIdeal)
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy ...
BOOLEAN candidatesLeft() const
int comp(const CanonicalForm &A, const CanonicalForm &B)
compare polynomials
#define omReallocSize(addr, o_size, size)
#define pGetExp(p, i)
Exponent.
static ideal FindUnivariatePolys(const idealFunctionals &l)
poly getSpanPoly(int number) const
idealFunctionals(int blockSize, int numFuncs)
void updateCandidates(poly m, const fglmVector v)
int newBasisElem(poly &p)
void nihilate(const number fac1, const number fac2, const fglmVector v)
BOOLEAN candidatesLeft() const
fglmSelem(poly p, int var)
oldGaussElem(const fglmVector newv, const fglmVector newp, number &newpdenom, number &newfac)
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
matHeader * grow(int var)
static BOOLEAN CalculateFunctionals(const ideal &theIdeal, idealFunctionals &l)
borderElem(poly p, fglmVector n)
void newGroebnerPoly(fglmVector &v, poly &p)
static FORCE_INLINE nMapFunc n_SetMap(const coeffs src, const coeffs dst)
set the mapping function pointers for translating numbers from src to dst
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
#define fglmASSERT(ignore1, ignore2)
BOOLEAN isBasisOrEdge() const
void rChangeCurrRing(ring r)
void newBorderElem(poly &m, fglmVector v)
int getEdgeNumber(const poly m) const
fglmVector getBorderDiv(const poly m, int &var) const
ideal idInit(int idsize, int rank)
initialise an ideal / module
const Variable & v
< [in] a sqrfree bivariate poly
void maFindPerm(char const *const *const preim_names, int preim_n, char const *const *const preim_par, int preim_p, char const *const *const names, int n, char const *const *const par, int nop, int *perm, int *par_perm, n_coeffType ch)
BOOLEAN dimension(leftv res, leftv args)
#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 pEnlargeSet(poly **p, int l, int increment)
void setelem(int i, number &n)
void pNorm(poly p, const ring R=currRing)
BOOLEAN fglmzero(ring sourceRing, ideal &sourceIdeal, ring destRing, ideal &destIdeal, BOOLEAN switchBack, BOOLEAN deleteIdeal)
fglmVector getVectorRep(const poly m)
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 FORCE_INLINE number n_SubringGcd(number a, number b, const coeffs r)
BOOLEAN FindUnivariateWrapper(ideal source, ideal &destIdeal)
BOOLEAN fglmquot(ideal sourceIdeal, poly quot, ideal &destIdeal)
#define pSetCoeff(p, n)
deletes old coeff before setting the new one
fglmVector addCols(const int var, int basisSize, const fglmVector v) const
fglmVector multiply(const fglmVector v, int var) const
#define pCopy(p)
return a copy of the poly