Macros | Typedefs | Enumerations | Functions
ideals.h File Reference
#include "polys/monomials/ring.h"
#include "polys/monomials/p_polys.h"
#include "polys/simpleideals.h"
#include "kernel/structs.h"

Go to the source code of this file.

Macros

#define idDelete(H)   id_Delete((H),currRing)
 delete an ideal More...
 
#define idMaxIdeal(D)   id_MaxIdeal(D,currRing)
 initialise the maximal ideal (at 0) More...
 
#define idPosConstant(I)   id_PosConstant(I,currRing)
 index of generator with leading term in ground ring (if any); otherwise -1 More...
 
#define idIsConstant(I)   id_IsConstant(I,currRing)
 
#define idSimpleAdd(A, B)   id_SimpleAdd(A,B,currRing)
 
#define idPrint(id)   id_Print(id, currRing, currRing)
 
#define idTest(id)   id_Test(id, currRing)
 

Typedefs

typedef ideal * resolvente
 

Enumerations

enum  GbVariant {
  GbDefault =0, GbStd, GbSlimgb, GbSba,
  GbGroebner, GbModstd, GbFfmod, GbNfmod,
  GbStdSat, GbSingmatic
}
 

Functions

static ideal idCopyFirstK (const ideal ide, const int k)
 
void idKeepFirstK (ideal ide, const int k)
 keeps the first k (>= 1) entries of the given ideal (Note that the kept polynomials may be zero.) More...
 
void idDelEquals (ideal id)
 
ideal id_Copy (ideal h1, const ring r)
 copy an ideal More...
 
ideal idCopy (ideal A)
 
ideal idAdd (ideal h1, ideal h2)
 h1 + h2 More...
 
BOOLEAN idInsertPoly (ideal h1, poly h2)
 insert h2 into h1 (if h2 is not the zero polynomial) return TRUE iff h2 was indeed inserted More...
 
BOOLEAN idInsertPolyOnPos (ideal I, poly p, int pos)
 insert p into I on position pos More...
 
BOOLEAN idInsertPolyWithTests (ideal h1, const int validEntries, const poly h2, const bool zeroOk, const bool duplicateOk)
 
static ideal idMult (ideal h1, ideal h2)
 hh := h1 * h2 More...
 
BOOLEAN idIs0 (ideal h)
 returns true if h is the zero ideal More...
 
static BOOLEAN idHomIdeal (ideal id, ideal Q=NULL)
 
static BOOLEAN idHomModule (ideal m, ideal Q, intvec **w)
 
BOOLEAN idTestHomModule (ideal m, ideal Q, intvec *w)
 
ideal idMinBase (ideal h1)
 
void idInitChoise (int r, int beg, int end, BOOLEAN *endch, int *choise)
 
void idGetNextChoise (int r, int end, BOOLEAN *endch, int *choise)
 
int idGetNumberOfChoise (int t, int d, int begin, int end, int *choise)
 
int binom (int n, int r)
 
ideal idFreeModule (int i)
 
ideal idSect (ideal h1, ideal h2, GbVariant a=GbDefault)
 
ideal idMultSect (resolvente arg, int length, GbVariant a=GbDefault)
 
ideal idSyzygies (ideal h1, tHomog h, intvec **w, BOOLEAN setSyzComp=TRUE, BOOLEAN setRegularity=FALSE, int *deg=NULL, GbVariant a=GbDefault)
 
ideal idLiftStd (ideal h1, matrix *m, tHomog h=testHomog, ideal *syz=NULL, GbVariant a=GbDefault)
 
ideal idLift (ideal mod, ideal sumod, ideal *rest=NULL, BOOLEAN goodShape=FALSE, BOOLEAN isSB=TRUE, BOOLEAN divide=FALSE, matrix *unit=NULL, GbVariant a=GbDefault)
 
void idLiftW (ideal P, ideal Q, int n, matrix &T, ideal &R, short *w=NULL)
 
intvecidMWLift (ideal mod, intvec *weights)
 
ideal idQuot (ideal h1, ideal h2, BOOLEAN h1IsStb=FALSE, BOOLEAN resultIsIdeal=FALSE)
 
ideal idElimination (ideal h1, poly delVar, intvec *hilb=NULL, GbVariant a=GbDefault)
 
ideal idMinors (matrix a, int ar, ideal R=NULL)
 compute all ar-minors of the matrix a the caller of mpRecMin the elements of the result are not in R (if R!=NULL) More...
 
ideal idMinEmbedding (ideal arg, BOOLEAN inPlace=FALSE, intvec **w=NULL)
 
ideal idHead (ideal h)
 
BOOLEAN idIsSubModule (ideal id1, ideal id2)
 
static ideal idVec2Ideal (poly vec)
 
ideal idSeries (int n, ideal M, matrix U=NULL, intvec *w=NULL)
 
static BOOLEAN idIsZeroDim (ideal i)
 
matrix idDiff (matrix i, int k)
 
matrix idDiffOp (ideal I, ideal J, BOOLEAN multiply=TRUE)
 
static intvecidSort (ideal id, BOOLEAN nolex=TRUE)
 
ideal idModulo (ideal h1, ideal h2, tHomog h=testHomog, intvec **w=NULL)
 
matrix idCoeffOfKBase (ideal arg, ideal kbase, poly how)
 
ideal idXXX (ideal h1, int k)
 
poly id_GCD (poly f, poly g, const ring r)
 
ideal id_Farey (ideal x, number N, const ring r)
 
ideal id_TensorModuleMult (const int m, const ideal M, const ring rRing)
 
ideal id_Satstd (const ideal I, ideal J, const ring r)
 
GbVariant syGetAlgorithm (char *n, const ring r, const ideal M)
 

Macro Definition Documentation

◆ idDelete

#define idDelete (   H)    id_Delete((H),currRing)

delete an ideal

Definition at line 29 of file ideals.h.

◆ idIsConstant

#define idIsConstant (   I)    id_IsConstant(I,currRing)

Definition at line 40 of file ideals.h.

◆ idMaxIdeal

#define idMaxIdeal (   D)    id_MaxIdeal(D,currRing)

initialise the maximal ideal (at 0)

Definition at line 33 of file ideals.h.

◆ idPosConstant

#define idPosConstant (   I)    id_PosConstant(I,currRing)

index of generator with leading term in ground ring (if any); otherwise -1

Definition at line 37 of file ideals.h.

◆ idPrint

#define idPrint (   id)    id_Print(id, currRing, currRing)

Definition at line 46 of file ideals.h.

◆ idSimpleAdd

#define idSimpleAdd (   A,
  B 
)    id_SimpleAdd(A,B,currRing)

Definition at line 42 of file ideals.h.

◆ idTest

#define idTest (   id)    id_Test(id, currRing)

Definition at line 47 of file ideals.h.

Typedef Documentation

◆ resolvente

typedef ideal* resolvente

Definition at line 18 of file ideals.h.

Enumeration Type Documentation

◆ GbVariant

enum GbVariant
Enumerator
GbDefault 
GbStd 
GbSlimgb 
GbSba 
GbGroebner 
GbModstd 
GbFfmod 
GbNfmod 
GbStdSat 
GbSingmatic 

Definition at line 118 of file ideals.h.

119 {
120  GbDefault=0,
121  // internal variants:
122  GbStd,
123  GbSlimgb,
124  GbSba,
125  // and the library functions:
126  GbGroebner,
127  GbModstd,
128  GbFfmod,
129  GbNfmod,
130  GbStdSat,
132 };
Definition: ideals.h:124
Definition: ideals.h:122

Function Documentation

◆ binom()

int binom ( int  n,
int  r 
)

Definition at line 922 of file simpleideals.cc.

923 {
924  int i,result;
925 
926  if (r==0) return 1;
927  if (n-r<r) return binom(n,n-r);
928  result = n-r+1;
929  for (i=2;i<=r;i++)
930  {
931  result *= n-r+i;
932  if (result<0)
933  {
934  WarnS("overflow in binomials");
935  return 0;
936  }
937  result /= i;
938  }
939  return result;
940 }
#define WarnS
Definition: emacs.cc:78
int i
Definition: cfEzgcd.cc:125
int binom(int n, int r)
return result
Definition: facAbsBiFact.cc:76

◆ id_Copy()

ideal id_Copy ( ideal  h1,
const ring  r 
)

copy an ideal

Definition at line 413 of file simpleideals.cc.

414 {
415  id_Test(h1, r);
416 
417  ideal h2 = idInit(IDELEMS(h1), h1->rank);
418  for (int i=IDELEMS(h1)-1; i>=0; i--)
419  h2->m[i] = p_Copy(h1->m[i],r);
420  return h2;
421 }
#define id_Test(A, lR)
Definition: simpleideals.h:79
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:811
int i
Definition: cfEzgcd.cc:125
#define IDELEMS(i)
Definition: simpleideals.h:23
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:35

◆ id_Farey()

ideal id_Farey ( ideal  x,
number  N,
const ring  r 
)

Definition at line 2724 of file ideals.cc.

2725 {
2726  int cnt=IDELEMS(x)*x->nrows;
2727  ideal result=idInit(cnt,x->rank);
2728  result->nrows=x->nrows; // for lifting matrices
2729  result->ncols=x->ncols; // for lifting matrices
2730 
2731  int i;
2732  for(i=cnt-1;i>=0;i--)
2733  {
2734  result->m[i]=p_Farey(x->m[i],N,r);
2735  }
2736  return result;
2737 }
poly p_Farey(poly p, number N, const ring r)
Definition: p_polys.cc:50
const CanonicalForm CFMap CFMap & N
Definition: cfEzgcd.cc:48
int i
Definition: cfEzgcd.cc:125
#define IDELEMS(i)
Definition: simpleideals.h:23
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:35
Variable x
Definition: cfModGcd.cc:4023
return result
Definition: facAbsBiFact.cc:76

◆ id_GCD()

poly id_GCD ( poly  f,
poly  g,
const ring  r 
)

Definition at line 2621 of file ideals.cc.

2622 {
2623  ideal I=idInit(2,1); I->m[0]=f; I->m[1]=g;
2624  intvec *w = NULL;
2625 
2626  ring save_r = currRing;
2627  rChangeCurrRing(r);
2628  ideal S=idSyzygies(I,testHomog,&w);
2629  rChangeCurrRing(save_r);
2630 
2631  if (w!=NULL) delete w;
2632  poly gg=p_TakeOutComp(&(S->m[0]), 2, r);
2633  id_Delete(&S, r);
2634  poly gcd_p=singclap_pdivide(f,gg, r);
2635  p_Delete(&gg, r);
2636 
2637  return gcd_p;
2638 }
void p_TakeOutComp(poly *p, long comp, poly *q, int *lq, const ring r)
Definition: p_polys.cc:3455
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
g
Definition: cfModGcd.cc:4031
poly singclap_pdivide(poly f, poly g, const ring r)
Definition: clapsing.cc:556
Definition: intvec.h:19
FILE * f
Definition: checklibs.c:9
void rChangeCurrRing(ring r)
Definition: polys.cc:14
ideal idSyzygies(ideal h1, tHomog h, intvec **w, BOOLEAN setSyzComp, BOOLEAN setRegularity, int *deg, GbVariant alg)
Definition: ideals.cc:728
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:856
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:35
#define NULL
Definition: omList.c:12
const CanonicalForm & w
Definition: facAbsFact.cc:55
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12

◆ id_Satstd()

ideal id_Satstd ( const ideal  I,
ideal  J,
const ring  r 
)

Definition at line 2982 of file ideals.cc.

2983 {
2984  ring save=currRing;
2985  if (currRing!=r) rChangeCurrRing(r);
2986  idSkipZeroes(J);
2987  id_satstdSaturatingVariables=(int*)omAlloc0((1+rVar(currRing))*sizeof(int));
2988  int k=IDELEMS(J);
2989  if (k>1)
2990  {
2991  for (int i=0; i<k; i++)
2992  {
2993  poly x = J->m[i];
2994  int li = p_Var(x,r);
2995  if (li>0)
2997  else
2998  {
2999  if (currRing!=save) rChangeCurrRing(save);
3000  WerrorS("ideal generators must be variables");
3001  return NULL;
3002  }
3003  }
3004  }
3005  else
3006  {
3007  poly x = J->m[0];
3008  for (int i=1; i<=r->N; i++)
3009  {
3010  int li = p_GetExp(x,i,r);
3011  if (li==1)
3013  else if (li>1)
3014  {
3015  if (currRing!=save) rChangeCurrRing(save);
3016  Werror("exponent(x(%d)^%d) must be 0 or 1",i,li);
3017  return NULL;
3018  }
3019  }
3020  }
3021  ideal res=kStd(I,r->qideal,testHomog,NULL,NULL,0,0,NULL,id_sat_vars_sp);
3024  if (currRing!=save) rChangeCurrRing(save);
3025  return res;
3026 }
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:586
ideal kStd(ideal F, ideal Q, tHomog h, intvec **w, intvec *hilb, int syzComp, int newIdeal, intvec *vw, s_poly_proc_t sp)
Definition: kstd1.cc:2088
void WerrorS(const char *s)
Definition: feFopen.cc:24
int k
Definition: cfEzgcd.cc:92
CanonicalForm res
Definition: facAbsFact.cc:64
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent : the integer VarOffset encodes:
Definition: p_polys.h:468
static BOOLEAN id_sat_vars_sp(kStrategy strat)
Definition: ideals.cc:2871
int i
Definition: cfEzgcd.cc:125
#define IDELEMS(i)
Definition: simpleideals.h:23
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
void rChangeCurrRing(ring r)
Definition: polys.cc:14
#define NULL
Definition: omList.c:12
static int * id_satstdSaturatingVariables
Definition: ideals.cc:2869
Variable x
Definition: cfModGcd.cc:4023
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
int p_Var(poly m, const ring r)
Definition: p_polys.cc:4562
void Werror(const char *fmt,...)
Definition: reporter.cc:189
#define omAlloc0(size)
Definition: omAllocDecl.h:211

◆ id_TensorModuleMult()

ideal id_TensorModuleMult ( const int  m,
const ideal  M,
const ring  rRing 
)

Definition at line 1790 of file simpleideals.cc.

1791 {
1792 // #ifdef DEBU
1793 // WarnS("tensorModuleMult!!!!");
1794 
1795  assume(m > 0);
1796  assume(M != NULL);
1797 
1798  const int n = rRing->N;
1799 
1800  assume(M->rank <= m * n);
1801 
1802  const int k = IDELEMS(M);
1803 
1804  ideal idTemp = idInit(k,m); // = {f_1, ..., f_k }
1805 
1806  for( int i = 0; i < k; i++ ) // for every w \in M
1807  {
1808  poly pTempSum = NULL;
1809 
1810  poly w = M->m[i];
1811 
1812  while(w != NULL) // for each term of w...
1813  {
1814  poly h = p_Head(w, rRing);
1815 
1816  const int gen = __p_GetComp(h, rRing); // 1 ...
1817 
1818  assume(gen > 0);
1819  assume(gen <= n*m);
1820 
1821  // TODO: write a formula with %, / instead of while!
1822  /*
1823  int c = gen;
1824  int v = 1;
1825  while(c > m)
1826  {
1827  c -= m;
1828  v++;
1829  }
1830  */
1831 
1832  int cc = gen % m;
1833  if( cc == 0) cc = m;
1834  int vv = 1 + (gen - cc) / m;
1835 
1836 // assume( cc == c );
1837 // assume( vv == v );
1838 
1839  // 1<= c <= m
1840  assume( cc > 0 );
1841  assume( cc <= m );
1842 
1843  assume( vv > 0 );
1844  assume( vv <= n );
1845 
1846  assume( (cc + (vv-1)*m) == gen );
1847 
1848  p_IncrExp(h, vv, rRing); // h *= var(j) && // p_AddExp(h, vv, 1, rRing);
1849  p_SetComp(h, cc, rRing);
1850 
1851  p_Setm(h, rRing); // addjust degree after the previous steps!
1852 
1853  pTempSum = p_Add_q(pTempSum, h, rRing); // it is slow since h will be usually put to the back of pTempSum!!!
1854 
1855  pIter(w);
1856  }
1857 
1858  idTemp->m[i] = pTempSum;
1859  }
1860 
1861  // simplify idTemp???
1862 
1863  ideal idResult = id_Transp(idTemp, rRing);
1864 
1865  id_Delete(&idTemp, rRing);
1866 
1867  return(idResult);
1868 }
#define __p_GetComp(p, r)
Definition: monomials.h:63
ideal id_Transp(ideal a, const ring rRing)
transpose a module
static long p_IncrExp(poly p, int v, ring r)
Definition: p_polys.h:590
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition: p_polys.h:246
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
int k
Definition: cfEzgcd.cc:92
#define pIter(p)
Definition: monomials.h:37
#define M
Definition: sirandom.c:24
static poly p_Head(poly p, const ring r)
Definition: p_polys.h:824
#define assume(x)
Definition: mod2.h:390
int m
Definition: cfEzgcd.cc:121
int i
Definition: cfEzgcd.cc:125
#define IDELEMS(i)
Definition: simpleideals.h:23
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:35
#define NULL
Definition: omList.c:12
const CanonicalForm & w
Definition: facAbsFact.cc:55
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:232
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:891
static Poly * h
Definition: janet.cc:971

◆ idAdd()

ideal idAdd ( ideal  h1,
ideal  h2 
)
inline

h1 + h2

Definition at line 68 of file ideals.h.

69 {
70  return id_Add(h1, h2, currRing);
71 }
ideal id_Add(ideal h1, ideal h2, const ring r)
h1 + h2
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12

◆ idCoeffOfKBase()

matrix idCoeffOfKBase ( ideal  arg,
ideal  kbase,
poly  how 
)

Definition at line 2497 of file ideals.cc.

2498 {
2499  matrix result;
2500  ideal tempKbase;
2501  poly p,q;
2502  intvec * convert;
2503  int i=IDELEMS(kbase),j=IDELEMS(arg),k,pos;
2504 #if 0
2505  while ((i>0) && (kbase->m[i-1]==NULL)) i--;
2506  if (idIs0(arg))
2507  return mpNew(i,1);
2508  while ((j>0) && (arg->m[j-1]==NULL)) j--;
2509  result = mpNew(i,j);
2510 #else
2511  result = mpNew(i, j);
2512  while ((j>0) && (arg->m[j-1]==NULL)) j--;
2513 #endif
2514 
2515  tempKbase = idCreateSpecialKbase(kbase,&convert);
2516  for (k=0;k<j;k++)
2517  {
2518  p = arg->m[k];
2519  while (p!=NULL)
2520  {
2521  q = idDecompose(p,how,tempKbase,&pos);
2522  if (pos>=0)
2523  {
2524  MATELEM(result,(*convert)[pos],k+1) =
2525  pAdd(MATELEM(result,(*convert)[pos],k+1),q);
2526  }
2527  else
2528  p_Delete(&q,currRing);
2529  pIter(p);
2530  }
2531  }
2532  idDelete(&tempKbase);
2533  return result;
2534 }
int j
Definition: facHensel.cc:105
#define pAdd(p, q)
Definition: polys.h:198
poly idDecompose(poly monom, poly how, ideal kbase, int *pos)
Definition: ideals.cc:2465
#define idDelete(H)
delete an ideal
Definition: ideals.h:29
int k
Definition: cfEzgcd.cc:92
#define pIter(p)
Definition: monomials.h:37
Definition: intvec.h:19
int i
Definition: cfEzgcd.cc:125
ideal idCreateSpecialKbase(ideal kBase, intvec **convert)
Definition: ideals.cc:2411
#define IDELEMS(i)
Definition: simpleideals.h:23
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:37
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:856
#define NULL
Definition: omList.c:12
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
int p
Definition: cfModGcd.cc:4019
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
return result
Definition: facAbsBiFact.cc:76
#define MATELEM(mat, i, j)
1-based access to matrix
Definition: matpol.h:29

◆ idCopy()

ideal idCopy ( ideal  A)
inline

Definition at line 60 of file ideals.h.

61 {
62  return id_Copy(A, currRing);
63 }
ideal id_Copy(ideal h1, const ring r)
copy an ideal
#define A
Definition: sirandom.c:23
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12

◆ idCopyFirstK()

static ideal idCopyFirstK ( const ideal  ide,
const int  k 
)
inlinestatic

Definition at line 20 of file ideals.h.

21 {
22  return id_CopyFirstK(ide, k, currRing);
23 }
int k
Definition: cfEzgcd.cc:92
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
ideal id_CopyFirstK(const ideal ide, const int k, const ring r)
copies the first k (>= 1) entries of the given ideal/module and returns these as a new ideal/module (...

◆ idDelEquals()

void idDelEquals ( ideal  id)

Definition at line 2832 of file ideals.cc.

2833 {
2834  int idsize = IDELEMS(id);
2835  poly_sort *id_sort = (poly_sort *)omAlloc0(idsize*sizeof(poly_sort));
2836  for (int i = 0; i < idsize; i++)
2837  {
2838  id_sort[i].p = id->m[i];
2839  id_sort[i].index = i;
2840  }
2841  idSort_qsort(id_sort, idsize);
2842  int index, index_i, index_j;
2843  int i = 0;
2844  for (int j = 1; j < idsize; j++)
2845  {
2846  if (id_sort[i].p != NULL && pEqualPolys(id_sort[i].p, id_sort[j].p))
2847  {
2848  index_i = id_sort[i].index;
2849  index_j = id_sort[j].index;
2850  if (index_j > index_i)
2851  {
2852  index = index_j;
2853  }
2854  else
2855  {
2856  index = index_i;
2857  i = j;
2858  }
2859  pDelete(&id->m[index]);
2860  }
2861  else
2862  {
2863  i = j;
2864  }
2865  }
2866  omFreeSize((ADDRESS)(id_sort), idsize*sizeof(poly_sort));
2867 }
int j
Definition: facHensel.cc:105
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
void * ADDRESS
Definition: auxiliary.h:133
#define pEqualPolys(p1, p2)
Definition: polys.h:395
int index
Definition: ideals.cc:2815
void idSort_qsort(poly_sort *id_sort, int idsize)
Definition: ideals.cc:2823
int i
Definition: cfEzgcd.cc:125
#define IDELEMS(i)
Definition: simpleideals.h:23
static int index(p_Length length, p_Ord ord)
Definition: p_Procs_Impl.h:592
poly p
Definition: ideals.cc:2814
#define NULL
Definition: omList.c:12
#define pDelete(p_ptr)
Definition: polys.h:181
int p
Definition: cfModGcd.cc:4019
#define omAlloc0(size)
Definition: omAllocDecl.h:211

◆ idDiff()

matrix idDiff ( matrix  i,
int  k 
)

Definition at line 2167 of file ideals.cc.

2168 {
2169  int e=MATCOLS(i)*MATROWS(i);
2170  matrix r=mpNew(MATROWS(i),MATCOLS(i));
2171  r->rank=i->rank;
2172  int j;
2173  for(j=0; j<e; j++)
2174  {
2175  r->m[j]=pDiff(i->m[j],k);
2176  }
2177  return r;
2178 }
int j
Definition: facHensel.cc:105
int k
Definition: cfEzgcd.cc:92
poly * m
Definition: matpol.h:18
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:37
#define MATCOLS(i)
Definition: matpol.h:27
#define pDiff(a, b)
Definition: polys.h:291
#define MATROWS(i)
Definition: matpol.h:26
long rank
Definition: matpol.h:19

◆ idDiffOp()

matrix idDiffOp ( ideal  I,
ideal  J,
BOOLEAN  multiply = TRUE 
)

Definition at line 2180 of file ideals.cc.

2181 {
2182  matrix r=mpNew(IDELEMS(I),IDELEMS(J));
2183  int i,j;
2184  for(i=0; i<IDELEMS(I); i++)
2185  {
2186  for(j=0; j<IDELEMS(J); j++)
2187  {
2188  MATELEM(r,i+1,j+1)=pDiffOp(I->m[i],J->m[j],multiply);
2189  }
2190  }
2191  return r;
2192 }
int j
Definition: facHensel.cc:105
int i
Definition: cfEzgcd.cc:125
#define IDELEMS(i)
Definition: simpleideals.h:23
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:37
#define pDiffOp(a, b, m)
Definition: polys.h:292
#define MATELEM(mat, i, j)
1-based access to matrix
Definition: matpol.h:29

◆ idElimination()

ideal idElimination ( ideal  h1,
poly  delVar,
intvec hilb = NULL,
GbVariant  a = GbDefault 
)

Definition at line 1572 of file ideals.cc.

1573 {
1574  int i,j=0,k,l;
1575  ideal h,hh, h3;
1576  rRingOrder_t *ord;
1577  int *block0,*block1;
1578  int ordersize=2;
1579  int **wv;
1580  tHomog hom;
1581  intvec * w;
1582  ring tmpR;
1583  ring origR = currRing;
1584 
1585  if (delVar==NULL)
1586  {
1587  return idCopy(h1);
1588  }
1589  if ((currRing->qideal!=NULL) && rIsPluralRing(origR))
1590  {
1591  WerrorS("cannot eliminate in a qring");
1592  return NULL;
1593  }
1594  if (idIs0(h1)) return idInit(1,h1->rank);
1595 #ifdef HAVE_PLURAL
1596  if (rIsPluralRing(origR))
1597  /* in the NC case, we have to check the admissibility of */
1598  /* the subalgebra to be intersected with */
1599  {
1600  if ((ncRingType(origR) != nc_skew) && (ncRingType(origR) != nc_exterior)) /* in (quasi)-commutative algebras every subalgebra is admissible */
1601  {
1602  if (nc_CheckSubalgebra(delVar,origR))
1603  {
1604  WerrorS("no elimination is possible: subalgebra is not admissible");
1605  return NULL;
1606  }
1607  }
1608  }
1609 #endif
1610  hom=(tHomog)idHomModule(h1,NULL,&w); //sets w to weight vector or NULL
1611  h3=idInit(16,h1->rank);
1612  for (k=0;; k++)
1613  {
1614  if (origR->order[k]!=0) ordersize++;
1615  else break;
1616  }
1617 #if 0
1618  if (rIsPluralRing(origR)) // we have too keep the odering: it may be needed
1619  // for G-algebra
1620  {
1621  for (k=0;k<ordersize-1; k++)
1622  {
1623  block0[k+1] = origR->block0[k];
1624  block1[k+1] = origR->block1[k];
1625  ord[k+1] = origR->order[k];
1626  if (origR->wvhdl[k]!=NULL) wv[k+1] = (int*) omMemDup(origR->wvhdl[k]);
1627  }
1628  }
1629  else
1630  {
1631  block0[1] = 1;
1632  block1[1] = (currRing->N);
1633  if (origR->OrdSgn==1) ord[1] = ringorder_wp;
1634  else ord[1] = ringorder_ws;
1635  wv[1]=(int*)omAlloc0((currRing->N)*sizeof(int));
1636  double wNsqr = (double)2.0 / (double)(currRing->N);
1638  int *x= (int * )omAlloc(2 * ((currRing->N) + 1) * sizeof(int));
1639  int sl=IDELEMS(h1) - 1;
1640  wCall(h1->m, sl, x, wNsqr);
1641  for (sl = (currRing->N); sl!=0; sl--)
1642  wv[1][sl-1] = x[sl + (currRing->N) + 1];
1643  omFreeSize((ADDRESS)x, 2 * ((currRing->N) + 1) * sizeof(int));
1644 
1645  ord[2]=ringorder_C;
1646  ord[3]=0;
1647  }
1648 #else
1649 #endif
1650  if ((hom==TRUE) && (origR->OrdSgn==1) && (!rIsPluralRing(origR)))
1651  {
1652  #if 1
1653  // we change to an ordering:
1654  // aa(1,1,1,...,0,0,0),wp(...),C
1655  // this seems to be better than version 2 below,
1656  // according to Tst/../elimiate_[3568].tat (- 17 %)
1657  ord=(rRingOrder_t*)omAlloc0(4*sizeof(rRingOrder_t));
1658  block0=(int*)omAlloc0(4*sizeof(int));
1659  block1=(int*)omAlloc0(4*sizeof(int));
1660  wv=(int**) omAlloc0(4*sizeof(int**));
1661  block0[0] = block0[1] = 1;
1662  block1[0] = block1[1] = rVar(origR);
1663  wv[0]=(int*)omAlloc0((rVar(origR) + 1)*sizeof(int));
1664  // use this special ordering: like ringorder_a, except that pFDeg, pWeights
1665  // ignore it
1666  ord[0] = ringorder_aa;
1667  for (j=0;j<rVar(origR);j++)
1668  if (pGetExp(delVar,j+1)!=0) wv[0][j]=1;
1669  BOOLEAN wp=FALSE;
1670  for (j=0;j<rVar(origR);j++)
1671  if (p_Weight(j+1,origR)!=1) { wp=TRUE;break; }
1672  if (wp)
1673  {
1674  wv[1]=(int*)omAlloc0((rVar(origR) + 1)*sizeof(int));
1675  for (j=0;j<rVar(origR);j++)
1676  wv[1][j]=p_Weight(j+1,origR);
1677  ord[1] = ringorder_wp;
1678  }
1679  else
1680  ord[1] = ringorder_dp;
1681  #else
1682  // we change to an ordering:
1683  // a(w1,...wn),wp(1,...0.....),C
1684  ord=(int*)omAlloc0(4*sizeof(int));
1685  block0=(int*)omAlloc0(4*sizeof(int));
1686  block1=(int*)omAlloc0(4*sizeof(int));
1687  wv=(int**) omAlloc0(4*sizeof(int**));
1688  block0[0] = block0[1] = 1;
1689  block1[0] = block1[1] = rVar(origR);
1690  wv[0]=(int*)omAlloc0((rVar(origR) + 1)*sizeof(int));
1691  wv[1]=(int*)omAlloc0((rVar(origR) + 1)*sizeof(int));
1692  ord[0] = ringorder_a;
1693  for (j=0;j<rVar(origR);j++)
1694  wv[0][j]=pWeight(j+1,origR);
1695  ord[1] = ringorder_wp;
1696  for (j=0;j<rVar(origR);j++)
1697  if (pGetExp(delVar,j+1)!=0) wv[1][j]=1;
1698  #endif
1699  ord[2] = ringorder_C;
1700  ord[3] = (rRingOrder_t)0;
1701  }
1702  else
1703  {
1704  // we change to an ordering:
1705  // aa(....),orig_ordering
1706  ord=(rRingOrder_t*)omAlloc0(ordersize*sizeof(rRingOrder_t));
1707  block0=(int*)omAlloc0(ordersize*sizeof(int));
1708  block1=(int*)omAlloc0(ordersize*sizeof(int));
1709  wv=(int**) omAlloc0(ordersize*sizeof(int**));
1710  for (k=0;k<ordersize-1; k++)
1711  {
1712  block0[k+1] = origR->block0[k];
1713  block1[k+1] = origR->block1[k];
1714  ord[k+1] = origR->order[k];
1715  if (origR->wvhdl[k]!=NULL) wv[k+1] = (int*) omMemDup(origR->wvhdl[k]);
1716  }
1717  block0[0] = 1;
1718  block1[0] = rVar(origR);
1719  wv[0]=(int*)omAlloc0((rVar(origR) + 1)*sizeof(int));
1720  for (j=0;j<rVar(origR);j++)
1721  if (pGetExp(delVar,j+1)!=0) wv[0][j]=1;
1722  // use this special ordering: like ringorder_a, except that pFDeg, pWeights
1723  // ignore it
1724  ord[0] = ringorder_aa;
1725  }
1726  // fill in tmp ring to get back the data later on
1727  tmpR = rCopy0(origR,FALSE,FALSE); // qring==NULL
1728  //rUnComplete(tmpR);
1729  tmpR->p_Procs=NULL;
1730  tmpR->order = ord;
1731  tmpR->block0 = block0;
1732  tmpR->block1 = block1;
1733  tmpR->wvhdl = wv;
1734  rComplete(tmpR, 1);
1735 
1736 #ifdef HAVE_PLURAL
1737  /* update nc structure on tmpR */
1738  if (rIsPluralRing(origR))
1739  {
1740  if ( nc_rComplete(origR, tmpR, false) ) // no quotient ideal!
1741  {
1742  WerrorS("no elimination is possible: ordering condition is violated");
1743  // cleanup
1744  rDelete(tmpR);
1745  if (w!=NULL)
1746  delete w;
1747  return NULL;
1748  }
1749  }
1750 #endif
1751  // change into the new ring
1752  //pChangeRing((currRing->N),currRing->OrdSgn,ord,block0,block1,wv);
1753  rChangeCurrRing(tmpR);
1754 
1755  //h = idInit(IDELEMS(h1),h1->rank);
1756  // fetch data from the old ring
1757  //for (k=0;k<IDELEMS(h1);k++) h->m[k] = prCopyR( h1->m[k], origR);
1758  h=idrCopyR(h1,origR,currRing);
1759  if (origR->qideal!=NULL)
1760  {
1761  WarnS("eliminate in q-ring: experimental");
1762  ideal q=idrCopyR(origR->qideal,origR,currRing);
1763  ideal s=idSimpleAdd(h,q);
1764  idDelete(&h);
1765  idDelete(&q);
1766  h=s;
1767  }
1768  // compute kStd
1769 #if 1
1770  //rWrite(tmpR);PrintLn();
1771  //BITSET save1;
1772  //SI_SAVE_OPT1(save1);
1773  //si_opt_1 |=1;
1774  //Print("h: %d gen, rk=%d\n",IDELEMS(h),h->rank);
1775  //extern char * showOption();
1776  //Print("%s\n",showOption());
1777  if (alg==GbDefault) alg=GbStd;
1778  if (alg==GbStd)
1779  {
1780  if (TEST_OPT_PROT) { PrintS("std:"); mflush(); }
1781  hh = kStd(h,NULL,hom,&w,hilb);
1782  }
1783  else if (alg==GbSlimgb)
1784  {
1785  if (TEST_OPT_PROT) { PrintS("slimgb:"); mflush(); }
1786  hh = t_rep_gb(currRing, h, 0);
1787  }
1788  else if (alg==GbGroebner)
1789  {
1790  if (TEST_OPT_PROT) { PrintS("groebner:"); mflush(); }
1791  BOOLEAN err;
1792  hh=(ideal)iiCallLibProc1("groebner",idCopy(h),MODUL_CMD,err);
1793  if (err)
1794  {
1795  Werror("error %d in >>groebner<<",err);
1796  hh=idInit(1,1);
1797  }
1798  }
1799  else if (alg==GbModstd)
1800  {
1801  if (TEST_OPT_PROT) { PrintS("modstd:"); mflush(); }
1802  BOOLEAN err;
1803  void *args[]={idCopy(h),(void*)1,NULL};
1804  int arg_t[]={IDEAL_CMD,INT_CMD,0};
1805  hh=(ideal)iiCallLibProcM("modStd",args,arg_t,err);
1806  if (err)
1807  {
1808  Werror("error %d in >>modStd<<",err);
1809  hh=idInit(1,1);
1810  }
1811  }
1812  else if (alg==GbSba)
1813  {
1814  if (TEST_OPT_PROT) { PrintS("sba:"); mflush(); }
1815  hh = kSba(h,currRing->qideal,hom,&w,1,0,NULL);
1816  }
1817  else
1818  {
1819  hh=idInit(1,1);
1820  Werror("wrong algorithm %d for SB",(int)alg);
1821  }
1822  //SI_RESTORE_OPT1(save1);
1823  idDelete(&h);
1824 #else
1825  extern ideal kGroebner(ideal F, ideal Q);
1826  hh=kGroebner(h,NULL);
1827 #endif
1828  // go back to the original ring
1829  rChangeCurrRing(origR);
1830  i = IDELEMS(hh)-1;
1831  while ((i >= 0) && (hh->m[i] == NULL)) i--;
1832  j = -1;
1833  // fetch data from temp ring
1834  for (k=0; k<=i; k++)
1835  {
1836  l=(currRing->N);
1837  while ((l>0) && (p_GetExp( hh->m[k],l,tmpR)*pGetExp(delVar,l)==0)) l--;
1838  if (l==0)
1839  {
1840  j++;
1841  if (j >= IDELEMS(h3))
1842  {
1843  pEnlargeSet(&(h3->m),IDELEMS(h3),16);
1844  IDELEMS(h3) += 16;
1845  }
1846  h3->m[j] = prMoveR( hh->m[k], tmpR,origR);
1847  hh->m[k] = NULL;
1848  }
1849  }
1850  id_Delete(&hh, tmpR);
1851  idSkipZeroes(h3);
1852  rDelete(tmpR);
1853  if (w!=NULL)
1854  delete w;
1855  return h3;
1856 }
for idElimination, like a, except pFDeg, pWeigths ignore it
Definition: ring.h:91
const CanonicalForm int s
Definition: facAbsFact.cc:55
int j
Definition: facHensel.cc:105
#define omMemDup(s)
Definition: omAllocDecl.h:264
Definition: tok.h:96
#define idDelete(H)
delete an ideal
Definition: ideals.h:29
#define TEST_OPT_PROT
Definition: options.h:102
#define FALSE
Definition: auxiliary.h:94
ideal kSba(ideal F, ideal Q, tHomog h, intvec **w, int sbaOrder, int arri, intvec *hilb, int syzComp, int newIdeal, intvec *vw)
Definition: kstd1.cc:2273
BOOLEAN nc_rComplete(const ring src, ring dest, bool bSetupQuotient)
Definition: ring.cc:5563
poly prMoveR(poly &p, ring src_r, ring dest_r)
Definition: prCopy.cc:89
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
#define idSimpleAdd(A, B)
Definition: ideals.h:42
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:586
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
#define TRUE
Definition: auxiliary.h:98
ideal kStd(ideal F, ideal Q, tHomog h, intvec **w, intvec *hilb, int syzComp, int newIdeal, intvec *vw, s_poly_proc_t sp)
Definition: kstd1.cc:2088
void * ADDRESS
Definition: auxiliary.h:133
void WerrorS(const char *s)
Definition: feFopen.cc:24
int k
Definition: cfEzgcd.cc:92
#define Q
Definition: sirandom.c:25
#define WarnS
Definition: emacs.cc:78
#define omAlloc(size)
Definition: omAllocDecl.h:210
void * iiCallLibProc1(const char *n, void *arg, int arg_type, BOOLEAN &err)
Definition: iplib.cc:612
#define mflush()
Definition: reporter.h:57
static BOOLEAN idHomModule(ideal m, ideal Q, intvec **w)
Definition: ideals.h:96
int p_Weight(int i, const ring r)
Definition: p_polys.cc:695
#define pGetExp(p, i)
Exponent.
Definition: polys.h:41
Definition: intvec.h:19
BOOLEAN rComplete(ring r, int force)
this needs to be called whenever a new ring is created: new fields in ring are created (like VarOffse...
Definition: ring.cc:3394
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent : the integer VarOffset encodes:
Definition: p_polys.h:468
tHomog
Definition: structs.h:39
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
Definition: ring.h:397
double(* wFunctional)(int *degw, int *lpol, int npol, double *rel, double wx, double wNsqr)
Definition: weight.cc:20
ring rCopy0(const ring r, BOOLEAN copy_qideal, BOOLEAN copy_ordering)
Definition: ring.cc:1365
ideal t_rep_gb(const ring r, ideal arg_I, int syz_comp, BOOLEAN F4_mode)
Definition: tgb.cc:3520
rRingOrder_t
order stuff
Definition: ring.h:67
int i
Definition: cfEzgcd.cc:125
Definition: nc.h:16
void PrintS(const char *s)
Definition: reporter.cc:284
Definition: ideals.h:124
#define IDELEMS(i)
Definition: simpleideals.h:23
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
ideal idCopy(ideal A)
Definition: ideals.h:60
void rChangeCurrRing(ring r)
Definition: polys.cc:14
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:35
Definition: nc.h:21
void * iiCallLibProcM(const char *n, void **args, int *arg_types, BOOLEAN &err)
args: NULL terminated arry of arguments arg_types: 0 terminated array of corresponding types ...
Definition: iplib.cc:646
#define NULL
Definition: omList.c:12
void pEnlargeSet(poly **p, int l, int increment)
Definition: p_polys.cc:3656
void wCall(poly *s, int sl, int *x, double wNsqr, const ring R)
Definition: weight.cc:108
void rDelete(ring r)
unconditionally deletes fields in r
Definition: ring.cc:448
const CanonicalForm & w
Definition: facAbsFact.cc:55
Variable x
Definition: cfModGcd.cc:4023
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
ideal idrCopyR(ideal id, ring src_r, ring dest_r)
Definition: prCopy.cc:191
static nc_type & ncRingType(nc_struct *p)
Definition: nc.h:159
BOOLEAN nc_CheckSubalgebra(poly PolyVar, ring r)
Definition: old.gring.cc:2568
static Poly * h
Definition: janet.cc:971
int BOOLEAN
Definition: auxiliary.h:85
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
void Werror(const char *fmt,...)
Definition: reporter.cc:189
ideal kGroebner(ideal F, ideal Q)
Definition: ipshell.cc:6231
Definition: ideals.h:122
#define omAlloc0(size)
Definition: omAllocDecl.h:211
int l
Definition: cfEzgcd.cc:93
double wFunctionalBuch(int *degw, int *lpol, int npol, double *rel, double wx, double wNsqr)
Definition: weight0.c:78
#define pWeight(i)
Definition: polys.h:275

◆ idFreeModule()

ideal idFreeModule ( int  i)
inline

Definition at line 111 of file ideals.h.

112 {
113  return id_FreeModule (i, currRing);
114 }
ideal id_FreeModule(int i, const ring r)
the free module of rank i
int i
Definition: cfEzgcd.cc:125
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12

◆ idGetNextChoise()

void idGetNextChoise ( int  r,
int  end,
BOOLEAN endch,
int *  choise 
)

Definition at line 864 of file simpleideals.cc.

865 {
866  int i = r-1,j;
867  while ((i >= 0) && (choise[i] == end))
868  {
869  i--;
870  end--;
871  }
872  if (i == -1)
873  *endch = TRUE;
874  else
875  {
876  choise[i]++;
877  for (j=i+1; j<r; j++)
878  {
879  choise[j] = choise[i]+j-i;
880  }
881  *endch = FALSE;
882  }
883 }
int j
Definition: facHensel.cc:105
#define FALSE
Definition: auxiliary.h:94
#define TRUE
Definition: auxiliary.h:98
int i
Definition: cfEzgcd.cc:125

◆ idGetNumberOfChoise()

int idGetNumberOfChoise ( int  t,
int  d,
int  begin,
int  end,
int *  choise 
)

Definition at line 890 of file simpleideals.cc.

891 {
892  int * localchoise,i,result=0;
893  BOOLEAN b=FALSE;
894 
895  if (d<=1) return 1;
896  localchoise=(int*)omAlloc((d-1)*sizeof(int));
897  idInitChoise(d-1,begin,end,&b,localchoise);
898  while (!b)
899  {
900  result++;
901  i = 0;
902  while ((i<t) && (localchoise[i]==choise[i])) i++;
903  if (i>=t)
904  {
905  i = t+1;
906  while ((i<d) && (localchoise[i-1]==choise[i])) i++;
907  if (i>=d)
908  {
909  omFreeSize((ADDRESS)localchoise,(d-1)*sizeof(int));
910  return result;
911  }
912  }
913  idGetNextChoise(d-1,end,&b,localchoise);
914  }
915  omFreeSize((ADDRESS)localchoise,(d-1)*sizeof(int));
916  return 0;
917 }
#define FALSE
Definition: auxiliary.h:94
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
void * ADDRESS
Definition: auxiliary.h:133
#define omAlloc(size)
Definition: omAllocDecl.h:210
CanonicalForm b
Definition: cfModGcd.cc:4044
int i
Definition: cfEzgcd.cc:125
void idGetNextChoise(int r, int end, BOOLEAN *endch, int *choise)
void idInitChoise(int r, int beg, int end, BOOLEAN *endch, int *choise)
int BOOLEAN
Definition: auxiliary.h:85
return result
Definition: facAbsBiFact.cc:76

◆ idHead()

ideal idHead ( ideal  h)

◆ idHomIdeal()

static BOOLEAN idHomIdeal ( ideal  id,
ideal  Q = NULL 
)
inlinestatic

Definition at line 91 of file ideals.h.

92 {
93  return id_HomIdeal(id, Q, currRing);
94 }
BOOLEAN id_HomIdeal(ideal id, ideal Q, const ring r)
#define Q
Definition: sirandom.c:25
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12

◆ idHomModule()

static BOOLEAN idHomModule ( ideal  m,
ideal  Q,
intvec **  w 
)
inlinestatic

Definition at line 96 of file ideals.h.

97 {
98  return id_HomModule(m, Q, w, currRing);
99 }
BOOLEAN id_HomModule(ideal m, ideal Q, intvec **w, const ring R)
#define Q
Definition: sirandom.c:25
int m
Definition: cfEzgcd.cc:121
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12

◆ idInitChoise()

void idInitChoise ( int  r,
int  beg,
int  end,
BOOLEAN endch,
int *  choise 
)

Definition at line 842 of file simpleideals.cc.

843 {
844  /*returns the first choise of r numbers between beg and end*/
845  int i;
846  for (i=0; i<r; i++)
847  {
848  choise[i] = 0;
849  }
850  if (r <= end-beg+1)
851  for (i=0; i<r; i++)
852  {
853  choise[i] = beg+i;
854  }
855  if (r > end-beg+1)
856  *endch = TRUE;
857  else
858  *endch = FALSE;
859 }
#define FALSE
Definition: auxiliary.h:94
#define TRUE
Definition: auxiliary.h:98
int i
Definition: cfEzgcd.cc:125

◆ idInsertPoly()

BOOLEAN idInsertPoly ( ideal  h1,
poly  h2 
)

insert h2 into h1 (if h2 is not the zero polynomial) return TRUE iff h2 was indeed inserted

Definition at line 649 of file simpleideals.cc.

650 {
651  if (h2==NULL) return FALSE;
652  assume (h1 != NULL);
653 
654  int j = IDELEMS(h1) - 1;
655 
656  while ((j >= 0) && (h1->m[j] == NULL)) j--;
657  j++;
658  if (j==IDELEMS(h1))
659  {
660  pEnlargeSet(&(h1->m),IDELEMS(h1),16);
661  IDELEMS(h1)+=16;
662  }
663  h1->m[j]=h2;
664  return TRUE;
665 }
int j
Definition: facHensel.cc:105
#define FALSE
Definition: auxiliary.h:94
#define TRUE
Definition: auxiliary.h:98
#define assume(x)
Definition: mod2.h:390
#define IDELEMS(i)
Definition: simpleideals.h:23
#define NULL
Definition: omList.c:12
void pEnlargeSet(poly **p, int l, int increment)
Definition: p_polys.cc:3656

◆ idInsertPolyOnPos()

BOOLEAN idInsertPolyOnPos ( ideal  I,
poly  p,
int  pos 
)

insert p into I on position pos

Definition at line 668 of file simpleideals.cc.

669 {
670  if (p==NULL) return FALSE;
671  assume (I != NULL);
672 
673  int j = IDELEMS(I) - 1;
674 
675  while ((j >= 0) && (I->m[j] == NULL)) j--;
676  j++;
677  if (j==IDELEMS(I))
678  {
679  pEnlargeSet(&(I->m),IDELEMS(I),IDELEMS(I)+1);
680  IDELEMS(I)+=1;
681  }
682  for(j = IDELEMS(I)-1;j>pos;j--)
683  I->m[j] = I->m[j-1];
684  I->m[pos]=p;
685  return TRUE;
686 }
int j
Definition: facHensel.cc:105
#define FALSE
Definition: auxiliary.h:94
#define TRUE
Definition: auxiliary.h:98
#define assume(x)
Definition: mod2.h:390
#define IDELEMS(i)
Definition: simpleideals.h:23
#define NULL
Definition: omList.c:12
void pEnlargeSet(poly **p, int l, int increment)
Definition: p_polys.cc:3656
int p
Definition: cfModGcd.cc:4019

◆ idInsertPolyWithTests()

BOOLEAN idInsertPolyWithTests ( ideal  h1,
const int  validEntries,
const poly  h2,
const bool  zeroOk,
const bool  duplicateOk 
)
inline

Definition at line 75 of file ideals.h.

76 {
77  return id_InsertPolyWithTests (h1, validEntries, h2, zeroOk, duplicateOk, currRing);
78 }
BOOLEAN id_InsertPolyWithTests(ideal h1, const int validEntries, const poly h2, const bool zeroOk, const bool duplicateOk, const ring r)
insert h2 into h1 depending on the two boolean parameters:
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12

◆ idIs0()

BOOLEAN idIs0 ( ideal  h)

returns true if h is the zero ideal

Definition at line 777 of file simpleideals.cc.

778 {
779  assume (h != NULL); // will fail :(
780 // if (h == NULL) return TRUE;
781 
782  for( int i = IDELEMS(h)-1; i >= 0; i-- )
783  if(h->m[i] != NULL)
784  return FALSE;
785 
786  return TRUE;
787 
788 }
#define FALSE
Definition: auxiliary.h:94
#define TRUE
Definition: auxiliary.h:98
#define assume(x)
Definition: mod2.h:390
int i
Definition: cfEzgcd.cc:125
#define IDELEMS(i)
Definition: simpleideals.h:23
#define NULL
Definition: omList.c:12
static Poly * h
Definition: janet.cc:971

◆ idIsSubModule()

BOOLEAN idIsSubModule ( ideal  id1,
ideal  id2 
)

Definition at line 2077 of file ideals.cc.

2078 {
2079  int i;
2080  poly p;
2081 
2082  if (idIs0(id1)) return TRUE;
2083  for (i=0;i<IDELEMS(id1);i++)
2084  {
2085  if (id1->m[i] != NULL)
2086  {
2087  p = kNF(id2,currRing->qideal,id1->m[i]);
2088  if (p != NULL)
2089  {
2090  p_Delete(&p,currRing);
2091  return FALSE;
2092  }
2093  }
2094  }
2095  return TRUE;
2096 }
poly kNF(ideal F, ideal Q, poly p, int syzComp, int lazyReduce)
Definition: kstd1.cc:2822
#define FALSE
Definition: auxiliary.h:94
#define TRUE
Definition: auxiliary.h:98
int i
Definition: cfEzgcd.cc:125
#define IDELEMS(i)
Definition: simpleideals.h:23
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:856
#define NULL
Definition: omList.c:12
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
int p
Definition: cfModGcd.cc:4019
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal

◆ idIsZeroDim()

static BOOLEAN idIsZeroDim ( ideal  i)
inlinestatic

Definition at line 178 of file ideals.h.

179 {
180  return id_IsZeroDim(i, currRing);
181 }
int i
Definition: cfEzgcd.cc:125
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
BOOLEAN id_IsZeroDim(ideal I, const ring r)

◆ idKeepFirstK()

void idKeepFirstK ( ideal  ide,
const int  k 
)

keeps the first k (>= 1) entries of the given ideal (Note that the kept polynomials may be zero.)

Definition at line 2800 of file ideals.cc.

2801 {
2802  for (int i = IDELEMS(id)-1; i >= k; i--)
2803  {
2804  if (id->m[i] != NULL) pDelete(&id->m[i]);
2805  }
2806  int kk=k;
2807  if (k==0) kk=1; /* ideals must have at least one element(0)*/
2808  pEnlargeSet(&(id->m), IDELEMS(id), kk-IDELEMS(id));
2809  IDELEMS(id) = kk;
2810 }
int k
Definition: cfEzgcd.cc:92
int i
Definition: cfEzgcd.cc:125
#define IDELEMS(i)
Definition: simpleideals.h:23
#define NULL
Definition: omList.c:12
void pEnlargeSet(poly **p, int l, int increment)
Definition: p_polys.cc:3656
#define pDelete(p_ptr)
Definition: polys.h:181

◆ idLift()

ideal idLift ( ideal  mod,
ideal  sumod,
ideal *  rest = NULL,
BOOLEAN  goodShape = FALSE,
BOOLEAN  isSB = TRUE,
BOOLEAN  divide = FALSE,
matrix unit = NULL,
GbVariant  a = GbDefault 
)

Definition at line 1111 of file ideals.cc.

1113 {
1114  int lsmod =id_RankFreeModule(submod,currRing), j, k;
1115  int comps_to_add=0;
1116  poly p;
1117 
1118  if (idIs0(submod))
1119  {
1120  if (unit!=NULL)
1121  {
1122  *unit=mpNew(1,1);
1123  MATELEM(*unit,1,1)=pOne();
1124  }
1125  if (rest!=NULL)
1126  {
1127  *rest=idInit(1,mod->rank);
1128  }
1129  return idInit(1,mod->rank);
1130  }
1131  if (idIs0(mod)) /* and not idIs0(submod) */
1132  {
1133  WerrorS("2nd module does not lie in the first");
1134  return NULL;
1135  }
1136  if (unit!=NULL)
1137  {
1138  comps_to_add = IDELEMS(submod);
1139  while ((comps_to_add>0) && (submod->m[comps_to_add-1]==NULL))
1140  comps_to_add--;
1141  }
1143  if ((k!=0) && (lsmod==0)) lsmod=1;
1144  k=si_max(k,(int)mod->rank);
1145  if (k<submod->rank) { WarnS("rk(submod) > rk(mod) ?");k=submod->rank; }
1146 
1147  ring orig_ring=currRing;
1148  ring syz_ring=rAssure_SyzOrder(orig_ring,TRUE);
1149  rSetSyzComp(k,syz_ring);
1150  rChangeCurrRing(syz_ring);
1151 
1152  ideal s_mod, s_temp;
1153  if (orig_ring != syz_ring)
1154  {
1155  s_mod = idrCopyR_NoSort(mod,orig_ring,syz_ring);
1156  s_temp = idrCopyR_NoSort(submod,orig_ring,syz_ring);
1157  }
1158  else
1159  {
1160  s_mod = mod;
1161  s_temp = idCopy(submod);
1162  }
1163  ideal s_h3;
1164  if (isSB)
1165  {
1166  s_h3 = idCopy(s_mod);
1167  idPrepareStd(s_h3, k+comps_to_add);
1168  }
1169  else
1170  {
1171  s_h3 = idPrepare(s_mod,(tHomog)FALSE,k+comps_to_add,NULL,alg);
1172  }
1173  if (!goodShape)
1174  {
1175  for (j=0;j<IDELEMS(s_h3);j++)
1176  {
1177  if ((s_h3->m[j] != NULL) && (pMinComp(s_h3->m[j]) > k))
1178  p_Delete(&(s_h3->m[j]),currRing);
1179  }
1180  }
1181  idSkipZeroes(s_h3);
1182  if (lsmod==0)
1183  {
1184  id_Shift(s_temp,1,currRing);
1185  }
1186  if (unit!=NULL)
1187  {
1188  for(j = 0;j<comps_to_add;j++)
1189  {
1190  p = s_temp->m[j];
1191  if (p!=NULL)
1192  {
1193  while (pNext(p)!=NULL) pIter(p);
1194  pNext(p) = pOne();
1195  pIter(p);
1196  pSetComp(p,1+j+k);
1197  pSetmComp(p);
1198  p = pNeg(p);
1199  }
1200  }
1201  s_temp->rank += (k+comps_to_add);
1202  }
1203  ideal s_result = kNF(s_h3,currRing->qideal,s_temp,k);
1204  s_result->rank = s_h3->rank;
1205  ideal s_rest = idInit(IDELEMS(s_result),k);
1206  idDelete(&s_h3);
1207  idDelete(&s_temp);
1208 
1209  for (j=0;j<IDELEMS(s_result);j++)
1210  {
1211  if (s_result->m[j]!=NULL)
1212  {
1213  if (pGetComp(s_result->m[j])<=k)
1214  {
1215  if (!divide)
1216  {
1217  if (isSB)
1218  {
1219  WarnS("first module not a standardbasis\n"
1220  "// ** or second not a proper submodule");
1221  }
1222  else
1223  WerrorS("2nd module does not lie in the first");
1224  idDelete(&s_result);
1225  idDelete(&s_rest);
1226  s_result=idInit(IDELEMS(submod),submod->rank);
1227  break;
1228  }
1229  else
1230  {
1231  p = s_rest->m[j] = s_result->m[j];
1232  while ((pNext(p)!=NULL) && (pGetComp(pNext(p))<=k)) pIter(p);
1233  s_result->m[j] = pNext(p);
1234  pNext(p) = NULL;
1235  }
1236  }
1237  p_Shift(&(s_result->m[j]),-k,currRing);
1238  pNeg(s_result->m[j]);
1239  }
1240  }
1241  if ((lsmod==0) && (s_rest!=NULL))
1242  {
1243  for (j=IDELEMS(s_rest);j>0;j--)
1244  {
1245  if (s_rest->m[j-1]!=NULL)
1246  {
1247  p_Shift(&(s_rest->m[j-1]),-1,currRing);
1248  s_rest->m[j-1] = s_rest->m[j-1];
1249  }
1250  }
1251  }
1252  if(syz_ring!=orig_ring)
1253  {
1254  idDelete(&s_mod);
1255  rChangeCurrRing(orig_ring);
1256  s_result = idrMoveR_NoSort(s_result, syz_ring, orig_ring);
1257  s_rest = idrMoveR_NoSort(s_rest, syz_ring, orig_ring);
1258  rDelete(syz_ring);
1259  }
1260  if (rest!=NULL)
1261  *rest = s_rest;
1262  else
1263  idDelete(&s_rest);
1264 //idPrint(s_result);
1265  if (unit!=NULL)
1266  {
1267  *unit=mpNew(comps_to_add,comps_to_add);
1268  int i;
1269  for(i=0;i<IDELEMS(s_result);i++)
1270  {
1271  poly p=s_result->m[i];
1272  poly q=NULL;
1273  while(p!=NULL)
1274  {
1275  if(pGetComp(p)<=comps_to_add)
1276  {
1277  pSetComp(p,0);
1278  if (q!=NULL)
1279  {
1280  pNext(q)=pNext(p);
1281  }
1282  else
1283  {
1284  pIter(s_result->m[i]);
1285  }
1286  pNext(p)=NULL;
1287  MATELEM(*unit,i+1,i+1)=pAdd(MATELEM(*unit,i+1,i+1),p);
1288  if(q!=NULL) p=pNext(q);
1289  else p=s_result->m[i];
1290  }
1291  else
1292  {
1293  q=p;
1294  pIter(p);
1295  }
1296  }
1297  p_Shift(&s_result->m[i],-comps_to_add,currRing);
1298  }
1299  }
1300  return s_result;
1301 }
#define pSetmComp(p)
TODO:
Definition: polys.h:268
int j
Definition: facHensel.cc:105
poly kNF(ideal F, ideal Q, poly p, int syzComp, int lazyReduce)
Definition: kstd1.cc:2822
static ideal idPrepare(ideal h1, tHomog hom, int syzcomp, intvec **w, GbVariant alg)
Definition: ideals.cc:580
static void idPrepareStd(ideal s_temp, int k)
Definition: ideals.cc:1077
#define pAdd(p, q)
Definition: polys.h:198
CF_NO_INLINE CanonicalForm mod(const CanonicalForm &, const CanonicalForm &)
Definition: cf_inline.cc:564
#define idDelete(H)
delete an ideal
Definition: ideals.h:29
#define FALSE
Definition: auxiliary.h:94
#define pNeg(p)
Definition: polys.h:193
CanonicalForm divide(const CanonicalForm &ff, const CanonicalForm &f, const CFList &as)
#define TRUE
Definition: auxiliary.h:98
ring rAssure_SyzOrder(const ring r, BOOLEAN complete)
Definition: ring.cc:4387
void WerrorS(const char *s)
Definition: feFopen.cc:24
int k
Definition: cfEzgcd.cc:92
#define WarnS
Definition: emacs.cc:78
#define pMinComp(p)
Definition: polys.h:295
#define pGetComp(p)
Component.
Definition: polys.h:37
#define pIter(p)
Definition: monomials.h:37
void id_Shift(ideal M, int s, const ring r)
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s
tHomog
Definition: structs.h:39
#define pSetComp(p, v)
Definition: polys.h:38
static int si_max(const int a, const int b)
Definition: auxiliary.h:138
int i
Definition: cfEzgcd.cc:125
#define pOne()
Definition: polys.h:310
#define IDELEMS(i)
Definition: simpleideals.h:23
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
ideal idCopy(ideal A)
Definition: ideals.h:60
void rSetSyzComp(int k, const ring r)
Definition: ring.cc:5016
void rChangeCurrRing(ring r)
Definition: polys.cc:14
void p_Shift(poly *p, int i, const ring r)
shifts components of the vector p by i
Definition: p_polys.cc:4612
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:37
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:856
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:35
#define NULL
Definition: omList.c:12
void rDelete(ring r)
unconditionally deletes fields in r
Definition: ring.cc:448
#define pNext(p)
Definition: monomials.h:36
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
int p
Definition: cfModGcd.cc:4019
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
ideal idrCopyR_NoSort(ideal id, ring src_r, ring dest_r)
Definition: prCopy.cc:204
ideal idrMoveR_NoSort(ideal &id, ring src_r, ring dest_r)
Definition: prCopy.cc:260
#define MATELEM(mat, i, j)
1-based access to matrix
Definition: matpol.h:29

◆ idLiftStd()

ideal idLiftStd ( ideal  h1,
matrix m,
tHomog  h = testHomog,
ideal *  syz = NULL,
GbVariant  a = GbDefault 
)

Definition at line 923 of file ideals.cc.

924 {
925  int i, j, t, inputIsIdeal=id_RankFreeModule(h1,currRing);
926  long k;
927  poly p=NULL, q;
928  intvec *w=NULL;
929 
930  idDelete((ideal*)ma);
931  BOOLEAN lift3=FALSE;
932  if (syz!=NULL) { lift3=TRUE; idDelete(syz); }
933  if (idIs0(h1))
934  {
935  *ma=mpNew(1,0);
936  if (lift3)
937  {
938  *syz=idFreeModule(IDELEMS(h1));
939  }
940  return idInit(1,h1->rank);
941  }
942 
943  BITSET save2;
944  SI_SAVE_OPT2(save2);
945 
947 
948  if ((k==1) && (!lift3)) si_opt_2 |=Sy_bit(V_IDLIFT);
949 
950  ring orig_ring = currRing;
951  ring syz_ring = rAssure_SyzOrder(orig_ring,TRUE);
952  rSetSyzComp(k,syz_ring);
953  rChangeCurrRing(syz_ring);
954 
955  ideal s_h1=h1;
956 
957  if (orig_ring != syz_ring)
958  s_h1 = idrCopyR_NoSort(h1,orig_ring,syz_ring);
959  else
960  s_h1 = h1;
961 
962  ideal s_h3=idPrepare(s_h1,hi,k,&w,alg); // main (syz) GB computation
963 
964  ideal s_h2 = idInit(IDELEMS(s_h3), s_h3->rank);
965 
966  if (lift3) (*syz)=idInit(IDELEMS(s_h3),IDELEMS(h1));
967 
968  if (w!=NULL) delete w;
969  i = 0;
970 
971  // now sort the result, SB : leave in s_h3
972  // T: put in s_h2
973  // syz: put in *syz
974  for (j=0; j<IDELEMS(s_h3); j++)
975  {
976  if (s_h3->m[j] != NULL)
977  {
978  //if (p_MinComp(s_h3->m[j],syz_ring) <= k)
979  if (pGetComp(s_h3->m[j]) <= k) // syz_ring == currRing
980  {
981  i++;
982  q = s_h3->m[j];
983  while (pNext(q) != NULL)
984  {
985  if (pGetComp(pNext(q)) > k)
986  {
987  s_h2->m[j] = pNext(q);
988  pNext(q) = NULL;
989  }
990  else
991  {
992  pIter(q);
993  }
994  }
995  if (!inputIsIdeal) p_Shift(&(s_h3->m[j]), -1,currRing);
996  }
997  else
998  {
999  // we a syzygy here:
1000  if (lift3)
1001  {
1002  p_Shift(&s_h3->m[j], -k,currRing);
1003  (*syz)->m[j]=s_h3->m[j];
1004  s_h3->m[j]=NULL;
1005  }
1006  else
1007  p_Delete(&(s_h3->m[j]),currRing);
1008  }
1009  }
1010  }
1011  idSkipZeroes(s_h3);
1012  //extern char * iiStringMatrix(matrix im, int dim,char ch);
1013  //PrintS("SB: ----------------------------------------\n");
1014  //PrintS(iiStringMatrix((matrix)s_h3,k,'\n'));
1015  //PrintLn();
1016  //PrintS("T: ----------------------------------------\n");
1017  //PrintS(iiStringMatrix((matrix)s_h2,h1->rank,'\n'));
1018  //PrintLn();
1019 
1020  if (lift3) idSkipZeroes(*syz);
1021 
1022  j = IDELEMS(s_h1);
1023 
1024 
1025  if (syz_ring!=orig_ring)
1026  {
1027  idDelete(&s_h1);
1028  rChangeCurrRing(orig_ring);
1029  }
1030 
1031  *ma = mpNew(j,i);
1032 
1033  i = 1;
1034  for (j=0; j<IDELEMS(s_h2); j++)
1035  {
1036  if (s_h2->m[j] != NULL)
1037  {
1038  q = prMoveR( s_h2->m[j], syz_ring,orig_ring);
1039  s_h2->m[j] = NULL;
1040 
1041  if (q!=NULL)
1042  {
1043  q=pReverse(q);
1044  while (q != NULL)
1045  {
1046  p = q;
1047  pIter(q);
1048  pNext(p) = NULL;
1049  t=pGetComp(p);
1050  pSetComp(p,0);
1051  pSetmComp(p);
1052  MATELEM(*ma,t-k,i) = pAdd(MATELEM(*ma,t-k,i),p);
1053  }
1054  }
1055  i++;
1056  }
1057  }
1058  idDelete(&s_h2);
1059 
1060  for (i=0; i<IDELEMS(s_h3); i++)
1061  {
1062  s_h3->m[i] = prMoveR_NoSort(s_h3->m[i], syz_ring,orig_ring);
1063  }
1064  if (lift3)
1065  {
1066  for (i=0; i<IDELEMS(*syz); i++)
1067  {
1068  (*syz)->m[i] = prMoveR_NoSort((*syz)->m[i], syz_ring,orig_ring);
1069  }
1070  }
1071 
1072  if (syz_ring!=orig_ring) rDelete(syz_ring);
1073  SI_RESTORE_OPT2(save2);
1074  return s_h3;
1075 }
#define pSetmComp(p)
TODO:
Definition: polys.h:268
int j
Definition: facHensel.cc:105
static ideal idPrepare(ideal h1, tHomog hom, int syzcomp, intvec **w, GbVariant alg)
Definition: ideals.cc:580
#define pAdd(p, q)
Definition: polys.h:198
#define idDelete(H)
delete an ideal
Definition: ideals.h:29
#define FALSE
Definition: auxiliary.h:94
poly prMoveR(poly &p, ring src_r, ring dest_r)
Definition: prCopy.cc:89
#define TRUE
Definition: auxiliary.h:98
ring rAssure_SyzOrder(const ring r, BOOLEAN complete)
Definition: ring.cc:4387
int k
Definition: cfEzgcd.cc:92
#define BITSET
Definition: structs.h:20
#define Sy_bit(x)
Definition: options.h:32
#define pGetComp(p)
Component.
Definition: polys.h:37
#define pIter(p)
Definition: monomials.h:37
Definition: intvec.h:19
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s
ideal idFreeModule(int i)
Definition: ideals.h:111
#define pSetComp(p, v)
Definition: polys.h:38
static int si_max(const int a, const int b)
Definition: auxiliary.h:138
int i
Definition: cfEzgcd.cc:125
#define IDELEMS(i)
Definition: simpleideals.h:23
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
static poly pReverse(poly p)
Definition: p_polys.h:334
void rSetSyzComp(int k, const ring r)
Definition: ring.cc:5016
void rChangeCurrRing(ring r)
Definition: polys.cc:14
void p_Shift(poly *p, int i, const ring r)
shifts components of the vector p by i
Definition: p_polys.cc:4612
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:37
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:856
#define SI_RESTORE_OPT2(A)
Definition: options.h:26
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:35
#define NULL
Definition: omList.c:12
void rDelete(ring r)
unconditionally deletes fields in r
Definition: ring.cc:448
const CanonicalForm & w
Definition: facAbsFact.cc:55
#define pNext(p)
Definition: monomials.h:36
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
poly prMoveR_NoSort(poly &p, ring src_r, ring dest_r)
Definition: prCopy.cc:100
int p
Definition: cfModGcd.cc:4019
unsigned si_opt_2
Definition: options.c:6
int BOOLEAN
Definition: auxiliary.h:85
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
ideal idrCopyR_NoSort(ideal id, ring src_r, ring dest_r)
Definition: prCopy.cc:204
#define V_IDLIFT
Definition: options.h:62
#define MATELEM(mat, i, j)
1-based access to matrix
Definition: matpol.h:29
#define SI_SAVE_OPT2(A)
Definition: options.h:23

◆ idLiftW()

void idLiftW ( ideal  P,
ideal  Q,
int  n,
matrix T,
ideal &  R,
short *  w = NULL 
)

Definition at line 1307 of file ideals.cc.

1308 {
1309  long N=0;
1310  int i;
1311  for(i=IDELEMS(Q)-1;i>=0;i--)
1312  if(w==NULL)
1313  N=si_max(N,p_Deg(Q->m[i],currRing));
1314  else
1315  N=si_max(N,p_DegW(Q->m[i],w,currRing));
1316  N+=n;
1317 
1318  T=mpNew(IDELEMS(Q),IDELEMS(P));
1319  R=idInit(IDELEMS(P),P->rank);
1320 
1321  for(i=IDELEMS(P)-1;i>=0;i--)
1322  {
1323  poly p;
1324  if(w==NULL)
1325  p=ppJet(P->m[i],N);
1326  else
1327  p=ppJetW(P->m[i],N,w);
1328 
1329  int j=IDELEMS(Q)-1;
1330  while(p!=NULL)
1331  {
1332  if(pDivisibleBy(Q->m[j],p))
1333  {
1334  poly p0=p_DivideM(pHead(p),pHead(Q->m[j]),currRing);
1335  if(w==NULL)
1336  p=pJet(pSub(p,ppMult_mm(Q->m[j],p0)),N);
1337  else
1338  p=pJetW(pSub(p,ppMult_mm(Q->m[j],p0)),N,w);
1339  pNormalize(p);
1340  if(((w==NULL)&&(p_Deg(p0,currRing)>n))||((w!=NULL)&&(p_DegW(p0,w,currRing)>n)))
1341  p_Delete(&p0,currRing);
1342  else
1343  MATELEM(T,j+1,i+1)=pAdd(MATELEM(T,j+1,i+1),p0);
1344  j=IDELEMS(Q)-1;
1345  }
1346  else
1347  {
1348  if(j==0)
1349  {
1350  poly p0=p;
1351  pIter(p);
1352  pNext(p0)=NULL;
1353  if(((w==NULL)&&(p_Deg(p0,currRing)>n))
1354  ||((w!=NULL)&&(p_DegW(p0,w,currRing)>n)))
1355  p_Delete(&p0,currRing);
1356  else
1357  R->m[i]=pAdd(R->m[i],p0);
1358  j=IDELEMS(Q)-1;
1359  }
1360  else
1361  j--;
1362  }
1363  }
1364  }
1365 }
int j
Definition: facHensel.cc:105
#define pAdd(p, q)
Definition: polys.h:198
#define ppJet(p, m)
Definition: polys.h:362
#define ppMult_mm(p, m)
Definition: polys.h:196
#define Q
Definition: sirandom.c:25
#define pJetW(p, m, iv)
Definition: polys.h:365
#define pIter(p)
Definition: monomials.h:37
long p_DegW(poly p, const short *w, const ring R)
Definition: p_polys.cc:680
long p_Deg(poly a, const ring r)
Definition: p_polys.cc:577
#define pSub(a, b)
Definition: polys.h:282
const CanonicalForm CFMap CFMap & N
Definition: cfEzgcd.cc:48
#define pJet(p, m)
Definition: polys.h:363
static int si_max(const int a, const int b)
Definition: auxiliary.h:138
int i
Definition: cfEzgcd.cc:125
#define pHead(p)
returns newly allocated copy of Lm(p), coef is copied, next=NULL, p might be NULL ...
Definition: polys.h:67
#define IDELEMS(i)
Definition: simpleideals.h:23
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:37
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:856
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:35
poly p_DivideM(poly a, poly b, const ring r)
Definition: p_polys.cc:1560
#define NULL
Definition: omList.c:12
#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:138
#define R
Definition: sirandom.c:26
const CanonicalForm & w
Definition: facAbsFact.cc:55
#define pNext(p)
Definition: monomials.h:36
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
int p
Definition: cfModGcd.cc:4019
#define ppJetW(p, m, iv)
Definition: polys.h:364
#define MATELEM(mat, i, j)
1-based access to matrix
Definition: matpol.h:29
#define pNormalize(p)
Definition: polys.h:312

◆ idMinBase()

ideal idMinBase ( ideal  h1)

Definition at line 47 of file ideals.cc.

48 {
49  ideal h2, h3,h4,e;
50  int j,k;
51  int i,l,ll;
52  intvec * wth;
53  BOOLEAN homog;
55  {
56  WarnS("minbase applies only to the local or homogeneous case over coefficient fields");
57  e=idCopy(h1);
58  return e;
59  }
60  homog = idHomModule(h1,currRing->qideal,&wth);
62  {
63  if(!homog)
64  {
65  WarnS("minbase applies only to the local or homogeneous case over coefficient fields");
66  e=idCopy(h1);
67  return e;
68  }
69  else
70  {
71  ideal re=kMin_std(h1,currRing->qideal,(tHomog)homog,&wth,h2,NULL,0,3);
72  idDelete(&re);
73  return h2;
74  }
75  }
76  e=idInit(1,h1->rank);
77  if (idIs0(h1))
78  {
79  return e;
80  }
81  pEnlargeSet(&(e->m),IDELEMS(e),15);
82  IDELEMS(e) = 16;
83  h2 = kStd(h1,currRing->qideal,isNotHomog,NULL);
84  h3 = idMaxIdeal(1);
85  h4=idMult(h2,h3);
86  idDelete(&h3);
87  h3=kStd(h4,currRing->qideal,isNotHomog,NULL);
88  k = IDELEMS(h3);
89  while ((k > 0) && (h3->m[k-1] == NULL)) k--;
90  j = -1;
91  l = IDELEMS(h2);
92  while ((l > 0) && (h2->m[l-1] == NULL)) l--;
93  for (i=l-1; i>=0; i--)
94  {
95  if (h2->m[i] != NULL)
96  {
97  ll = 0;
98  while ((ll < k) && ((h3->m[ll] == NULL)
99  || !pDivisibleBy(h3->m[ll],h2->m[i])))
100  ll++;
101  if (ll >= k)
102  {
103  j++;
104  if (j > IDELEMS(e)-1)
105  {
106  pEnlargeSet(&(e->m),IDELEMS(e),16);
107  IDELEMS(e) += 16;
108  }
109  e->m[j] = pCopy(h2->m[i]);
110  }
111  }
112  }
113  idDelete(&h2);
114  idDelete(&h3);
115  idDelete(&h4);
116  if (currRing->qideal!=NULL)
117  {
118  h3=idInit(1,e->rank);
119  h2=kNF(h3,currRing->qideal,e);
120  idDelete(&h3);
121  idDelete(&e);
122  e=h2;
123  }
124  idSkipZeroes(e);
125  return e;
126 }
#define idMaxIdeal(D)
initialise the maximal ideal (at 0)
Definition: ideals.h:33
int j
Definition: facHensel.cc:105
poly kNF(ideal F, ideal Q, poly p, int syzComp, int lazyReduce)
Definition: kstd1.cc:2822
#define idDelete(H)
delete an ideal
Definition: ideals.h:29
ideal kStd(ideal F, ideal Q, tHomog h, intvec **w, intvec *hilb, int syzComp, int newIdeal, intvec *vw, s_poly_proc_t sp)
Definition: kstd1.cc:2088
int k
Definition: cfEzgcd.cc:92
#define WarnS
Definition: emacs.cc:78
static BOOLEAN idHomModule(ideal m, ideal Q, intvec **w)
Definition: ideals.h:96
Definition: intvec.h:19
tHomog
Definition: structs.h:39
int i
Definition: cfEzgcd.cc:125
#define IDELEMS(i)
Definition: simpleideals.h:23
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
ideal idCopy(ideal A)
Definition: ideals.h:60
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:35
static BOOLEAN rField_is_Ring(const ring r)
Definition: ring.h:479
#define NULL
Definition: omList.c:12
#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:138
void pEnlargeSet(poly **p, int l, int increment)
Definition: p_polys.cc:3656
BOOLEAN rHasGlobalOrdering(const ring r)
Definition: ring.h:754
ideal kMin_std(ideal F, ideal Q, tHomog h, intvec **w, ideal &M, intvec *hilb, int syzComp, int reduced)
Definition: kstd1.cc:2673
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
int BOOLEAN
Definition: auxiliary.h:85
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
static ideal idMult(ideal h1, ideal h2)
hh := h1 * h2
Definition: ideals.h:84
int l
Definition: cfEzgcd.cc:93
#define pCopy(p)
return a copy of the poly
Definition: polys.h:180

◆ idMinEmbedding()

ideal idMinEmbedding ( ideal  arg,
BOOLEAN  inPlace = FALSE,
intvec **  w = NULL 
)

Definition at line 2563 of file ideals.cc.

2564 {
2565  if (idIs0(arg)) return idInit(1,arg->rank);
2566  int i,next_gen,next_comp;
2567  ideal res=arg;
2568  if (!inPlace) res = idCopy(arg);
2569  res->rank=si_max(res->rank,id_RankFreeModule(res,currRing));
2570  int *red_comp=(int*)omAlloc((res->rank+1)*sizeof(int));
2571  for (i=res->rank;i>=0;i--) red_comp[i]=i;
2572 
2573  int del=0;
2574  loop
2575  {
2576  next_gen = id_ReadOutPivot(res, &next_comp, currRing);
2577  if (next_gen<0) break;
2578  del++;
2579  syGaussForOne(res,next_gen,next_comp,0,IDELEMS(res));
2580  for(i=next_comp+1;i<=arg->rank;i++) red_comp[i]--;
2581  if ((w !=NULL)&&(*w!=NULL))
2582  {
2583  for(i=next_comp;i<(*w)->length();i++) (**w)[i-1]=(**w)[i];
2584  }
2585  }
2586 
2587  idDeleteComps(res,red_comp,del);
2588  idSkipZeroes(res);
2589  omFree(red_comp);
2590 
2591  if ((w !=NULL)&&(*w!=NULL) &&(del>0))
2592  {
2593  int nl=si_max((*w)->length()-del,1);
2594  intvec *wtmp=new intvec(nl);
2595  for(i=0;i<res->rank;i++) (*wtmp)[i]=(**w)[i];
2596  delete *w;
2597  *w=wtmp;
2598  }
2599  return res;
2600 }
#define loop
Definition: structs.h:80
#define omAlloc(size)
Definition: omAllocDecl.h:210
Definition: intvec.h:19
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s
CanonicalForm res
Definition: facAbsFact.cc:64
#define omFree(addr)
Definition: omAllocDecl.h:261
static int si_max(const int a, const int b)
Definition: auxiliary.h:138
int i
Definition: cfEzgcd.cc:125
#define IDELEMS(i)
Definition: simpleideals.h:23
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
ideal idCopy(ideal A)
Definition: ideals.h:60
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:35
#define NULL
Definition: omList.c:12
static void idDeleteComps(ideal arg, int *red_comp, int del)
Definition: ideals.cc:2536
const CanonicalForm & w
Definition: facAbsFact.cc:55
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
void syGaussForOne(ideal syz, int elnum, int ModComp, int from, int till)
Definition: syz.cc:218
int id_ReadOutPivot(ideal arg, int *comp, const ring r)
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal

◆ idMinors()

ideal idMinors ( matrix  a,
int  ar,
ideal  R = NULL 
)

compute all ar-minors of the matrix a the caller of mpRecMin the elements of the result are not in R (if R!=NULL)

Definition at line 2008 of file ideals.cc.

2009 {
2010 
2011  const ring origR=currRing;
2012  id_Test((ideal)a, origR);
2013 
2014  const int r = a->nrows;
2015  const int c = a->ncols;
2016 
2017  if((ar<=0) || (ar>r) || (ar>c))
2018  {
2019  Werror("%d-th minor, matrix is %dx%d",ar,r,c);
2020  return NULL;
2021  }
2022 
2023  ideal h = id_Matrix2Module(mp_Copy(a,origR),origR);
2024  long bound = sm_ExpBound(h,c,r,ar,origR);
2025  id_Delete(&h, origR);
2026 
2027  ring tmpR = sm_RingChange(origR,bound);
2028 
2029  matrix b = mpNew(r,c);
2030 
2031  for (int i=r*c-1;i>=0;i--)
2032  if (a->m[i] != NULL)
2033  b->m[i] = prCopyR(a->m[i],origR,tmpR);
2034 
2035  id_Test( (ideal)b, tmpR);
2036 
2037  if (R!=NULL)
2038  {
2039  R = idrCopyR(R,origR,tmpR); // TODO: overwrites R? memory leak?
2040  //if (ar>1) // otherwise done in mpMinorToResult
2041  //{
2042  // matrix bb=(matrix)kNF(R,currRing->qideal,(ideal)b);
2043  // bb->rank=b->rank; bb->nrows=b->nrows; bb->ncols=b->ncols;
2044  // idDelete((ideal*)&b); b=bb;
2045  //}
2046  id_Test( R, tmpR);
2047  }
2048 
2049 
2050  ideal result = idInit(32,1);
2051 
2052  int elems = 0;
2053 
2054  if(ar>1)
2055  mp_RecMin(ar-1,result,elems,b,r,c,NULL,R,tmpR);
2056  else
2057  mp_MinorToResult(result,elems,b,r,c,R,tmpR);
2058 
2059  id_Test( (ideal)b, tmpR);
2060 
2061  id_Delete((ideal *)&b, tmpR);
2062 
2063  if (R!=NULL) id_Delete(&R,tmpR);
2064 
2065  idSkipZeroes(result);
2066  rChangeCurrRing(origR);
2067  result = idrMoveR(result,tmpR,origR);
2068  sm_KillModifiedRing(tmpR);
2069  idTest(result);
2070  return result;
2071 }
ring sm_RingChange(const ring origR, long bound)
Definition: sparsmat.cc:258
static CanonicalForm bound(const CFMatrix &M)
Definition: cf_linsys.cc:460
poly prCopyR(poly p, ring src_r, ring dest_r)
Definition: prCopy.cc:34
int ncols
Definition: matpol.h:21
#define id_Test(A, lR)
Definition: simpleideals.h:79
void mp_RecMin(int ar, ideal result, int &elems, matrix a, int lr, int lc, poly barDiv, ideal R, const ring r)
produces recursively the ideal of all arxar-minors of a
Definition: matpol.cc:1603
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
void mp_MinorToResult(ideal result, int &elems, matrix a, int r, int c, ideal R, const ring)
entries of a are minors and go to result (only if not in R)
Definition: matpol.cc:1507
long sm_ExpBound(ideal m, int di, int ra, int t, const ring currRing)
Definition: sparsmat.cc:188
poly * m
Definition: matpol.h:18
CanonicalForm b
Definition: cfModGcd.cc:4044
int nrows
Definition: matpol.h:20
ideal idrMoveR(ideal &id, ring src_r, ring dest_r)
Definition: prCopy.cc:247
int i
Definition: cfEzgcd.cc:125
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
void rChangeCurrRing(ring r)
Definition: polys.cc:14
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:37
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:35
#define NULL
Definition: omList.c:12
void sm_KillModifiedRing(ring r)
Definition: sparsmat.cc:289
#define R
Definition: sirandom.c:26
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
ideal idrCopyR(ideal id, ring src_r, ring dest_r)
Definition: prCopy.cc:191
matrix mp_Copy(matrix a, const ring r)
copies matrix a (from ring r to r)
Definition: matpol.cc:64
static Poly * h
Definition: janet.cc:971
ideal id_Matrix2Module(matrix mat, const ring R)
converts mat to module, destroys mat
void Werror(const char *fmt,...)
Definition: reporter.cc:189
return result
Definition: facAbsBiFact.cc:76
#define idTest(id)
Definition: ideals.h:47

◆ idModulo()

ideal idModulo ( ideal  h1,
ideal  h2,
tHomog  h = testHomog,
intvec **  w = NULL 
)

Definition at line 2252 of file ideals.cc.

2253 {
2254  intvec *wtmp=NULL;
2255 
2256  int i,k,rk,flength=0,slength,length;
2257  poly p,q;
2258 
2259  if (idIs0(h2))
2260  return idFreeModule(si_max(1,h2->ncols));
2261  if (!idIs0(h1))
2262  flength = id_RankFreeModule(h1,currRing);
2263  slength = id_RankFreeModule(h2,currRing);
2264  length = si_max(flength,slength);
2265  if (length==0)
2266  {
2267  length = 1;
2268  }
2269  ideal temp = idInit(IDELEMS(h2),length+IDELEMS(h2));
2270  if ((w!=NULL)&&((*w)!=NULL))
2271  {
2272  //Print("input weights:");(*w)->show(1);PrintLn();
2273  int d;
2274  int k;
2275  wtmp=new intvec(length+IDELEMS(h2));
2276  for (i=0;i<length;i++)
2277  ((*wtmp)[i])=(**w)[i];
2278  for (i=0;i<IDELEMS(h2);i++)
2279  {
2280  poly p=h2->m[i];
2281  if (p!=NULL)
2282  {
2283  d = p_Deg(p,currRing);
2284  k= pGetComp(p);
2285  if (slength>0) k--;
2286  d +=((**w)[k]);
2287  ((*wtmp)[i+length]) = d;
2288  }
2289  }
2290  //Print("weights:");wtmp->show(1);PrintLn();
2291  }
2292  for (i=0;i<IDELEMS(h2);i++)
2293  {
2294  temp->m[i] = pCopy(h2->m[i]);
2295  q = pOne();
2296  pSetComp(q,i+1+length);
2297  pSetmComp(q);
2298  if(temp->m[i]!=NULL)
2299  {
2300  if (slength==0) p_Shift(&(temp->m[i]),1,currRing);
2301  p = temp->m[i];
2302  while (pNext(p)!=NULL) pIter(p);
2303  pNext(p) = q; // will be sorted later correctly
2304  }
2305  else
2306  temp->m[i]=q;
2307  }
2308  rk = k = IDELEMS(h2);
2309  if (!idIs0(h1))
2310  {
2311  pEnlargeSet(&(temp->m),IDELEMS(temp),IDELEMS(h1));
2312  IDELEMS(temp) += IDELEMS(h1);
2313  for (i=0;i<IDELEMS(h1);i++)
2314  {
2315  if (h1->m[i]!=NULL)
2316  {
2317  temp->m[k] = pCopy(h1->m[i]);
2318  if (flength==0) p_Shift(&(temp->m[k]),1,currRing);
2319  k++;
2320  }
2321  }
2322  }
2323 
2324  ring orig_ring=currRing;
2325  ring syz_ring=rAssure_SyzOrder(orig_ring, TRUE);
2326  rSetSyzComp(length,syz_ring);
2327  rChangeCurrRing(syz_ring);
2328  // we can use OPT_RETURN_SB only, if syz_ring==orig_ring,
2329  // therefore we disable OPT_RETURN_SB for modulo:
2330  // (see tr. #701)
2331  //if (TEST_OPT_RETURN_SB)
2332  // rSetSyzComp(IDELEMS(h2)+length, syz_ring);
2333  //else
2334  // rSetSyzComp(length, syz_ring);
2335  ideal s_temp;
2336 
2337  if (syz_ring != orig_ring)
2338  {
2339  s_temp = idrMoveR_NoSort(temp, orig_ring, syz_ring);
2340  }
2341  else
2342  {
2343  s_temp = temp;
2344  }
2345 
2346  idTest(s_temp);
2347  ideal s_temp1 = kStd(s_temp,currRing->qideal,hom,&wtmp,NULL,length);
2348 
2349  //if (wtmp!=NULL) Print("output weights:");wtmp->show(1);PrintLn();
2350  if ((w!=NULL) && (*w !=NULL) && (wtmp!=NULL))
2351  {
2352  delete *w;
2353  *w=new intvec(IDELEMS(h2));
2354  for (i=0;i<IDELEMS(h2);i++)
2355  ((**w)[i])=(*wtmp)[i+length];
2356  }
2357  if (wtmp!=NULL) delete wtmp;
2358 
2359  for (i=0;i<IDELEMS(s_temp1);i++)
2360  {
2361  if ((s_temp1->m[i]!=NULL)
2362  && (((int)pGetComp(s_temp1->m[i]))<=length))
2363  {
2364  p_Delete(&(s_temp1->m[i]),currRing);
2365  }
2366  else
2367  {
2368  p_Shift(&(s_temp1->m[i]),-length,currRing);
2369  }
2370  }
2371  s_temp1->rank = rk;
2372  idSkipZeroes(s_temp1);
2373 
2374  if (syz_ring!=orig_ring)
2375  {
2376  rChangeCurrRing(orig_ring);
2377  s_temp1 = idrMoveR_NoSort(s_temp1, syz_ring, orig_ring);
2378  rDelete(syz_ring);
2379  // Hmm ... here seems to be a memory leak
2380  // However, simply deleting it causes memory trouble
2381  // idDelete(&s_temp);
2382  }
2383  else
2384  {
2385  idDelete(&temp);
2386  }
2387  idTest(s_temp1);
2388  return s_temp1;
2389 }
#define pSetmComp(p)
TODO:
Definition: polys.h:268
#define idDelete(H)
delete an ideal
Definition: ideals.h:29
#define TRUE
Definition: auxiliary.h:98
ring rAssure_SyzOrder(const ring r, BOOLEAN complete)
Definition: ring.cc:4387
ideal kStd(ideal F, ideal Q, tHomog h, intvec **w, intvec *hilb, int syzComp, int newIdeal, intvec *vw, s_poly_proc_t sp)
Definition: kstd1.cc:2088
int k
Definition: cfEzgcd.cc:92
#define pGetComp(p)
Component.
Definition: polys.h:37
#define pIter(p)
Definition: monomials.h:37
long p_Deg(poly a, const ring r)
Definition: p_polys.cc:577
Definition: intvec.h:19
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s
ideal idFreeModule(int i)
Definition: ideals.h:111
#define pSetComp(p, v)
Definition: polys.h:38
static int si_max(const int a, const int b)
Definition: auxiliary.h:138
int i
Definition: cfEzgcd.cc:125
#define pOne()
Definition: polys.h:310
#define IDELEMS(i)
Definition: simpleideals.h:23
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
void rSetSyzComp(int k, const ring r)
Definition: ring.cc:5016
void rChangeCurrRing(ring r)
Definition: polys.cc:14
void p_Shift(poly *p, int i, const ring r)
shifts components of the vector p by i
Definition: p_polys.cc:4612
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:856
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:35
#define NULL
Definition: omList.c:12
void pEnlargeSet(poly **p, int l, int increment)
Definition: p_polys.cc:3656
void rDelete(ring r)
unconditionally deletes fields in r
Definition: ring.cc:448
static BOOLEAN length(leftv result, leftv arg)
Definition: interval.cc:263
const CanonicalForm & w
Definition: facAbsFact.cc:55
#define pNext(p)
Definition: monomials.h:36
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
int p
Definition: cfModGcd.cc:4019
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
ideal idrMoveR_NoSort(ideal &id, ring src_r, ring dest_r)
Definition: prCopy.cc:260
#define pCopy(p)
return a copy of the poly
Definition: polys.h:180
#define idTest(id)
Definition: ideals.h:47

◆ idMult()

static ideal idMult ( ideal  h1,
ideal  h2 
)
inlinestatic

hh := h1 * h2

Definition at line 84 of file ideals.h.

85 {
86  return id_Mult(h1, h2, currRing);
87 }
ideal id_Mult(ideal h1, ideal h2, const ring R)
h1 * h2 one h_i must be an ideal (with at least one column) the other h_i may be a module (with no co...
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12

◆ idMultSect()

ideal idMultSect ( resolvente  arg,
int  length,
GbVariant  a = GbDefault 
)

Definition at line 419 of file ideals.cc.

420 {
421  int i,j=0,k=0,l,maxrk=-1,realrki;
422  unsigned syzComp;
423  ideal bigmat,tempstd,result;
424  poly p;
425  int isIdeal=0;
426  intvec * w=NULL;
427 
428  /* find 0-ideals and max rank -----------------------------------*/
429  for (i=0;i<length;i++)
430  {
431  if (!idIs0(arg[i]))
432  {
433  realrki=id_RankFreeModule(arg[i],currRing);
434  k++;
435  j += IDELEMS(arg[i]);
436  if (realrki>maxrk) maxrk = realrki;
437  }
438  else
439  {
440  if (arg[i]!=NULL)
441  {
442  return idInit(1,arg[i]->rank);
443  }
444  }
445  }
446  if (maxrk == 0)
447  {
448  isIdeal = 1;
449  maxrk = 1;
450  }
451  /* init -----------------------------------------------------------*/
452  j += maxrk;
453  syzComp = k*maxrk;
454 
455  ring orig_ring=currRing;
456  ring syz_ring=rAssure_SyzOrder(orig_ring,TRUE);
457  rSetSyzComp(syzComp,syz_ring);
458  rChangeCurrRing(syz_ring);
459 
460  bigmat = idInit(j,(k+1)*maxrk);
461  /* create unit matrices ------------------------------------------*/
462  for (i=0;i<maxrk;i++)
463  {
464  for (j=0;j<=k;j++)
465  {
466  p = pOne();
467  pSetComp(p,i+1+j*maxrk);
468  pSetmComp(p);
469  bigmat->m[i] = pAdd(bigmat->m[i],p);
470  }
471  }
472  /* enter given ideals ------------------------------------------*/
473  i = maxrk;
474  k = 0;
475  for (j=0;j<length;j++)
476  {
477  if (arg[j]!=NULL)
478  {
479  for (l=0;l<IDELEMS(arg[j]);l++)
480  {
481  if (arg[j]->m[l]!=NULL)
482  {
483  if (syz_ring==orig_ring)
484  bigmat->m[i] = pCopy(arg[j]->m[l]);
485  else
486  bigmat->m[i] = prCopyR(arg[j]->m[l], orig_ring,currRing);
487  p_Shift(&(bigmat->m[i]),k*maxrk+isIdeal,currRing);
488  i++;
489  }
490  }
491  k++;
492  }
493  }
494  /* std computation --------------------------------------------*/
495  if (alg==GbDefault) alg=GbStd;
496  if (alg==GbStd)
497  {
498  if (TEST_OPT_PROT) { PrintS("std:"); mflush(); }
499  tempstd = kStd(bigmat,currRing->qideal,testHomog,&w,NULL,syzComp);
500  if (w!=NULL) delete w;
501  idDelete(&bigmat);
502  }
503  else if (alg==GbSlimgb)
504  {
505  if (TEST_OPT_PROT) { PrintS("slimgb:"); mflush(); }
506  tempstd = t_rep_gb(currRing, bigmat, syzComp);
507  idDelete(&bigmat);
508  }
509  else if (alg==GbGroebner)
510  {
511  if (TEST_OPT_PROT) { PrintS("groebner:"); mflush(); }
512  BOOLEAN err;
513  tempstd=(ideal)iiCallLibProc1("groebner",bigmat,MODUL_CMD,err);
514  if (err)
515  {
516  Werror("error %d in >>groebner<<",err);
517  tempstd=idInit(1,1);
518  }
519  }
520 // else if (alg==GbModstd): requires ideal, not module
521 // {
522 // if (TEST_OPT_PROT) { PrintS("modstd:"); mflush(); }
523 // BOOLEAN err;
524 // tempstd=(ideal)iiCallLibProc1("modStd",bigmat,MODUL_CMD,err);
525 // if (err)
526 // {
527 // Werror("error %d in >>modStd<<",err);
528 // tempstd=idInit(1,1);
529 // }
530 // }
531  //else if (alg==GbSba): requires order C,...
532  //{
533  // if (TEST_OPT_PROT) { PrintS("sba:"); mflush(); }
534  // tempstd = kSba(bigmat,currRing->qideal,hom,w,1,0,NULL,syzComp);
535  // idDelete(&bigmat);
536  //}
537  else
538  {
539  tempstd=idInit(1,1);
540  Werror("wrong algorithm %d for SB",(int)alg);
541  }
542 
543  if(syz_ring!=orig_ring)
544  rChangeCurrRing(orig_ring);
545 
546  /* interprete result ----------------------------------------*/
547  result = idInit(IDELEMS(tempstd),maxrk);
548  k = 0;
549  for (j=0;j<IDELEMS(tempstd);j++)
550  {
551  if ((tempstd->m[j]!=NULL) && (__p_GetComp(tempstd->m[j],syz_ring)>syzComp))
552  {
553  if (syz_ring==orig_ring)
554  p = pCopy(tempstd->m[j]);
555  else
556  p = prCopyR(tempstd->m[j], syz_ring,currRing);
557  p_Shift(&p,-syzComp-isIdeal,currRing);
558  result->m[k] = p;
559  k++;
560  }
561  }
562  /* clean up ----------------------------------------------------*/
563  if(syz_ring!=orig_ring)
564  rChangeCurrRing(syz_ring);
565  idDelete(&tempstd);
566  if(syz_ring!=orig_ring)
567  {
568  rChangeCurrRing(orig_ring);
569  rDelete(syz_ring);
570  }
571  idSkipZeroes(result);
572  return result;
573 }
#define __p_GetComp(p, r)
Definition: monomials.h:63
#define pSetmComp(p)
TODO:
Definition: polys.h:268
int j
Definition: facHensel.cc:105
#define pAdd(p, q)
Definition: polys.h:198
poly prCopyR(poly p, ring src_r, ring dest_r)
Definition: prCopy.cc:34
#define idDelete(H)
delete an ideal
Definition: ideals.h:29
#define TEST_OPT_PROT
Definition: options.h:102
#define TRUE
Definition: auxiliary.h:98
ring rAssure_SyzOrder(const ring r, BOOLEAN complete)
Definition: ring.cc:4387
ideal kStd(ideal F, ideal Q, tHomog h, intvec **w, intvec *hilb, int syzComp, int newIdeal, intvec *vw, s_poly_proc_t sp)
Definition: kstd1.cc:2088
int k
Definition: cfEzgcd.cc:92
void * iiCallLibProc1(const char *n, void *arg, int arg_type, BOOLEAN &err)
Definition: iplib.cc:612
#define mflush()
Definition: reporter.h:57
Definition: intvec.h:19
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s
ideal t_rep_gb(const ring r, ideal arg_I, int syz_comp, BOOLEAN F4_mode)
Definition: tgb.cc:3520
#define pSetComp(p, v)
Definition: polys.h:38
int m
Definition: cfEzgcd.cc:121
int i
Definition: cfEzgcd.cc:125
void PrintS(const char *s)
Definition: reporter.cc:284
#define pOne()
Definition: polys.h:310
#define IDELEMS(i)
Definition: simpleideals.h:23
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
void rSetSyzComp(int k, const ring r)
Definition: ring.cc:5016
void rChangeCurrRing(ring r)
Definition: polys.cc:14
void p_Shift(poly *p, int i, const ring r)
shifts components of the vector p by i
Definition: p_polys.cc:4612
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:35
#define NULL
Definition: omList.c:12
void rDelete(ring r)
unconditionally deletes fields in r
Definition: ring.cc:448
static BOOLEAN length(leftv result, leftv arg)
Definition: interval.cc:263
const CanonicalForm & w
Definition: facAbsFact.cc:55
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
int p
Definition: cfModGcd.cc:4019
int BOOLEAN
Definition: auxiliary.h:85
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
void Werror(const char *fmt,...)
Definition: reporter.cc:189
Definition: ideals.h:122
return result
Definition: facAbsBiFact.cc:76
int l
Definition: cfEzgcd.cc:93
#define pCopy(p)
return a copy of the poly
Definition: polys.h:180

◆ idMWLift()

intvec* idMWLift ( ideal  mod,
intvec weights 
)

Definition at line 2394 of file ideals.cc.

2395 {
2396  if (idIs0(mod)) return new intvec(2);
2397  int i=IDELEMS(mod);
2398  while ((i>0) && (mod->m[i-1]==NULL)) i--;
2399  intvec *result = new intvec(i+1);
2400  while (i>0)
2401  {
2402  (*result)[i]=currRing->pFDeg(mod->m[i],currRing)+(*weights)[pGetComp(mod->m[i])];
2403  }
2404  return result;
2405 }
CF_NO_INLINE CanonicalForm mod(const CanonicalForm &, const CanonicalForm &)
Definition: cf_inline.cc:564
#define pGetComp(p)
Component.
Definition: polys.h:37
Definition: intvec.h:19
int i
Definition: cfEzgcd.cc:125
#define IDELEMS(i)
Definition: simpleideals.h:23
#define NULL
Definition: omList.c:12
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
return result
Definition: facAbsBiFact.cc:76

◆ idQuot()

ideal idQuot ( ideal  h1,
ideal  h2,
BOOLEAN  h1IsStb = FALSE,
BOOLEAN  resultIsIdeal = FALSE 
)

Definition at line 1477 of file ideals.cc.

1478 {
1479  // first check for special case h1:(0)
1480  if (idIs0(h2))
1481  {
1482  ideal res;
1483  if (resultIsIdeal)
1484  {
1485  res = idInit(1,1);
1486  res->m[0] = pOne();
1487  }
1488  else
1489  res = idFreeModule(h1->rank);
1490  return res;
1491  }
1492  int i, kmax;
1493  BOOLEAN addOnlyOne=TRUE;
1494  tHomog hom=isNotHomog;
1495  intvec * weights1;
1496 
1497  ideal s_h4 = idInitializeQuot (h1,h2,h1IsStb,&addOnlyOne,&kmax);
1498 
1499  hom = (tHomog)idHomModule(s_h4,currRing->qideal,&weights1);
1500 
1501  ring orig_ring=currRing;
1502  ring syz_ring=rAssure_SyzOrder(orig_ring,TRUE);
1503  rSetSyzComp(kmax-1,syz_ring);
1504  rChangeCurrRing(syz_ring);
1505  if (orig_ring!=syz_ring)
1506  // s_h4 = idrMoveR_NoSort(s_h4,orig_ring, syz_ring);
1507  s_h4 = idrMoveR(s_h4,orig_ring, syz_ring);
1508  idTest(s_h4);
1509  #if 0
1510  void ipPrint_MA0(matrix m, const char *name);
1511  matrix m=idModule2Matrix(idCopy(s_h4));
1512  PrintS("start:\n");
1513  ipPrint_MA0(m,"Q");
1514  idDelete((ideal *)&m);
1515  PrintS("last elem:");wrp(s_h4->m[IDELEMS(s_h4)-1]);PrintLn();
1516  #endif
1517  ideal s_h3;
1518  if (addOnlyOne)
1519  {
1520  BITSET old_test1;
1521  SI_SAVE_OPT1(old_test1);
1523  s_h3 = kStd(s_h4,currRing->qideal,hom,&weights1,NULL,0/*kmax-1*/,IDELEMS(s_h4)-1);
1524  SI_RESTORE_OPT1(old_test1);
1525  }
1526  else
1527  {
1528  s_h3 = kStd(s_h4,currRing->qideal,hom,&weights1,NULL,kmax-1);
1529  }
1530  #if 0
1531  // only together with the above debug stuff
1532  idSkipZeroes(s_h3);
1533  m=idModule2Matrix(idCopy(s_h3));
1534  Print("result, kmax=%d:\n",kmax);
1535  ipPrint_MA0(m,"S");
1536  idDelete((ideal *)&m);
1537  #endif
1538  idTest(s_h3);
1539  if (weights1!=NULL) delete weights1;
1540  idDelete(&s_h4);
1541 
1542  for (i=0;i<IDELEMS(s_h3);i++)
1543  {
1544  if ((s_h3->m[i]!=NULL) && (pGetComp(s_h3->m[i])>=kmax))
1545  {
1546  if (resultIsIdeal)
1547  p_Shift(&s_h3->m[i],-kmax,currRing);
1548  else
1549  p_Shift(&s_h3->m[i],-kmax+1,currRing);
1550  }
1551  else
1552  p_Delete(&s_h3->m[i],currRing);
1553  }
1554  if (resultIsIdeal)
1555  s_h3->rank = 1;
1556  else
1557  s_h3->rank = h1->rank;
1558  if(syz_ring!=orig_ring)
1559  {
1560  rChangeCurrRing(orig_ring);
1561  s_h3 = idrMoveR_NoSort(s_h3, syz_ring, orig_ring);
1562  rDelete(syz_ring);
1563  }
1564  idSkipZeroes(s_h3);
1565  idTest(s_h3);
1566  return s_h3;
1567 }
unsigned si_opt_1
Definition: options.c:5
void PrintLn()
Definition: reporter.cc:310
#define Print
Definition: emacs.cc:80
#define idDelete(H)
delete an ideal
Definition: ideals.h:29
#define TRUE
Definition: auxiliary.h:98
ring rAssure_SyzOrder(const ring r, BOOLEAN complete)
Definition: ring.cc:4387
ideal kStd(ideal F, ideal Q, tHomog h, intvec **w, intvec *hilb, int syzComp, int newIdeal, intvec *vw, s_poly_proc_t sp)
Definition: kstd1.cc:2088
#define SI_SAVE_OPT1(A)
Definition: options.h:22
#define BITSET
Definition: structs.h:20
#define Sy_bit(x)
Definition: options.h:32
#define pGetComp(p)
Component.
Definition: polys.h:37
static BOOLEAN idHomModule(ideal m, ideal Q, intvec **w)
Definition: ideals.h:96
static ideal idInitializeQuot(ideal h1, ideal h2, BOOLEAN h1IsStb, BOOLEAN *addOnlyOne, int *kkmax)
Definition: ideals.cc:1372
Definition: intvec.h:19
CanonicalForm res
Definition: facAbsFact.cc:64
tHomog
Definition: structs.h:39
ideal idFreeModule(int i)
Definition: ideals.h:111
void ipPrint_MA0(matrix m, const char *name)
Definition: ipprint.cc:57
ideal idrMoveR(ideal &id, ring src_r, ring dest_r)
Definition: prCopy.cc:247
int m
Definition: cfEzgcd.cc:121
int i
Definition: cfEzgcd.cc:125
void PrintS(const char *s)
Definition: reporter.cc:284
#define pOne()
Definition: polys.h:310
char name(const Variable &v)
Definition: factory.h:180
#define IDELEMS(i)
Definition: simpleideals.h:23
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
ideal idCopy(ideal A)
Definition: ideals.h:60
void rSetSyzComp(int k, const ring r)
Definition: ring.cc:5016
void rChangeCurrRing(ring r)
Definition: polys.cc:14
void p_Shift(poly *p, int i, const ring r)
shifts components of the vector p by i
Definition: p_polys.cc:4612
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:856
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:35
static BOOLEAN rField_is_Ring(const ring r)
Definition: ring.h:479
#define NULL
Definition: omList.c:12
void rDelete(ring r)
unconditionally deletes fields in r
Definition: ring.cc:448
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
#define OPT_SB_1
Definition: options.h:94
void wrp(poly p)
Definition: polys.h:305
int BOOLEAN
Definition: auxiliary.h:85
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
#define SI_RESTORE_OPT1(A)
Definition: options.h:25
ideal idrMoveR_NoSort(ideal &id, ring src_r, ring dest_r)
Definition: prCopy.cc:260
#define idTest(id)
Definition: ideals.h:47

◆ idSect()

ideal idSect ( ideal  h1,
ideal  h2,
GbVariant  a = GbDefault 
)

Definition at line 199 of file ideals.cc.

200 {
201  int i,j,k;
202  unsigned length;
203  int flength = id_RankFreeModule(h1,currRing);
204  int slength = id_RankFreeModule(h2,currRing);
205  int rank=si_max(h1->rank,h2->rank);
206  if ((idIs0(h1)) || (idIs0(h2))) return idInit(1,rank);
207 
208  ideal first,second,temp,temp1,result;
209  poly p,q;
210 
211  if (IDELEMS(h1)<IDELEMS(h2))
212  {
213  first = h1;
214  second = h2;
215  }
216  else
217  {
218  first = h2;
219  second = h1;
220  int t=flength; flength=slength; slength=t;
221  }
222  length = si_max(flength,slength);
223  if (length==0)
224  {
225  if ((currRing->qideal==NULL)
226  && (currRing->OrdSgn==1)
227  && (!rIsPluralRing(currRing))
229  return idSectWithElim(first,second);
230  else length = 1;
231  }
232  if (TEST_OPT_PROT) PrintS("intersect by syzygy methods\n");
233  j = IDELEMS(first);
234 
235  ring orig_ring=currRing;
236  ring syz_ring=rAssure_SyzOrder(orig_ring,TRUE);
237  rSetSyzComp(length,syz_ring);
238  rChangeCurrRing(syz_ring);
239 
240  while ((j>0) && (first->m[j-1]==NULL)) j--;
241  temp = idInit(j /*IDELEMS(first)*/+IDELEMS(second),length+j);
242  k = 0;
243  for (i=0;i<j;i++)
244  {
245  if (first->m[i]!=NULL)
246  {
247  if (syz_ring==orig_ring)
248  temp->m[k] = pCopy(first->m[i]);
249  else
250  temp->m[k] = prCopyR(first->m[i], orig_ring, syz_ring);
251  q = pOne();
252  pSetComp(q,i+1+length);
253  pSetmComp(q);
254  if (flength==0) p_Shift(&(temp->m[k]),1,currRing);
255  p = temp->m[k];
256  while (pNext(p)!=NULL) pIter(p);
257  pNext(p) = q;
258  k++;
259  }
260  }
261  for (i=0;i<IDELEMS(second);i++)
262  {
263  if (second->m[i]!=NULL)
264  {
265  if (syz_ring==orig_ring)
266  temp->m[k] = pCopy(second->m[i]);
267  else
268  temp->m[k] = prCopyR(second->m[i], orig_ring,currRing);
269  if (slength==0) p_Shift(&(temp->m[k]),1,currRing);
270  k++;
271  }
272  }
273  intvec *w=NULL;
274  if (alg==GbDefault) alg=GbStd;
275  if (alg==GbStd)
276  {
277  if (TEST_OPT_PROT) { PrintS("std:"); mflush(); }
278  temp1 = kStd(temp,currRing->qideal,testHomog,&w,NULL,length);
279  if (w!=NULL) delete w;
280  idDelete(&temp);
281  }
282  else if (alg==GbSlimgb)
283  {
284  if (TEST_OPT_PROT) { PrintS("slimgb:"); mflush(); }
285  temp1 = t_rep_gb(currRing, temp, temp->rank);
286  idDelete(&temp);
287  }
288  else if (alg==GbGroebner)
289  {
290  if (TEST_OPT_PROT) { PrintS("groebner:"); mflush(); }
291  BOOLEAN err;
292  temp1=(ideal)iiCallLibProc1("groebner",temp,MODUL_CMD,err);
293  if (err)
294  {
295  Werror("error %d in >>groebner<<",err);
296  temp1=idInit(1,1);
297  }
298  }
299  else if (alg==GbModstd)
300  {
301  if (TEST_OPT_PROT) { PrintS("modStd:"); mflush(); }
302  BOOLEAN err;
303  void *args[]={temp,(void*)1,NULL};
304  int arg_t[]={MODUL_CMD,INT_CMD,0};
305  temp1=(ideal)iiCallLibProcM("modStd",args,arg_t,err);
306  if (err)
307  {
308  Werror("error %d in >>modStd<<",err);
309  temp1=idInit(1,1);
310  }
311  }
312  else if (alg==GbStdSat)
313  {
314  if (TEST_OPT_PROT) { PrintS("std:sat:"); mflush(); }
315  BOOLEAN err;
316  // search for 2nd block of vars
317  int i=0;
318  int block=-1;
319  loop
320  {
321  if ((currRing->order[i]!=ringorder_c)
322  && (currRing->order[i]!=ringorder_C)
323  && (currRing->order[i]!=ringorder_s))
324  {
325  if (currRing->order[i]==0) { err=TRUE;break;}
326  block++;
327  if (block==1) { block=i; break;}
328  }
329  i++;
330  }
331  if (block>0)
332  {
333  if (TEST_OPT_PROT)
334  {
335  Print("sat(%d..%d)\n",currRing->block0[block],currRing->block1[block]);
336  mflush();
337  }
338  ideal v=idInit(currRing->block1[block]-currRing->block0[block]+1,1);
339  for(i=currRing->block0[block];i<=currRing->block1[block];i++)
340  {
341  v->m[i-currRing->block0[block]]=pOne();
342  pSetExp(v->m[i-currRing->block0[block]],i,1);
343  pSetm(v->m[i-currRing->block0[block]]);
344  }
345  void *args[]={temp,v,NULL};
346  int arg_t[]={MODUL_CMD,IDEAL_CMD,0};
347  temp1=(ideal)iiCallLibProcM("satstd",args,arg_t,err);
348  }
349  if (err)
350  {
351  Werror("error %d in >>satstd<<",err);
352  temp1=idInit(1,1);
353  }
354  }
355 
356  if(syz_ring!=orig_ring)
357  rChangeCurrRing(orig_ring);
358 
359  result = idInit(IDELEMS(temp1),rank);
360  j = 0;
361  for (i=0;i<IDELEMS(temp1);i++)
362  {
363  if ((temp1->m[i]!=NULL)
364  && (__p_GetComp(temp1->m[i],syz_ring)>length))
365  {
366  if(syz_ring==orig_ring)
367  {
368  p = temp1->m[i];
369  }
370  else
371  {
372  p = prMoveR(temp1->m[i], syz_ring,orig_ring);
373  }
374  temp1->m[i]=NULL;
375  while (p!=NULL)
376  {
377  q = pNext(p);
378  pNext(p) = NULL;
379  k = pGetComp(p)-1-length;
380  pSetComp(p,0);
381  pSetmComp(p);
382  /* Warning! multiply only from the left! it's very important for Plural */
383  result->m[j] = pAdd(result->m[j],pMult(p,pCopy(first->m[k])));
384  p = q;
385  }
386  j++;
387  }
388  }
389  if(syz_ring!=orig_ring)
390  {
391  rChangeCurrRing(syz_ring);
392  idDelete(&temp1);
393  rChangeCurrRing(orig_ring);
394  rDelete(syz_ring);
395  }
396  else
397  {
398  idDelete(&temp1);
399  }
400 
401  idSkipZeroes(result);
402  if (TEST_OPT_RETURN_SB)
403  {
404  w=NULL;
405  temp1=kStd(result,currRing->qideal,testHomog,&w);
406  if (w!=NULL) delete w;
407  idDelete(&result);
408  idSkipZeroes(temp1);
409  return temp1;
410  }
411  else //temp1=kInterRed(result,currRing->qideal);
412  return result;
413 }
#define __p_GetComp(p, r)
Definition: monomials.h:63
#define pSetmComp(p)
TODO:
Definition: polys.h:268
int j
Definition: facHensel.cc:105
#define pSetm(p)
Definition: polys.h:266
#define Print
Definition: emacs.cc:80
Definition: tok.h:96
#define pAdd(p, q)
Definition: polys.h:198
#define block
Definition: scanner.cc:665
poly prCopyR(poly p, ring src_r, ring dest_r)
Definition: prCopy.cc:34
#define idDelete(H)
delete an ideal
Definition: ideals.h:29
#define TEST_OPT_PROT
Definition: options.h:102
#define pSetExp(p, i, v)
Definition: polys.h:42
poly prMoveR(poly &p, ring src_r, ring dest_r)
Definition: prCopy.cc:89
#define TRUE
Definition: auxiliary.h:98
ring rAssure_SyzOrder(const ring r, BOOLEAN complete)
Definition: ring.cc:4387
ideal kStd(ideal F, ideal Q, tHomog h, intvec **w, intvec *hilb, int syzComp, int newIdeal, intvec *vw, s_poly_proc_t sp)
Definition: kstd1.cc:2088
int k
Definition: cfEzgcd.cc:92
#define TEST_V_INTERSECT_ELIM
Definition: options.h:141
#define loop
Definition: structs.h:80
#define pGetComp(p)
Component.
Definition: polys.h:37
void * iiCallLibProc1(const char *n, void *arg, int arg_type, BOOLEAN &err)
Definition: iplib.cc:612
#define mflush()
Definition: reporter.h:57
#define pIter(p)
Definition: monomials.h:37
Definition: intvec.h:19
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
Definition: ring.h:397
ideal idSectWithElim(ideal h1, ideal h2)
Definition: ideals.cc:129
ideal t_rep_gb(const ring r, ideal arg_I, int syz_comp, BOOLEAN F4_mode)
Definition: tgb.cc:3520
#define pSetComp(p, v)
Definition: polys.h:38
static int si_max(const int a, const int b)
Definition: auxiliary.h:138
int i
Definition: cfEzgcd.cc:125
void PrintS(const char *s)
Definition: reporter.cc:284
#define pOne()
Definition: polys.h:310
#define IDELEMS(i)
Definition: simpleideals.h:23
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
void rSetSyzComp(int k, const ring r)
Definition: ring.cc:5016
void rChangeCurrRing(ring r)
Definition: polys.cc:14
void p_Shift(poly *p, int i, const ring r)
shifts components of the vector p by i
Definition: p_polys.cc:4612
#define TEST_OPT_RETURN_SB
Definition: options.h:111
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:35
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
void * iiCallLibProcM(const char *n, void **args, int *arg_types, BOOLEAN &err)
args: NULL terminated arry of arguments arg_types: 0 terminated array of corresponding types ...
Definition: iplib.cc:646
#define NULL
Definition: omList.c:12
void rDelete(ring r)
unconditionally deletes fields in r
Definition: ring.cc:448
#define pMult(p, q)
Definition: polys.h:202
static BOOLEAN length(leftv result, leftv arg)
Definition: interval.cc:263
const CanonicalForm & w
Definition: facAbsFact.cc:55
#define pNext(p)
Definition: monomials.h:36
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
#define TEST_V_INTERSECT_SYZ
Definition: options.h:142
int p
Definition: cfModGcd.cc:4019
s?
Definition: ring.h:76
int BOOLEAN
Definition: auxiliary.h:85
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
void Werror(const char *fmt,...)
Definition: reporter.cc:189
Definition: ideals.h:122
return result
Definition: facAbsBiFact.cc:76
#define pCopy(p)
return a copy of the poly
Definition: polys.h:180

◆ idSeries()

ideal idSeries ( int  n,
ideal  M,
matrix  U = NULL,
intvec w = NULL 
)

Definition at line 2150 of file ideals.cc.

2151 {
2152  for(int i=IDELEMS(M)-1;i>=0;i--)
2153  {
2154  if(U==NULL)
2155  M->m[i]=pSeries(n,M->m[i],NULL,w);
2156  else
2157  {
2158  M->m[i]=pSeries(n,M->m[i],MATELEM(U,i+1,i+1),w);
2159  MATELEM(U,i+1,i+1)=NULL;
2160  }
2161  }
2162  if(U!=NULL)
2163  idDelete((ideal*)&U);
2164  return M;
2165 }
#define idDelete(H)
delete an ideal
Definition: ideals.h:29
#define M
Definition: sirandom.c:24
int i
Definition: cfEzgcd.cc:125
#define IDELEMS(i)
Definition: simpleideals.h:23
#define pSeries(n, p, u, w)
Definition: polys.h:367
#define NULL
Definition: omList.c:12
#define MATELEM(mat, i, j)
1-based access to matrix
Definition: matpol.h:29

◆ idSort()

static intvec* idSort ( ideal  id,
BOOLEAN  nolex = TRUE 
)
inlinestatic

Definition at line 186 of file ideals.h.

187 {
188  return id_Sort(id, nolex, currRing);
189 }
intvec * id_Sort(const ideal id, const BOOLEAN nolex, const ring r)
sorts the ideal w.r.t. the actual ringordering uses lex-ordering when nolex = FALSE ...
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12

◆ idSyzygies()

ideal idSyzygies ( ideal  h1,
tHomog  h,
intvec **  w,
BOOLEAN  setSyzComp = TRUE,
BOOLEAN  setRegularity = FALSE,
int *  deg = NULL,
GbVariant  a = GbDefault 
)

Definition at line 728 of file ideals.cc.

730 {
731  ideal s_h1;
732  int j, k, length=0,reg;
733  BOOLEAN isMonomial=TRUE;
734  int ii, idElemens_h1;
735 
736  assume(h1 != NULL);
737 
738  idElemens_h1=IDELEMS(h1);
739 #ifdef PDEBUG
740  for(ii=0;ii<idElemens_h1 /*IDELEMS(h1)*/;ii++) pTest(h1->m[ii]);
741 #endif
742  if (idIs0(h1))
743  {
744  ideal result=idFreeModule(idElemens_h1/*IDELEMS(h1)*/);
745  return result;
746  }
747  int slength=(int)id_RankFreeModule(h1,currRing);
748  k=si_max(1,slength /*id_RankFreeModule(h1)*/);
749 
750  assume(currRing != NULL);
751  ring orig_ring=currRing;
752  ring syz_ring=rAssure_SyzComp(orig_ring,TRUE);
753  if (setSyzComp) rSetSyzComp(k,syz_ring);
754 
755  if (orig_ring != syz_ring)
756  {
757  rChangeCurrRing(syz_ring);
758  s_h1=idrCopyR_NoSort(h1,orig_ring,syz_ring);
759  }
760  else
761  {
762  s_h1 = h1;
763  }
764 
765  idTest(s_h1);
766 
767  ideal s_h3=idPrepare(s_h1,h,k,w,alg); // main (syz) GB computation
768 
769  if (s_h3==NULL)
770  {
771  if (orig_ring != syz_ring)
772  {
773  rChangeCurrRing(orig_ring);
774  rDelete(syz_ring);
775  }
776  return idFreeModule( idElemens_h1 /*IDELEMS(h1)*/);
777  }
778 
779  if (orig_ring != syz_ring)
780  {
781  idDelete(&s_h1);
782  for (j=0; j<IDELEMS(s_h3); j++)
783  {
784  if (s_h3->m[j] != NULL)
785  {
786  if (p_MinComp(s_h3->m[j],syz_ring) > k)
787  p_Shift(&s_h3->m[j], -k,syz_ring);
788  else
789  p_Delete(&s_h3->m[j],syz_ring);
790  }
791  }
792  idSkipZeroes(s_h3);
793  s_h3->rank -= k;
794  rChangeCurrRing(orig_ring);
795  s_h3 = idrMoveR_NoSort(s_h3, syz_ring, orig_ring);
796  rDelete(syz_ring);
797  #ifdef HAVE_PLURAL
798  if (rIsPluralRing(orig_ring))
799  {
800  id_DelMultiples(s_h3,orig_ring);
801  idSkipZeroes(s_h3);
802  }
803  #endif
804  idTest(s_h3);
805  return s_h3;
806  }
807 
808  ideal e = idInit(IDELEMS(s_h3), s_h3->rank);
809 
810  for (j=IDELEMS(s_h3)-1; j>=0; j--)
811  {
812  if (s_h3->m[j] != NULL)
813  {
814  if (p_MinComp(s_h3->m[j],syz_ring) <= k)
815  {
816  e->m[j] = s_h3->m[j];
817  isMonomial=isMonomial && (pNext(s_h3->m[j])==NULL);
818  p_Delete(&pNext(s_h3->m[j]),syz_ring);
819  s_h3->m[j] = NULL;
820  }
821  }
822  }
823 
824  idSkipZeroes(s_h3);
825  idSkipZeroes(e);
826 
827  if ((deg != NULL)
828  && (!isMonomial)
830  && (setRegularity)
831  && (h==isHomog)
832  && (!rIsPluralRing(currRing))
833  && (!rField_is_Ring(currRing))
834  )
835  {
836  assume(orig_ring==syz_ring);
837  ring dp_C_ring = rAssure_dp_C(syz_ring); // will do rChangeCurrRing later
838  if (dp_C_ring != syz_ring)
839  {
840  rChangeCurrRing(dp_C_ring);
841  e = idrMoveR_NoSort(e, syz_ring, dp_C_ring);
842  }
843  resolvente res = sySchreyerResolvente(e,-1,&length,TRUE, TRUE);
844  intvec * dummy = syBetti(res,length,&reg, *w);
845  *deg = reg+2;
846  delete dummy;
847  for (j=0;j<length;j++)
848  {
849  if (res[j]!=NULL) idDelete(&(res[j]));
850  }
851  omFreeSize((ADDRESS)res,length*sizeof(ideal));
852  idDelete(&e);
853  if (dp_C_ring != orig_ring)
854  {
855  rChangeCurrRing(orig_ring);
856  rDelete(dp_C_ring);
857  }
858  }
859  else
860  {
861  idDelete(&e);
862  }
863  assume(orig_ring==currRing);
864  idTest(s_h3);
865  if (currRing->qideal != NULL)
866  {
867  ideal ts_h3=kStd(s_h3,currRing->qideal,h,w);
868  idDelete(&s_h3);
869  s_h3 = ts_h3;
870  }
871  return s_h3;
872 }
#define TEST_OPT_NOTREGULARITY
Definition: options.h:118
int j
Definition: facHensel.cc:105
static ideal idPrepare(ideal h1, tHomog hom, int syzcomp, intvec **w, GbVariant alg)
Definition: ideals.cc:580
#define idDelete(H)
delete an ideal
Definition: ideals.h:29
#define pTest(p)
Definition: polys.h:410
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
#define TRUE
Definition: auxiliary.h:98
ideal kStd(ideal F, ideal Q, tHomog h, intvec **w, intvec *hilb, int syzComp, int newIdeal, intvec *vw, s_poly_proc_t sp)
Definition: kstd1.cc:2088
void * ADDRESS
Definition: auxiliary.h:133
int k
Definition: cfEzgcd.cc:92
Definition: intvec.h:19
void id_DelMultiples(ideal id, const ring r)
ideal id = (id[i]), c any unit if id[i] = c*id[j] then id[j] is deleted for j > i ...
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s
CanonicalForm res
Definition: facAbsFact.cc:64
ideal idFreeModule(int i)
Definition: ideals.h:111
#define assume(x)
Definition: mod2.h:390
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
Definition: ring.h:397
ring rAssure_SyzComp(const ring r, BOOLEAN complete)
Definition: ring.cc:4392
ring rAssure_dp_C(const ring r)
Definition: ring.cc:4910
static int si_max(const int a, const int b)
Definition: auxiliary.h:138
static long p_MinComp(poly p, ring lmRing, ring tailRing)
Definition: p_polys.h:312
resolvente sySchreyerResolvente(ideal arg, int maxlength, int *length, BOOLEAN isMonomial=FALSE, BOOLEAN notReplace=FALSE)
Definition: syz0.cc:855
#define IDELEMS(i)
Definition: simpleideals.h:23
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
void rSetSyzComp(int k, const ring r)
Definition: ring.cc:5016
void rChangeCurrRing(ring r)
Definition: polys.cc:14
void p_Shift(poly *p, int i, const ring r)
shifts components of the vector p by i
Definition: p_polys.cc:4612
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:856
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:35
static BOOLEAN rField_is_Ring(const ring r)
Definition: ring.h:479
#define NULL
Definition: omList.c:12
void rDelete(ring r)
unconditionally deletes fields in r
Definition: ring.cc:448
static BOOLEAN length(leftv result, leftv arg)
Definition: interval.cc:263
#define pNext(p)
Definition: monomials.h:36
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
ideal * resolvente
Definition: ideals.h:18
intvec * syBetti(resolvente res, int length, int *regularity, intvec *weights, BOOLEAN tomin, int *row_shift)
Definition: syz.cc:770
static Poly * h
Definition: janet.cc:971
int BOOLEAN
Definition: auxiliary.h:85
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
ideal idrCopyR_NoSort(ideal id, ring src_r, ring dest_r)
Definition: prCopy.cc:204
return result
Definition: facAbsBiFact.cc:76
ideal idrMoveR_NoSort(ideal &id, ring src_r, ring dest_r)
Definition: prCopy.cc:260
#define idTest(id)
Definition: ideals.h:47

◆ idTestHomModule()

BOOLEAN idTestHomModule ( ideal  m,
ideal  Q,
intvec w 
)

Definition at line 2098 of file ideals.cc.

2099 {
2100  if ((Q!=NULL) && (!idHomIdeal(Q,NULL))) { PrintS(" Q not hom\n"); return FALSE;}
2101  if (idIs0(m)) return TRUE;
2102 
2103  int cmax=-1;
2104  int i;
2105  poly p=NULL;
2106  int length=IDELEMS(m);
2107  polyset P=m->m;
2108  for (i=length-1;i>=0;i--)
2109  {
2110  p=P[i];
2111  if (p!=NULL) cmax=si_max(cmax,(int)pMaxComp(p)+1);
2112  }
2113  if (w != NULL)
2114  if (w->length()+1 < cmax)
2115  {
2116  // Print("length: %d - %d \n", w->length(),cmax);
2117  return FALSE;
2118  }
2119 
2120  if(w!=NULL)
2121  p_SetModDeg(w, currRing);
2122 
2123  for (i=length-1;i>=0;i--)
2124  {
2125  p=P[i];
2126  if (p!=NULL)
2127  {
2128  int d=currRing->pFDeg(p,currRing);
2129  loop
2130  {
2131  pIter(p);
2132  if (p==NULL) break;
2133  if (d!=currRing->pFDeg(p,currRing))
2134  {
2135  //pWrite(q); wrp(p); Print(" -> %d - %d\n",d,pFDeg(p,currRing));
2136  if(w!=NULL)
2138  return FALSE;
2139  }
2140  }
2141  }
2142  }
2143 
2144  if(w!=NULL)
2146 
2147  return TRUE;
2148 }
void p_SetModDeg(intvec *w, ring r)
Definition: p_polys.cc:3633
static BOOLEAN idHomIdeal(ideal id, ideal Q=NULL)
Definition: ideals.h:91
#define pMaxComp(p)
Definition: polys.h:294
#define FALSE
Definition: auxiliary.h:94
#define TRUE
Definition: auxiliary.h:98
#define Q
Definition: sirandom.c:25
#define loop
Definition: structs.h:80
#define pIter(p)
Definition: monomials.h:37
int m
Definition: cfEzgcd.cc:121
static int si_max(const int a, const int b)
Definition: auxiliary.h:138
poly * polyset
Definition: polys.h:254
int i
Definition: cfEzgcd.cc:125
void PrintS(const char *s)
Definition: reporter.cc:284
#define IDELEMS(i)
Definition: simpleideals.h:23
#define NULL
Definition: omList.c:12
int length() const
Definition: intvec.h:94
static BOOLEAN length(leftv result, leftv arg)
Definition: interval.cc:263
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
int p
Definition: cfModGcd.cc:4019
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal

◆ idVec2Ideal()

static ideal idVec2Ideal ( poly  vec)
inlinestatic

Definition at line 171 of file ideals.h.

172 {
173  return id_Vec2Ideal(vec, currRing);
174 }
fq_nmod_poly_t * vec
Definition: facHensel.cc:103
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
ideal id_Vec2Ideal(poly vec, const ring R)

◆ idXXX()

ideal idXXX ( ideal  h1,
int  k 
)

Definition at line 876 of file ideals.cc.

877 {
878  ideal s_h1;
879  intvec *w=NULL;
880 
881  assume(currRing != NULL);
882  ring orig_ring=currRing;
883  ring syz_ring=rAssure_SyzComp(orig_ring,TRUE);
884  rSetSyzComp(k,syz_ring);
885  rChangeCurrRing(syz_ring);
886 
887  if (orig_ring != syz_ring)
888  {
889  s_h1=idrCopyR_NoSort(h1,orig_ring, syz_ring);
890  }
891  else
892  {
893  s_h1 = h1;
894  }
895 
896  ideal s_h3=kStd(s_h1,NULL,testHomog,&w,NULL,k);
897 
898  if (s_h3==NULL)
899  {
900  return idFreeModule(IDELEMS(h1));
901  }
902 
903  if (orig_ring != syz_ring)
904  {
905  idDelete(&s_h1);
906  idSkipZeroes(s_h3);
907  rChangeCurrRing(orig_ring);
908  s_h3 = idrMoveR_NoSort(s_h3, syz_ring, orig_ring);
909  rDelete(syz_ring);
910  idTest(s_h3);
911  return s_h3;
912  }
913 
914  idSkipZeroes(s_h3);
915  idTest(s_h3);
916  return s_h3;
917 }
#define idDelete(H)
delete an ideal
Definition: ideals.h:29
#define TRUE
Definition: auxiliary.h:98
ideal kStd(ideal F, ideal Q, tHomog h, intvec **w, intvec *hilb, int syzComp, int newIdeal, intvec *vw, s_poly_proc_t sp)
Definition: kstd1.cc:2088
int k
Definition: cfEzgcd.cc:92
Definition: intvec.h:19
ideal idFreeModule(int i)
Definition: ideals.h:111
#define assume(x)
Definition: mod2.h:390
ring rAssure_SyzComp(const ring r, BOOLEAN complete)
Definition: ring.cc:4392
#define IDELEMS(i)
Definition: simpleideals.h:23
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
void rSetSyzComp(int k, const ring r)
Definition: ring.cc:5016
void rChangeCurrRing(ring r)
Definition: polys.cc:14
#define NULL
Definition: omList.c:12
void rDelete(ring r)
unconditionally deletes fields in r
Definition: ring.cc:448
const CanonicalForm & w
Definition: facAbsFact.cc:55
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
ideal idrCopyR_NoSort(ideal id, ring src_r, ring dest_r)
Definition: prCopy.cc:204
ideal idrMoveR_NoSort(ideal &id, ring src_r, ring dest_r)
Definition: prCopy.cc:260
#define idTest(id)
Definition: ideals.h:47

◆ syGetAlgorithm()

GbVariant syGetAlgorithm ( char *  n,
const ring  r,
const ideal  M 
)

Definition at line 3028 of file ideals.cc.

3029 {
3030  GbVariant alg=GbDefault;
3031  if (strcmp(n,"slimgb")==0) alg=GbSlimgb;
3032  else if (strcmp(n,"std")==0) alg=GbStd;
3033  else if (strcmp(n,"sba")==0) alg=GbSba;
3034  else if (strcmp(n,"singmatic")==0) alg=GbSingmatic;
3035  else if (strcmp(n,"groebner")==0) alg=GbGroebner;
3036  else if (strcmp(n,"modstd")==0) alg=GbModstd;
3037  else if (strcmp(n,"ffmod")==0) alg=GbFfmod;
3038  else if (strcmp(n,"nfmod")==0) alg=GbNfmod;
3039  else if (strcmp(n,"std:sat")==0) alg=GbStdSat;
3040  else Warn(">>%s<< is an unknown algorithm",n);
3041 
3042  if (alg==GbSlimgb) // test conditions for slimgb
3043  {
3044  if(rHasGlobalOrdering(r)
3045  &&(!rIsPluralRing(r))
3046  &&(r->qideal==NULL)
3047  &&(!rField_is_Ring(r)))
3048  {
3049  return GbSlimgb;
3050  }
3051  if (TEST_OPT_PROT)
3052  WarnS("requires: coef:field, commutative, global ordering, not qring");
3053  }
3054  else if (alg==GbSba) // cond. for sba
3055  {
3056  if(rField_is_Domain(r)
3057  &&(!rIsPluralRing(r))
3058  &&(rHasGlobalOrdering(r)))
3059  {
3060  return GbSba;
3061  }
3062  if (TEST_OPT_PROT)
3063  WarnS("requires: coef:domain, commutative, global ordering");
3064  }
3065  else if (alg==GbGroebner) // cond. for groebner
3066  {
3067  return GbGroebner;
3068  }
3069  else if(alg==GbModstd) // cond for modstd: Q or Q(a)
3070  {
3071  if(ggetid("modStd")==NULL)
3072  {
3073  WarnS(">>modStd<< not found");
3074  }
3075  else if(rField_is_Q(r)
3076  &&(!rIsPluralRing(r))
3077  &&(rHasGlobalOrdering(r)))
3078  {
3079  return GbModstd;
3080  }
3081  if (TEST_OPT_PROT)
3082  WarnS("requires: coef:QQ, commutative, global ordering");
3083  }
3084  else if(alg==GbStdSat) // cond for std:sat: 2 blocks of variables
3085  {
3086  if(ggetid("satstd")==NULL)
3087  {
3088  WarnS(">>satstd<< not found");
3089  }
3090  else
3091  {
3092  return GbStdSat;
3093  }
3094  }
3095 
3096  return GbStd; // no conditions for std
3097 }
idhdl ggetid(const char *n)
Definition: ipid.cc:521
#define TEST_OPT_PROT
Definition: options.h:102
GbVariant
Definition: ideals.h:118
static BOOLEAN rField_is_Domain(const ring r)
Definition: ring.h:482
#define WarnS
Definition: emacs.cc:78
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
Definition: ring.h:397
static BOOLEAN rField_is_Q(const ring r)
Definition: ring.h:501
Definition: ideals.h:124
static BOOLEAN rField_is_Ring(const ring r)
Definition: ring.h:479
#define NULL
Definition: omList.c:12
BOOLEAN rHasGlobalOrdering(const ring r)
Definition: ring.h:754
Definition: ideals.h:122
#define Warn
Definition: emacs.cc:77