My Project  UNKNOWN_GIT_VERSION
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 23 of file sparsmat.h.

◆ SM_MULT

#define SM_MULT   sm_MultDiv

Definition at line 22 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 401 of file sparsmat.cc.

403 {
404  int r=id_RankFreeModule(I,R),t=r;
405  int c=IDELEMS(I),s=c;
406  long bound;
407  ring tmpR;
408  sparse_mat *bareiss;
409 
410  if ((x>0) && (x<t))
411  t-=x;
412  if ((y>1) && (y<s))
413  s-=y;
414  if (t>s) t=s;
415  bound=sm_ExpBound(I,c,r,t,R);
416  tmpR=sm_RingChange(R,bound);
417  ideal II = idrCopyR(I, R, tmpR);
418  bareiss = new sparse_mat(II,tmpR);
419  if (bareiss->smGetAct() == NULL)
420  {
421  delete bareiss;
422  *iv=new intvec(1,rVar(tmpR));
423  }
424  else
425  {
426  id_Delete(&II,tmpR);
427  bareiss->smNewBareiss(x, y);
428  II = bareiss->smRes2Mod();
429  *iv = new intvec(bareiss->smGetRed());
430  bareiss->smToIntvec(*iv);
431  delete bareiss;
432  II = idrMoveR(II,tmpR,R);
433  }
434  sm_KillModifiedRing(tmpR);
435  M=II;

◆ sm_CallDet()

poly sm_CallDet ( ideal  I,
const  ring 
)

Definition at line 356 of file sparsmat.cc.

358 {
359  if (I->ncols != I->rank)
360  {
361  Werror("det of %ld x %d module (matrix)",I->rank,I->ncols);
362  return NULL;
363  }
364  int r=id_RankFreeModule(I,R);
365  if (I->ncols != r) // some 0-lines at the end
366  {
367  return NULL;
368  }
369  long bound=sm_ExpBound(I,r,r,r,R);
370  number diag,h=n_Init(1,R->cf);
371  poly res;
372  ring tmpR;
373  sparse_mat *det;
374  ideal II;
375 
376  tmpR=sm_RingChange(R,bound);
377  II = idrCopyR(I, R, tmpR);
378  diag = sm_Cleardenom(II,tmpR);
379  det = new sparse_mat(II,tmpR);
380  id_Delete(&II,tmpR);
381  if (det->smGetAct() == NULL)
382  {
383  delete det;
384  sm_KillModifiedRing(tmpR);
385  return NULL;
386  }
387  res=det->smDet();
388  if(det->smGetSign()<0) res=p_Neg(res,tmpR);
389  delete det;
390  res = prMoveR(res, tmpR, R);
391  sm_KillModifiedRing(tmpR);
392  if (!n_Equal(diag,h,R->cf))
393  {
394  p_Mult_nn(res,diag,R);
395  p_Normalize(res,R);
396  }
397  n_Delete(&diag,R->cf);
398  n_Delete(&h,R->cf);
399  return res;

◆ sm_CallSolv()

ideal sm_CallSolv ( ideal  I,
const  ring 
)

Definition at line 2370 of file sparsmat.cc.

2372 {
2373  sparse_number_mat *linsolv;
2374  ring tmpR;
2375  ideal rr;
2376 
2377  if (id_IsConstant(I,R)==FALSE)
2378  {
2379  WerrorS("symbol in equation");
2380  return NULL;
2381  }
2382  I->rank = id_RankFreeModule(I,R);
2383  if (smCheckSolv(I)) return NULL;
2384  tmpR=sm_RingChange(R,1);
2385  rr=idrCopyR(I,R, tmpR);
2386  linsolv = new sparse_number_mat(rr,tmpR);
2387  rr=NULL;
2388  linsolv->smTriangular();
2389  if (linsolv->smIsSing() == 0)
2390  {
2391  linsolv->smSolv();
2392  rr = linsolv->smRes2Ideal();
2393  }
2394  else
2395  WerrorS("singular problem for linsolv");
2396  delete linsolv;
2397  if (rr!=NULL)
2398  rr = idrMoveR(rr,tmpR,R);
2399  sm_KillModifiedRing(tmpR);
2400  return rr;

◆ sm_CheckDet()

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

Definition at line 305 of file sparsmat.cc.

307 {
308  int s,t,i;
309  poly p;
310 
311  if (d>100)
312  return sw;
313  if (!rField_is_Q(r))
314  return sw;
315  s = t = 0;
316  if (sw)
317  {
318  for(i=IDELEMS(I)-1;i>=0;i--)
319  {
320  p=I->m[i];
321  if (p!=NULL)
322  {
323  if(!p_IsConstant(p,r))
324  return sw;
325  s++;
326  t+=n_Size(pGetCoeff(p),r->cf);
327  }
328  }
329  }
330  else
331  {
332  for(i=IDELEMS(I)-1;i>=0;i--)
333  {
334  p=I->m[i];
335  if (!p_IsConstantPoly(p,r))
336  return sw;
337  while (p!=NULL)
338  {
339  s++;
340  t+=n_Size(pGetCoeff(p),r->cf);
341  pIter(p);
342  }
343  }
344  }
345  s*=15;
346  if (t>s)
347  return !sw;
348  else
349  return sw;

◆ sm_ExpBound()

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

Definition at line 188 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;

◆ sm_KillModifiedRing()

void sm_KillModifiedRing ( ring  r)

Definition at line 289 of file sparsmat.cc.

291 {
292  if (r->qideal!=NULL) id_Delete(&(r->qideal),r);
293  for(int i=r->N-1;i>=0;i--) omFree(r->names[i]);
294  omFreeSize(r->names,r->N*sizeof(char*));

◆ sm_MultDiv()

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

Definition at line 1813 of file sparsmat.cc.

1815 {
1816  poly pa, e, res, r;
1817  BOOLEAN lead;
1818 
1819  if ((c == NULL) || p_LmIsConstantComp(c,R))
1820  {
1821  return pp_Mult_qq(a, b, R);
1822  }
1823  if (smSmaller(a, b))
1824  {
1825  r = a;
1826  a = b;
1827  b = r;
1828  }
1829  res = NULL;
1830  e = p_Init(R);
1831  lead = FALSE;
1832  while (!lead)
1833  {
1834  pSetCoeff0(e,pGetCoeff(b));
1835  if (sm_IsNegQuot(e, b, c, R))
1836  {
1837  lead = p_LmDivisibleByNoComp(e, a, R);
1838  r = sm_SelectCopy_ExpMultDiv(a, e, b, c, R);
1839  }
1840  else
1841  {
1842  lead = TRUE;
1843  r = pp_Mult_mm(a, e,R);
1844  }
1845  if (lead)
1846  {
1847  if (res != NULL)
1848  {
1849  sm_FindRef(&pa, &res, r, R);
1850  if (pa == NULL)
1851  lead = FALSE;
1852  }
1853  else
1854  {
1855  pa = res = r;
1856  }
1857  }
1858  else
1859  res = p_Add_q(res, r, R);
1860  pIter(b);
1861  if (b == NULL)
1862  {
1863  p_LmFree(e, R);
1864  return res;
1865  }
1866  }
1867  do
1868  {
1869  pSetCoeff0(e,pGetCoeff(b));
1870  if (sm_IsNegQuot(e, b, c, R))
1871  {
1872  r = sm_SelectCopy_ExpMultDiv(a, e, b, c, R);
1873  if (p_LmDivisibleByNoComp(e, a,R))
1874  sm_CombineChain(&pa, r, R);
1875  else
1876  pa = p_Add_q(pa,r,R);
1877  }
1878  else
1879  {
1880  r = pp_Mult_mm(a, e, R);
1881  sm_CombineChain(&pa, r, R);
1882  }
1883  pIter(b);
1884  } while (b != NULL);
1885  p_LmFree(e, R);
1886  return res;

◆ sm_RingChange()

ring sm_RingChange ( const  ring,
long   
)

Definition at line 258 of file sparsmat.cc.

260 {
261 // *origR =currRing;
262  ring tmpR=rCopy0(origR,FALSE,FALSE);
264  int *block0=(int*)omAlloc0(3*sizeof(int));
265  int *block1=(int*)omAlloc0(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;

◆ sm_SpecialPolyDiv()

void sm_SpecialPolyDiv ( poly  ,
poly  ,
const  ring 
)

Definition at line 1894 of file sparsmat.cc.

1896 {
1897  if (pNext(b) == NULL)
1898  {
1899  sm_PolyDivN(a, pGetCoeff(b),R);
1900  return;
1901  }
1902  sm_ExactPolyDiv(a, b, R);
sm_IsNegQuot
static BOOLEAN sm_IsNegQuot(poly, const poly, const poly, const ring)
Definition: sparsmat.cc:1960
FALSE
#define FALSE
Definition: auxiliary.h:94
p_GetComp
#define p_GetComp(p, r)
Definition: monomials.h:62
p_LmIsConstantComp
static BOOLEAN p_LmIsConstantComp(const poly p, const ring r)
Definition: p_polys.h:948
p_GetExp
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent @Note: the integer VarOffset encodes:
Definition: p_polys.h:458
j
int j
Definition: facHensel.cc:105
omFree
#define omFree(addr)
Definition: omAllocDecl.h:259
p_Normalize
void p_Normalize(poly p, const ring r)
Definition: p_polys.cc:3720
TEST_OPT_PROT
#define TEST_OPT_PROT
Definition: options.h:101
k
int k
Definition: cfEzgcd.cc:92
idrCopyR_NoSort
ideal idrCopyR_NoSort(ideal id, ring src_r, ring dest_r)
Definition: prCopy.cc:205
sparse_mat::smToIntvec
void smToIntvec(intvec *)
Definition: sparsmat.cc:518
x
Variable x
Definition: cfModGcd.cc:4023
y
const CanonicalForm int const CFList const Variable & y
Definition: facAbsFact.cc:57
ADDRESS
void * ADDRESS
Definition: auxiliary.h:133
sparse_number_mat::smRes2Ideal
ideal smRes2Ideal()
Definition: sparsmat.cc:2560
p_Neg
static poly p_Neg(poly p, const ring r)
Definition: p_polys.h:1029
sparse_mat::smGetRed
int smGetRed()
Definition: sparsmat.cc:173
rKillModifiedRing
void rKillModifiedRing(ring r)
Definition: ring.cc:2972
id_IsConstant
BOOLEAN id_IsConstant(ideal id, const ring r)
test if the ideal has only constant polynomials NOTE: zero ideal/module is also constant
Definition: simpleideals.cc:390
sparse_mat::smGetSign
int smGetSign()
Definition: sparsmat.cc:171
smMinSelect
static void smMinSelect(long *, int, int)
Definition: sparsmat.cc:236
n_Delete
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:454
pp_Mult_mm
static poly pp_Mult_mm(poly p, poly m, const ring r)
Definition: p_polys.h:973
sm_RingChange
ring sm_RingChange(const ring origR, long bound)
Definition: sparsmat.cc:258
smCheckSolv
static BOOLEAN smCheckSolv(ideal)
Definition: sparsmat.cc:2943
b
CanonicalForm b
Definition: cfModGcd.cc:4044
rCopy0
ring rCopy0(const ring r, BOOLEAN copy_qideal, BOOLEAN copy_ordering)
Definition: ring.cc:1339
prMoveR
poly prMoveR(poly &p, ring src_r, ring dest_r)
Definition: prCopy.cc:90
currRing
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
rVar
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:581
TRUE
#define TRUE
Definition: auxiliary.h:98
i
int i
Definition: cfEzgcd.cc:125
id_Delete
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
Definition: simpleideals.cc:113
res
CanonicalForm res
Definition: facAbsFact.cc:64
idrMoveR
ideal idrMoveR(ideal &id, ring src_r, ring dest_r)
Definition: prCopy.cc:248
id_RankFreeModule
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s
Definition: simpleideals.cc:781
M
#define M
Definition: sirandom.c:24
omFreeSize
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:258
BOOLEAN
int BOOLEAN
Definition: auxiliary.h:85
sm_FindRef
static void sm_FindRef(poly *, poly *, poly, const ring)
Definition: sparsmat.cc:2074
smSmaller
static BOOLEAN smSmaller(poly, poly)
Definition: sparsmat.cc:2016
sparse_mat::smNewBareiss
void smNewBareiss(int, int)
Definition: sparsmat.cc:603
h
static Poly * h
Definition: janet.cc:972
sparse_number_mat::smIsSing
int smIsSing()
Definition: sparsmat.cc:2357
pp_Mult_qq
static poly pp_Mult_qq(poly p, poly q, const ring r)
Definition: p_polys.h:1073
intvec
Definition: intvec.h:16
pIter
#define pIter(p)
Definition: monomials.h:35
omAlloc
#define omAlloc(size)
Definition: omAllocDecl.h:208
n_Init
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:537
sm_CombineChain
static void sm_CombineChain(poly *, poly, const ring)
Definition: sparsmat.cc:2027
p_Init
static poly p_Init(const ring r, omBin bin)
Definition: p_polys.h:1240
sparse_mat::smRes2Mod
ideal smRes2Mod()
Definition: sparsmat.cc:502
sm_KillModifiedRing
void sm_KillModifiedRing(ring r)
Definition: sparsmat.cc:289
sm_PolyDivN
static void sm_PolyDivN(poly, const number, const ring)
Definition: sparsmat.cc:2003
ringorder_c
Definition: ring.h:72
ringorder_dp
Definition: ring.h:78
sm_Cleardenom
static number sm_Cleardenom(ideal, const ring)
Definition: sparsmat.cc:2277
p_LmFree
static void p_LmFree(poly p, ring)
Definition: p_polys.h:671
p_Add_q
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:878
sm_SelectCopy_ExpMultDiv
static poly sm_SelectCopy_ExpMultDiv(poly p, poly m, poly a, poly b, const ring currRing)
Definition: sparsmat.cc:98
bound
static CanonicalForm bound(const CFMatrix &M)
Definition: cf_linsys.cc:460
Print
#define Print
Definition: emacs.cc:79
sparse_mat
Definition: sparsmat.cc:124
Werror
void Werror(const char *fmt,...)
Definition: reporter.cc:188
pSetCoeff0
#define pSetCoeff0(p, n)
Definition: monomials.h:57
WerrorS
void WerrorS(const char *s)
Definition: feFopen.cc:24
m
int m
Definition: cfEzgcd.cc:121
NULL
#define NULL
Definition: omList.c:9
sparse_number_mat
Definition: sparsmat.cc:2329
sparse_number_mat::smSolv
void smSolv()
Definition: sparsmat.cc:2483
R
#define R
Definition: sirandom.c:26
sparse_mat::smGetAct
smpoly * smGetAct()
Definition: sparsmat.cc:172
sparse_number_mat::smTriangular
void smTriangular()
Definition: sparsmat.cc:2452
sm_ExactPolyDiv
static void sm_ExactPolyDiv(poly, poly, const ring)
Definition: sparsmat.cc:1905
n_Equal
static FORCE_INLINE BOOLEAN n_Equal(number a, number b, const coeffs r)
TRUE iff 'a' and 'b' represent the same number; they may have different representations.
Definition: coeffs.h:459
p
int p
Definition: cfModGcd.cc:4019
p_IsConstantPoly
static BOOLEAN p_IsConstantPoly(const poly p, const ring r)
Definition: p_polys.h:1921
p_IsConstant
static BOOLEAN p_IsConstant(const poly p, const ring r)
Definition: p_polys.h:1907
s
const CanonicalForm int s
Definition: facAbsFact.cc:55
sm_ExpBound
long sm_ExpBound(ideal m, int di, int ra, int t, const ring currRing)
Definition: sparsmat.cc:188
IDELEMS
#define IDELEMS(i)
Definition: simpleideals.h:24
pGetCoeff
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy
Definition: monomials.h:42
n_Size
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:569
p_LmDivisibleByNoComp
static BOOLEAN p_LmDivisibleByNoComp(poly a, poly b, const ring r)
Definition: p_polys.h:1786
rRingOrder_t
rRingOrder_t
order stuff
Definition: ring.h:67
pNext
#define pNext(p)
Definition: monomials.h:34
sparse_mat::smDet
poly smDet()
Definition: sparsmat.cc:529
omAlloc0
#define omAlloc0(size)
Definition: omAllocDecl.h:209
p_Mult_nn
static poly p_Mult_nn(poly p, number n, const ring r)
Definition: p_polys.h:900
idrCopyR
ideal idrCopyR(ideal id, ring src_r, ring dest_r)
Definition: prCopy.cc:192
rField_is_Q
static BOOLEAN rField_is_Q(const ring r)
Definition: ring.h:496
rComplete
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:3368