Loading...
Searching...
No Matches
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()

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.

{
if (rOrd_is_Comp_dp(currRing) && currRing->ExpL_Size > 2)
{
// pp_Mult_Coeff_mm_DivSelectMult only works for (c/C,dp) and
// ExpL_Size > 2
// should be generalized, at least to dp with ExpL_Size == 2
// (is the case for 1 variable)
int shorter;
p = currRing->p_Procs->pp_Mult_Coeff_mm_DivSelectMult(p, m, a, b,
shorter, currRing);
lp -= shorter;
}
else
{
p = pp_Mult_Coeff_mm_DivSelect(p, lp, m, currRing);
sm_ExpMultDiv(p, a, b, currRing);
}
return p;
}
m
int m
Definition cfEzgcd.cc:128
p
int p
Definition cfModGcd.cc:4086
b
CanonicalForm b
Definition cfModGcd.cc:4111
pp_Mult_Coeff_mm_DivSelect
static poly pp_Mult_Coeff_mm_DivSelect(poly p, const poly m, const ring r)
Definition p_polys.h:1097
currRing
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition polys.cc:13
rOrd_is_Comp_dp
static BOOLEAN rOrd_is_Comp_dp(const ring r)
Definition ring.h:784
sm_ExpMultDiv
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.

{
int r=id_RankFreeModule(I,R),t=r;
int c=IDELEMS(I),s=c;
long bound;
ring tmpR;
sparse_mat *bareiss;
if ((x>0) && (x<t))
t-=x;
if ((y>1) && (y<s))
s-=y;
if (t>s) t=s;
bound=sm_ExpBound(I,c,r,t,R);
tmpR=sm_RingChange(R,bound);
ideal II = idrCopyR(I, R, tmpR);
bareiss = new sparse_mat(II,tmpR);
if (bareiss->smGetAct() == NULL)
{
delete bareiss;
*iv=new intvec(1,rVar(tmpR));
}
else
{
id_Delete(&II,tmpR);
bareiss->smNewBareiss(x, y);
II = bareiss->smRes2Mod();
*iv = new intvec(bareiss->smGetRed());
bareiss->smToIntvec(*iv);
delete bareiss;
II = idrMoveR(II,tmpR,R);
}
sm_KillModifiedRing(tmpR);
M=II;
}
x
Variable x
Definition cfModGcd.cc:4090
bound
static CanonicalForm bound(const CFMatrix &M)
Definition cf_linsys.cc:460
intvec
Definition intvec.h:24
sparse_mat
Definition sparsmat.cc:124
sparse_mat::smToIntvec
void smToIntvec(intvec *)
Definition sparsmat.cc:464
sparse_mat::smGetRed
int smGetRed()
Definition sparsmat.cc:173
sparse_mat::smGetAct
smpoly * smGetAct()
Definition sparsmat.cc:172
sparse_mat::smNewBareiss
void smNewBareiss(int, int)
Definition sparsmat.cc:549
sparse_mat::smRes2Mod
ideal smRes2Mod()
Definition sparsmat.cc:448
s
const CanonicalForm int s
Definition facAbsFact.cc:51
y
const CanonicalForm int const CFList const Variable & y
Definition facAbsFact.cc:53
NULL
#define NULL
Definition omList.c:12
idrMoveR
ideal idrMoveR(ideal &id, ring src_r, ring dest_r)
Definition prCopy.cc:248
idrCopyR
ideal idrCopyR(ideal id, ring src_r, ring dest_r)
Definition prCopy.cc:192
rVar
static short rVar(const ring r)
define rVar(r) (r->N)
Definition ring.h:598
id_Delete
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
Definition simpleideals.cc:123
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:992
IDELEMS
#define IDELEMS(i)
Definition simpleideals.h:23
R
#define R
Definition sirandom.c:27
M
#define M
Definition sirandom.c:25
sm_ExpBound
long sm_ExpBound(ideal m, int di, int ra, int t, const ring currRing)
Definition sparsmat.cc:188
sm_RingChange
ring sm_RingChange(const ring origR, long bound)
Definition sparsmat.cc:258
sm_KillModifiedRing
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.

{
if (I->ncols != I->rank)
{
Werror("det of %ld x %d module (matrix)",I->rank,I->ncols);
return NULL;
}
int r=id_RankFreeModule(I,R);
if (I->ncols != r) // some 0-lines at the end
{
return NULL;
}
long bound=sm_ExpBound(I,r,r,r,R);
number diag,h=n_Init(1,R->cf);
poly res;
ring tmpR;
sparse_mat *det;
ideal II;
tmpR=sm_RingChange(R,bound);
II = idrCopyR(I, R, tmpR);
diag = sm_Cleardenom(II,tmpR);
det = new sparse_mat(II,tmpR);
id_Delete(&II,tmpR);
if (det->smGetAct() == NULL)
{
delete det;
sm_KillModifiedRing(tmpR);
return NULL;
}
res=det->smDet();
if(det->smGetSign()<0) res=p_Neg(res,tmpR);
delete det;
res = prMoveR(res, tmpR, R);
sm_KillModifiedRing(tmpR);
if (!n_Equal(diag,h,R->cf))
{
p_Mult_nn(res,diag,R);
p_Normalize(res,R);
}
n_Delete(&diag,R->cf);
n_Delete(&h,R->cf);
return res;
}
sparse_mat::smGetSign
int smGetSign()
Definition sparsmat.cc:171
sparse_mat::smDet
poly smDet()
Definition sparsmat.cc:475
n_Delete
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition coeffs.h:461
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:541
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:466
res
CanonicalForm res
Definition facAbsFact.cc:60
h
STATIC_VAR Poly * h
Definition janet.cc:971
p_Normalize
void p_Normalize(poly p, const ring r)
Definition p_polys.cc:3939
p_Neg
static poly p_Neg(poly p, const ring r)
Definition p_polys.h:1114
p_Mult_nn
static poly p_Mult_nn(poly p, number n, const ring r)
Definition p_polys.h:960
prMoveR
poly prMoveR(poly &p, ring src_r, ring dest_r)
Definition prCopy.cc:90
Werror
void Werror(const char *fmt,...)
Definition reporter.cc:189
sm_Cleardenom
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.

{
sparse_number_mat *linsolv;
ring tmpR;
ideal rr;
if (id_IsConstant(I,R)==FALSE)
{
WerrorS("symbol in equation");
return NULL;
}
I->rank = id_RankFreeModule(I,R);
if (smCheckSolv(I)) return NULL;
tmpR=sm_RingChange(R,1);
rr=idrCopyR(I,R, tmpR);
linsolv = new sparse_number_mat(rr,tmpR);
rr=NULL;
linsolv->smTriangular();
if (linsolv->smIsSing() == 0)
{
linsolv->smSolv();
rr = linsolv->smRes2Ideal();
}
else
WerrorS("singular problem for linsolv");
delete linsolv;
if (rr!=NULL)
rr = idrMoveR(rr,tmpR,R);
sm_KillModifiedRing(tmpR);
return rr;
}
FALSE
#define FALSE
Definition auxiliary.h:97
sparse_number_mat
Definition sparsmat.cc:2275
sparse_number_mat::smIsSing
int smIsSing()
Definition sparsmat.cc:2303
sparse_number_mat::smRes2Ideal
ideal smRes2Ideal()
Definition sparsmat.cc:2506
sparse_number_mat::smTriangular
void smTriangular()
Definition sparsmat.cc:2398
sparse_number_mat::smSolv
void smSolv()
Definition sparsmat.cc:2429
WerrorS
void WerrorS(const char *s)
Definition feFopen.cc:24
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:529
smCheckSolv
static BOOLEAN smCheckSolv(ideal)
Definition sparsmat.cc:2889

## sm_Cleardenom()

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

static

Definition at line 2223 of file sparsmat.cc.

{
poly a;
number x,y,res=n_Init(1,R->cf);
BOOLEAN sw=FALSE;
for (int i=0; i<IDELEMS(id); i++)
{
a = id->m[i];
sw = sm_HaveDenom(a,R);
if (sw) break;
}
if (!sw) return res;
for (int i=0; i<IDELEMS(id); i++)
{
a = id->m[i];
if (a!=NULL)
{
x = n_Copy(pGetCoeff(a),R->cf);
p_Cleardenom(a, R);
y = n_Div(x,pGetCoeff(a),R->cf);
n_Delete(&x,R->cf);
x = n_Mult(res,y,R->cf);
n_Normalize(x,R->cf);
n_Delete(&res,R->cf);
res = x;
}
}
return res;
}
BOOLEAN
int BOOLEAN
Definition auxiliary.h:88
i
int i
Definition cfEzgcd.cc:132
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:639
n_Copy
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of 'n'
Definition coeffs.h:457
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:618
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:581
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:44
p_Cleardenom
poly p_Cleardenom(poly p, const ring r)
Definition p_polys.cc:2893
sm_HaveDenom
static BOOLEAN sm_HaveDenom(poly, const ring)
Definition sparsmat.cc:2204

## sm_CombineChain()

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

static

Definition at line 1973 of file sparsmat.cc.

{
poly pa = *px, pb;
number x;
int i;
loop
{
pb = pNext(pa);
if (pb == NULL)
{
pa = pNext(pa) = r;
break;
}
i = p_LmCmp(pb, r,R);
if (i > 0)
pa = pb;
else
{
if (i == 0)
{
x = n_Add(pGetCoeff(pb), pGetCoeff(r),R->cf);
p_LmDelete(&r,R);
if (n_IsZero(x,R->cf))
{
p_LmDelete(&pb,R);
pNext(pa) = p_Add_q(pb,r,R);
}
else
{
pa = pb;
p_SetCoeff(pa,x,R);
pNext(pa) = p_Add_q(pNext(pa), r, R);
}
}
else
{
pa = pNext(pa) = r;
pNext(pa) = p_Add_q(pb, pNext(pa),R);
}
break;
}
}
*px = pa;
}
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:653
n_IsZero
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
Definition coeffs.h:470
pa
static BOOLEAN pa(leftv res, leftv args)
Definition cohomo.cc:3770
pb
static BOOLEAN pb(leftv res, leftv args)
Definition cohomo.cc:3796
pNext
#define pNext(p)
Definition monomials.h:36
p_Add_q
static poly p_Add_q(poly p, poly q, const ring r)
Definition p_polys.h:938
p_LmDelete
static void p_LmDelete(poly p, const ring r)
Definition p_polys.h:725
p_SetCoeff
static number p_SetCoeff(poly p, number n, ring r)
Definition p_polys.h:414
p_LmCmp
static int p_LmCmp(poly p, poly q, const ring r)
Definition p_polys.h:1601
loop
#define loop
Definition structs.h:71

## sm_ElemDelete()

void sm_ElemDelete | ( | smpoly * | r,
|  | const ring | R )

static

Definition at line 2076 of file sparsmat.cc.

{
smpoly a = *r, b = a->n;
p_Delete(&a->m, R);
omFreeBin((void *)a, smprec_bin);
*r = b;
}
omFreeBin
#define omFreeBin(addr, bin)
Definition omAllocDecl.h:259
p_Delete
static void p_Delete(poly *p, const ring r)
Definition p_polys.h:903
smprec_bin
VAR omBin smprec_bin
Definition sparsmat.cc:74
smpoly
sm_prec * smpoly
Definition sparsmat.cc:46

## sm_ExactPolyDiv()

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

static

Definition at line 1851 of file sparsmat.cc.

{
const number x = pGetCoeff(b);
poly tail = pNext(b), e = p_Init(R);
poly h;
number y, yn;
int lt = pLength(tail);
if (lt + 1 >= SM_MIN_LENGTH_BUCKET && !TEST_OPT_NOT_BUCKETS)
{
kBucket_pt bucket = kBucketCreate(R);
kBucketInit(bucket, pNext(a), 0);
int lh = 0;
do
{
y = n_Div(pGetCoeff(a), x, R->cf);
n_Normalize(y, R->cf);
p_SetCoeff(a,y, R);
yn = n_InpNeg(n_Copy(y, R->cf), R->cf);
pSetCoeff0(e,yn);
lh = lt;
if (sm_IsNegQuot(e, a, b, R))
{
h = pp_Mult_Coeff_mm_DivSelect_MultDiv(tail, lh, e, a, b, R);
}
else
h = pp_Mult_mm(tail, e, R);
n_Delete(&yn, R->cf);
kBucket_Add_q(bucket, h, &lh);
a = pNext(a) = kBucketExtractLm(bucket);
} while (a!=NULL);
kBucketDestroy(&bucket);
}
else
{
do
{
y = n_Div(pGetCoeff(a), x, R->cf);
n_Normalize(y, R->cf);
p_SetCoeff(a,y, R);
yn = n_InpNeg(n_Copy(y, R->cf), R->cf);
pSetCoeff0(e,yn);
if (sm_IsNegQuot(e, a, b, R))
h = sm_SelectCopy_ExpMultDiv(tail, e, a, b, R);
else
h = pp_Mult_mm(tail, e, R);
n_Delete(&yn, R->cf);
a = pNext(a) = p_Add_q(pNext(a), h, R);
} while (a!=NULL);
}
p_LmFree(e, R);
}
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:560
kBucketDestroy
void kBucketDestroy(kBucket_pt *bucket_pt)
Definition kbuckets.cc:216
kBucketInit
void kBucketInit(kBucket_pt bucket, poly lm, int length)
Definition kbuckets.cc:493
kBucketExtractLm
poly kBucketExtractLm(kBucket_pt bucket)
Definition kbuckets.cc:511
kBucketCreate
kBucket_pt kBucketCreate(const ring bucket_ring)
Creation/Destruction of buckets.
Definition kbuckets.cc:209
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:660
pSetCoeff0
#define pSetCoeff0(p, n)
Definition monomials.h:59
TEST_OPT_NOT_BUCKETS
#define TEST_OPT_NOT_BUCKETS
Definition options.h:107
pLength
static int pLength(poly a)
Definition p_polys.h:190
pp_Mult_mm
static poly pp_Mult_mm(poly p, poly m, const ring r)
Definition p_polys.h:1033
p_LmFree
static void p_LmFree(poly p, ring)
Definition p_polys.h:685
p_Init
static poly p_Init(const ring r, omBin bin)
Definition p_polys.h:1341
kBucket_pt
kBucket * kBucket_pt
Definition ring.h:26
SM_MIN_LENGTH_BUCKET
#define SM_MIN_LENGTH_BUCKET
Definition sparsmat.cc:40
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:76
sm_SelectCopy_ExpMultDiv
static poly sm_SelectCopy_ExpMultDiv(poly p, poly m, poly a, poly b, const ring currRing)
Definition sparsmat.cc:98
sm_IsNegQuot
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.

{
poly p;
long kr, kc;
long *r, *c;
int al, bl, i, j, k;
if (ra==0) ra=1;
al = di*sizeof(long);
c = (long *)omAlloc(al);
bl = ra*sizeof(long);
r = (long *)omAlloc0(bl);
for (i=di-1;i>=0;i--)
{
kc = 0;
p = m->m[i];
while(p!=NULL)
{
k = p_GetComp(p, currRing)-1;
kr = r[k];
for (j=currRing->N;j>0;j--)
{
long t=p_GetExp(p,j, currRing);
if(t /*p_GetExp(p,j, currRing)*/ >kc)
kc=t; /*p_GetExp(p,j, currRing);*/
if(t /*p_GetExp(p,j, currRing)s*/ >kr)
kr=t; /*p_GetExp(p,j, currRing);*/
}
r[k] = kr;
pIter(p);
}
c[i] = kc;
}
if (t<di) smMinSelect(c, t, di);
if (t<ra) smMinSelect(r, t, ra);
kr = kc = 0;
for (j=t-1;j>=0;j--)
{
kr += r[j];
kc += c[j];
}
omFreeSize((ADDRESS)c, al);
omFreeSize((ADDRESS)r, bl);
if (kr<kc) kc = kr;
if (kr<1) kr = 1;
return kr;
}
ADDRESS
void * ADDRESS
Definition auxiliary.h:120
k
int k
Definition cfEzgcd.cc:99
j
int j
Definition facHensel.cc:110
p_GetComp
#define p_GetComp(p, r)
Definition monomials.h:64
pIter
#define pIter(p)
Definition monomials.h:37
omFreeSize
#define omFreeSize(addr, size)
Definition omAllocDecl.h:260
omAlloc
#define omAlloc(size)
Definition omAllocDecl.h:210
omAlloc0
#define omAlloc0(size)
Definition omAllocDecl.h:211
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:471
smMinSelect
static void smMinSelect(long *, int, int)
Definition sparsmat.cc:236

## sm_ExpMultDiv()

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

static

Definition at line 1931 of file sparsmat.cc.

{
p_Test(t,R);
p_LmTest(b,R);
p_LmTest(c,R);
poly bc = p_New(R);
p_ExpVectorDiff(bc, b, c, R);
while(t!=NULL)
{
p_ExpVectorAdd(t, bc, R);
pIter(t);
}
p_LmFree(bc, R);
}
p_ExpVectorAdd
static void p_ExpVectorAdd(poly p1, poly p2, const ring r)
Definition p_polys.h:1432
p_ExpVectorDiff
static void p_ExpVectorDiff(poly pr, poly p1, poly p2, const ring r)
Definition p_polys.h:1495
p_New
static poly p_New(const ring, omBin bin)
Definition p_polys.h:666
p_LmTest
#define p_LmTest(p, r)
Definition p_polys.h:162
p_Test
#define p_Test(p, r)
Definition p_polys.h:161

## sm_FindRef()

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

static

Definition at line 2020 of file sparsmat.cc.

{
number x;
int i;
poly pa = *px, pp = NULL;
loop
{
i = p_LmCmp(pa, r,R);
if (i > 0)
{
pp = pa;
pIter(pa);
if (pa==NULL)
{
pNext(pp) = r;
break;
}
}
else
{
if (i == 0)
{
x = n_Add(pGetCoeff(pa), pGetCoeff(r),R->cf);
p_LmDelete(&r,R);
if (n_IsZero(x,R->cf))
{
p_LmDelete(&pa,R);
if (pp!=NULL)
pNext(pp) = p_Add_q(pa,r,R);
else
*px = p_Add_q(pa,r,R);
}
else
{
pp = pa;
p_SetCoeff(pp,x,R);
pNext(pp) = p_Add_q(pNext(pp), r, R);
}
}
else
{
if (pp!=NULL)
pp = pNext(pp) = r;
else
*px = pp = r;
pNext(pp) = p_Add_q(pa, pNext(r),R);
}
break;
}
}
*ref = pp;
}
pp
CanonicalForm FACTORY_PUBLIC pp(const CanonicalForm &)
CanonicalForm pp ( const CanonicalForm & f ).
Definition cf_gcd.cc:676

## sm_HaveDenom()

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

static

Definition at line 2204 of file sparsmat.cc.

{
BOOLEAN sw;
number x;
while (a != NULL)
{
x = n_GetDenom(pGetCoeff(a),R->cf);
sw = n_IsOne(x,R->cf);
n_Delete(&x,R->cf);
if (!sw)
{
return TRUE;
}
pIter(a);
}
return FALSE;
}
TRUE
#define TRUE
Definition auxiliary.h:101
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:606
n_IsOne
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff 'n' represents the one element.
Definition coeffs.h:474

## sm_IsNegQuot()

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

static

Definition at line 1906 of file sparsmat.cc.

{
if (p_LmDivisibleByNoComp(c, b,R))
{
p_ExpVectorDiff(a, b, c,R);
// Hmm: here used to be a p_Setm(a): but it is unnecessary,
// if b and c are correct
return FALSE;
}
else
{
int i;
for (i=rVar(R); i>0; i--)
{
if(p_GetExp(c,i,R) > p_GetExp(b,i,R))
p_SetExp(a,i,p_GetExp(c,i,R)-p_GetExp(b,i,R),R);
else
p_SetExp(a,i,0,R);
}
// here we actually might need a p_Setm, if a is to be used in
// comparisons
return TRUE;
}
}
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:490
p_LmDivisibleByNoComp
static BOOLEAN p_LmDivisibleByNoComp(poly a, poly b, const ring r)
Definition p_polys.h:1898

## sm_KillModifiedRing()

void sm_KillModifiedRing | ( | ring | r | ) |

Definition at line 289 of file sparsmat.cc.

{
if (r->qideal!=NULL) id_Delete(&(r->qideal),r);
for(int i=r->N-1;i>=0;i--) omFree(r->names[i]);
omFreeSize(r->names,r->N*sizeof(char*));
rKillModifiedRing(r);
}
omFree
#define omFree(addr)
Definition omAllocDecl.h:261
rKillModifiedRing
void rKillModifiedRing(ring r)
Definition ring.cc:3119

## sm_MultDiv()

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

Definition at line 1759 of file sparsmat.cc.

{
poly pa, e, res, r;
BOOLEAN lead;
if ((c == NULL) || p_LmIsConstantComp(c,R))
{
return pp_Mult_qq(a, b, R);
}
if (smSmaller(a, b))
{
r = a;
a = b;
b = r;
}
res = NULL;
e = p_Init(R);
lead = FALSE;
while (!lead)
{
pSetCoeff0(e,pGetCoeff(b));
if (sm_IsNegQuot(e, b, c, R))
{
lead = p_LmDivisibleByNoComp(e, a, R);
r = sm_SelectCopy_ExpMultDiv(a, e, b, c, R);
}
else
{
lead = TRUE;
r = pp_Mult_mm(a, e,R);
}
if (lead)
{
if (res != NULL)
{
sm_FindRef(&pa, &res, r, R);
if (pa == NULL)
lead = FALSE;
}
else
{
pa = res = r;
}
}
else
res = p_Add_q(res, r, R);
pIter(b);
if (b == NULL)
{
p_LmFree(e, R);
return res;
}
}
do
{
pSetCoeff0(e,pGetCoeff(b));
if (sm_IsNegQuot(e, b, c, R))
{
r = sm_SelectCopy_ExpMultDiv(a, e, b, c, R);
if (p_LmDivisibleByNoComp(e, a,R))
sm_CombineChain(&pa, r, R);
else
pa = p_Add_q(pa,r,R);
}
else
{
r = pp_Mult_mm(a, e, R);
sm_CombineChain(&pa, r, R);
}
pIter(b);
} while (b != NULL);
p_LmFree(e, R);
return res;
}
p_LmIsConstantComp
static BOOLEAN p_LmIsConstantComp(const poly p, const ring r)
Definition p_polys.h:1008
pp_Mult_qq
static poly pp_Mult_qq(poly p, poly q, const ring r)
Definition p_polys.h:1167
sm_CombineChain
static void sm_CombineChain(poly *, poly, const ring)
Definition sparsmat.cc:1973
smSmaller
static BOOLEAN smSmaller(poly, poly)
Definition sparsmat.cc:1962
sm_FindRef
static void sm_FindRef(poly *, poly *, poly, const ring)
Definition sparsmat.cc:2020

## sm_NumberDelete()

void sm_NumberDelete | ( | smnumber * | r,
|  | const ring | R )

static

Definition at line 2825 of file sparsmat.cc.

{
smnumber a = *r, b = a->n;
n_Delete(&a->m,R->cf);
omFreeBin((ADDRESS)a, smnrec_bin);
*r = b;
}
smnrec_bin
STATIC_VAR omBin smnrec_bin
Definition sparsmat.cc:2264
smnumber
sm_nrec * smnumber
Definition sparsmat.cc:2257

## sm_Poly2Smnumber()

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

static

Definition at line 2845 of file sparsmat.cc.

{
smnumber a, res;
poly p = q;
if (p == NULL)
return NULL;
a = res = (smnumber)omAllocBin(smnrec_bin);
a->pos = p_GetComp(p,R);
a->m = pGetCoeff(p);
pGetCoeff(p)=NULL;
loop
{
pIter(p);
if (p == NULL)
{
p_Delete(&q,R);
a->n = NULL;
return res;
}
a = a->n = (smnumber)omAllocBin(smnrec_bin);
a->pos = p_GetComp(p,R);
a->m = pGetCoeff(p);
pGetCoeff(p)=NULL;
}
}
omAllocBin
#define omAllocBin(bin)
Definition omAllocDecl.h:205

## sm_Poly2Smpoly()

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

static

Definition at line 2097 of file sparsmat.cc.

{
poly pp;
smpoly res, a;
long x;
if (q == NULL)
return NULL;
a = res = (smpoly)omAllocBin(smprec_bin);
a->pos = x = p_GetComp(q,R);
a->m = q;
a->e = 0;
loop
{
p_SetComp(q,0,R);
pp = q;
pIter(q);
if (q == NULL)
{
a->n = NULL;
return res;
}
if (p_GetComp(q,R) != x)
{
a = a->n = (smpoly)omAllocBin(smprec_bin);
pNext(pp) = NULL;
a->pos = x = p_GetComp(q,R);
a->m = q;
a->e = 0;
}
}
}
p_SetComp
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition p_polys.h:249

## sm_PolyDivN()

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

static

Definition at line 1949 of file sparsmat.cc.

{
number y;
do
{
y = n_Div(pGetCoeff(a),x, R->cf);
n_Normalize(y, R->cf);
p_SetCoeff(a,y, R);
pIter(a);
} while (a != NULL);
}

## sm_PolyWeight()

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

static

Definition at line 2175 of file sparsmat.cc.

{
poly p = a->m;
int i;
float res = (float)n_Size(pGetCoeff(p),R->cf);
if (pNext(p) == NULL)
{
for(i=rVar(R); i>0; i--)
{
if (p_GetExp(p,i,R) != 0) return res+1.0;
}
return res;
}
else
{
i = 0;
res = 0.0;
do
{
i++;
res += (float)n_Size(pGetCoeff(p),R->cf);
pIter(p);
}
while (p);
return res+(float)i;
}
}
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:573

## sm_RingChange()

ring sm_RingChange | ( | const ring | origR,
|  | long | bound )

Definition at line 258 of file sparsmat.cc.

{
// *origR =currRing;
ring tmpR=rCopy0(origR,FALSE,FALSE);
rRingOrder_t *ord=(rRingOrder_t*)omAlloc0(3*sizeof(rRingOrder_t));
int *block0=(int*)omAlloc0(3*sizeof(int));
int *block1=(int*)omAlloc0(3*sizeof(int));
ord[0]=ringorder_c;
ord[1]=ringorder_dp;
tmpR->order=ord;
tmpR->OrdSgn=1;
block0[1]=1;
tmpR->block0=block0;
block1[1]=tmpR->N;
tmpR->block1=block1;
tmpR->bitmask = 2*bound;
tmpR->wvhdl = (int **)omAlloc0((3) * sizeof(int*));
// ???
// if (tmpR->bitmask > currRing->bitmask) tmpR->bitmask = currRing->bitmask;
rComplete(tmpR,1);
if (origR->qideal!=NULL)
{
tmpR->qideal= idrCopyR_NoSort(origR->qideal, origR, tmpR);
}
if (TEST_OPT_PROT)
Print("[%ld:%d]", (long) tmpR->bitmask, tmpR->ExpL_Size);
return tmpR;
}
Print
#define Print
Definition emacs.cc:80
TEST_OPT_PROT
#define TEST_OPT_PROT
Definition options.h:105
idrCopyR_NoSort
ideal idrCopyR_NoSort(ideal id, ring src_r, ring dest_r)
Definition prCopy.cc:205
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:3527
rCopy0
ring rCopy0(const ring r, BOOLEAN copy_qideal, BOOLEAN copy_ordering)
Definition ring.cc:1427
rRingOrder_t
rRingOrder_t
order stuff
Definition ring.h:69
ringorder_dp
@ ringorder_dp
Definition ring.h:79
ringorder_c
@ ringorder_c
Definition ring.h:73

## sm_SelectCopy_ExpMultDiv()

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

static

Definition at line 98 of file sparsmat.cc.

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

## sm_Smnumber2Poly()

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

static

Definition at line 2876 of file sparsmat.cc.

{
poly res;
if (a == NULL) return NULL;
res = p_Init(R);
pSetCoeff0(res, a);
return res;
}

## sm_Smpoly2Poly()

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

static

Definition at line 2134 of file sparsmat.cc.

{
smpoly b;
poly res, pp, q;
long x;
if (a == NULL)
return NULL;
x = a->pos;
q = res = a->m;
loop
{
p_SetComp(q,x,R);
pp = q;
pIter(q);
if (q == NULL)
break;
}
loop
{
b = a;
a = a->n;
omFreeBin((void *)b, smprec_bin);
if (a == NULL)
return res;
x = a->pos;
q = pNext(pp) = a->m;
loop
{
p_SetComp(q,x,R);
pp = q;
pIter(q);
if (q == NULL)
break;
}
}
}

## sm_SpecialPolyDiv()

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

Definition at line 1840 of file sparsmat.cc.

{
if (pNext(b) == NULL)
{
sm_PolyDivN(a, pGetCoeff(b),R);
return;
}
sm_ExactPolyDiv(a, b, R);
}
sm_ExactPolyDiv
static void sm_ExactPolyDiv(poly, poly, const ring)
Definition sparsmat.cc:1851
sm_PolyDivN
static void sm_PolyDivN(poly, const number, const ring)
Definition sparsmat.cc:1949

## smCheckSolv()

BOOLEAN smCheckSolv | ( | ideal | I | ) |

static

Definition at line 2889 of file sparsmat.cc.

{ int i = I->ncols;
if ((i == 0) || (i != I->rank-1))
{
WerrorS("wrong dimensions for linsolv");
return TRUE;
}
for(;i;i--)
{
if(I->m[i-1] == NULL)
{
WerrorS("singular input for linsolv");
return TRUE;
}
}
return FALSE;
}

## smElemCopy()

smpoly smElemCopy | ( | smpoly | a | ) |

static

Definition at line 2085 of file sparsmat.cc.

{
smpoly r = (smpoly)omAllocBin(smprec_bin);
memcpy(r, a, sizeof(smprec));
/* r->m = pCopy(r->m); */
return r;
}
smprec
Definition sparsmat.cc:48

## smMinSelect()

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

static

Definition at line 236 of file sparsmat.cc.

{
long m;
int pos, i;
do
{
d--;
pos = d;
m = c[pos];
for (i=d-1;i>=0;i--)
{
if(c[i]<m)
{
pos = i;
m = c[i];
}
}
for (i=pos;i<d;i++) c[i] = c[i+1];
} while (d>t);
}

## smNumberCopy()

smnumber smNumberCopy | ( | smnumber | a | ) |

static

Definition at line 2834 of file sparsmat.cc.

{
smnumber r = (smnumber)omAllocBin(smnrec_bin);
memcpy(r, a, sizeof(smnrec));
return r;
}
smnrec
Definition sparsmat.cc:2258

## smSmaller()

BOOLEAN smSmaller | ( | poly | a,
|  | poly | b )

static

Definition at line 1962 of file sparsmat.cc.

{
loop
{
pIter(b);
if (b == NULL) return TRUE;
pIter(a);
if (a == NULL) return FALSE;
}
}

## 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.