Macros | Functions
sparsmat.h File Reference

Go to the source code of this file.

Macros

#define SM_MULT   sm_MultDiv
 
#define SM_DIV   sm_SpecialPolyDiv
 

Functions

poly sm_MultDiv (poly, poly, const poly, const ring)
 
void sm_SpecialPolyDiv (poly, poly, const ring)
 
poly sm_CallDet (ideal I, const ring)
 
void sm_CallBareiss (ideal smat, int x, int y, ideal &M, intvec **iv, const ring)
 
ideal sm_CallSolv (ideal I, const ring)
 
ring sm_RingChange (const ring, long)
 
void sm_KillModifiedRing (ring r)
 
long sm_ExpBound (ideal, int, int, int, const ring)
 
BOOLEAN sm_CheckDet (ideal, int, BOOLEAN, const ring)
 

Macro Definition Documentation

◆ SM_DIV

#define SM_DIV   sm_SpecialPolyDiv

Definition at line 24 of file sparsmat.h.

◆ SM_MULT

#define SM_MULT   sm_MultDiv

Definition at line 23 of file sparsmat.h.

Function Documentation

◆ sm_CallBareiss()

void sm_CallBareiss ( ideal  smat,
int  x,
int  y,
ideal &  M,
intvec **  iv,
const ring   
)

Definition at line 400 of file sparsmat.cc.

401 {
402  int r=id_RankFreeModule(I,R),t=r;
403  int c=IDELEMS(I),s=c;
404  long bound;
405  ring tmpR;
406  sparse_mat *bareiss;
407 
408  if ((x>0) && (x<t))
409  t-=x;
410  if ((y>1) && (y<s))
411  s-=y;
412  if (t>s) t=s;
413  bound=sm_ExpBound(I,c,r,t,R);
414  tmpR=sm_RingChange(R,bound);
415  ideal II = idrCopyR(I, R, tmpR);
416  bareiss = new sparse_mat(II,tmpR);
417  if (bareiss->smGetAct() == NULL)
418  {
419  delete bareiss;
420  *iv=new intvec(1,rVar(tmpR));
421  }
422  else
423  {
424  id_Delete(&II,tmpR);
425  bareiss->smNewBareiss(x, y);
426  II = bareiss->smRes2Mod();
427  *iv = new intvec(bareiss->smGetRed());
428  bareiss->smToIntvec(*iv);
429  delete bareiss;
430  II = idrMoveR(II,tmpR,R);
431  }
432  sm_KillModifiedRing(tmpR);
433  M=II;
434 }
int smGetRed()
Definition: sparsmat.cc:174
const CanonicalForm int s
Definition: facAbsFact.cc:55
ring sm_RingChange(const ring origR, long bound)
Definition: sparsmat.cc:259
const CanonicalForm int const CFList const Variable & y
Definition: facAbsFact.cc:57
static CanonicalForm bound(const CFMatrix &M)
Definition: cf_linsys.cc:460
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
long sm_ExpBound(ideal m, int di, int ra, int t, const ring currRing)
Definition: sparsmat.cc:189
#define M
Definition: sirandom.c:24
void smNewBareiss(int, int)
Definition: sparsmat.cc:602
const ring r
Definition: syzextra.cc:208
Definition: intvec.h:14
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s
const ring R
Definition: DebugPrint.cc:36
ideal idrMoveR(ideal &id, ring src_r, ring dest_r)
Definition: prCopy.cc:249
#define IDELEMS(i)
Definition: simpleideals.h:24
#define NULL
Definition: omList.c:10
ideal smRes2Mod()
Definition: sparsmat.cc:501
void sm_KillModifiedRing(ring r)
Definition: sparsmat.cc:290
Variable x
Definition: cfModGcd.cc:4023
ideal idrCopyR(ideal id, ring src_r, ring dest_r)
Definition: prCopy.cc:193
void smToIntvec(intvec *)
Definition: sparsmat.cc:517
smpoly * smGetAct()
Definition: sparsmat.cc:173

◆ sm_CallDet()

poly sm_CallDet ( ideal  I,
const ring   
)

Definition at line 355 of file sparsmat.cc.

356 {
357  if (I->ncols != I->rank)
358  {
359  Werror("det of %ld x %d module (matrix)",I->rank,I->ncols);
360  return NULL;
361  }
362  int r=id_RankFreeModule(I,R);
363  if (I->ncols != r) // some 0-lines at the end
364  {
365  return NULL;
366  }
367  long bound=sm_ExpBound(I,r,r,r,R);
368  number diag,h=n_Init(1,R->cf);
369  poly res;
370  ring tmpR;
371  sparse_mat *det;
372  ideal II;
373 
374  tmpR=sm_RingChange(R,bound);
375  II = idrCopyR(I, R, tmpR);
376  diag = sm_Cleardenom(II,tmpR);
377  det = new sparse_mat(II,tmpR);
378  id_Delete(&II,tmpR);
379  if (det->smGetAct() == NULL)
380  {
381  delete det;
382  sm_KillModifiedRing(tmpR);
383  return NULL;
384  }
385  res=det->smDet();
386  if(det->smGetSign()<0) res=p_Neg(res,tmpR);
387  delete det;
388  res = prMoveR(res, tmpR, R);
389  sm_KillModifiedRing(tmpR);
390  if (!n_Equal(diag,h,R->cf))
391  {
392  p_Mult_nn(res,diag,R);
393  p_Normalize(res,R);
394  }
395  n_Delete(&diag,R->cf);
396  n_Delete(&h,R->cf);
397  return res;
398 }
ring sm_RingChange(const ring origR, long bound)
Definition: sparsmat.cc:259
static CanonicalForm bound(const CFMatrix &M)
Definition: cf_linsys.cc:460
int smGetSign()
Definition: sparsmat.cc:172
poly prMoveR(poly &p, ring src_r, ring dest_r)
Definition: prCopy.cc:91
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition: coeffs.h:542
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
static number sm_Cleardenom(ideal, const ring)
Definition: sparsmat.cc:2276
long sm_ExpBound(ideal m, int di, int ra, int t, const ring currRing)
Definition: sparsmat.cc:189
poly res
Definition: myNF.cc:322
const ring r
Definition: syzextra.cc:208
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s
const ring R
Definition: DebugPrint.cc:36
static poly p_Mult_nn(poly p, number n, const ring r)
Definition: p_polys.h:895
void p_Normalize(poly p, const ring r)
Definition: p_polys.cc:3680
#define NULL
Definition: omList.c:10
void sm_KillModifiedRing(ring r)
Definition: sparsmat.cc:290
poly smDet()
Definition: sparsmat.cc:528
static FORCE_INLINE BOOLEAN n_Equal(number a, number b, const coeffs r)
TRUE iff &#39;a&#39; and &#39;b&#39; represent the same number; they may have different representations.
Definition: coeffs.h:464
ideal idrCopyR(ideal id, ring src_r, ring dest_r)
Definition: prCopy.cc:193
static poly p_Neg(poly p, const ring r)
Definition: p_polys.h:1013
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:459
polyrec * poly
Definition: hilb.h:10
static Poly * h
Definition: janet.cc:978
void Werror(const char *fmt,...)
Definition: reporter.cc:189
smpoly * smGetAct()
Definition: sparsmat.cc:173

◆ sm_CallSolv()

ideal sm_CallSolv ( ideal  I,
const ring   
)

Definition at line 2369 of file sparsmat.cc.

2370 {
2371  sparse_number_mat *linsolv;
2372  ring tmpR;
2373  ideal rr;
2374 
2375  if (id_IsConstant(I,R)==FALSE)
2376  {
2377  WerrorS("symbol in equation");
2378  return NULL;
2379  }
2380  I->rank = id_RankFreeModule(I,R);
2381  if (smCheckSolv(I)) return NULL;
2382  tmpR=sm_RingChange(R,1);
2383  rr=idrCopyR(I,R, tmpR);
2384  linsolv = new sparse_number_mat(rr,tmpR);
2385  rr=NULL;
2386  linsolv->smTriangular();
2387  if (linsolv->smIsSing() == 0)
2388  {
2389  linsolv->smSolv();
2390  rr = linsolv->smRes2Ideal();
2391  }
2392  else
2393  WerrorS("singular problem for linsolv");
2394  delete linsolv;
2395  if (rr!=NULL)
2396  rr = idrMoveR(rr,tmpR,R);
2397  sm_KillModifiedRing(tmpR);
2398  return rr;
2399 }
ring sm_RingChange(const ring origR, long bound)
Definition: sparsmat.cc:259
#define FALSE
Definition: auxiliary.h:94
ideal smRes2Ideal()
Definition: sparsmat.cc:2559
BOOLEAN id_IsConstant(ideal id, const ring r)
test if the ideal has only constant polynomials NOTE: zero ideal/module is also constant ...
void WerrorS(const char *s)
Definition: feFopen.cc:24
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s
static BOOLEAN smCheckSolv(ideal)
Definition: sparsmat.cc:2942
const ring R
Definition: DebugPrint.cc:36
ideal idrMoveR(ideal &id, ring src_r, ring dest_r)
Definition: prCopy.cc:249
#define NULL
Definition: omList.c:10
void sm_KillModifiedRing(ring r)
Definition: sparsmat.cc:290
ideal idrCopyR(ideal id, ring src_r, ring dest_r)
Definition: prCopy.cc:193

◆ sm_CheckDet()

BOOLEAN sm_CheckDet ( ideal  ,
int  ,
BOOLEAN  ,
const ring   
)

Definition at line 304 of file sparsmat.cc.

305 {
306  int s,t,i;
307  poly p;
308 
309  if (d>100)
310  return sw;
311  if (!rField_is_Q(r))
312  return sw;
313  s = t = 0;
314  if (sw)
315  {
316  for(i=IDELEMS(I)-1;i>=0;i--)
317  {
318  p=I->m[i];
319  if (p!=NULL)
320  {
321  if(!p_IsConstant(p,r))
322  return sw;
323  s++;
324  t+=n_Size(pGetCoeff(p),r->cf);
325  }
326  }
327  }
328  else
329  {
330  for(i=IDELEMS(I)-1;i>=0;i--)
331  {
332  p=I->m[i];
333  if (!p_IsConstantPoly(p,r))
334  return sw;
335  while (p!=NULL)
336  {
337  s++;
338  t+=n_Size(pGetCoeff(p),r->cf);
339  pIter(p);
340  }
341  }
342  }
343  s*=15;
344  if (t>s)
345  return !sw;
346  else
347  return sw;
348 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
return P p
Definition: myNF.cc:203
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy ...
Definition: monomials.h:51
#define pIter(p)
Definition: monomials.h:44
const ring r
Definition: syzextra.cc:208
static BOOLEAN p_IsConstant(const poly p, const ring r)
Definition: p_polys.h:1876
int i
Definition: cfEzgcd.cc:123
static BOOLEAN rField_is_Q(const ring r)
Definition: ring.h:501
#define IDELEMS(i)
Definition: simpleideals.h:24
#define NULL
Definition: omList.c:10
static BOOLEAN p_IsConstantPoly(const poly p, const ring r)
Definition: p_polys.h:1890
polyrec * poly
Definition: hilb.h:10
static FORCE_INLINE int n_Size(number n, const coeffs r)
return a non-negative measure for the complexity of n; return 0 only when n represents zero; (used fo...
Definition: coeffs.h:574

◆ sm_ExpBound()

long sm_ExpBound ( ideal  ,
int  ,
int  ,
int  ,
const ring   
)

Definition at line 189 of file sparsmat.cc.

190 {
191  poly p;
192  long kr, kc;
193  long *r, *c;
194  int al, bl, i, j, k;
195 
196  if (ra==0) ra=1;
197  al = di*sizeof(long);
198  c = (long *)omAlloc(al);
199  bl = ra*sizeof(long);
200  r = (long *)omAlloc0(bl);
201  for (i=di-1;i>=0;i--)
202  {
203  kc = 0;
204  p = m->m[i];
205  while(p!=NULL)
206  {
207  k = p_GetComp(p, currRing)-1;
208  kr = r[k];
209  for (j=currRing->N;j>0;j--)
210  {
211  long t=p_GetExp(p,j, currRing);
212  if(t /*p_GetExp(p,j, currRing)*/ >kc)
213  kc=t; /*p_GetExp(p,j, currRing);*/
214  if(t /*p_GetExp(p,j, currRing)s*/ >kr)
215  kr=t; /*p_GetExp(p,j, currRing);*/
216  }
217  r[k] = kr;
218  pIter(p);
219  }
220  c[i] = kc;
221  }
222  if (t<di) smMinSelect(c, t, di);
223  if (t<ra) smMinSelect(r, t, ra);
224  kr = kc = 0;
225  for (j=t-1;j>=0;j--)
226  {
227  kr += r[j];
228  kc += c[j];
229  }
230  omFreeSize((ADDRESS)c, al);
231  omFreeSize((ADDRESS)r, bl);
232  if (kr<kc) kc = kr;
233  if (kr<1) kr = 1;
234  return kr;
235 }
return P p
Definition: myNF.cc:203
#define p_GetComp(p, r)
Definition: monomials.h:72
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
void * ADDRESS
Definition: auxiliary.h:115
int k
Definition: cfEzgcd.cc:93
#define omAlloc(size)
Definition: omAllocDecl.h:210
#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
const ring r
Definition: syzextra.cc:208
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:464
int j
Definition: myNF.cc:70
int m
Definition: cfEzgcd.cc:119
int i
Definition: cfEzgcd.cc:123
#define NULL
Definition: omList.c:10
static void smMinSelect(long *, int, int)
Definition: sparsmat.cc:237
polyrec * poly
Definition: hilb.h:10
#define omAlloc0(size)
Definition: omAllocDecl.h:211

◆ sm_KillModifiedRing()

void sm_KillModifiedRing ( ring  r)

Definition at line 290 of file sparsmat.cc.

291 {
292  if (r->qideal!=NULL) id_Delete(&(r->qideal),r);
294 }
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
const ring r
Definition: syzextra.cc:208
#define NULL
Definition: omList.c:10
void rKillModifiedRing(ring r)
Definition: ring.cc:2972

◆ sm_MultDiv()

poly sm_MultDiv ( poly  ,
poly  ,
const poly  ,
const ring   
)

Definition at line 1812 of file sparsmat.cc.

1813 {
1814  poly pa, e, res, r;
1815  BOOLEAN lead;
1816 
1817  if ((c == NULL) || p_LmIsConstantComp(c,R))
1818  {
1819  return pp_Mult_qq(a, b, R);
1820  }
1821  if (smSmaller(a, b))
1822  {
1823  r = a;
1824  a = b;
1825  b = r;
1826  }
1827  res = NULL;
1828  e = p_Init(R);
1829  lead = FALSE;
1830  while (!lead)
1831  {
1832  pSetCoeff0(e,pGetCoeff(b));
1833  if (sm_IsNegQuot(e, b, c, R))
1834  {
1835  lead = p_LmDivisibleByNoComp(e, a, R);
1836  r = sm_SelectCopy_ExpMultDiv(a, e, b, c, R);
1837  }
1838  else
1839  {
1840  lead = TRUE;
1841  r = pp_Mult_mm(a, e,R);
1842  }
1843  if (lead)
1844  {
1845  if (res != NULL)
1846  {
1847  sm_FindRef(&pa, &res, r, R);
1848  if (pa == NULL)
1849  lead = FALSE;
1850  }
1851  else
1852  {
1853  pa = res = r;
1854  }
1855  }
1856  else
1857  res = p_Add_q(res, r, R);
1858  pIter(b);
1859  if (b == NULL)
1860  {
1861  p_LmFree(e, R);
1862  return res;
1863  }
1864  }
1865  do
1866  {
1867  pSetCoeff0(e,pGetCoeff(b));
1868  if (sm_IsNegQuot(e, b, c, R))
1869  {
1870  r = sm_SelectCopy_ExpMultDiv(a, e, b, c, R);
1871  if (p_LmDivisibleByNoComp(e, a,R))
1872  sm_CombineChain(&pa, r, R);
1873  else
1874  pa = p_Add_q(pa,r,R);
1875  }
1876  else
1877  {
1878  r = pp_Mult_mm(a, e, R);
1879  sm_CombineChain(&pa, r, R);
1880  }
1881  pIter(b);
1882  } while (b != NULL);
1883  p_LmFree(e, R);
1884  return res;
1885 }
static BOOLEAN p_LmIsConstantComp(const poly p, const ring r)
Definition: p_polys.h:932
const poly a
Definition: syzextra.cc:212
#define FALSE
Definition: auxiliary.h:94
static BOOLEAN p_LmDivisibleByNoComp(poly a, poly b, const ring r)
Definition: p_polys.h:1754
static BOOLEAN smSmaller(poly, poly)
Definition: sparsmat.cc:2015
static poly pp_Mult_mm(poly p, poly m, const ring r)
Definition: p_polys.h:957
#define TRUE
Definition: auxiliary.h:98
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy ...
Definition: monomials.h:51
static void p_LmFree(poly p, ring)
Definition: p_polys.h:678
#define pIter(p)
Definition: monomials.h:44
poly res
Definition: myNF.cc:322
const ring r
Definition: syzextra.cc:208
static void sm_FindRef(poly *, poly *, poly, const ring)
Definition: sparsmat.cc:2073
static poly pp_Mult_qq(poly p, poly q, const ring r)
Definition: p_polys.h:1070
const ring R
Definition: DebugPrint.cc:36
#define NULL
Definition: omList.c:10
static void sm_CombineChain(poly *, poly, const ring)
Definition: sparsmat.cc:2026
#define pSetCoeff0(p, n)
Definition: monomials.h:67
polyrec * poly
Definition: hilb.h:10
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:877
static poly sm_SelectCopy_ExpMultDiv(poly p, poly m, poly a, poly b, const ring currRing)
Definition: sparsmat.cc:99
int BOOLEAN
Definition: auxiliary.h:85
static poly p_Init(const ring r, omBin bin)
Definition: p_polys.h:1243
const poly b
Definition: syzextra.cc:213
static BOOLEAN sm_IsNegQuot(poly, const poly, const poly, const ring)
Definition: sparsmat.cc:1959

◆ sm_RingChange()

ring sm_RingChange ( const ring  ,
long   
)

Definition at line 259 of file sparsmat.cc.

260 {
261 // *origR =currRing;
262  ring tmpR=rCopy0(origR,FALSE,FALSE);
264  int *block0=(int*)omAlloc(3*sizeof(int));
265  int *block1=(int*)omAlloc(3*sizeof(int));
266  ord[0]=ringorder_c;
267  ord[1]=ringorder_dp;
268  tmpR->order=ord;
269  tmpR->OrdSgn=1;
270  block0[1]=1;
271  tmpR->block0=block0;
272  block1[1]=tmpR->N;
273  tmpR->block1=block1;
274  tmpR->bitmask = 2*bound;
275  tmpR->wvhdl = (int **)omAlloc0((3) * sizeof(int*));
276 
277 // ???
278 // if (tmpR->bitmask > currRing->bitmask) tmpR->bitmask = currRing->bitmask;
279 
280  rComplete(tmpR,1);
281  if (origR->qideal!=NULL)
282  {
283  tmpR->qideal= idrCopyR_NoSort(origR->qideal, origR, tmpR);
284  }
285  if (TEST_OPT_PROT)
286  Print("[%ld:%d]", (long) tmpR->bitmask, tmpR->ExpL_Size);
287  return tmpR;
288 }
static CanonicalForm bound(const CFMatrix &M)
Definition: cf_linsys.cc:460
#define Print
Definition: emacs.cc:83
#define TEST_OPT_PROT
Definition: options.h:98
#define FALSE
Definition: auxiliary.h:94
#define omAlloc(size)
Definition: omAllocDecl.h:210
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:3365
ring rCopy0(const ring r, BOOLEAN copy_qideal, BOOLEAN copy_ordering)
Definition: ring.cc:1325
rRingOrder_t
order stuff
Definition: ring.h:75
#define NULL
Definition: omList.c:10
ideal idrCopyR_NoSort(ideal id, ring src_r, ring dest_r)
Definition: prCopy.cc:206
#define omAlloc0(size)
Definition: omAllocDecl.h:211

◆ sm_SpecialPolyDiv()

void sm_SpecialPolyDiv ( poly  ,
poly  ,
const ring   
)

Definition at line 1893 of file sparsmat.cc.

1894 {
1895  if (pNext(b) == NULL)
1896  {
1897  sm_PolyDivN(a, pGetCoeff(b),R);
1898  return;
1899  }
1900  sm_ExactPolyDiv(a, b, R);
1901 }
const poly a
Definition: syzextra.cc:212
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy ...
Definition: monomials.h:51
const ring R
Definition: DebugPrint.cc:36
static void sm_PolyDivN(poly, const number, const ring)
Definition: sparsmat.cc:2002
#define NULL
Definition: omList.c:10
#define pNext(p)
Definition: monomials.h:43
static void sm_ExactPolyDiv(poly, poly, const ring)
Definition: sparsmat.cc:1904
const poly b
Definition: syzextra.cc:213