Loading...
Searching...
No Matches
sparse_mat Class Reference

## Public Member Functions

| sparse_mat (ideal, const ring)
| ~sparse_mat ()
int | smGetSign ()
smpoly * | smGetAct ()
int | smGetRed ()
ideal | smRes2Mod ()
poly | smDet ()
void | smNewBareiss (int, int)
void | smToIntvec (intvec *)

## Private Member Functions

void | smColToRow ()
void | smRowToCol ()
void | smFinalMult ()
void | smSparseHomog ()
void | smWeights ()
void | smPivot ()
void | smNewWeights ()
void | smNewPivot ()
void | smZeroElim ()
void | smToredElim ()
void | smCopToRes ()
void | smSelectPR ()
void | sm1Elim ()
void | smHElim ()
void | smMultCol ()
poly | smMultPoly (smpoly)
void | smActDel ()
void | smColDel ()
void | smPivDel ()
void | smSign ()
void | smInitPerm ()
int | smCheckNormalize ()
void | smNormalize ()

## Private Attributes

int | nrows
int | ncols
int | sign
int | act
int | crd
int | tored
int | inred
int | rpiv
int | cpiv
int | normalize
int * | perm
float | wpoints
float * | wrw
float * | wcl
smpoly * | m_act
smpoly * | m_res
smpoly * | m_row
smpoly | red
smpoly | piv
smpoly | oldpiv
smpoly | dumm
ring | _R

## Detailed Description

Definition at line 124 of file sparsmat.cc.

## Constructor & Destructor Documentation

## sparse_mat()

sparse_mat::sparse_mat | ( | ideal | smat,
|  | const ring | RR )

Definition at line 386 of file sparsmat.cc.

{
int i;
poly* pmat;
_R=RR;
ncols = smat->ncols;
nrows = id_RankFreeModule(smat,RR);
if (nrows <= 0)
{
m_act = NULL;
return;
}
sign = 1;
inred = act = ncols;
crd = 0;
tored = nrows; // without border
i = tored+1;
perm = (int *)omAlloc(sizeof(int)*(i+1));
perm[i] = 0;
m_row = (smpoly *)omAlloc0(sizeof(smpoly)*i);
wrw = (float *)omAlloc(sizeof(float)*i);
i = ncols+1;
wcl = (float *)omAlloc(sizeof(float)*i);
m_act = (smpoly *)omAlloc(sizeof(smpoly)*i);
m_res = (smpoly *)omAlloc0(sizeof(smpoly)*i);
dumm = (smpoly)omAllocBin(smprec_bin);
m_res[0] = (smpoly)omAllocBin(smprec_bin);
m_res[0]->m = NULL;
pmat = smat->m;
for(i=ncols; i; i--)
{
m_act[i] = sm_Poly2Smpoly(pmat[i-1], RR);
pmat[i-1] = NULL;
}
this->smZeroElim();
oldpiv = NULL;
}
i
int i
Definition cfEzgcd.cc:132
sparse_mat::tored
int tored
Definition sparsmat.cc:130
sparse_mat::ncols
int ncols
Definition sparsmat.cc:126
sparse_mat::crd
int crd
Definition sparsmat.cc:129
sparse_mat::m_row
smpoly * m_row
Definition sparsmat.cc:139
sparse_mat::wcl
float * wcl
Definition sparsmat.cc:136
sparse_mat::m_res
smpoly * m_res
Definition sparsmat.cc:138
sparse_mat::dumm
smpoly dumm
Definition sparsmat.cc:142
sparse_mat::inred
int inred
Definition sparsmat.cc:131
sparse_mat::wrw
float * wrw
Definition sparsmat.cc:136
sparse_mat::m_act
smpoly * m_act
Definition sparsmat.cc:137
sparse_mat::oldpiv
smpoly oldpiv
Definition sparsmat.cc:141
sparse_mat::nrows
int nrows
Definition sparsmat.cc:126
sparse_mat::smZeroElim
void smZeroElim()
Definition sparsmat.cc:1134
sparse_mat::act
int act
Definition sparsmat.cc:128
sparse_mat::perm
int * perm
Definition sparsmat.cc:134
sparse_mat::sign
int sign
Definition sparsmat.cc:127
sparse_mat::_R
ring _R
Definition sparsmat.cc:143
omAlloc
#define omAlloc(size)
Definition omAllocDecl.h:210
omAllocBin
#define omAllocBin(bin)
Definition omAllocDecl.h:205
omAlloc0
#define omAlloc0(size)
Definition omAllocDecl.h:211
NULL
#define NULL
Definition omList.c:12
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
smprec_bin
VAR omBin smprec_bin
Definition sparsmat.cc:74
smpoly
sm_prec * smpoly
Definition sparsmat.cc:46
sm_Poly2Smpoly
static smpoly sm_Poly2Smpoly(poly, const ring)
Definition sparsmat.cc:2097

## ~sparse_mat()

sparse_mat::~sparse_mat | ( |  | ) |

Definition at line 428 of file sparsmat.cc.

{
int i;
if (m_act == NULL) return;
omFreeBin((ADDRESS)m_res[0], smprec_bin);
omFreeBin((ADDRESS)dumm, smprec_bin);
i = ncols+1;
omFreeSize((ADDRESS)m_res, sizeof(smpoly)*i);
omFreeSize((ADDRESS)m_act, sizeof(smpoly)*i);
omFreeSize((ADDRESS)wcl, sizeof(float)*i);
i = nrows+1;
omFreeSize((ADDRESS)wrw, sizeof(float)*i);
omFreeSize((ADDRESS)m_row, sizeof(smpoly)*i);
omFreeSize((ADDRESS)perm, sizeof(int)*(i+1));
}
ADDRESS
void * ADDRESS
Definition auxiliary.h:120
omFreeSize
#define omFreeSize(addr, size)
Definition omAllocDecl.h:260
omFreeBin
#define omFreeBin(addr, bin)
Definition omAllocDecl.h:259

## Member Function Documentation

## sm1Elim()

void sparse_mat::sm1Elim | ( |  | ) |

private

Definition at line 799 of file sparsmat.cc.

{
poly p = piv->m; // pivotelement
smpoly c = m_act[act]; // pivotcolumn
smpoly r = red; // row to reduce
smpoly res, a, b;
poly w, ha, hb;
if ((c == NULL) || (r == NULL))
{
while (r!=NULL) sm_ElemDelete(&r,_R);
return;
}
do
{
a = m_act[r->pos];
res = dumm;
res->n = NULL;
b = c;
w = r->m;
loop // combine the chains a and b: p*a + w*b
{
if (a == NULL)
{
do
{
res = res->n = smElemCopy(b);
res->m = pp_Mult_qq(b->m, w,_R);
res->e = 1;
res->f = sm_PolyWeight(res,_R);
b = b->n;
} while (b != NULL);
break;
}
if (a->pos < b->pos)
{
res = res->n = a;
a = a->n;
}
else if (a->pos > b->pos)
{
res = res->n = smElemCopy(b);
res->m = pp_Mult_qq(b->m, w,_R);
res->e = 1;
res->f = sm_PolyWeight(res,_R);
b = b->n;
}
else
{
ha = pp_Mult_qq(a->m, p,_R);
p_Delete(&a->m,_R);
hb = pp_Mult_qq(b->m, w,_R);
ha = p_Add_q(ha, hb,_R);
if (ha != NULL)
{
a->m = ha;
a->e = 1;
a->f = sm_PolyWeight(a,_R);
res = res->n = a;
a = a->n;
}
else
{
sm_ElemDelete(&a,_R);
}
b = b->n;
}
if (b == NULL)
{
res->n = a;
break;
}
}
m_act[r->pos] = dumm->n;
sm_ElemDelete(&r,_R);
} while (r != NULL);
}
p
int p
Definition cfModGcd.cc:4086
b
CanonicalForm b
Definition cfModGcd.cc:4111
sparse_mat::red
smpoly red
Definition sparsmat.cc:140
sparse_mat::piv
smpoly piv
Definition sparsmat.cc:141
res
CanonicalForm res
Definition facAbsFact.cc:60
w
const CanonicalForm & w
Definition facAbsFact.cc:51
p_Add_q
static poly p_Add_q(poly p, poly q, const ring r)
Definition p_polys.h:938
p_Delete
static void p_Delete(poly *p, const ring r)
Definition p_polys.h:903
pp_Mult_qq
static poly pp_Mult_qq(poly p, poly q, const ring r)
Definition p_polys.h:1167
sm_ElemDelete
static void sm_ElemDelete(smpoly *, const ring)
Definition sparsmat.cc:2076
sm_PolyWeight
static float sm_PolyWeight(smpoly, const ring)
Definition sparsmat.cc:2175
smElemCopy
static smpoly smElemCopy(smpoly)
Definition sparsmat.cc:2085
loop
#define loop
Definition structs.h:71

## smActDel()

void sparse_mat::smActDel | ( |  | ) |

private

Definition at line 1475 of file sparsmat.cc.

{
smpoly a;
int i;
for (i=act; i; i--)
{
a = m_act[i];
do
{
sm_ElemDelete(&a,_R);
} while (a != NULL);
}
}

## smCheckNormalize()

int sparse_mat::smCheckNormalize | ( |  | ) |

private

Definition at line 1413 of file sparsmat.cc.

{
int i;
smpoly a;
for (i=act; i; i--)
{
a = m_act[i];
do
{
if(sm_HaveDenom(a->m,_R)) return 1;
a = a->n;
} while (a != NULL);
}
return 0;
}
sm_HaveDenom
static BOOLEAN sm_HaveDenom(poly, const ring)
Definition sparsmat.cc:2204

## smColDel()

void sparse_mat::smColDel | ( |  | ) |

private

Definition at line 1493 of file sparsmat.cc.

{
smpoly a = m_act[act];
while (a != NULL)
{
sm_ElemDelete(&a,_R);
}
}

## smColToRow()

void sparse_mat::smColToRow | ( |  | ) |

private

Definition at line 1081 of file sparsmat.cc.

{
smpoly c = m_act[act];
smpoly h;
while (c != NULL)
{
h = c;
c = c->n;
h->n = m_row[h->pos];
m_row[h->pos] = h;
h->pos = crd;
}
}
h
STATIC_VAR Poly * h
Definition janet.cc:971

## smCopToRes()

void sparse_mat::smCopToRes | ( |  | ) |

private

Definition at line 1203 of file sparsmat.cc.

{
smpoly a,ap,r,h;
int i,j,k,l;
i = 0;
if (act)
{
a = m_act[act]; // init perm
do
{
i++;
perm[crd+i] = a->pos;
a = a->n;
} while ((a != NULL) && (a->pos <= tored));
for (j=act-1;j;j--) // load all positions of perm
{
a = m_act[j];
k = 1;
loop
{
if (perm[crd+k] >= a->pos)
{
if (perm[crd+k] > a->pos)
{
for (l=i;l>=k;l--) perm[crd+l+1] = perm[crd+l];
perm[crd+k] = a->pos;
i++;
}
a = a->n;
if ((a == NULL) || (a->pos > tored)) break;
}
k++;
if ((k > i) && (a->pos <= tored))
{
do
{
i++;
perm[crd+i] = a->pos;
a = a->n;
} while ((a != NULL) && (a->pos <= tored));
break;
}
}
}
}
for (j=act;j;j--) // renumber m_act
{
k = 1;
a = m_act[j];
while ((a != NULL) && (a->pos <= tored))
{
if (perm[crd+k] == a->pos)
{
a->pos = crd+k;
a = a->n;
}
k++;
}
}
tored = crd+i;
for(k=1;k<=i;k++) // clean this from m_row
{
j = perm[crd+k];
if (m_row[j] != NULL)
{
r = m_row[j];
m_row[j] = NULL;
do
{
ap = m_res[r->pos];
loop
{
a = ap->n;
if (a == NULL)
{
h = ap->n = r;
r = r->n;
h->n = NULL;
h->pos = crd+k;
break;
}
ap = a;
}
} while (r!=NULL);
}
}
while(act) // clean m_act
{
crd++;
m_res[crd] = m_act[act];
act--;
}
for (i=1;i<=tored;i++) // take the rest of m_row
{
if(m_row[i] != NULL)
{
tored++;
r = m_row[i];
m_row[i] = NULL;
perm[tored] = i;
do
{
ap = m_res[r->pos];
loop
{
a = ap->n;
if (a == NULL)
{
h = ap->n = r;
r = r->n;
h->n = NULL;
h->pos = tored;
break;
}
ap = a;
}
} while (r!=NULL);
}
}
for (i=tored+1;i<=nrows;i++) // take the rest of m_row
{
if(m_row[i] != NULL)
{
r = m_row[i];
m_row[i] = NULL;
do
{
ap = m_res[r->pos];
loop
{
a = ap->n;
if (a == NULL)
{
h = ap->n = r;
r = r->n;
h->n = NULL;
h->pos = i;
break;
}
ap = a;
}
} while (r!=NULL);
}
}
while (inred < ncols) // take unreducable
{
crd++;
inred++;
m_res[crd] = m_res[inred];
}
}
l
int l
Definition cfEzgcd.cc:100
k
int k
Definition cfEzgcd.cc:99
j
int j
Definition facHensel.cc:110

## smDet()

poly sparse_mat::smDet | ( |  | ) |

Definition at line 475 of file sparsmat.cc.

{
poly res = NULL;
if (sign == 0)
{
this->smActDel();
return NULL;
}
if (act < 2)
{
if (act != 0) res = m_act[1]->m;
omFreeBin((void *)m_act[1], smprec_bin);
return res;
}
normalize = 0;
this->smInitPerm();
this->smPivot();
this->smSign();
this->smSelectPR();
this->sm1Elim();
crd++;
m_res[crd] = piv;
this->smColDel();
act--;
this->smZeroElim();
if (sign == 0)
{
this->smActDel();
return NULL;
}
if (act < 2)
{
this->smFinalMult();
this->smPivDel();
if (act != 0) res = m_act[1]->m;
omFreeBin((void *)m_act[1], smprec_bin);
return res;
}
loop
{
this->smNewPivot();
this->smSign();
this->smSelectPR();
this->smMultCol();
this->smHElim();
crd++;
m_res[crd] = piv;
this->smColDel();
act--;
this->smZeroElim();
if (sign == 0)
{
this->smPivDel();
this->smActDel();
return NULL;
}
if (act < 2)
{
if (TEST_OPT_PROT) PrintS(".\n");
this->smFinalMult();
this->smPivDel();
if (act != 0) res = m_act[1]->m;
omFreeBin((void *)m_act[1], smprec_bin);
return res;
}
}
}
sparse_mat::smFinalMult
void smFinalMult()
Definition sparsmat.cc:1384
sparse_mat::smInitPerm
void smInitPerm()
Definition sparsmat.cc:1548
sparse_mat::smActDel
void smActDel()
Definition sparsmat.cc:1475
sparse_mat::sm1Elim
void sm1Elim()
Definition sparsmat.cc:799
sparse_mat::smPivDel
void smPivDel()
Definition sparsmat.cc:1506
sparse_mat::smColDel
void smColDel()
Definition sparsmat.cc:1493
sparse_mat::smPivot
void smPivot()
Definition sparsmat.cc:642
sparse_mat::normalize
int normalize
Definition sparsmat.cc:133
sparse_mat::smSelectPR
void smSelectPR()
Definition sparsmat.cc:1017
sparse_mat::smSign
void smSign()
Definition sparsmat.cc:1520
sparse_mat::smHElim
void smHElim()
Definition sparsmat.cc:878
sparse_mat::smMultCol
void smMultCol()
Definition sparsmat.cc:1359
sparse_mat::smNewPivot
void smNewPivot()
Definition sparsmat.cc:737
TEST_OPT_PROT
#define TEST_OPT_PROT
Definition options.h:105
PrintS
void PrintS(const char *s)
Definition reporter.cc:288

## smFinalMult()

void sparse_mat::smFinalMult | ( |  | ) |

private

Definition at line 1384 of file sparsmat.cc.

{
smpoly a;
poly ha;
int i, f;
int e = crd;
for (i=act; i; i--)
{
a = m_act[i];
do
{
f = a->e;
if (f < e)
{
ha = SM_MULT(a->m, m_res[e]->m, m_res[f]->m, _R);
p_Delete(&a->m,_R);
if (f) SM_DIV(ha, m_res[f]->m, _R);
a->m = ha;
}
if (normalize) p_Normalize(a->m, _R);
a = a->n;
} while (a != NULL);
}
}
m
int m
Definition cfEzgcd.cc:128
f
FILE * f
Definition checklibs.c:9
p_Normalize
void p_Normalize(poly p, const ring r)
Definition p_polys.cc:3939
SM_DIV
#define SM_DIV
Definition sparsmat.h:24
SM_MULT
#define SM_MULT
Definition sparsmat.h:23

## smGetAct()

smpoly * sparse_mat::smGetAct | ( |  | ) |

inline

Definition at line 172 of file sparsmat.cc.

{ return m_act; }

## smGetRed()

int sparse_mat::smGetRed | ( |  | ) |

inline

Definition at line 173 of file sparsmat.cc.

{ return tored; }

## smGetSign()

int sparse_mat::smGetSign | ( |  | ) |

inline

Definition at line 171 of file sparsmat.cc.

{ return sign; }

## smHElim()

void sparse_mat::smHElim | ( |  | ) |

private

Definition at line 878 of file sparsmat.cc.

{
poly hp = this->smMultPoly(piv);
poly gp = piv->m; // pivotelement
smpoly c = m_act[act]; // pivotcolumn
smpoly r = red; // row to reduce
smpoly res, a, b;
poly ha, hr, x, y;
int e, ip, ir, ia;
if ((c == NULL) || (r == NULL))
{
while(r!=NULL) sm_ElemDelete(&r,_R);
p_Delete(&hp,_R);
return;
}
e = crd+1;
ip = piv->e;
do
{
a = m_act[r->pos];
res = dumm;
res->n = NULL;
b = c;
hr = r->m;
ir = r->e;
loop // combine the chains a and b: (hp,gp)*a(l) + hr*b(h)
{
if (a == NULL)
{
do
{
res = res->n = smElemCopy(b);
x = SM_MULT(b->m, hr, m_res[ir]->m,_R);
b = b->n;
if(ir) SM_DIV(x, m_res[ir]->m,_R);
res->m = x;
res->e = e;
res->f = sm_PolyWeight(res,_R);
} while (b != NULL);
break;
}
if (a->pos < b->pos)
{
res = res->n = a;
a = a->n;
}
else if (a->pos > b->pos)
{
res = res->n = smElemCopy(b);
x = SM_MULT(b->m, hr, m_res[ir]->m,_R);
b = b->n;
if(ir) SM_DIV(x, m_res[ir]->m,_R);
res->m = x;
res->e = e;
res->f = sm_PolyWeight(res,_R);
}
else
{
ha = a->m;
ia = a->e;
if (ir >= ia)
{
if (ir > ia)
{
x = SM_MULT(ha, m_res[ir]->m, m_res[ia]->m,_R);
p_Delete(&ha,_R);
ha = x;
if (ia) SM_DIV(ha, m_res[ia]->m,_R);
ia = ir;
}
x = SM_MULT(ha, gp, m_res[ia]->m,_R);
p_Delete(&ha,_R);
y = SM_MULT(b->m, hr, m_res[ia]->m,_R);
}
else if (ir >= ip)
{
if (ia < crd)
{
x = SM_MULT(ha, m_res[crd]->m, m_res[ia]->m,_R);
p_Delete(&ha,_R);
ha = x;
SM_DIV(ha, m_res[ia]->m,_R);
}
y = hp;
if(ir > ip)
{
y = SM_MULT(y, m_res[ir]->m, m_res[ip]->m,_R);
if (ip) SM_DIV(y, m_res[ip]->m,_R);
}
ia = ir;
x = SM_MULT(ha, y, m_res[ia]->m,_R);
if (y != hp) p_Delete(&y,_R);
p_Delete(&ha,_R);
y = SM_MULT(b->m, hr, m_res[ia]->m,_R);
}
else
{
x = SM_MULT(hr, m_res[ia]->m, m_res[ir]->m,_R);
if (ir) SM_DIV(x, m_res[ir]->m,_R);
y = SM_MULT(b->m, x, m_res[ia]->m,_R);
p_Delete(&x,_R);
x = SM_MULT(ha, gp, m_res[ia]->m,_R);
p_Delete(&ha,_R);
}
ha = p_Add_q(x, y,_R);
if (ha != NULL)
{
if (ia) SM_DIV(ha, m_res[ia]->m,_R);
a->m = ha;
a->e = e;
a->f = sm_PolyWeight(a,_R);
res = res->n = a;
a = a->n;
}
else
{
a->m = NULL;
sm_ElemDelete(&a,_R);
}
b = b->n;
}
if (b == NULL)
{
res->n = a;
break;
}
}
m_act[r->pos] = dumm->n;
sm_ElemDelete(&r,_R);
} while (r != NULL);
p_Delete(&hp,_R);
}
x
Variable x
Definition cfModGcd.cc:4090
gp
CanonicalForm gp
Definition cfModGcd.cc:4110
sparse_mat::smMultPoly
poly smMultPoly(smpoly)
Definition sparsmat.cc:1453
y
const CanonicalForm int const CFList const Variable & y
Definition facAbsFact.cc:53

## smInitPerm()

void sparse_mat::smInitPerm | ( |  | ) |

private

Definition at line 1548 of file sparsmat.cc.

{
int i;
for (i=act;i;i--) perm[i]=i;
}

## smMultCol()

void sparse_mat::smMultCol | ( |  | ) |

private

Definition at line 1359 of file sparsmat.cc.

{
smpoly a = m_act[act];
int e = crd;
poly ha;
int f;
while (a != NULL)
{
f = a->e;
if (f < e)
{
ha = SM_MULT(a->m, m_res[e]->m, m_res[f]->m,_R);
p_Delete(&a->m,_R);
if (f) SM_DIV(ha, m_res[f]->m,_R);
a->m = ha;
if (normalize) p_Normalize(a->m,_R);
}
a = a->n;
}
}

## smMultPoly()

poly sparse_mat::smMultPoly | ( | smpoly | a | ) |

private

Definition at line 1453 of file sparsmat.cc.

{
int f = a->e;
poly r, h;
if (f < crd)
{
h = r = a->m;
h = SM_MULT(h, m_res[crd]->m, m_res[f]->m, _R);
if (f) SM_DIV(h, m_res[f]->m, _R);
a->m = h;
if (normalize) p_Normalize(a->m,_R);
a->f = sm_PolyWeight(a,_R);
return r;
}
else
return NULL;
}

## smNewBareiss()

void sparse_mat::smNewBareiss | ( | int | x,
|  | int | y )

Definition at line 549 of file sparsmat.cc.

{
if ((x > 0) && (x < nrows))
{
tored -= x;
this->smToredElim();
}
if (y < 1) y = 1;
if (act <= y)
{
this->smCopToRes();
return;
}
normalize = this->smCheckNormalize();
if (normalize) this->smNormalize();
this->smPivot();
this->smSelectPR();
this->sm1Elim();
crd++;
this->smColToRow();
act--;
this->smRowToCol();
this->smZeroElim();
if (tored != nrows)
this->smToredElim();
if (act <= y)
{
this->smFinalMult();
this->smCopToRes();
return;
}
loop
{
if (normalize) this->smNormalize();
this->smNewPivot();
this->smSelectPR();
this->smMultCol();
this->smHElim();
crd++;
this->smColToRow();
act--;
this->smRowToCol();
this->smZeroElim();
if (tored != nrows)
this->smToredElim();
if (act <= y)
{
if (TEST_OPT_PROT) PrintS(".\n");
this->smFinalMult();
this->smCopToRes();
return;
}
}
}
sparse_mat::smCopToRes
void smCopToRes()
Definition sparsmat.cc:1203
sparse_mat::smToredElim
void smToredElim()
Definition sparsmat.cc:1164
sparse_mat::smColToRow
void smColToRow()
Definition sparsmat.cc:1081
sparse_mat::smNormalize
void smNormalize()
Definition sparsmat.cc:1433
sparse_mat::smCheckNormalize
int smCheckNormalize()
Definition sparsmat.cc:1413
sparse_mat::smRowToCol
void smRowToCol()
Definition sparsmat.cc:1101

## smNewPivot()

void sparse_mat::smNewPivot | ( |  | ) |

private

Definition at line 737 of file sparsmat.cc.

{
float wopt = 1.0e30, hp = piv->f;
float wc, wr, wp, w;
smpoly a;
int i, copt, ropt, f, e = crd;
this->smNewWeights();
for (i=act; i; i--)
{
a = m_act[i];
loop
{
if (a->pos > tored)
break;
w = a->f;
f = a->e;
if (f < e)
{
w *= hp;
if (f) w /= m_res[f]->f;
}
wc = wcl[i]-w;
wr = wrw[a->pos]-w;
if ((wr<0.25) || (wc<0.25)) // row or column with only one point
{
if (w<wopt)
{
wopt = w;
copt = i;
ropt = a->pos;
}
}
else // elimination
{
wp = w*(wpoints-wcl[i]-wr);
wp += wr*wc;
if (wp < wopt)
{
wopt = wp;
copt = i;
ropt = a->pos;
}
}
a = a->n;
if (a == NULL)
break;
}
}
rpiv = ropt;
cpiv = copt;
if (cpiv != act)
{
a = m_act[act];
m_act[act] = m_act[cpiv];
m_act[cpiv] = a;
}
}
sparse_mat::rpiv
int rpiv
Definition sparsmat.cc:132
sparse_mat::cpiv
int cpiv
Definition sparsmat.cc:132
sparse_mat::wpoints
float wpoints
Definition sparsmat.cc:135
sparse_mat::smNewWeights
void smNewWeights()
Definition sparsmat.cc:699

## smNewWeights()

void sparse_mat::smNewWeights | ( |  | ) |

private

Definition at line 699 of file sparsmat.cc.

{
float wc, wp, w, hp = piv->f;
smpoly a;
int i, f, e = crd;
wp = 0.0;
for (i=tored; i; i--) wrw[i] = 0.0; // ???
for (i=act; i; i--)
{
wc = 0.0;
a = m_act[i];
loop
{
if (a->pos > tored)
break;
w = a->f;
f = a->e;
if (f < e)
{
w *= hp;
if (f) w /= m_res[f]->f;
}
wc += w;
wrw[a->pos] += w;
a = a->n;
if (a == NULL)
break;
}
wp += wc;
wcl[i] = wc;
}
wpoints = wp;
}

## smNormalize()

void sparse_mat::smNormalize | ( |  | ) |

private

Definition at line 1433 of file sparsmat.cc.

{
smpoly a;
int i;
int e = crd;
for (i=act; i; i--)
{
a = m_act[i];
do
{
if (e == a->e) p_Normalize(a->m,_R);
a = a->n;
} while (a != NULL);
}
}

## smPivDel()

void sparse_mat::smPivDel | ( |  | ) |

private

Definition at line 1506 of file sparsmat.cc.

{
int i=crd;
while (i != 0)
{
sm_ElemDelete(&m_res[i],_R);
i--;
}
}

## smPivot()

void sparse_mat::smPivot | ( |  | ) |

private

Definition at line 642 of file sparsmat.cc.

{
float wopt = 1.0e30;
float wc, wr, wp, w;
smpoly a;
int i, copt, ropt;
this->smWeights();
for (i=act; i; i--)
{
a = m_act[i];
loop
{
if (a->pos > tored)
break;
w = a->f;
wc = wcl[i]-w;
wr = wrw[a->pos]-w;
if ((wr<0.25) || (wc<0.25)) // row or column with only one point
{
if (w<wopt)
{
wopt = w;
copt = i;
ropt = a->pos;
}
}
else // elimination
{
wp = w*(wpoints-wcl[i]-wr);
wp += wr*wc;
if (wp < wopt)
{
wopt = wp;
copt = i;
ropt = a->pos;
}
}
a = a->n;
if (a == NULL)
break;
}
}
rpiv = ropt;
cpiv = copt;
if (cpiv != act)
{
a = m_act[act];
m_act[act] = m_act[cpiv];
m_act[cpiv] = a;
}
}
sparse_mat::smWeights
void smWeights()
Definition sparsmat.cc:610

## smRes2Mod()

ideal sparse_mat::smRes2Mod | ( |  | ) |

Definition at line 448 of file sparsmat.cc.

{
ideal res = idInit(crd, crd);
int i;
for (i=crd; i; i--)
{
res->m[i-1] = sm_Smpoly2Poly(m_res[i],_R);
res->rank=si_max(res->rank, p_MaxComp(res->m[i-1],_R));
}
return res;
}
si_max
static int si_max(const int a, const int b)
Definition auxiliary.h:125
p_MaxComp
static long p_MaxComp(poly p, ring lmRing, ring tailRing)
Definition p_polys.h:294
idInit
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition simpleideals.cc:35
sm_Smpoly2Poly
static poly sm_Smpoly2Poly(smpoly, const ring)
Definition sparsmat.cc:2134

## smRowToCol()

void sparse_mat::smRowToCol | ( |  | ) |

private

Definition at line 1101 of file sparsmat.cc.

{
smpoly r = m_row[rpiv];
smpoly a, ap, h;
m_row[rpiv] = NULL;
perm[crd] = rpiv;
piv->pos = crd;
m_res[crd] = piv;
while (r != NULL)
{
ap = m_res[r->pos];
loop
{
a = ap->n;
if (a == NULL)
{
ap->n = h = r;
r = r->n;
h->n = a;
h->pos = crd;
break;
}
ap = a;
}
}
}

## smSelectPR()

void sparse_mat::smSelectPR | ( |  | ) |

private

Definition at line 1017 of file sparsmat.cc.

{
smpoly b = dumm;
smpoly a, ap;
int i;
if (TEST_OPT_PROT)
{
if ((crd+1)%10)
PrintS(".");
else
PrintS(".\n");
}
a = m_act[act];
if (a->pos < rpiv)
{
do
{
ap = a;
a = a->n;
} while (a->pos < rpiv);
ap->n = a->n;
}
else
m_act[act] = a->n;
piv = a;
a->n = NULL;
for (i=1; i<act; i++)
{
a = m_act[i];
if (a->pos < rpiv)
{
loop
{
ap = a;
a = a->n;
if ((a == NULL) || (a->pos > rpiv))
break;
if (a->pos == rpiv)
{
ap->n = a->n;
a->m = p_Neg(a->m,_R);
b = b->n = a;
b->pos = i;
break;
}
}
}
else if (a->pos == rpiv)
{
m_act[i] = a->n;
a->m = p_Neg(a->m,_R);
b = b->n = a;
b->pos = i;
}
}
b->n = NULL;
red = dumm->n;
}
p_Neg
static poly p_Neg(poly p, const ring r)
Definition p_polys.h:1114

## smSign()

void sparse_mat::smSign | ( |  | ) |

private

Definition at line 1520 of file sparsmat.cc.

{
int j,i;
if (act > 2)
{
if (cpiv!=act) sign=-sign;
if ((act%2)==0) sign=-sign;
i=1;
j=perm[1];
while(j<rpiv)
{
sign=-sign;
i++;
j=perm[i];
}
while(perm[i]!=0)
{
perm[i]=perm[i+1];
i++;
}
}
else
{
if (cpiv!=1) sign=-sign;
if (rpiv!=perm[1]) sign=-sign;
}
}

## smSparseHomog()

void sparse_mat::smSparseHomog | ( |  | ) |

private

## smToIntvec()

void sparse_mat::smToIntvec | ( | intvec * | v | ) |

Definition at line 464 of file sparsmat.cc.

{
int i;
for (i=v->rows()-1; i>=0; i--)
(*v)[i] = perm[i+1];
}
v
const Variable & v
< [in] a sqrfree bivariate poly
Definition facBivar.h:39

## smToredElim()

void sparse_mat::smToredElim | ( |  | ) |

private

Definition at line 1164 of file sparsmat.cc.

{
int i = 0;
int j;
loop
{
i++;
if (i > act) return;
if (m_act[i]->pos > tored)
{
m_res[inred] = m_act[i];
inred--;
break;
}
}
j = i;
loop
{
j++;
if (j > act) break;
if (m_act[j]->pos > tored)
{
m_res[inred] = m_act[j];
inred--;
}
else
{
m_act[i] = m_act[j];
i++;
}
}
act -= (j-i);
sign = 0;
}

## smWeights()

void sparse_mat::smWeights | ( |  | ) |

private

Definition at line 610 of file sparsmat.cc.

{
float wc, wp, w;
smpoly a;
int i;
wp = 0.0;
for (i=tored; i; i--) wrw[i] = 0.0; // ???
for (i=act; i; i--)
{
wc = 0.0;
a = m_act[i];
loop
{
if (a->pos > tored)
break;
w = a->f = sm_PolyWeight(a,_R);
wc += w;
wrw[a->pos] += w;
a = a->n;
if (a == NULL)
break;
}
wp += wc;
wcl[i] = wc;
}
wpoints = wp;
}

## smZeroElim()

void sparse_mat::smZeroElim | ( |  | ) |

private

Definition at line 1134 of file sparsmat.cc.

{
int i = 0;
int j;
loop
{
i++;
if (i > act) return;
if (m_act[i] == NULL) break;
}
j = i;
loop
{
j++;
if (j > act) break;
if (m_act[j] != NULL)
{
m_act[i] = m_act[j];
i++;
}
}
act -= (j-i);
sign = 0;
}

## Field Documentation

## _R

ring sparse_mat::_R

private

Definition at line 143 of file sparsmat.cc.

## act

int sparse_mat::act

private

Definition at line 128 of file sparsmat.cc.

## cpiv

int sparse_mat::cpiv

private

Definition at line 132 of file sparsmat.cc.

## crd

int sparse_mat::crd

private

Definition at line 129 of file sparsmat.cc.

## dumm

smpoly sparse_mat::dumm

private

Definition at line 142 of file sparsmat.cc.

## inred

int sparse_mat::inred

private

Definition at line 131 of file sparsmat.cc.

## m_act

smpoly* sparse_mat::m_act

private

Definition at line 137 of file sparsmat.cc.

## m_res

smpoly* sparse_mat::m_res

private

Definition at line 138 of file sparsmat.cc.

## m_row

smpoly* sparse_mat::m_row

private

Definition at line 139 of file sparsmat.cc.

## ncols

int sparse_mat::ncols

private

Definition at line 126 of file sparsmat.cc.

## normalize

int sparse_mat::normalize

private

Definition at line 133 of file sparsmat.cc.

## nrows

int sparse_mat::nrows

private

Definition at line 126 of file sparsmat.cc.

## oldpiv

smpoly sparse_mat::oldpiv

private

Definition at line 141 of file sparsmat.cc.

## perm

int* sparse_mat::perm

private

Definition at line 134 of file sparsmat.cc.

## piv

smpoly sparse_mat::piv

private

Definition at line 141 of file sparsmat.cc.

## red

smpoly sparse_mat::red

private

Definition at line 140 of file sparsmat.cc.

## rpiv

int sparse_mat::rpiv

private

Definition at line 132 of file sparsmat.cc.

## sign

int sparse_mat::sign

private

Definition at line 127 of file sparsmat.cc.

## tored

int sparse_mat::tored

private

Definition at line 130 of file sparsmat.cc.

## wcl

float * sparse_mat::wcl

private

Definition at line 136 of file sparsmat.cc.

## wpoints

float sparse_mat::wpoints

private

Definition at line 135 of file sparsmat.cc.

## wrw

float* sparse_mat::wrw

private

Definition at line 136 of file sparsmat.cc.

The documentation for this class was generated from the following file:

- libpolys/polys/sparsmat.cc