My Project  debian-1:4.1.2-p1+ds-2
Data Structures | Macros | Typedefs | Functions | Variables
sparsmat.cc File Reference
#include "misc/auxiliary.h"
#include "misc/mylimits.h"
#include "misc/options.h"
#include "reporter/reporter.h"
#include "misc/intvec.h"
#include "coeffs/numbers.h"
#include "monomials/ring.h"
#include "monomials/p_polys.h"
#include "simpleideals.h"
#include "sparsmat.h"
#include "prCopy.h"
#include "templates/p_Procs.h"
#include "kbuckets.h"
#include "operations/p_Mult_q.h"

Go to the source code of this file.

Data Structures

struct  sm_prec
 
class  sparse_mat
 
struct  sm_nrec
 
class  sparse_number_mat
 

Macros

#define SM_MIN_LENGTH_BUCKET   MIN_LENGTH_BUCKET - 5
 

Typedefs

typedef sm_prec * smpoly
 
typedef sm_nrec * smnumber
 

Functions

static void sm_ExactPolyDiv (poly, poly, const ring)
 
static BOOLEAN sm_IsNegQuot (poly, const poly, const poly, const ring)
 
static void sm_ExpMultDiv (poly, const poly, const poly, const ring)
 
static void sm_PolyDivN (poly, const number, const ring)
 
static BOOLEAN smSmaller (poly, poly)
 
static void sm_CombineChain (poly *, poly, const ring)
 
static void sm_FindRef (poly *, poly *, poly, const ring)
 
static void sm_ElemDelete (smpoly *, const ring)
 
static smpoly smElemCopy (smpoly)
 
static float sm_PolyWeight (smpoly, const ring)
 
static smpoly sm_Poly2Smpoly (poly, const ring)
 
static poly sm_Smpoly2Poly (smpoly, const ring)
 
static BOOLEAN sm_HaveDenom (poly, const ring)
 
static number sm_Cleardenom (ideal, const ring)
 
static poly pp_Mult_Coeff_mm_DivSelect_MultDiv (poly p, int &lp, poly m, poly a, poly b, const ring currRing)
 
static poly sm_SelectCopy_ExpMultDiv (poly p, poly m, poly a, poly b, const ring currRing)
 
static void smMinSelect (long *, int, int)
 
long sm_ExpBound (ideal m, int di, int ra, int t, const ring currRing)
 
ring sm_RingChange (const ring origR, long bound)
 
void sm_KillModifiedRing (ring r)
 
poly sm_CallDet (ideal I, const ring R)
 
void sm_CallBareiss (ideal I, int x, int y, ideal &M, intvec **iv, const ring R)
 
poly sm_MultDiv (poly a, poly b, const poly c, const ring R)
 
void sm_SpecialPolyDiv (poly a, poly b, const ring R)
 
static void sm_NumberDelete (smnumber *, const ring R)
 
static smnumber smNumberCopy (smnumber)
 
static smnumber sm_Poly2Smnumber (poly, const ring)
 
static poly sm_Smnumber2Poly (number, const ring)
 
static BOOLEAN smCheckSolv (ideal)
 
ideal sm_CallSolv (ideal I, const ring R)
 

Variables

VAR omBin smprec_bin = omGetSpecBin(sizeof(smprec))
 
STATIC_VAR omBin smnrec_bin = omGetSpecBin(sizeof(smnrec))
 

Data Structure Documentation

◆ smprec

struct smprec

Definition at line 46 of file sparsmat.cc.

Data Fields
int e
float f
poly m
smpoly n
int pos

◆ smnrec

struct smnrec

Definition at line 2257 of file sparsmat.cc.

Data Fields
number m
smnumber n
int pos

Macro Definition Documentation

◆ SM_MIN_LENGTH_BUCKET

#define SM_MIN_LENGTH_BUCKET   MIN_LENGTH_BUCKET - 5

Definition at line 39 of file sparsmat.cc.

Typedef Documentation

◆ smnumber

typedef sm_nrec* smnumber

Definition at line 2256 of file sparsmat.cc.

◆ smpoly

typedef sm_prec* smpoly

Definition at line 45 of file sparsmat.cc.

Function Documentation

◆ pp_Mult_Coeff_mm_DivSelect_MultDiv()

static poly pp_Mult_Coeff_mm_DivSelect_MultDiv ( poly  p,
int &  lp,
poly  m,
poly  a,
poly  b,
const ring  currRing 
)
static

Definition at line 75 of file sparsmat.cc.

78 {
79  if (rOrd_is_Comp_dp(currRing) && currRing->ExpL_Size > 2)
80  {
81  // pp_Mult_Coeff_mm_DivSelectMult only works for (c/C,dp) and
82  // ExpL_Size > 2
83  // should be generalized, at least to dp with ExpL_Size == 2
84  // (is the case for 1 variable)
85  int shorter;
86  p = currRing->p_Procs->pp_Mult_Coeff_mm_DivSelectMult(p, m, a, b,
87  shorter, currRing);
88  lp -= shorter;
89  }
90  else
91  {
93  sm_ExpMultDiv(p, a, b, currRing);
94  }
95  return p;

◆ sm_CallBareiss()

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

Definition at line 346 of file sparsmat.cc.

348 {
349  int r=id_RankFreeModule(I,R),t=r;
350  int c=IDELEMS(I),s=c;
351  long bound;
352  ring tmpR;
353  sparse_mat *bareiss;
354 
355  if ((x>0) && (x<t))
356  t-=x;
357  if ((y>1) && (y<s))
358  s-=y;
359  if (t>s) t=s;
360  bound=sm_ExpBound(I,c,r,t,R);
361  tmpR=sm_RingChange(R,bound);
362  ideal II = idrCopyR(I, R, tmpR);
363  bareiss = new sparse_mat(II,tmpR);
364  if (bareiss->smGetAct() == NULL)
365  {
366  delete bareiss;
367  *iv=new intvec(1,rVar(tmpR));
368  }
369  else
370  {
371  id_Delete(&II,tmpR);
372  bareiss->smNewBareiss(x, y);
373  II = bareiss->smRes2Mod();
374  *iv = new intvec(bareiss->smGetRed());
375  bareiss->smToIntvec(*iv);
376  delete bareiss;
377  II = idrMoveR(II,tmpR,R);
378  }
379  sm_KillModifiedRing(tmpR);
380  M=II;

◆ sm_CallDet()

poly sm_CallDet ( ideal  I,
const ring  R 
)

Definition at line 301 of file sparsmat.cc.

303 {
304  if (I->ncols != I->rank)
305  {
306  Werror("det of %ld x %d module (matrix)",I->rank,I->ncols);
307  return NULL;
308  }
309  int r=id_RankFreeModule(I,R);
310  if (I->ncols != r) // some 0-lines at the end
311  {
312  return NULL;
313  }
314  long bound=sm_ExpBound(I,r,r,r,R);
315  number diag,h=n_Init(1,R->cf);
316  poly res;
317  ring tmpR;
318  sparse_mat *det;
319  ideal II;
320 
321  tmpR=sm_RingChange(R,bound);
322  II = idrCopyR(I, R, tmpR);
323  diag = sm_Cleardenom(II,tmpR);
324  det = new sparse_mat(II,tmpR);
325  id_Delete(&II,tmpR);
326  if (det->smGetAct() == NULL)
327  {
328  delete det;
329  sm_KillModifiedRing(tmpR);
330  return NULL;
331  }
332  res=det->smDet();
333  if(det->smGetSign()<0) res=p_Neg(res,tmpR);
334  delete det;
335  res = prMoveR(res, tmpR, R);
336  sm_KillModifiedRing(tmpR);
337  if (!n_Equal(diag,h,R->cf))
338  {
339  p_Mult_nn(res,diag,R);
340  p_Normalize(res,R);
341  }
342  n_Delete(&diag,R->cf);
343  n_Delete(&h,R->cf);
344  return res;

◆ sm_CallSolv()

ideal sm_CallSolv ( ideal  I,
const ring  R 
)

Definition at line 2315 of file sparsmat.cc.

2317 {
2318  sparse_number_mat *linsolv;
2319  ring tmpR;
2320  ideal rr;
2321 
2322  if (id_IsConstant(I,R)==FALSE)
2323  {
2324  WerrorS("symbol in equation");
2325  return NULL;
2326  }
2327  I->rank = id_RankFreeModule(I,R);
2328  if (smCheckSolv(I)) return NULL;
2329  tmpR=sm_RingChange(R,1);
2330  rr=idrCopyR(I,R, tmpR);
2331  linsolv = new sparse_number_mat(rr,tmpR);
2332  rr=NULL;
2333  linsolv->smTriangular();
2334  if (linsolv->smIsSing() == 0)
2335  {
2336  linsolv->smSolv();
2337  rr = linsolv->smRes2Ideal();
2338  }
2339  else
2340  WerrorS("singular problem for linsolv");
2341  delete linsolv;
2342  if (rr!=NULL)
2343  rr = idrMoveR(rr,tmpR,R);
2344  sm_KillModifiedRing(tmpR);
2345  return rr;

◆ sm_Cleardenom()

static number sm_Cleardenom ( ideal  id,
const ring  R 
)
static

Definition at line 2222 of file sparsmat.cc.

2224 {
2225  poly a;
2226  number x,y,res=n_Init(1,R->cf);
2227  BOOLEAN sw=FALSE;
2228 
2229  for (int i=0; i<IDELEMS(id); i++)
2230  {
2231  a = id->m[i];
2232  sw = sm_HaveDenom(a,R);
2233  if (sw) break;
2234  }
2235  if (!sw) return res;
2236  for (int i=0; i<IDELEMS(id); i++)
2237  {
2238  a = id->m[i];
2239  if (a!=NULL)
2240  {
2241  x = n_Copy(pGetCoeff(a),R->cf);
2242  p_Cleardenom(a, R);
2243  y = n_Div(x,pGetCoeff(a),R->cf);
2244  n_Delete(&x,R->cf);
2245  x = n_Mult(res,y,R->cf);
2246  n_Normalize(x,R->cf);
2247  n_Delete(&res,R->cf);
2248  res = x;
2249  }
2250  }
2251  return res;

◆ sm_CombineChain()

static void sm_CombineChain ( poly *  px,
poly  r,
const ring  R 
)
static

Definition at line 1972 of file sparsmat.cc.

1974 {
1975  poly pa = *px, pb;
1976  number x;
1977  int i;
1978 
1979  loop
1980  {
1981  pb = pNext(pa);
1982  if (pb == NULL)
1983  {
1984  pa = pNext(pa) = r;
1985  break;
1986  }
1987  i = p_LmCmp(pb, r,R);
1988  if (i > 0)
1989  pa = pb;
1990  else
1991  {
1992  if (i == 0)
1993  {
1994  x = n_Add(pGetCoeff(pb), pGetCoeff(r),R->cf);
1995  p_LmDelete(&r,R);
1996  if (n_IsZero(x,R->cf))
1997  {
1998  p_LmDelete(&pb,R);
1999  pNext(pa) = p_Add_q(pb,r,R);
2000  }
2001  else
2002  {
2003  pa = pb;
2004  p_SetCoeff(pa,x,R);
2005  pNext(pa) = p_Add_q(pNext(pa), r, R);
2006  }
2007  }
2008  else
2009  {
2010  pa = pNext(pa) = r;
2011  pNext(pa) = p_Add_q(pb, pNext(pa),R);
2012  }
2013  break;
2014  }
2015  }
2016  *px = pa;

◆ sm_ElemDelete()

static void sm_ElemDelete ( smpoly r,
const ring  R 
)
static

Definition at line 2075 of file sparsmat.cc.

2077 {
2078  smpoly a = *r, b = a->n;
2079 
2080  p_Delete(&a->m, R);
2081  omFreeBin((void *)a, smprec_bin);
2082  *r = b;

◆ sm_ExactPolyDiv()

static void sm_ExactPolyDiv ( poly  a,
poly  b,
const ring  R 
)
static

Definition at line 1850 of file sparsmat.cc.

1852 {
1853  const number x = pGetCoeff(b);
1854  poly tail = pNext(b), e = p_Init(R);
1855  poly h;
1856  number y, yn;
1857  int lt = pLength(tail);
1858 
1859  if (lt + 1 >= SM_MIN_LENGTH_BUCKET && !TEST_OPT_NOT_BUCKETS)
1860  {
1861  kBucket_pt bucket = kBucketCreate(R);
1862  kBucketInit(bucket, pNext(a), 0);
1863  int lh = 0;
1864  do
1865  {
1866  y = n_Div(pGetCoeff(a), x, R->cf);
1867  n_Normalize(y, R->cf);
1868  p_SetCoeff(a,y, R);
1869  yn = n_InpNeg(n_Copy(y, R->cf), R->cf);
1870  pSetCoeff0(e,yn);
1871  lh = lt;
1872  if (sm_IsNegQuot(e, a, b, R))
1873  {
1874  h = pp_Mult_Coeff_mm_DivSelect_MultDiv(tail, lh, e, a, b, R);
1875  }
1876  else
1877  h = pp_Mult_mm(tail, e, R);
1878  n_Delete(&yn, R->cf);
1879  kBucket_Add_q(bucket, h, &lh);
1880 
1881  a = pNext(a) = kBucketExtractLm(bucket);
1882  } while (a!=NULL);
1883  kBucketDestroy(&bucket);
1884  }
1885  else
1886  {
1887  do
1888  {
1889  y = n_Div(pGetCoeff(a), x, R->cf);
1890  n_Normalize(y, R->cf);
1891  p_SetCoeff(a,y, R);
1892  yn = n_InpNeg(n_Copy(y, R->cf), R->cf);
1893  pSetCoeff0(e,yn);
1894  if (sm_IsNegQuot(e, a, b, R))
1895  h = sm_SelectCopy_ExpMultDiv(tail, e, a, b, R);
1896  else
1897  h = pp_Mult_mm(tail, e, R);
1898  n_Delete(&yn, R->cf);
1899  a = pNext(a) = p_Add_q(pNext(a), h, R);
1900  } while (a!=NULL);
1901  }
1902  p_LmFree(e, R);

◆ sm_ExpBound()

long sm_ExpBound ( ideal  m,
int  di,
int  ra,
int  t,
const ring  currRing 
)

Definition at line 187 of file sparsmat.cc.

189 {
190  poly p;
191  long kr, kc;
192  long *r, *c;
193  int al, bl, i, j, k;
194 
195  if (ra==0) ra=1;
196  al = di*sizeof(long);
197  c = (long *)omAlloc(al);
198  bl = ra*sizeof(long);
199  r = (long *)omAlloc0(bl);
200  for (i=di-1;i>=0;i--)
201  {
202  kc = 0;
203  p = m->m[i];
204  while(p!=NULL)
205  {
206  k = p_GetComp(p, currRing)-1;
207  kr = r[k];
208  for (j=currRing->N;j>0;j--)
209  {
210  long t=p_GetExp(p,j, currRing);
211  if(t /*p_GetExp(p,j, currRing)*/ >kc)
212  kc=t; /*p_GetExp(p,j, currRing);*/
213  if(t /*p_GetExp(p,j, currRing)s*/ >kr)
214  kr=t; /*p_GetExp(p,j, currRing);*/
215  }
216  r[k] = kr;
217  pIter(p);
218  }
219  c[i] = kc;
220  }
221  if (t<di) smMinSelect(c, t, di);
222  if (t<ra) smMinSelect(r, t, ra);
223  kr = kc = 0;
224  for (j=t-1;j>=0;j--)
225  {
226  kr += r[j];
227  kc += c[j];
228  }
229  omFreeSize((ADDRESS)c, al);
230  omFreeSize((ADDRESS)r, bl);
231  if (kr<kc) kc = kr;
232  if (kr<1) kr = 1;
233  return kr;

◆ sm_ExpMultDiv()

static void sm_ExpMultDiv ( poly  t,
const poly  b,
const poly  c,
const ring  R 
)
static

Definition at line 1930 of file sparsmat.cc.

1932 {
1933  p_Test(t,R);
1934  p_LmTest(b,R);
1935  p_LmTest(c,R);
1936  poly bc = p_New(R);
1937 
1938  p_ExpVectorDiff(bc, b, c, R);
1939 
1940  while(t!=NULL)
1941  {
1942  p_ExpVectorAdd(t, bc, R);
1943  pIter(t);
1944  }
1945  p_LmFree(bc, R);

◆ sm_FindRef()

static void sm_FindRef ( poly *  ref,
poly *  px,
poly  r,
const ring  R 
)
static

Definition at line 2019 of file sparsmat.cc.

2021 {
2022  number x;
2023  int i;
2024  poly pa = *px, pp = NULL;
2025 
2026  loop
2027  {
2028  i = p_LmCmp(pa, r,R);
2029  if (i > 0)
2030  {
2031  pp = pa;
2032  pIter(pa);
2033  if (pa==NULL)
2034  {
2035  pNext(pp) = r;
2036  break;
2037  }
2038  }
2039  else
2040  {
2041  if (i == 0)
2042  {
2043  x = n_Add(pGetCoeff(pa), pGetCoeff(r),R->cf);
2044  p_LmDelete(&r,R);
2045  if (n_IsZero(x,R->cf))
2046  {
2047  p_LmDelete(&pa,R);
2048  if (pp!=NULL)
2049  pNext(pp) = p_Add_q(pa,r,R);
2050  else
2051  *px = p_Add_q(pa,r,R);
2052  }
2053  else
2054  {
2055  pp = pa;
2056  p_SetCoeff(pp,x,R);
2057  pNext(pp) = p_Add_q(pNext(pp), r, R);
2058  }
2059  }
2060  else
2061  {
2062  if (pp!=NULL)
2063  pp = pNext(pp) = r;
2064  else
2065  *px = pp = r;
2066  pNext(pp) = p_Add_q(pa, pNext(r),R);
2067  }
2068  break;
2069  }
2070  }
2071  *ref = pp;

◆ sm_HaveDenom()

static BOOLEAN sm_HaveDenom ( poly  a,
const ring  R 
)
static

Definition at line 2203 of file sparsmat.cc.

2205 {
2206  BOOLEAN sw;
2207  number x;
2208 
2209  while (a != NULL)
2210  {
2211  x = n_GetDenom(pGetCoeff(a),R->cf);
2212  sw = n_IsOne(x,R->cf);
2213  n_Delete(&x,R->cf);
2214  if (!sw)
2215  {
2216  return TRUE;
2217  }
2218  pIter(a);
2219  }
2220  return FALSE;

◆ sm_IsNegQuot()

static BOOLEAN sm_IsNegQuot ( poly  a,
const poly  b,
const poly  c,
const ring  R 
)
static

Definition at line 1905 of file sparsmat.cc.

1907 {
1908  if (p_LmDivisibleByNoComp(c, b,R))
1909  {
1910  p_ExpVectorDiff(a, b, c,R);
1911  // Hmm: here used to be a p_Setm(a): but it is unnecessary,
1912  // if b and c are correct
1913  return FALSE;
1914  }
1915  else
1916  {
1917  int i;
1918  for (i=rVar(R); i>0; i--)
1919  {
1920  if(p_GetExp(c,i,R) > p_GetExp(b,i,R))
1921  p_SetExp(a,i,p_GetExp(c,i,R)-p_GetExp(b,i,R),R);
1922  else
1923  p_SetExp(a,i,0,R);
1924  }
1925  // here we actually might need a p_Setm, if a is to be used in
1926  // comparisons
1927  return TRUE;
1928  }

◆ sm_KillModifiedRing()

void sm_KillModifiedRing ( ring  r)

Definition at line 288 of file sparsmat.cc.

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

◆ sm_MultDiv()

poly sm_MultDiv ( poly  a,
poly  b,
const poly  c,
const ring  R 
)

Definition at line 1758 of file sparsmat.cc.

1760 {
1761  poly pa, e, res, r;
1762  BOOLEAN lead;
1763 
1764  if ((c == NULL) || p_LmIsConstantComp(c,R))
1765  {
1766  return pp_Mult_qq(a, b, R);
1767  }
1768  if (smSmaller(a, b))
1769  {
1770  r = a;
1771  a = b;
1772  b = r;
1773  }
1774  res = NULL;
1775  e = p_Init(R);
1776  lead = FALSE;
1777  while (!lead)
1778  {
1779  pSetCoeff0(e,pGetCoeff(b));
1780  if (sm_IsNegQuot(e, b, c, R))
1781  {
1782  lead = p_LmDivisibleByNoComp(e, a, R);
1783  r = sm_SelectCopy_ExpMultDiv(a, e, b, c, R);
1784  }
1785  else
1786  {
1787  lead = TRUE;
1788  r = pp_Mult_mm(a, e,R);
1789  }
1790  if (lead)
1791  {
1792  if (res != NULL)
1793  {
1794  sm_FindRef(&pa, &res, r, R);
1795  if (pa == NULL)
1796  lead = FALSE;
1797  }
1798  else
1799  {
1800  pa = res = r;
1801  }
1802  }
1803  else
1804  res = p_Add_q(res, r, R);
1805  pIter(b);
1806  if (b == NULL)
1807  {
1808  p_LmFree(e, R);
1809  return res;
1810  }
1811  }
1812  do
1813  {
1814  pSetCoeff0(e,pGetCoeff(b));
1815  if (sm_IsNegQuot(e, b, c, R))
1816  {
1817  r = sm_SelectCopy_ExpMultDiv(a, e, b, c, R);
1818  if (p_LmDivisibleByNoComp(e, a,R))
1819  sm_CombineChain(&pa, r, R);
1820  else
1821  pa = p_Add_q(pa,r,R);
1822  }
1823  else
1824  {
1825  r = pp_Mult_mm(a, e, R);
1826  sm_CombineChain(&pa, r, R);
1827  }
1828  pIter(b);
1829  } while (b != NULL);
1830  p_LmFree(e, R);
1831  return res;

◆ sm_NumberDelete()

static void sm_NumberDelete ( smnumber r,
const ring  R 
)
static

Definition at line 2824 of file sparsmat.cc.

2826 {
2827  smnumber a = *r, b = a->n;
2828 
2829  n_Delete(&a->m,R->cf);
2831  *r = b;

◆ sm_Poly2Smnumber()

static smnumber sm_Poly2Smnumber ( poly  q,
const ring  R 
)
static

Definition at line 2844 of file sparsmat.cc.

2846 {
2847  smnumber a, res;
2848  poly p = q;
2849 
2850  if (p == NULL)
2851  return NULL;
2853  a->pos = p_GetComp(p,R);
2854  a->m = pGetCoeff(p);
2855  n_New(&pGetCoeff(p),R->cf);
2856  loop
2857  {
2858  pIter(p);
2859  if (p == NULL)
2860  {
2861  p_Delete(&q,R);
2862  a->n = NULL;
2863  return res;
2864  }
2865  a = a->n = (smnumber)omAllocBin(smnrec_bin);
2866  a->pos = p_GetComp(p,R);
2867  a->m = pGetCoeff(p);
2868  n_New(&pGetCoeff(p),R->cf);
2869  }

◆ sm_Poly2Smpoly()

static smpoly sm_Poly2Smpoly ( poly  q,
const ring  R 
)
static

Definition at line 2096 of file sparsmat.cc.

2098 {
2099  poly pp;
2100  smpoly res, a;
2101  long x;
2102 
2103  if (q == NULL)
2104  return NULL;
2105  a = res = (smpoly)omAllocBin(smprec_bin);
2106  a->pos = x = p_GetComp(q,R);
2107  a->m = q;
2108  a->e = 0;
2109  loop
2110  {
2111  p_SetComp(q,0,R);
2112  pp = q;
2113  pIter(q);
2114  if (q == NULL)
2115  {
2116  a->n = NULL;
2117  return res;
2118  }
2119  if (p_GetComp(q,R) != x)
2120  {
2121  a = a->n = (smpoly)omAllocBin(smprec_bin);
2122  pNext(pp) = NULL;
2123  a->pos = x = p_GetComp(q,R);
2124  a->m = q;
2125  a->e = 0;
2126  }
2127  }

◆ sm_PolyDivN()

static void sm_PolyDivN ( poly  a,
const number  x,
const ring  R 
)
static

Definition at line 1948 of file sparsmat.cc.

1950 {
1951  number y;
1952 
1953  do
1954  {
1955  y = n_Div(pGetCoeff(a),x, R->cf);
1956  n_Normalize(y, R->cf);
1957  p_SetCoeff(a,y, R);
1958  pIter(a);
1959  } while (a != NULL);

◆ sm_PolyWeight()

static float sm_PolyWeight ( smpoly  a,
const ring  R 
)
static

Definition at line 2174 of file sparsmat.cc.

2176 {
2177  poly p = a->m;
2178  int i;
2179  float res = (float)n_Size(pGetCoeff(p),R->cf);
2180 
2181  if (pNext(p) == NULL)
2182  {
2183  for(i=rVar(R); i>0; i--)
2184  {
2185  if (p_GetExp(p,i,R) != 0) return res+1.0;
2186  }
2187  return res;
2188  }
2189  else
2190  {
2191  i = 0;
2192  res = 0.0;
2193  do
2194  {
2195  i++;
2196  res += (float)n_Size(pGetCoeff(p),R->cf);
2197  pIter(p);
2198  }
2199  while (p);
2200  return res+(float)i;
2201  }

◆ sm_RingChange()

ring sm_RingChange ( const ring  origR,
long  bound 
)

Definition at line 257 of file sparsmat.cc.

259 {
260 // *origR =currRing;
261  ring tmpR=rCopy0(origR,FALSE,FALSE);
263  int *block0=(int*)omAlloc0(3*sizeof(int));
264  int *block1=(int*)omAlloc0(3*sizeof(int));
265  ord[0]=ringorder_c;
266  ord[1]=ringorder_dp;
267  tmpR->order=ord;
268  tmpR->OrdSgn=1;
269  block0[1]=1;
270  tmpR->block0=block0;
271  block1[1]=tmpR->N;
272  tmpR->block1=block1;
273  tmpR->bitmask = 2*bound;
274  tmpR->wvhdl = (int **)omAlloc0((3) * sizeof(int*));
275 
276 // ???
277 // if (tmpR->bitmask > currRing->bitmask) tmpR->bitmask = currRing->bitmask;
278 
279  rComplete(tmpR,1);
280  if (origR->qideal!=NULL)
281  {
282  tmpR->qideal= idrCopyR_NoSort(origR->qideal, origR, tmpR);
283  }
284  if (TEST_OPT_PROT)
285  Print("[%ld:%d]", (long) tmpR->bitmask, tmpR->ExpL_Size);
286  return tmpR;

◆ sm_SelectCopy_ExpMultDiv()

static poly sm_SelectCopy_ExpMultDiv ( poly  p,
poly  m,
poly  a,
poly  b,
const ring  currRing 
)
static

Definition at line 97 of file sparsmat.cc.

99 {
100  int lp = 0;
101  return pp_Mult_Coeff_mm_DivSelect_MultDiv(p, lp, m, a, b, currRing);

◆ sm_Smnumber2Poly()

static poly sm_Smnumber2Poly ( number  a,
const ring  R 
)
static

Definition at line 2875 of file sparsmat.cc.

2877 {
2878  poly res;
2879 
2880  if (a == NULL) return NULL;
2881  res = p_Init(R);
2882  pSetCoeff0(res, a);
2883  return res;

◆ sm_Smpoly2Poly()

static poly sm_Smpoly2Poly ( smpoly  a,
const ring  R 
)
static

Definition at line 2133 of file sparsmat.cc.

2135 {
2136  smpoly b;
2137  poly res, pp, q;
2138  long x;
2139 
2140  if (a == NULL)
2141  return NULL;
2142  x = a->pos;
2143  q = res = a->m;
2144  loop
2145  {
2146  p_SetComp(q,x,R);
2147  pp = q;
2148  pIter(q);
2149  if (q == NULL)
2150  break;
2151  }
2152  loop
2153  {
2154  b = a;
2155  a = a->n;
2156  omFreeBin((void *)b, smprec_bin);
2157  if (a == NULL)
2158  return res;
2159  x = a->pos;
2160  q = pNext(pp) = a->m;
2161  loop
2162  {
2163  p_SetComp(q,x,R);
2164  pp = q;
2165  pIter(q);
2166  if (q == NULL)
2167  break;
2168  }
2169  }

◆ sm_SpecialPolyDiv()

void sm_SpecialPolyDiv ( poly  a,
poly  b,
const ring  R 
)

Definition at line 1839 of file sparsmat.cc.

1841 {
1842  if (pNext(b) == NULL)
1843  {
1844  sm_PolyDivN(a, pGetCoeff(b),R);
1845  return;
1846  }
1847  sm_ExactPolyDiv(a, b, R);

◆ smCheckSolv()

static BOOLEAN smCheckSolv ( ideal  I)
static

Definition at line 2888 of file sparsmat.cc.

2890 { int i = I->ncols;
2891  if ((i == 0) || (i != I->rank-1))
2892  {
2893  WerrorS("wrong dimensions for linsolv");
2894  return TRUE;
2895  }
2896  for(;i;i--)
2897  {
2898  if(I->m[i-1] == NULL)
2899  {
2900  WerrorS("singular input for linsolv");
2901  return TRUE;
2902  }
2903  }
2904  return FALSE;

◆ smElemCopy()

static smpoly smElemCopy ( smpoly  a)
static

Definition at line 2084 of file sparsmat.cc.

2086 {
2088  memcpy(r, a, sizeof(smprec));
2089 /* r->m = pCopy(r->m); */
2090  return r;

◆ smMinSelect()

static void smMinSelect ( long *  c,
int  t,
int  d 
)
static

Definition at line 235 of file sparsmat.cc.

237 {
238  long m;
239  int pos, i;
240  do
241  {
242  d--;
243  pos = d;
244  m = c[pos];
245  for (i=d-1;i>=0;i--)
246  {
247  if(c[i]<m)
248  {
249  pos = i;
250  m = c[i];
251  }
252  }
253  for (i=pos;i<d;i++) c[i] = c[i+1];
254  } while (d>t);

◆ smNumberCopy()

static smnumber smNumberCopy ( smnumber  a)
static

Definition at line 2833 of file sparsmat.cc.

2835 {
2837  memcpy(r, a, sizeof(smnrec));
2838  return r;

◆ smSmaller()

static BOOLEAN smSmaller ( poly  a,
poly  b 
)
static

Definition at line 1961 of file sparsmat.cc.

1963 {
1964  loop
1965  {
1966  pIter(b);
1967  if (b == NULL) return TRUE;
1968  pIter(a);
1969  if (a == NULL) return FALSE;
1970  }

Variable Documentation

◆ smnrec_bin

STATIC_VAR omBin smnrec_bin = omGetSpecBin(sizeof(smnrec))

Definition at line 2263 of file sparsmat.cc.

◆ smprec_bin

VAR omBin smprec_bin = omGetSpecBin(sizeof(smprec))

Definition at line 73 of file sparsmat.cc.

sm_IsNegQuot
static BOOLEAN sm_IsNegQuot(poly, const poly, const poly, const ring)
Definition: sparsmat.cc:1905
FALSE
#define FALSE
Definition: auxiliary.h:96
p_GetComp
#define p_GetComp(p, r)
Definition: monomials.h:61
p_LmIsConstantComp
static BOOLEAN p_LmIsConstantComp(const poly p, const ring r)
Definition: p_polys.h:950
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:456
j
int j
Definition: facHensel.cc:105
smprec
Definition: sparsmat.cc:46
omFree
#define omFree(addr)
Definition: omAllocDecl.h:259
p_Normalize
void p_Normalize(poly p, const ring r)
Definition: p_polys.cc:3729
TEST_OPT_PROT
#define TEST_OPT_PROT
Definition: options.h:100
k
int k
Definition: cfEzgcd.cc:92
idrCopyR_NoSort
ideal idrCopyR_NoSort(ideal id, ring src_r, ring dest_r)
Definition: prCopy.cc:204
sparse_mat::smToIntvec
void smToIntvec(intvec *)
Definition: sparsmat.cc:463
x
Variable x
Definition: cfModGcd.cc:4023
p_ExpVectorDiff
static void p_ExpVectorDiff(poly pr, poly p1, poly p2, const ring r)
Definition: p_polys.h:1395
y
const CanonicalForm int const CFList const Variable & y
Definition: facAbsFact.cc:57
n_New
#define n_New(n, r)
Definition: coeffs.h:439
ADDRESS
void * ADDRESS
Definition: auxiliary.h:135
h
STATIC_VAR Poly * h
Definition: janet.cc:971
sparse_number_mat::smRes2Ideal
ideal smRes2Ideal()
Definition: sparsmat.cc:2505
p_Neg
static poly p_Neg(poly p, const ring r)
Definition: p_polys.h:1031
sparse_mat::smGetRed
int smGetRed()
Definition: sparsmat.cc:172
rKillModifiedRing
void rKillModifiedRing(ring r)
Definition: ring.cc:3001
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:399
smprec_bin
VAR omBin smprec_bin
Definition: sparsmat.cc:73
sparse_mat::smGetSign
int smGetSign()
Definition: sparsmat.cc:170
smMinSelect
static void smMinSelect(long *, int, int)
Definition: sparsmat.cc:235
n_Delete
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:454
p_Test
#define p_Test(p, r)
Definition: p_polys.h:154
omAllocBin
#define omAllocBin(bin)
Definition: omAllocDecl.h:203
pp_Mult_mm
static poly pp_Mult_mm(poly p, poly m, const ring r)
Definition: p_polys.h:975
n_IsZero
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
Definition: coeffs.h:463
sm_RingChange
ring sm_RingChange(const ring origR, long bound)
Definition: sparsmat.cc:257
n_IsOne
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff 'n' represents the one element.
Definition: coeffs.h:467
loop
#define loop
Definition: structs.h:79
smCheckSolv
static BOOLEAN smCheckSolv(ideal)
Definition: sparsmat.cc:2888
b
CanonicalForm b
Definition: cfModGcd.cc:4044
n_Normalize
static FORCE_INLINE void n_Normalize(number &n, const coeffs r)
inplace-normalization of n; produces some canonical representation of n;
Definition: coeffs.h:577
p_New
BOOLEAN p_New(leftv res, leftv args)
Definition: cohomo.cc:4952
pb
BOOLEAN pb(leftv res, leftv args)
Definition: cohomo.cc:4373
pp_Mult_Coeff_mm_DivSelect
static poly pp_Mult_Coeff_mm_DivSelect(poly p, const poly m, const ring r)
Definition: p_polys.h:1014
p_SetExp
static unsigned long p_SetExp(poly p, const unsigned long e, const unsigned long iBitmask, const int VarOffset)
set a single variable exponent @Note: VarOffset encodes the position in p->exp
Definition: p_polys.h:475
rCopy0
ring rCopy0(const ring r, BOOLEAN copy_qideal, BOOLEAN copy_ordering)
Definition: ring.cc:1364
prMoveR
poly prMoveR(poly &p, ring src_r, ring dest_r)
Definition: prCopy.cc:89
pLength
static unsigned pLength(poly a)
Definition: p_polys.h:182
n_Add
static FORCE_INLINE number n_Add(number a, number b, const coeffs r)
return the sum of 'a' and 'b', i.e., a+b
Definition: coeffs.h:655
rVar
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:586
kBucketExtractLm
poly kBucketExtractLm(kBucket_pt bucket)
Definition: kbuckets.cc:510
p_ExpVectorAdd
static void p_ExpVectorAdd(poly p1, poly p2, const ring r)
Definition: p_polys.h:1332
TRUE
#define TRUE
Definition: auxiliary.h:100
i
int i
Definition: cfEzgcd.cc:125
id_Delete
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
Definition: simpleideals.cc:122
res
CanonicalForm res
Definition: facAbsFact.cc:64
kBucket_Add_q
void kBucket_Add_q(kBucket_pt bucket, poly q, int *l)
Add to Bucket a poly ,i.e. Bpoly == q+Bpoly.
Definition: kbuckets.cc:653
idrMoveR
ideal idrMoveR(ideal &id, ring src_r, ring dest_r)
Definition: prCopy.cc:247
kBucketDestroy
void kBucketDestroy(kBucket_pt *bucket_pt)
Definition: kbuckets.cc:215
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:790
M
#define M
Definition: sirandom.c:25
smnumber
sm_nrec * smnumber
Definition: sparsmat.cc:2256
TEST_OPT_NOT_BUCKETS
#define TEST_OPT_NOT_BUCKETS
Definition: options.h:102
omFreeSize
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:258
BOOLEAN
int BOOLEAN
Definition: auxiliary.h:87
kBucketInit
void kBucketInit(kBucket_pt bucket, poly lm, int length)
Definition: kbuckets.cc:492
sm_FindRef
static void sm_FindRef(poly *, poly *, poly, const ring)
Definition: sparsmat.cc:2019
smpoly
sm_prec * smpoly
Definition: sparsmat.cc:45
smSmaller
static BOOLEAN smSmaller(poly, poly)
Definition: sparsmat.cc:1961
sparse_mat::smNewBareiss
void smNewBareiss(int, int)
Definition: sparsmat.cc:548
p_LmDelete
static void p_LmDelete(poly p, const ring r)
Definition: p_polys.h:697
sparse_number_mat::smIsSing
int smIsSing()
Definition: sparsmat.cc:2302
pp_Mult_qq
static poly pp_Mult_qq(poly p, poly q, const ring r)
Definition: p_polys.h:1075
intvec
Definition: intvec.h:18
pIter
#define pIter(p)
Definition: monomials.h:34
p_Cleardenom
poly p_Cleardenom(poly p, const ring r)
Definition: p_polys.cc:2788
n_Mult
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of 'a' and 'b', i.e., a*b
Definition: coeffs.h:635
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:1972
p_Init
static poly p_Init(const ring r, omBin bin)
Definition: p_polys.h:1242
p_LmCmp
static int p_LmCmp(poly p, poly q, const ring r)
Definition: p_polys.h:1481
sparse_mat::smRes2Mod
ideal smRes2Mod()
Definition: sparsmat.cc:447
pp
CanonicalForm pp(const CanonicalForm &)
CanonicalForm pp ( const CanonicalForm & f )
Definition: cf_gcd.cc:248
sm_KillModifiedRing
void sm_KillModifiedRing(ring r)
Definition: sparsmat.cc:288
n_InpNeg
static FORCE_INLINE number n_InpNeg(number n, const coeffs r)
in-place negation of n MUST BE USED: n = n_InpNeg(n) (no copy is returned)
Definition: coeffs.h:556
sm_PolyDivN
static void sm_PolyDivN(poly, const number, const ring)
Definition: sparsmat.cc:1948
ringorder_c
Definition: ring.h:71
ringorder_dp
Definition: ring.h:77
p_LmTest
#define p_LmTest(p, r)
Definition: p_polys.h:155
smnrec
Definition: sparsmat.cc:2257
sm_Cleardenom
static number sm_Cleardenom(ideal, const ring)
Definition: sparsmat.cc:2222
p_LmFree
static void p_LmFree(poly p, ring)
Definition: p_polys.h:669
p_Delete
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:845
p_Add_q
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:880
pp_Mult_Coeff_mm_DivSelect_MultDiv
static poly pp_Mult_Coeff_mm_DivSelect_MultDiv(poly p, int &lp, poly m, poly a, poly b, const ring currRing)
Definition: sparsmat.cc:75
sm_SelectCopy_ExpMultDiv
static poly sm_SelectCopy_ExpMultDiv(poly p, poly m, poly a, poly b, const ring currRing)
Definition: sparsmat.cc:97
bound
static CanonicalForm bound(const CFMatrix &M)
Definition: cf_linsys.cc:460
sm_ExpMultDiv
static void sm_ExpMultDiv(poly, const poly, const poly, const ring)
Definition: sparsmat.cc:1930
Print
#define Print
Definition: emacs.cc:79
sparse_mat
Definition: sparsmat.cc:123
Werror
void Werror(const char *fmt,...)
Definition: reporter.cc:188
rOrd_is_Comp_dp
static BOOLEAN rOrd_is_Comp_dp(const ring r)
Definition: ring.h:769
p_SetCoeff
static number p_SetCoeff(poly p, number n, ring r)
Definition: p_polys.h:399
pSetCoeff0
#define pSetCoeff0(p, n)
Definition: monomials.h:56
SM_MIN_LENGTH_BUCKET
#define SM_MIN_LENGTH_BUCKET
Definition: sparsmat.cc:39
n_Copy
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of 'n'
Definition: coeffs.h:450
WerrorS
void WerrorS(const char *s)
Definition: feFopen.cc:24
m
int m
Definition: cfEzgcd.cc:121
NULL
#define NULL
Definition: omList.c:11
sparse_number_mat
Definition: sparsmat.cc:2274
sparse_number_mat::smSolv
void smSolv()
Definition: sparsmat.cc:2428
p_SetComp
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition: p_polys.h:237
kBucket
Definition: kbuckets.h:177
R
#define R
Definition: sirandom.c:27
sparse_mat::smGetAct
smpoly * smGetAct()
Definition: sparsmat.cc:171
pa
BOOLEAN pa(leftv res, leftv args)
Definition: cohomo.cc:4346
sparse_number_mat::smTriangular
void smTriangular()
Definition: sparsmat.cc:2397
sm_ExactPolyDiv
static void sm_ExactPolyDiv(poly, poly, const ring)
Definition: sparsmat.cc:1850
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
kBucketCreate
kBucket_pt kBucketCreate(const ring bucket_ring)
Creation/Destruction of buckets.
Definition: kbuckets.cc:208
currRing
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
s
const CanonicalForm int s
Definition: facAbsFact.cc:55
n_Div
static FORCE_INLINE number n_Div(number a, number b, const coeffs r)
return the quotient of 'a' and 'b', i.e., a/b; raises an error if 'b' is not invertible in r exceptio...
Definition: coeffs.h:614
sm_ExpBound
long sm_ExpBound(ideal m, int di, int ra, int t, const ring currRing)
Definition: sparsmat.cc:187
IDELEMS
#define IDELEMS(i)
Definition: simpleideals.h:23
sm_HaveDenom
static BOOLEAN sm_HaveDenom(poly, const ring)
Definition: sparsmat.cc:2203
smnrec_bin
STATIC_VAR omBin smnrec_bin
Definition: sparsmat.cc:2263
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:41
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
omFreeBin
#define omFreeBin(addr, bin)
Definition: omAllocDecl.h:257
p_LmDivisibleByNoComp
static BOOLEAN p_LmDivisibleByNoComp(poly a, poly b, const ring r)
Definition: p_polys.h:1788
n_GetDenom
static FORCE_INLINE number n_GetDenom(number &n, const coeffs r)
return the denominator of n (if elements of r are by nature not fractional, result is 1)
Definition: coeffs.h:602
rRingOrder_t
rRingOrder_t
order stuff
Definition: ring.h:66
pNext
#define pNext(p)
Definition: monomials.h:33
sparse_mat::smDet
poly smDet()
Definition: sparsmat.cc:474
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:902
idrCopyR
ideal idrCopyR(ideal id, ring src_r, ring dest_r)
Definition: prCopy.cc:191
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:3397