My Project
Loading...
Searching...
No Matches
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 47 of file sparsmat.cc.

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

◆ smnrec

struct smnrec

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

Typedef Documentation

◆ smnumber

typedef sm_nrec* smnumber

Definition at line 2257 of file sparsmat.cc.

◆ smpoly

typedef sm_prec* smpoly

Definition at line 46 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 76 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 {
94 }
95 return p;
96}
int m
Definition: cfEzgcd.cc:128
int p
Definition: cfModGcd.cc:4078
CanonicalForm b
Definition: cfModGcd.cc:4103
static poly pp_Mult_Coeff_mm_DivSelect(poly p, const poly m, const ring r)
Definition: p_polys.h:1088
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
static BOOLEAN rOrd_is_Comp_dp(const ring r)
Definition: ring.h:772
static void sm_ExpMultDiv(poly, const poly, const poly, const ring)
Definition: sparsmat.cc:1931

◆ sm_CallBareiss()

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

Definition at line 347 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 }
380 M=II;
381}
Variable x
Definition: cfModGcd.cc:4082
static CanonicalForm bound(const CFMatrix &M)
Definition: cf_linsys.cc:460
Definition: intvec.h:23
void smToIntvec(intvec *)
Definition: sparsmat.cc:464
int smGetRed()
Definition: sparsmat.cc:173
smpoly * smGetAct()
Definition: sparsmat.cc:172
void smNewBareiss(int, int)
Definition: sparsmat.cc:549
ideal smRes2Mod()
Definition: sparsmat.cc:448
const CanonicalForm int s
Definition: facAbsFact.cc:51
const CanonicalForm int const CFList const Variable & y
Definition: facAbsFact.cc:53
#define NULL
Definition: omList.c:12
ideal idrMoveR(ideal &id, ring src_r, ring dest_r)
Definition: prCopy.cc:248
ideal idrCopyR(ideal id, ring src_r, ring dest_r)
Definition: prCopy.cc:192
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:592
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s
#define IDELEMS(i)
Definition: simpleideals.h:23
#define R
Definition: sirandom.c:27
#define M
Definition: sirandom.c:25
long sm_ExpBound(ideal m, int di, int ra, int t, const ring currRing)
Definition: sparsmat.cc:188
ring sm_RingChange(const ring origR, long bound)
Definition: sparsmat.cc:258
void sm_KillModifiedRing(ring r)
Definition: sparsmat.cc:289

◆ sm_CallDet()

poly sm_CallDet ( ideal  I,
const ring  R 
)

Definition at line 302 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;
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);
337 if (!n_Equal(diag,h,R->cf))
338 {
339 p_Mult_nn(res,diag,R);
341 }
342 n_Delete(&diag,R->cf);
343 n_Delete(&h,R->cf);
344 return res;
345}
int smGetSign()
Definition: sparsmat.cc:171
poly smDet()
Definition: sparsmat.cc:475
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:452
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:535
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:457
CanonicalForm res
Definition: facAbsFact.cc:60
STATIC_VAR Poly * h
Definition: janet.cc:971
void p_Normalize(poly p, const ring r)
Definition: p_polys.cc:3813
static poly p_Neg(poly p, const ring r)
Definition: p_polys.h:1105
static poly p_Mult_nn(poly p, number n, const ring r)
Definition: p_polys.h:956
poly prMoveR(poly &p, ring src_r, ring dest_r)
Definition: prCopy.cc:90
void Werror(const char *fmt,...)
Definition: reporter.cc:189
static number sm_Cleardenom(ideal, const ring)
Definition: sparsmat.cc:2223

◆ sm_CallSolv()

ideal sm_CallSolv ( ideal  I,
const ring  R 
)

Definition at line 2316 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;
2346}
#define FALSE
Definition: auxiliary.h:96
ideal smRes2Ideal()
Definition: sparsmat.cc:2506
void WerrorS(const char *s)
Definition: feFopen.cc:24
BOOLEAN id_IsConstant(ideal id, const ring r)
test if the ideal has only constant polynomials NOTE: zero ideal/module is also constant
static BOOLEAN smCheckSolv(ideal)
Definition: sparsmat.cc:2889

◆ sm_Cleardenom()

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

Definition at line 2223 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;
2252}
int BOOLEAN
Definition: auxiliary.h:87
int i
Definition: cfEzgcd.cc:132
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:633
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of 'n'
Definition: coeffs.h:448
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:612
static FORCE_INLINE void n_Normalize(number &n, const coeffs r)
inplace-normalization of n; produces some canonical representation of n;
Definition: coeffs.h:575
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
poly p_Cleardenom(poly p, const ring r)
Definition: p_polys.cc:2845
static BOOLEAN sm_HaveDenom(poly, const ring)
Definition: sparsmat.cc:2204

◆ sm_CombineChain()

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

Definition at line 1973 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;
2017}
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:647
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
Definition: coeffs.h:461
static BOOLEAN pa(leftv res, leftv args)
Definition: cohomo.cc:3723
static BOOLEAN pb(leftv res, leftv args)
Definition: cohomo.cc:3747
#define pNext(p)
Definition: monomials.h:36
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:934
static void p_LmDelete(poly p, const ring r)
Definition: p_polys.h:721
static number p_SetCoeff(poly p, number n, ring r)
Definition: p_polys.h:410
static int p_LmCmp(poly p, poly q, const ring r)
Definition: p_polys.h:1578
#define loop
Definition: structs.h:75

◆ sm_ElemDelete()

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

Definition at line 2076 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;
2083}
#define omFreeBin(addr, bin)
Definition: omAllocDecl.h:259
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:899
VAR omBin smprec_bin
Definition: sparsmat.cc:74
sm_prec * smpoly
Definition: sparsmat.cc:46

◆ sm_ExactPolyDiv()

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

Definition at line 1851 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
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);
1903}
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:554
void kBucketDestroy(kBucket_pt *bucket_pt)
Definition: kbuckets.cc:216
void kBucketInit(kBucket_pt bucket, poly lm, int length)
Definition: kbuckets.cc:493
poly kBucketExtractLm(kBucket_pt bucket)
Definition: kbuckets.cc:511
kBucket_pt kBucketCreate(const ring bucket_ring)
Creation/Destruction of buckets.
Definition: kbuckets.cc:209
void kBucket_Add_q(kBucket_pt bucket, poly q, int *l)
Add to Bucket a poly ,i.e. Bpoly == q+Bpoly.
Definition: kbuckets.cc:660
#define pSetCoeff0(p, n)
Definition: monomials.h:59
#define TEST_OPT_NOT_BUCKETS
Definition: options.h:106
static int pLength(poly a)
Definition: p_polys.h:188
static poly pp_Mult_mm(poly p, poly m, const ring r)
Definition: p_polys.h:1029
static void p_LmFree(poly p, ring)
Definition: p_polys.h:681
static poly p_Init(const ring r, omBin bin)
Definition: p_polys.h:1318
#define SM_MIN_LENGTH_BUCKET
Definition: sparsmat.cc:40
static poly pp_Mult_Coeff_mm_DivSelect_MultDiv(poly p, int &lp, poly m, poly a, poly b, const ring currRing)
Definition: sparsmat.cc:76
static poly sm_SelectCopy_ExpMultDiv(poly p, poly m, poly a, poly b, const ring currRing)
Definition: sparsmat.cc:98
static BOOLEAN sm_IsNegQuot(poly, const poly, const poly, const ring)
Definition: sparsmat.cc:1906

◆ sm_ExpBound()

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

Definition at line 188 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;
234}
void * ADDRESS
Definition: auxiliary.h:119
int k
Definition: cfEzgcd.cc:99
int j
Definition: facHensel.cc:110
#define p_GetComp(p, r)
Definition: monomials.h:64
#define pIter(p)
Definition: monomials.h:37
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
#define omAlloc(size)
Definition: omAllocDecl.h:210
#define omAlloc0(size)
Definition: omAllocDecl.h:211
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:467
static void smMinSelect(long *, int, int)
Definition: sparsmat.cc:236

◆ sm_ExpMultDiv()

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

Definition at line 1931 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);
1946}
static void p_ExpVectorAdd(poly p1, poly p2, const ring r)
Definition: p_polys.h:1409
static void p_ExpVectorDiff(poly pr, poly p1, poly p2, const ring r)
Definition: p_polys.h:1472
static poly p_New(const ring, omBin bin)
Definition: p_polys.h:662
#define p_LmTest(p, r)
Definition: p_polys.h:160
#define p_Test(p, r)
Definition: p_polys.h:159

◆ sm_FindRef()

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

Definition at line 2020 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;
2072}
CanonicalForm FACTORY_PUBLIC pp(const CanonicalForm &)
CanonicalForm pp ( const CanonicalForm & f )
Definition: cf_gcd.cc:676

◆ sm_HaveDenom()

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

Definition at line 2204 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;
2221}
#define TRUE
Definition: auxiliary.h:100
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:600
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff 'n' represents the one element.
Definition: coeffs.h:465

◆ sm_IsNegQuot()

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

Definition at line 1906 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 }
1929}
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:486
static BOOLEAN p_LmDivisibleByNoComp(poly a, poly b, const ring r)
Definition: p_polys.h:1875

◆ sm_KillModifiedRing()

void sm_KillModifiedRing ( ring  r)

Definition at line 289 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*));
295}
#define omFree(addr)
Definition: omAllocDecl.h:261
void rKillModifiedRing(ring r)
Definition: ring.cc:3059

◆ sm_MultDiv()

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

Definition at line 1759 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 {
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 {
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;
1832}
static BOOLEAN p_LmIsConstantComp(const poly p, const ring r)
Definition: p_polys.h:1004
static poly pp_Mult_qq(poly p, poly q, const ring r)
Definition: p_polys.h:1149
static void sm_CombineChain(poly *, poly, const ring)
Definition: sparsmat.cc:1973
static BOOLEAN smSmaller(poly, poly)
Definition: sparsmat.cc:1962
static void sm_FindRef(poly *, poly *, poly, const ring)
Definition: sparsmat.cc:2020

◆ sm_NumberDelete()

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

Definition at line 2825 of file sparsmat.cc.

2826{
2827 smnumber a = *r, b = a->n;
2828
2829 n_Delete(&a->m,R->cf);
2831 *r = b;
2832}
STATIC_VAR omBin smnrec_bin
Definition: sparsmat.cc:2264
sm_nrec * smnumber
Definition: sparsmat.cc:2257

◆ sm_Poly2Smnumber()

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

Definition at line 2845 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 pGetCoeff(p)=NULL;
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 pGetCoeff(p)=NULL;
2869 }
2870}
#define omAllocBin(bin)
Definition: omAllocDecl.h:205

◆ sm_Poly2Smpoly()

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

Definition at line 2097 of file sparsmat.cc.

2098{
2099 poly pp;
2100 smpoly res, a;
2101 long x;
2102
2103 if (q == NULL)
2104 return NULL;
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 }
2128}
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition: p_polys.h:245

◆ sm_PolyDivN()

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

Definition at line 1949 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);
1960}

◆ sm_PolyWeight()

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

Definition at line 2175 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 }
2202}
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:567

◆ sm_RingChange()

ring sm_RingChange ( const ring  origR,
long  bound 
)

Definition at line 258 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;
287}
#define Print
Definition: emacs.cc:80
#define TEST_OPT_PROT
Definition: options.h:104
ideal idrCopyR_NoSort(ideal id, ring src_r, ring dest_r)
Definition: prCopy.cc:205
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:3450
ring rCopy0(const ring r, BOOLEAN copy_qideal, BOOLEAN copy_ordering)
Definition: ring.cc:1421
rRingOrder_t
order stuff
Definition: ring.h:68
@ ringorder_dp
Definition: ring.h:78
@ ringorder_c
Definition: ring.h:72

◆ sm_SelectCopy_ExpMultDiv()

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

Definition at line 98 of file sparsmat.cc.

99{
100 int lp = 0;
102}

◆ sm_Smnumber2Poly()

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

Definition at line 2876 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;
2884}

◆ sm_Smpoly2Poly()

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

Definition at line 2134 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 }
2170}

◆ sm_SpecialPolyDiv()

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

Definition at line 1840 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);
1848}
static void sm_ExactPolyDiv(poly, poly, const ring)
Definition: sparsmat.cc:1851
static void sm_PolyDivN(poly, const number, const ring)
Definition: sparsmat.cc:1949

◆ smCheckSolv()

static BOOLEAN smCheckSolv ( ideal  I)
static

Definition at line 2889 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;
2905}

◆ smElemCopy()

static smpoly smElemCopy ( smpoly  a)
static

Definition at line 2085 of file sparsmat.cc.

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

◆ smMinSelect()

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

Definition at line 236 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);
255}

◆ smNumberCopy()

static smnumber smNumberCopy ( smnumber  a)
static

Definition at line 2834 of file sparsmat.cc.

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

◆ smSmaller()

static BOOLEAN smSmaller ( poly  a,
poly  b 
)
static

Definition at line 1962 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 }
1971}

Variable Documentation

◆ smnrec_bin

STATIC_VAR omBin smnrec_bin = omGetSpecBin(sizeof(smnrec))

Definition at line 2264 of file sparsmat.cc.

◆ smprec_bin

VAR omBin smprec_bin = omGetSpecBin(sizeof(smprec))

Definition at line 74 of file sparsmat.cc.