Functions | Variables
customstd.cc File Reference
#include <Singular/libsingular.h>
#include <vector>
#include <iostream>

Go to the source code of this file.

Functions

static BOOLEAN sat_vars_sp (kStrategy strat)
 
static BOOLEAN satstd (leftv res, leftv args)
 
static BOOLEAN abort_if_monomial_sp (kStrategy strat)
 
BOOLEAN monomialabortstd (leftv res, leftv args)
 
int SI_MOD_INIT() customstd (SModulFunctions *p)
 

Variables

ideal idealCache =NULL
 
std::vector< int > customstd_satstdSaturatingVariables
 

Function Documentation

◆ abort_if_monomial_sp()

static BOOLEAN abort_if_monomial_sp ( kStrategy  strat)
static

Definition at line 207 of file customstd.cc.

208 {
209  BOOLEAN b = FALSE; // set b to TRUE, if spoly was changed,
210  // let it remain FALSE otherwise
211  if (strat->P.t_p==NULL)
212  {
213  poly p=strat->P.p;
214  if (pNext(p)==NULL)
215  {
216  while ((strat->Ll >= 0))
217  deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
218  return FALSE;
219  }
220  }
221  else
222  {
223  poly p=strat->P.t_p;
224  if (pNext(p)==NULL)
225  {
226  while ((strat->Ll >= 0))
227  deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
228  return FALSE;
229  }
230  }
231  return b; // return TRUE if sp was changed, FALSE if not
232 }
int Ll
Definition: kutil.h:339
#define FALSE
Definition: auxiliary.h:94
return P p
Definition: myNF.cc:203
void deleteInL(LSet set, int *length, int j, kStrategy strat)
Definition: kutil.cc:1165
LObject P
Definition: kutil.h:288
LSet L
Definition: kutil.h:313
#define NULL
Definition: omList.c:10
#define pNext(p)
Definition: monomials.h:43
polyrec * poly
Definition: hilb.h:10
int BOOLEAN
Definition: auxiliary.h:85
const poly b
Definition: syzextra.cc:213

◆ customstd()

int SI_MOD_INIT() customstd ( SModulFunctions p)

Definition at line 432 of file customstd.cc.

433 {
434  // p->iiAddCproc("std_demo","std_with_display",FALSE,std_with_display);
435  p->iiAddCproc("customstd.lib","satstd",FALSE,satstd);
436  // p->iiAddCproc("std_demo","satstdWithInitialCheck",FALSE,satstdWithInitialCheck);
437  p->iiAddCproc("customstd.lib","monomialabortstd",FALSE,monomialabortstd);
438  // PrintS("init of std_demo - type `listvar(Std_demo);` to its contents\n");
439  return (MAX_TOK);
440 }
#define FALSE
Definition: auxiliary.h:94
BOOLEAN monomialabortstd(leftv res, leftv args)
Definition: customstd.cc:234
Definition: tok.h:213
int(* iiAddCproc)(const char *libname, const char *procname, BOOLEAN pstatic, BOOLEAN(*func)(leftv res, leftv v))
Definition: ipid.h:71
static BOOLEAN satstd(leftv res, leftv args)
Definition: customstd.cc:141

◆ monomialabortstd()

BOOLEAN monomialabortstd ( leftv  res,
leftv  args 
)

Definition at line 234 of file customstd.cc.

235 {
236  if (args!=NULL)
237  {
238  if ((args->Typ()==IDEAL_CMD) && (args->next==NULL))
239  {
240  ideal I=(ideal)args->Data();
242  idSkipZeroes(I);
243  res->rtyp=IDEAL_CMD;
244  res->data=(char*)I;
245  return FALSE;
246  }
247  }
248  WerrorS("monomialabortstd: unexpected parameters");
249  return TRUE;
250 }
#define FALSE
Definition: auxiliary.h:94
#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:2231
void WerrorS(const char *s)
Definition: feFopen.cc:24
int Typ()
Definition: subexpr.cc:995
void * data
Definition: subexpr.h:88
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:10
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
leftv next
Definition: subexpr.h:86
#define NULL
Definition: omList.c:10
static BOOLEAN abort_if_monomial_sp(kStrategy strat)
Definition: customstd.cc:207
int rtyp
Definition: subexpr.h:91
void * Data()
Definition: subexpr.cc:1137

◆ sat_vars_sp()

static BOOLEAN sat_vars_sp ( kStrategy  strat)
static

Definition at line 44 of file customstd.cc.

45 {
46  BOOLEAN b = FALSE; // set b to TRUE, if spoly was changed,
47  // let it remain FALSE otherwise
48  if (strat->P.t_p==NULL)
49  {
50  poly p=strat->P.p;
51 
52  // iterate over all terms of p and
53  // compute the minimum mm of all exponent vectors
54  int *mm=(int*)omAlloc((1+rVar(currRing))*sizeof(int));
55  int *m0=(int*)omAlloc((1+rVar(currRing))*sizeof(int));
56  p_GetExpV(p,mm,currRing);
57  bool nonTrivialSaturationToBeDone=true;
58  for (p=pNext(p); p!=NULL; pIter(p))
59  {
60  nonTrivialSaturationToBeDone=false;
61  p_GetExpV(p,m0,currRing);
62  for (int i=customstd_satstdSaturatingVariables.size()-1; i>=0; i--)
63  {
65  mm[li]=si_min(mm[li],m0[li]);
66  if (mm[li]>0) nonTrivialSaturationToBeDone=true;
67  }
68  // abort if the minimum is zero in each component
69  if (nonTrivialSaturationToBeDone==false) break;
70  }
71  if (nonTrivialSaturationToBeDone==true)
72  {
73  // std::cout << "simplifying!" << std::endl;
74  p=p_Copy(strat->P.p,currRing);
75  memset(&strat->P,0,sizeof(strat->P));
76  strat->P.tailRing = strat->tailRing;
77  strat->P.p=p;
78  while(p!=NULL)
79  {
80  for (int i=customstd_satstdSaturatingVariables.size()-1; i>=0; i--)
81  {
83  p_SubExp(p,li,mm[li],currRing);
84  }
85  p_Setm(p,currRing);
86  pIter(p);
87  }
88  b = TRUE;
89  }
90  omFree(mm);
91  omFree(m0);
92  }
93  else
94  {
95  poly p=strat->P.t_p;
96 
97  // iterate over all terms of p and
98  // compute the minimum mm of all exponent vectors
99  int *mm=(int*)omAlloc((1+rVar(currRing))*sizeof(int));
100  int *m0=(int*)omAlloc((1+rVar(currRing))*sizeof(int));
101  p_GetExpV(p,mm,strat->tailRing);
102  bool nonTrivialSaturationToBeDone=true;
103  for (p = pNext(p); p!=NULL; pIter(p))
104  {
105  nonTrivialSaturationToBeDone=false;
106  p_GetExpV(p,m0,strat->tailRing);
107  for(int i=customstd_satstdSaturatingVariables.size()-1; i>=0; i--)
108  {
110  mm[li]=si_min(mm[li],m0[li]);
111  if (mm[li]>0) nonTrivialSaturationToBeDone = true;
112  }
113  // abort if the minimum is zero in each component
114  if (!nonTrivialSaturationToBeDone) break;
115  }
116  if (nonTrivialSaturationToBeDone)
117  {
118  p=p_Copy(strat->P.t_p,strat->tailRing);
119  memset(&strat->P,0,sizeof(strat->P));
120  strat->P.tailRing = strat->tailRing;
121  strat->P.t_p=p;
122  while(p!=NULL)
123  {
124  for(int i=customstd_satstdSaturatingVariables.size()-1; i>=0; i--)
125  {
127  p_SubExp(p,li,mm[li],strat->tailRing);
128  }
129  p_Setm(p,strat->tailRing);
130  pIter(p);
131  }
132  strat->P.GetP();
133  b = TRUE;
134  }
135  omFree(mm);
136  omFree(m0);
137  }
138  return b; // return TRUE if sp was changed, FALSE if not
139 }
std::vector< int > customstd_satstdSaturatingVariables
Definition: customstd.cc:8
static int si_min(const int a, const int b)
Definition: auxiliary.h:121
#define FALSE
Definition: auxiliary.h:94
return P p
Definition: myNF.cc:203
static void p_GetExpV(poly p, int *ev, const ring r)
Definition: p_polys.h:1443
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:583
#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:804
static long p_SubExp(poly p, int v, long ee, ring r)
Definition: p_polys.h:608
#define pIter(p)
Definition: monomials.h:44
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:10
#define omFree(addr)
Definition: omAllocDecl.h:261
LObject P
Definition: kutil.h:288
int i
Definition: cfEzgcd.cc:123
#define NULL
Definition: omList.c:10
ring tailRing
Definition: kutil.h:331
#define pNext(p)
Definition: monomials.h:43
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:228
polyrec * poly
Definition: hilb.h:10
int BOOLEAN
Definition: auxiliary.h:85
const poly b
Definition: syzextra.cc:213

◆ satstd()

static BOOLEAN satstd ( leftv  res,
leftv  args 
)
static

Definition at line 141 of file customstd.cc.

142 {
143  leftv u = args;
144  if ((u!=NULL) && (u->Typ()==IDEAL_CMD))
145  {
146  leftv v = u->next;
147 
148  if (v==NULL)
149  {
150  int n = rVar(currRing);
151  customstd_satstdSaturatingVariables = std::vector<int>(n);
152  for (int i=n-1; i>=0; i--)
154  }
155  else
156  {
157  if (v->Typ()==IDEAL_CMD)
158  {
159  ideal J = (ideal) v->Data();
160 
161  int k = IDELEMS(J);
162  customstd_satstdSaturatingVariables = std::vector<int>(k);
163  for (int i=0; i<k; i++)
164  {
165  poly x = J->m[i];
166  int li = p_Var(x,currRing);
167  if (li>0)
169  else
170  {
171  WerrorS("satstd: second argument only ideals generated by variables supported for now");
172  return TRUE;
173  }
174  }
175  }
176  else
177  {
178  WerrorS("satstd: unexpected parameters");
179  return TRUE;
180  }
181  }
182 
183  ideal I = (ideal) u->Data();
184 
185  idealCache = NULL;
186  I=kStd(I,currRing->qideal,testHomog,NULL,NULL,0,0,NULL,sat_vars_sp);
187  customstd_satstdSaturatingVariables = std::vector<int>();
188 
189  res->rtyp=IDEAL_CMD;
190  if (idealCache)
191  {
192  id_Delete(&I,currRing);
193  res->data = (char*) idealCache;
194  idealCache = NULL;
195  }
196  else
197  {
198  idSkipZeroes(I);
199  res->data=(char*)I;
200  }
201  return FALSE;
202  }
203  WerrorS("satstd: unexpected parameters");
204  return TRUE;
205 }
Class used for (list of) interpreter objects.
Definition: subexpr.h:82
std::vector< int > customstd_satstdSaturatingVariables
Definition: customstd.cc:8
#define FALSE
Definition: auxiliary.h:94
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:583
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:2231
void WerrorS(const char *s)
Definition: feFopen.cc:24
int k
Definition: cfEzgcd.cc:93
int Typ()
Definition: subexpr.cc:995
void * data
Definition: subexpr.h:88
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:10
ideal idealCache
Definition: customstd.cc:6
int i
Definition: cfEzgcd.cc:123
#define IDELEMS(i)
Definition: simpleideals.h:24
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
leftv next
Definition: subexpr.h:86
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
#define NULL
Definition: omList.c:10
int rtyp
Definition: subexpr.h:91
Variable x
Definition: cfModGcd.cc:4023
void * Data()
Definition: subexpr.cc:1137
polyrec * poly
Definition: hilb.h:10
static BOOLEAN sat_vars_sp(kStrategy strat)
Definition: customstd.cc:44
int p_Var(poly m, const ring r)
Definition: p_polys.cc:4511

Variable Documentation

◆ customstd_satstdSaturatingVariables

std::vector<int> customstd_satstdSaturatingVariables

Definition at line 8 of file customstd.cc.

◆ idealCache

ideal idealCache =NULL

Definition at line 6 of file customstd.cc.