Data Structures | Functions | Variables
ideals.cc File Reference
#include "kernel/mod2.h"
#include "misc/options.h"
#include "misc/intvec.h"
#include "coeffs/coeffs.h"
#include "coeffs/numbers.h"
#include "polys/monomials/ring.h"
#include "polys/matpol.h"
#include "polys/weight.h"
#include "polys/sparsmat.h"
#include "polys/prCopy.h"
#include "polys/nc/nc.h"
#include "kernel/ideals.h"
#include "kernel/polys.h"
#include "kernel/GBEngine/kstd1.h"
#include "kernel/GBEngine/kutil.h"
#include "kernel/GBEngine/tgb.h"
#include "kernel/GBEngine/syz.h"
#include "Singular/ipshell.h"
#include "Singular/ipid.h"
#include "polys/clapsing.h"

Go to the source code of this file.

Data Structures

struct  poly_sort
 

Functions

ideal idMinBase (ideal h1)
 
ideal idSectWithElim (ideal h1, ideal h2)
 
ideal idSect (ideal h1, ideal h2, GbVariant alg)
 
ideal idMultSect (resolvente arg, int length, GbVariant alg)
 
static ideal idPrepare (ideal h1, tHomog hom, int syzcomp, intvec **w, GbVariant alg)
 
ideal idSyzygies (ideal h1, tHomog h, intvec **w, BOOLEAN setSyzComp, BOOLEAN setRegularity, int *deg, GbVariant alg)
 
ideal idXXX (ideal h1, int k)
 
ideal idLiftStd (ideal h1, matrix *ma, tHomog hi, ideal *syz, GbVariant alg)
 
static void idPrepareStd (ideal s_temp, int k)
 
ideal idLift (ideal mod, ideal submod, ideal *rest, BOOLEAN goodShape, BOOLEAN isSB, BOOLEAN divide, matrix *unit, GbVariant alg)
 
void idLiftW (ideal P, ideal Q, int n, matrix &T, ideal &R, short *w)
 
static ideal idInitializeQuot (ideal h1, ideal h2, BOOLEAN h1IsStb, BOOLEAN *addOnlyOne, int *kkmax)
 
ideal idQuot (ideal h1, ideal h2, BOOLEAN h1IsStb, BOOLEAN resultIsIdeal)
 
ideal idElimination (ideal h1, poly delVar, intvec *hilb, GbVariant alg)
 
ideal idMinors (matrix a, int ar, ideal R)
 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...
 
BOOLEAN idIsSubModule (ideal id1, ideal id2)
 
BOOLEAN idTestHomModule (ideal m, ideal Q, intvec *w)
 
ideal idSeries (int n, ideal M, matrix U, intvec *w)
 
matrix idDiff (matrix i, int k)
 
matrix idDiffOp (ideal I, ideal J, BOOLEAN multiply)
 
ideal idModulo (ideal h2, ideal h1, tHomog hom, intvec **w)
 
intvecidMWLift (ideal mod, intvec *weights)
 
ideal idCreateSpecialKbase (ideal kBase, intvec **convert)
 
int idIndexOfKBase (poly monom, ideal kbase)
 
poly idDecompose (poly monom, poly how, ideal kbase, int *pos)
 
matrix idCoeffOfKBase (ideal arg, ideal kbase, poly how)
 
static void idDeleteComps (ideal arg, int *red_comp, int del)
 
ideal idMinEmbedding (ideal arg, BOOLEAN inPlace, intvec **w)
 
poly id_GCD (poly f, poly g, const ring r)
 
ideal id_Farey (ideal x, number N, const ring r)
 
void idKeepFirstK (ideal id, const int k)
 keeps the first k (>= 1) entries of the given ideal (Note that the kept polynomials may be zero.) More...
 
int pCompare_qsort (const void *a, const void *b)
 
void idSort_qsort (poly_sort *id_sort, int idsize)
 
void idDelEquals (ideal id)
 
static BOOLEAN id_sat_vars_sp (kStrategy strat)
 
ideal id_Satstd (const ideal I, ideal J, const ring r)
 
GbVariant syGetAlgorithm (char *n, const ring r, const ideal)
 

Variables

static int * id_satstdSaturatingVariables =NULL
 

Data Structure Documentation

◆ poly_sort

struct poly_sort

Definition at line 2812 of file ideals.cc.

Data Fields
int index
poly p

Function Documentation

◆ 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_sat_vars_sp()

static BOOLEAN id_sat_vars_sp ( kStrategy  strat)
static

Definition at line 2871 of file ideals.cc.

2872 {
2873  BOOLEAN b = FALSE; // set b to TRUE, if spoly was changed,
2874  // let it remain FALSE otherwise
2875  if (strat->P.t_p==NULL)
2876  {
2877  poly p=strat->P.p;
2878 
2879  // iterate over all terms of p and
2880  // compute the minimum mm of all exponent vectors
2881  int *mm=(int*)omAlloc((1+rVar(currRing))*sizeof(int));
2882  int *m0=(int*)omAlloc0((1+rVar(currRing))*sizeof(int));
2883  p_GetExpV(p,mm,currRing);
2884  bool nonTrivialSaturationToBeDone=true;
2885  for (p=pNext(p); p!=NULL; pIter(p))
2886  {
2887  nonTrivialSaturationToBeDone=false;
2888  p_GetExpV(p,m0,currRing);
2889  for (int i=rVar(currRing); i>0; i--)
2890  {
2892  {
2893  mm[i]=si_min(mm[i],m0[i]);
2894  if (mm[i]>0) nonTrivialSaturationToBeDone=true;
2895  }
2896  else mm[i]=0;
2897  }
2898  // abort if the minimum is zero in each component
2899  if (!nonTrivialSaturationToBeDone) break;
2900  }
2901  if (nonTrivialSaturationToBeDone)
2902  {
2903  // std::cout << "simplifying!" << std::endl;
2904  if (TEST_OPT_PROT) { PrintS("S"); mflush(); }
2905  p=p_Copy(strat->P.p,currRing);
2906  //pWrite(p);
2907  // for (int i=rVar(currRing); i>0; i--)
2908  // if (mm[i]!=0) Print("x_%d:%d ",i,mm[i]);
2909  //PrintLn();
2910  memset(&strat->P,0,sizeof(strat->P));
2911  strat->P.tailRing = strat->tailRing;
2912  strat->P.p=p;
2913  while(p!=NULL)
2914  {
2915  for (int i=rVar(currRing); i>0; i--)
2916  {
2917  p_SubExp(p,i,mm[i],currRing);
2918  }
2919  p_Setm(p,currRing);
2920  pIter(p);
2921  }
2922  b = TRUE;
2923  }
2924  omFree(mm);
2925  omFree(m0);
2926  }
2927  else
2928  {
2929  poly p=strat->P.t_p;
2930 
2931  // iterate over all terms of p and
2932  // compute the minimum mm of all exponent vectors
2933  int *mm=(int*)omAlloc((1+rVar(currRing))*sizeof(int));
2934  int *m0=(int*)omAlloc0((1+rVar(currRing))*sizeof(int));
2935  p_GetExpV(p,mm,strat->tailRing);
2936  bool nonTrivialSaturationToBeDone=true;
2937  for (p = pNext(p); p!=NULL; pIter(p))
2938  {
2939  nonTrivialSaturationToBeDone=false;
2940  p_GetExpV(p,m0,strat->tailRing);
2941  for(int i=rVar(currRing); i>0; i--)
2942  {
2944  {
2945  mm[i]=si_min(mm[i],m0[i]);
2946  if (mm[i]>0) nonTrivialSaturationToBeDone = true;
2947  }
2948  else mm[i]=0;
2949  }
2950  // abort if the minimum is zero in each component
2951  if (!nonTrivialSaturationToBeDone) break;
2952  }
2953  if (nonTrivialSaturationToBeDone)
2954  {
2955  if (TEST_OPT_PROT) { PrintS("S"); mflush(); }
2956  p=p_Copy(strat->P.t_p,strat->tailRing);
2957  //p_Write(p,strat->tailRing);
2958  // for (int i=rVar(currRing); i>0; i--)
2959  // if (mm[i]!=0) Print("x_%d:%d ",i,mm[i]);
2960  //PrintLn();
2961  memset(&strat->P,0,sizeof(strat->P));
2962  strat->P.tailRing = strat->tailRing;
2963  strat->P.t_p=p;
2964  while(p!=NULL)
2965  {
2966  for(int i=rVar(currRing); i>0; i--)
2967  {
2968  p_SubExp(p,i,mm[i],strat->tailRing);
2969  }
2970  p_Setm(p,strat->tailRing);
2971  pIter(p);
2972  }
2973  strat->P.GetP();
2974  b = TRUE;
2975  }
2976  omFree(mm);
2977  omFree(m0);
2978  }
2979  return b; // return TRUE if sp was changed, FALSE if not
2980 }
#define TEST_OPT_PROT
Definition: options.h:102
static int si_min(const int a, const int b)
Definition: auxiliary.h:139
#define FALSE
Definition: auxiliary.h:94
static void p_GetExpV(poly p, int *ev, const ring r)
Definition: p_polys.h:1455
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:586
#define TRUE
Definition: auxiliary.h:98
#define omAlloc(size)
Definition: omAllocDecl.h:210
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:811
static long p_SubExp(poly p, int v, long ee, ring r)
Definition: p_polys.h:612
#define mflush()
Definition: reporter.h:57
#define pIter(p)
Definition: monomials.h:37
CanonicalForm b
Definition: cfModGcd.cc:4044
#define omFree(addr)
Definition: omAllocDecl.h:261
LObject P
Definition: kutil.h:298
int i
Definition: cfEzgcd.cc:125
void PrintS(const char *s)
Definition: reporter.cc:284
#define NULL
Definition: omList.c:12
ring tailRing
Definition: kutil.h:341
static int * id_satstdSaturatingVariables
Definition: ideals.cc:2869
#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
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:232
int p
Definition: cfModGcd.cc:4019
int BOOLEAN
Definition: auxiliary.h:85
#define omAlloc0(size)
Definition: omAllocDecl.h:211

◆ 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

◆ 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

◆ idCreateSpecialKbase()

ideal idCreateSpecialKbase ( ideal  kBase,
intvec **  convert 
)

Definition at line 2411 of file ideals.cc.

2412 {
2413  int i;
2414  ideal result;
2415 
2416  if (idIs0(kBase)) return NULL;
2417  result = idInit(IDELEMS(kBase),kBase->rank);
2418  *convert = idSort(kBase,FALSE);
2419  for (i=0;i<(*convert)->length();i++)
2420  {
2421  result->m[i] = pCopy(kBase->m[(**convert)[i]-1]);
2422  }
2423  return result;
2424 }
#define FALSE
Definition: auxiliary.h:94
static intvec * idSort(ideal id, BOOLEAN nolex=TRUE)
Definition: ideals.h:186
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
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
return result
Definition: facAbsBiFact.cc:76
#define pCopy(p)
return a copy of the poly
Definition: polys.h:180

◆ idDecompose()

poly idDecompose ( poly  monom,
poly  how,
ideal  kbase,
int *  pos 
)

Definition at line 2465 of file ideals.cc.

2466 {
2467  int i;
2468  poly coeff=pOne(), base=pOne();
2469 
2470  for (i=1;i<=(currRing->N);i++)
2471  {
2472  if (pGetExp(how,i)>0)
2473  {
2474  pSetExp(base,i,pGetExp(monom,i));
2475  }
2476  else
2477  {
2478  pSetExp(coeff,i,pGetExp(monom,i));
2479  }
2480  }
2481  pSetComp(base,pGetComp(monom));
2482  pSetm(base);
2483  pSetCoeff(coeff,nCopy(pGetCoeff(monom)));
2484  pSetm(coeff);
2485  *pos = idIndexOfKBase(base,kbase);
2486  if (*pos<0)
2487  p_Delete(&coeff,currRing);
2489  return coeff;
2490 }
#define pSetm(p)
Definition: polys.h:266
#define pSetExp(p, i, v)
Definition: polys.h:42
int idIndexOfKBase(poly monom, ideal kbase)
Definition: ideals.cc:2429
char N base
Definition: ValueTraits.h:144
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy ...
Definition: monomials.h:44
#define pGetComp(p)
Component.
Definition: polys.h:37
#define pGetExp(p, i)
Exponent.
Definition: polys.h:41
#define pSetComp(p, v)
Definition: polys.h:38
int i
Definition: cfEzgcd.cc:125
#define pOne()
Definition: polys.h:310
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:856
#define nCopy(n)
Definition: numbers.h:15
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
#define pSetCoeff(p, n)
deletes old coeff before setting the new one
Definition: polys.h:31

◆ 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

◆ idDeleteComps()

static void idDeleteComps ( ideal  arg,
int *  red_comp,
int  del 
)
static

Definition at line 2536 of file ideals.cc.

2538 {
2539  int i,j;
2540  poly p;
2541 
2542  for (i=IDELEMS(arg)-1;i>=0;i--)
2543  {
2544  p = arg->m[i];
2545  while (p!=NULL)
2546  {
2547  j = pGetComp(p);
2548  if (red_comp[j]!=j)
2549  {
2550  pSetComp(p,red_comp[j]);
2551  pSetmComp(p);
2552  }
2553  pIter(p);
2554  }
2555  }
2556  (arg->rank) -= del;
2557 }
#define pSetmComp(p)
TODO:
Definition: polys.h:268
int j
Definition: facHensel.cc:105
#define pGetComp(p)
Component.
Definition: polys.h:37
#define pIter(p)
Definition: monomials.h:37
#define pSetComp(p, v)
Definition: polys.h:38
int i
Definition: cfEzgcd.cc:125
#define IDELEMS(i)
Definition: simpleideals.h:23
#define NULL
Definition: omList.c:12
int p
Definition: cfModGcd.cc:4019

◆ 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 
)

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,
GbVariant  alg 
)

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

◆ idIndexOfKBase()

int idIndexOfKBase ( poly  monom,
ideal  kbase 
)

Definition at line 2429 of file ideals.cc.

2430 {
2431  int j=IDELEMS(kbase);
2432 
2433  while ((j>0) && (kbase->m[j-1]==NULL)) j--;
2434  if (j==0) return -1;
2435  int i=(currRing->N);
2436  while (i>0)
2437  {
2438  loop
2439  {
2440  if (pGetExp(monom,i)>pGetExp(kbase->m[j-1],i)) return -1;
2441  if (pGetExp(monom,i)==pGetExp(kbase->m[j-1],i)) break;
2442  j--;
2443  if (j==0) return -1;
2444  }
2445  if (i==1)
2446  {
2447  while(j>0)
2448  {
2449  if (pGetComp(monom)==pGetComp(kbase->m[j-1])) return j-1;
2450  if (pGetComp(monom)>pGetComp(kbase->m[j-1])) return -1;
2451  j--;
2452  }
2453  }
2454  i--;
2455  }
2456  return -1;
2457 }
int j
Definition: facHensel.cc:105
#define loop
Definition: structs.h:80
#define pGetComp(p)
Component.
Definition: polys.h:37
#define pGetExp(p, i)
Exponent.
Definition: polys.h:41
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

◆ idInitializeQuot()

static ideal idInitializeQuot ( ideal  h1,
ideal  h2,
BOOLEAN  h1IsStb,
BOOLEAN addOnlyOne,
int *  kkmax 
)
static

addOnlyOne &&

Definition at line 1372 of file ideals.cc.

1373 {
1374  idTest(h1);
1375  idTest(h2);
1376 
1377  ideal temph1;
1378  poly p,q = NULL;
1379  int i,l,ll,k,kkk,kmax;
1380  int j = 0;
1381  int k1 = id_RankFreeModule(h1,currRing);
1382  int k2 = id_RankFreeModule(h2,currRing);
1383  tHomog hom=isNotHomog;
1384  k=si_max(k1,k2);
1385  if (k==0)
1386  k = 1;
1387  if ((k2==0) && (k>1)) *addOnlyOne = FALSE;
1388  intvec * weights;
1389  hom = (tHomog)idHomModule(h1,currRing->qideal,&weights);
1390  if /**addOnlyOne &&*/ (/*(*/ !h1IsStb /*)*/)
1391  temph1 = kStd(h1,currRing->qideal,hom,&weights,NULL);
1392  else
1393  temph1 = idCopy(h1);
1394  if (weights!=NULL) delete weights;
1395  idTest(temph1);
1396 /*--- making a single vector from h2 ---------------------*/
1397  for (i=0; i<IDELEMS(h2); i++)
1398  {
1399  if (h2->m[i] != NULL)
1400  {
1401  p = pCopy(h2->m[i]);
1402  if (k2 == 0)
1403  p_Shift(&p,j*k+1,currRing);
1404  else
1405  p_Shift(&p,j*k,currRing);
1406  q = pAdd(q,p);
1407  j++;
1408  }
1409  }
1410  *kkmax = kmax = j*k+1;
1411 /*--- adding a monomial for the result (syzygy) ----------*/
1412  p = q;
1413  while (pNext(p)!=NULL) pIter(p);
1414  pNext(p) = pOne();
1415  pIter(p);
1416  pSetComp(p,kmax);
1417  pSetmComp(p);
1418 /*--- constructing the big matrix ------------------------*/
1419  ideal h4 = idInit(k,kmax+k-1);
1420  h4->m[0] = q;
1421  if (k2 == 0)
1422  {
1423  for (i=1; i<k; i++)
1424  {
1425  if (h4->m[i-1]!=NULL)
1426  {
1427  p = p_Copy_noCheck(h4->m[i-1], currRing); /*h4->m[i-1]!=NULL*/
1428  p_Shift(&p,1,currRing);
1429  h4->m[i] = p;
1430  }
1431  else break;
1432  }
1433  }
1434  idSkipZeroes(h4);
1435  kkk = IDELEMS(h4);
1436  i = IDELEMS(temph1);
1437  for (l=0; l<i; l++)
1438  {
1439  if(temph1->m[l]!=NULL)
1440  {
1441  for (ll=0; ll<j; ll++)
1442  {
1443  p = pCopy(temph1->m[l]);
1444  if (k1 == 0)
1445  p_Shift(&p,ll*k+1,currRing);
1446  else
1447  p_Shift(&p,ll*k,currRing);
1448  if (kkk >= IDELEMS(h4))
1449  {
1450  pEnlargeSet(&(h4->m),IDELEMS(h4),16);
1451  IDELEMS(h4) += 16;
1452  }
1453  h4->m[kkk] = p;
1454  kkk++;
1455  }
1456  }
1457  }
1458 /*--- if h2 goes in as single vector - the h1-part is just SB ---*/
1459  if (*addOnlyOne)
1460  {
1461  idSkipZeroes(h4);
1462  p = h4->m[0];
1463  for (i=0;i<IDELEMS(h4)-1;i++)
1464  {
1465  h4->m[i] = h4->m[i+1];
1466  }
1467  h4->m[IDELEMS(h4)-1] = p;
1468  }
1469  idDelete(&temph1);
1470  //idTest(h4);//see remark at the beginning
1471  return h4;
1472 }
#define pSetmComp(p)
TODO:
Definition: polys.h:268
int j
Definition: facHensel.cc:105
#define pAdd(p, q)
Definition: polys.h:198
#define idDelete(H)
delete an ideal
Definition: ideals.h:29
#define FALSE
Definition: auxiliary.h:94
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
static poly p_Copy_noCheck(poly p, const ring r)
returns a copy of p (without any additional testing)
Definition: p_polys.h:801
#define pIter(p)
Definition: monomials.h:37
static BOOLEAN idHomModule(ideal m, ideal Q, intvec **w)
Definition: ideals.h:96
Definition: intvec.h:19
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 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 pEnlargeSet(poly **p, int l, int increment)
Definition: p_polys.cc:3656
#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
int l
Definition: cfEzgcd.cc:93
#define pCopy(p)
return a copy of the poly
Definition: polys.h:180
#define idTest(id)
Definition: ideals.h:47

◆ 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

◆ idKeepFirstK()

void idKeepFirstK ( ideal  id,
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  submod,
ideal *  rest,
BOOLEAN  goodShape,
BOOLEAN  isSB,
BOOLEAN  divide,
matrix unit,
GbVariant  alg 
)

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 ma,
tHomog  hi,
ideal *  syz,
GbVariant  alg 
)

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 
)

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,
intvec **  w 
)

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 
)

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  h2,
ideal  h1,
tHomog  hom,
intvec **  w 
)

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

◆ idMultSect()

ideal idMultSect ( resolvente  arg,
int  length,
GbVariant  alg 
)

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

◆ idPrepare()

static ideal idPrepare ( ideal  h1,
tHomog  hom,
int  syzcomp,
intvec **  w,
GbVariant  alg 
)
static

Definition at line 580 of file ideals.cc.

581 {
582  ideal h2;
583  int j,k;
584  poly p,q;
585 
586  if (idIs0(h1)) return NULL;
587  k = id_RankFreeModule(h1,currRing);
588  h2=idCopy(h1);
589  int i = IDELEMS(h2);
590  if (k == 0)
591  {
592  id_Shift(h2,1,currRing);
593  k = 1;
594  }
595  if (syzcomp<k)
596  {
597  Warn("syzcomp too low, should be %d instead of %d",k,syzcomp);
598  syzcomp = k;
600  }
601  h2->rank = syzcomp+i;
602 
603  //if (hom==testHomog)
604  //{
605  // if(idHomIdeal(h1,currRing->qideal))
606  // {
607  // hom=TRUE;
608  // }
609  //}
610 
611  for (j=0; j<i; j++)
612  {
613  p = h2->m[j];
614  q = pOne();
615  pSetComp(q,syzcomp+1+j);
616  pSetmComp(q);
617  if (p!=NULL)
618  {
619  while (pNext(p)) pIter(p);
620  p->next = q;
621  }
622  else
623  h2->m[j]=q;
624  }
625 
626  idTest(h2);
627 
628  ideal h3=NULL;
629  if (alg==GbDefault) alg=GbStd;
630  if (alg==GbStd)
631  {
632  if (TEST_OPT_PROT) { PrintS("std:"); mflush(); }
633  h3 = kStd(h2,currRing->qideal,hom,w,NULL,syzcomp);
634  }
635  else if (alg==GbSlimgb)
636  {
637  if (TEST_OPT_PROT) { PrintS("slimgb:"); mflush(); }
638  h3 = t_rep_gb(currRing, h2, syzcomp);
639  }
640  else if (alg==GbGroebner)
641  {
642  if (TEST_OPT_PROT) { PrintS("groebner:"); mflush(); }
643  BOOLEAN err;
644  h3=(ideal)iiCallLibProc1("groebner",idCopy(h2),MODUL_CMD,err);
645  if (err)
646  {
647  Werror("error %d in >>groebner<<",err);
648  h3=idInit(1,1);
649  }
650  }
651  else if (alg==GbModstd)
652  {
653  if (TEST_OPT_PROT) { PrintS("modstd:"); mflush(); }
654  BOOLEAN err;
655  void *args[]={idCopy(h2),(void*)1,NULL};
656  int arg_t[]={MODUL_CMD,INT_CMD,0};
657  h3=(ideal)iiCallLibProcM("modStd",args,arg_t,err);
658  if (err)
659  {
660  Werror("error %d in >>modStd<<",err);
661  h3=idInit(1,1);
662  }
663  }
664  else if (alg==GbStdSat)
665  {
666  if (TEST_OPT_PROT) { PrintS("std:sat:"); mflush(); }
667  BOOLEAN err;
668  // search for 2nd block of vars
669  int i=0;
670  int block=-1;
671  loop
672  {
673  if ((currRing->order[i]!=ringorder_c)
674  && (currRing->order[i]!=ringorder_C)
675  && (currRing->order[i]!=ringorder_s))
676  {
677  if (currRing->order[i]==0) { err=TRUE;break;}
678  block++;
679  if (block==1) { block=i; break;}
680  }
681  i++;
682  }
683  if (block>0)
684  {
685  if (TEST_OPT_PROT)
686  {
687  Print("sat(%d..%d)\n",currRing->block0[block],currRing->block1[block]);
688  mflush();
689  }
690  ideal v=idInit(currRing->block1[block]-currRing->block0[block]+1,1);
691  for(i=currRing->block0[block];i<=currRing->block1[block];i++)
692  {
693  v->m[i-currRing->block0[block]]=pOne();
694  pSetExp(v->m[i-currRing->block0[block]],i,1);
695  pSetm(v->m[i-currRing->block0[block]]);
696  }
697  void *args[]={idCopy(h2),v,NULL};
698  int arg_t[]={MODUL_CMD,IDEAL_CMD,0};
699  h3=(ideal)iiCallLibProcM("satstd",args,arg_t,err);
700  }
701  if (err)
702  {
703  Werror("error %d in >>satstd<<",err);
704  h3=idInit(1,1);
705  }
706  }
707  //else if (alg==GbSba): requires order C,...
708  //{
709  // if (TEST_OPT_PROT) { PrintS("sba:"); mflush(); }
710  // h3 = kSba(h2,currRing->qideal,hom,w,1,0,NULL,syzcomp);
711  //}
712  else
713  {
714  h3=idInit(1,1);
715  Werror("wrong algorithm %d for SB",(int)alg);
716  }
717 
718  idDelete(&h2);
719  return h3;
720 }
#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 block
Definition: scanner.cc:665
#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
#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
#define loop
Definition: structs.h:80
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
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
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 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
ideal idCopy(ideal A)
Definition: ideals.h:60
void rSetSyzComp(int k, const ring r)
Definition: ring.cc:5016
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
#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
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
#define idTest(id)
Definition: ideals.h:47
#define Warn
Definition: emacs.cc:77

◆ idPrepareStd()

static void idPrepareStd ( ideal  s_temp,
int  k 
)
static

Definition at line 1077 of file ideals.cc.

1078 {
1079  int j,rk=id_RankFreeModule(s_temp,currRing);
1080  poly p,q;
1081 
1082  if (rk == 0)
1083  {
1084  for (j=0; j<IDELEMS(s_temp); j++)
1085  {
1086  if (s_temp->m[j]!=NULL) pSetCompP(s_temp->m[j],1);
1087  }
1088  k = si_max(k,1);
1089  }
1090  for (j=0; j<IDELEMS(s_temp); j++)
1091  {
1092  if (s_temp->m[j]!=NULL)
1093  {
1094  p = s_temp->m[j];
1095  q = pOne();
1096  //pGetCoeff(q)=nInpNeg(pGetCoeff(q)); //set q to -1
1097  pSetComp(q,k+1+j);
1098  pSetmComp(q);
1099  while (pNext(p)) pIter(p);
1100  pNext(p) = q;
1101  }
1102  }
1103  s_temp->rank = k+IDELEMS(s_temp);
1104 }
#define pSetmComp(p)
TODO:
Definition: polys.h:268
int j
Definition: facHensel.cc:105
int k
Definition: cfEzgcd.cc:92
#define pIter(p)
Definition: monomials.h:37
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s
#define pSetCompP(a, i)
Definition: polys.h:298
#define pSetComp(p, v)
Definition: polys.h:38
static int si_max(const int a, const int b)
Definition: auxiliary.h:138
#define pOne()
Definition: polys.h:310
#define IDELEMS(i)
Definition: simpleideals.h:23
#define NULL
Definition: omList.c:12
#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

◆ idQuot()

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

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  alg 
)

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

◆ idSectWithElim()

ideal idSectWithElim ( ideal  h1,
ideal  h2 
)

Definition at line 129 of file ideals.cc.

131 {
132  if (TEST_OPT_PROT) PrintS("intersect by elimination method\n");
133  assume(!idIs0(h1));
134  assume(!idIs0(h2));
135  assume(IDELEMS(h1)<=IDELEMS(h2));
138  // add a new variable:
139  int j;
140  ring origRing=currRing;
141  ring r=rCopy0(origRing);
142  r->N++;
143  r->block0[0]=1;
144  r->block1[0]= r->N;
145  omFree(r->order);
146  r->order=(rRingOrder_t*)omAlloc0(3*sizeof(rRingOrder_t));
147  r->order[0]=ringorder_dp;
148  r->order[1]=ringorder_C;
149  char **names=(char**)omAlloc0(rVar(r) * sizeof(char_ptr));
150  for (j=0;j<r->N-1;j++) names[j]=r->names[j];
151  names[r->N-1]=omStrDup("@");
152  omFree(r->names);
153  r->names=names;
154  rComplete(r,TRUE);
155  // fetch h1, h2
156  ideal h;
157  h1=idrCopyR(h1,origRing,r);
158  h2=idrCopyR(h2,origRing,r);
159  // switch to temp. ring r
160  rChangeCurrRing(r);
161  // create 1-t, t
162  poly omt=p_One(currRing);
163  p_SetExp(omt,r->N,1,currRing);
164  p_Setm(omt,currRing);
165  poly t=p_Copy(omt,currRing);
166  omt=p_Neg(omt,currRing);
167  omt=p_Add_q(omt,pOne(),currRing);
168  // compute (1-t)*h1
169  h1=(ideal)mp_MultP((matrix)h1,omt,currRing);
170  // compute t*h2
171  h2=(ideal)mp_MultP((matrix)h2,pCopy(t),currRing);
172  // (1-t)h1 + t*h2
173  h=idInit(IDELEMS(h1)+IDELEMS(h2),1);
174  int l;
175  for (l=IDELEMS(h1)-1; l>=0; l--)
176  {
177  h->m[l] = h1->m[l]; h1->m[l]=NULL;
178  }
179  j=IDELEMS(h1);
180  for (l=IDELEMS(h2)-1; l>=0; l--)
181  {
182  h->m[l+j] = h2->m[l]; h2->m[l]=NULL;
183  }
184  idDelete(&h1);
185  idDelete(&h2);
186  // eliminate t:
187  ideal res=idElimination(h,t);
188  // cleanup
189  idDelete(&h);
190  pDelete(&t);
191  if (res!=NULL) res=idrMoveR(res,r,origRing);
192  rChangeCurrRing(origRing);
193  rDelete(r);
194  return res;
195 }
int j
Definition: facHensel.cc:105
#define idDelete(H)
delete an ideal
Definition: ideals.h:29
#define TEST_OPT_PROT
Definition: options.h:102
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:586
#define TRUE
Definition: auxiliary.h:98
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:811
char * char_ptr
Definition: structs.h:58
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
poly p_One(const ring r)
Definition: p_polys.cc:1303
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
#define omFree(addr)
Definition: omAllocDecl.h:261
#define assume(x)
Definition: mod2.h:390
ring rCopy0(const ring r, BOOLEAN copy_qideal, BOOLEAN copy_ordering)
Definition: ring.cc:1365
rRingOrder_t
order stuff
Definition: ring.h:67
ideal idrMoveR(ideal &id, ring src_r, ring dest_r)
Definition: prCopy.cc:247
void PrintS(const char *s)
Definition: reporter.cc:284
#define pOne()
Definition: polys.h:310
#define IDELEMS(i)
Definition: simpleideals.h:23
void rChangeCurrRing(ring r)
Definition: polys.cc:14
matrix mp_MultP(matrix a, poly p, const ring R)
multiply a matrix &#39;a&#39; by a poly &#39;p&#39;, destroy the args
Definition: matpol.cc:148
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:35
ideal idElimination(ideal h1, poly delVar, intvec *hilb, GbVariant alg)
Definition: ideals.cc:1572
static unsigned long p_SetExp(poly p, const unsigned long e, const unsigned long iBitmask, const int VarOffset)
set a single variable exponent : VarOffset encodes the position in p->exp
Definition: p_polys.h:487
#define NULL
Definition: omList.c:12
void rDelete(ring r)
unconditionally deletes fields in r
Definition: ring.cc:448
#define pDelete(p_ptr)
Definition: polys.h:181
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 void p_Setm(poly p, const ring r)
Definition: p_polys.h:232
static poly p_Neg(poly p, const ring r)
Definition: p_polys.h:1042
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:891
static Poly * h
Definition: janet.cc:971
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
#define omAlloc0(size)
Definition: omAllocDecl.h:211
int l
Definition: cfEzgcd.cc:93
#define pCopy(p)
return a copy of the poly
Definition: polys.h:180
#define omStrDup(s)
Definition: omAllocDecl.h:263

◆ idSeries()

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

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_qsort()

void idSort_qsort ( poly_sort id_sort,
int  idsize 
)

Definition at line 2823 of file ideals.cc.

2824 {
2825  qsort(id_sort, idsize, sizeof(poly_sort), pCompare_qsort);
2826 }
int pCompare_qsort(const void *a, const void *b)
Definition: ideals.cc:2818

◆ idSyzygies()

ideal idSyzygies ( ideal  h1,
tHomog  h,
intvec **  w,
BOOLEAN  setSyzComp,
BOOLEAN  setRegularity,
int *  deg,
GbVariant  alg 
)

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

◆ 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

◆ pCompare_qsort()

int pCompare_qsort ( const void *  a,
const void *  b 
)

Definition at line 2818 of file ideals.cc.

2819 {
2820  return (p_Compare(((poly_sort *)a)->p, ((poly_sort *)b)->p,currRing));
2821 }
CanonicalForm b
Definition: cfModGcd.cc:4044
int p_Compare(const poly a, const poly b, const ring R)
Definition: p_polys.cc:4812
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

◆ syGetAlgorithm()

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

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

Variable Documentation

◆ id_satstdSaturatingVariables

int* id_satstdSaturatingVariables =NULL
static

Definition at line 2869 of file ideals.cc.