Loading...
Searching...
No Matches
mp_permmatrix Class Reference

## Public Member Functions

| mp_permmatrix ()
| mp_permmatrix (matrix, ring)
| mp_permmatrix (mp_permmatrix *)
| ~mp_permmatrix ()
int | mpGetRow ()
int | mpGetCol ()
int | mpGetRdim ()
int | mpGetCdim ()
int | mpGetSign ()
void | mpSetSearch (int s)
void | mpSaveArray ()
poly | mpGetElem (int, int)
void | mpSetElem (poly, int, int)
void | mpDelElem (int, int)
void | mpElimBareiss (poly)
int | mpPivotBareiss (row_col_weight *)
int | mpPivotRow (row_col_weight *, int)
void | mpToIntvec (intvec *)
void | mpRowReorder ()
void | mpColReorder ()

## Private Member Functions

void | mpInitMat ()
poly * | mpRowAdr (int r)
poly * | mpColAdr (int c)
void | mpRowWeight (float *)
void | mpColWeight (float *)
void | mpRowSwap (int, int)
void | mpColSwap (int, int)

## Private Attributes

int | a_m
int | a_n
int | s_m
int | s_n
int | sign
int | piv_s
int * | qrow
int * | qcol
poly * | Xarray
ring | _R

## Detailed Description

Definition at line 919 of file matpol.cc.

## Constructor & Destructor Documentation

## mp_permmatrix() [1/3]

mp_permmatrix::mp_permmatrix | ( |  | ) |

inline

Definition at line 936 of file matpol.cc.

: a_m(0) {}
mp_permmatrix::a_m
int a_m
Definition matpol.cc:922

## mp_permmatrix() [2/3]

mp_permmatrix::mp_permmatrix | ( | matrix | A,
|  | ring | R )

Definition at line 957 of file matpol.cc.

: sign(1)
{
a_m = A->nrows;
a_n = A->ncols;
this->mpInitMat();
Xarray = A->m;
_R=R;
}
mp_permmatrix::a_n
int a_n
Definition matpol.cc:922
mp_permmatrix::Xarray
poly * Xarray
Definition matpol.cc:924
mp_permmatrix::mpInitMat
void mpInitMat()
Definition matpol.cc:1079
mp_permmatrix::_R
ring _R
Definition matpol.cc:925
mp_permmatrix::sign
int sign
Definition matpol.cc:922
R
#define R
Definition sirandom.c:27
A
#define A
Definition sirandom.c:24

## mp_permmatrix() [3/3]

mp_permmatrix::mp_permmatrix | ( | mp_permmatrix * | M | ) |

Definition at line 966 of file matpol.cc.

{
poly p, *athis, *aM;
int i, j;
_R=M->_R;
a_m = M->s_m;
a_n = M->s_n;
sign = M->sign;
this->mpInitMat();
Xarray = (poly *)omAlloc0(a_m*a_n*sizeof(poly));
for (i=a_m-1; i>=0; i--)
{
athis = this->mpRowAdr(i);
aM = M->mpRowAdr(i);
for (j=a_n-1; j>=0; j--)
{
p = aM[M->qcol[j]];
if (p)
{
athis[j] = p_Copy(p,_R);
}
}
}
}
i
int i
Definition cfEzgcd.cc:132
p
int p
Definition cfModGcd.cc:4086
mp_permmatrix::mpRowAdr
poly * mpRowAdr(int r)
Definition matpol.cc:927
j
int j
Definition facHensel.cc:110
omAlloc0
#define omAlloc0(size)
Definition omAllocDecl.h:211
p_Copy
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition p_polys.h:848
M
#define M
Definition sirandom.c:25

## ~mp_permmatrix()

mp_permmatrix::~mp_permmatrix | ( |  | ) |

Definition at line 992 of file matpol.cc.

{
int k;
if (a_m != 0)
{
omFreeSize((ADDRESS)qrow,a_m*sizeof(int));
omFreeSize((ADDRESS)qcol,a_n*sizeof(int));
if (Xarray != NULL)
{
for (k=a_m*a_n-1; k>=0; k--)
p_Delete(&Xarray[k],_R);
omFreeSize((ADDRESS)Xarray,a_m*a_n*sizeof(poly));
}
}
}
ADDRESS
void * ADDRESS
Definition auxiliary.h:120
k
int k
Definition cfEzgcd.cc:99
mp_permmatrix::qrow
int * qrow
Definition matpol.cc:923
mp_permmatrix::qcol
int * qcol
Definition matpol.cc:923
omFreeSize
#define omFreeSize(addr, size)
Definition omAllocDecl.h:260
NULL
#define NULL
Definition omList.c:12
p_Delete
static void p_Delete(poly *p, const ring r)
Definition p_polys.h:903

## Member Function Documentation

## mpColAdr()

poly * mp_permmatrix::mpColAdr | ( | int | c | ) |

inline private

Definition at line 929 of file matpol.cc.

{ return &(Xarray[qcol[c]]); }

## mpColReorder()

void mp_permmatrix::mpColReorder | ( |  | ) |

Definition at line 1092 of file matpol.cc.

{
int k, j, j1, j2;
if (a_n > a_m)
k = a_n - a_m;
else
k = 0;
for (j=a_n-1; j>=k; j--)
{
j1 = qcol[j];
if (j1 != j)
{
this->mpColSwap(j1, j);
j2 = 0;
while (qcol[j2] != j) j2++;
qcol[j2] = j1;
}
}
}
mp_permmatrix::mpColSwap
void mpColSwap(int, int)
Definition matpol.cc:1065

## mpColSwap()

void mp_permmatrix::mpColSwap | ( | int | j1,
|  | int | j2 )

private

Definition at line 1065 of file matpol.cc.

{
poly p, *a1, *a2;
int i, k = a_n*a_m;
a1 = &(Xarray[j1]);
a2 = &(Xarray[j2]);
for (i=0; i< k; i+=a_n)
{
p = a1[i];
a1[i] = a2[i];
a2[i] = p;
}
}

## mpColWeight()

void mp_permmatrix::mpColWeight | ( | float * | wcol | ) |

private

Definition at line 1011 of file matpol.cc.

{
poly p, *a;
int i, j;
float count;
for (j=s_n; j>=0; j--)
{
a = this->mpColAdr(j);
count = 0.0;
for(i=s_m; i>=0; i--)
{
p = a[a_n*qrow[i]];
if (p)
count += mp_PolyWeight(p,_R);
}
wcol[j] = count;
}
}
mp_permmatrix::s_m
int s_m
Definition matpol.cc:922
mp_permmatrix::s_n
int s_n
Definition matpol.cc:922
mp_permmatrix::mpColAdr
poly * mpColAdr(int c)
Definition matpol.cc:929
mp_PolyWeight
static float mp_PolyWeight(poly p, const ring r)
Definition matpol.cc:1296
count
int status int void size_t count
Definition si_signals.h:69

## mpDelElem()

void mp_permmatrix::mpDelElem | ( | int | ,
|  | int | )

## mpElimBareiss()

void mp_permmatrix::mpElimBareiss | ( | poly | div | ) |

Definition at line 1238 of file matpol.cc.

{
poly piv, elim, q1, q2, *ap, *a;
int i, j, jj;
ap = this->mpRowAdr(s_m);
piv = ap[qcol[s_n]];
for(i=s_m-1; i>=0; i--)
{
a = this->mpRowAdr(i);
elim = a[qcol[s_n]];
if (elim != NULL)
{
elim = p_Neg(elim,_R);
for (j=s_n-1; j>=0; j--)
{
q2 = NULL;
jj = qcol[j];
if (ap[jj] != NULL)
{
q2 = SM_MULT(ap[jj], elim, div,_R);
if (a[jj] != NULL)
{
q1 = SM_MULT(a[jj], piv, div,_R);
p_Delete(&a[jj],_R);
q2 = p_Add_q(q2, q1, _R);
}
}
else if (a[jj] != NULL)
{
q2 = SM_MULT(a[jj], piv, div, _R);
}
if ((q2!=NULL) && div)
SM_DIV(q2, div, _R);
a[jj] = q2;
}
p_Delete(&a[qcol[s_n]], _R);
}
else
{
for (j=s_n-1; j>=0; j--)
{
jj = qcol[j];
if (a[jj] != NULL)
{
q2 = SM_MULT(a[jj], piv, div, _R);
p_Delete(&a[jj], _R);
if (div)
SM_DIV(q2, div, _R);
a[jj] = q2;
}
}
}
}
}
div
CF_NO_INLINE FACTORY_PUBLIC CanonicalForm div(const CanonicalForm &, const CanonicalForm &)
p_Neg
static poly p_Neg(poly p, const ring r)
Definition p_polys.h:1114
p_Add_q
static poly p_Add_q(poly p, poly q, const ring r)
Definition p_polys.h:938
SM_DIV
#define SM_DIV
Definition sparsmat.h:24
SM_MULT
#define SM_MULT
Definition sparsmat.h:23

## mpGetCdim()

int mp_permmatrix::mpGetCdim | ( |  | ) |

inline

Definition at line 943 of file matpol.cc.

{ return s_n; }

## mpGetCol()

int mp_permmatrix::mpGetCol | ( |  | ) |

## mpGetElem()

poly mp_permmatrix::mpGetElem | ( | int | r,
|  | int | c )

Definition at line 1230 of file matpol.cc.

{
return Xarray[a_n*qrow[r]+qcol[c]];
}

## mpGetRdim()

int mp_permmatrix::mpGetRdim | ( |  | ) |

inline

Definition at line 942 of file matpol.cc.

{ return s_m; }

## mpGetRow()

int mp_permmatrix::mpGetRow | ( |  | ) |

## mpGetSign()

int mp_permmatrix::mpGetSign | ( |  | ) |

inline

Definition at line 944 of file matpol.cc.

{ return sign; }

## mpInitMat()

void mp_permmatrix::mpInitMat | ( |  | ) |

private

Definition at line 1079 of file matpol.cc.

{
int k;
s_m = a_m;
s_n = a_n;
piv_s = 0;
qrow = (int *)omAlloc(a_m*sizeof(int));
qcol = (int *)omAlloc(a_n*sizeof(int));
for (k=a_m-1; k>=0; k--) qrow[k] = k;
for (k=a_n-1; k>=0; k--) qcol[k] = k;
}
mp_permmatrix::piv_s
int piv_s
Definition matpol.cc:922
omAlloc
#define omAlloc(size)
Definition omAllocDecl.h:210

## mpPivotBareiss()

int mp_permmatrix::mpPivotBareiss | ( | row_col_weight * | C | ) |

Definition at line 1153 of file matpol.cc.

{
poly p, *a;
int i, j, iopt, jopt;
float sum, f1, f2, fo, r, ro, lp;
float *dr = C->wrow, *dc = C->wcol;
fo = 1.0e20;
ro = 0.0;
iopt = jopt = -1;
s_n--;
s_m--;
if (s_m == 0)
return 0;
if (s_n == 0)
{
for(i=s_m; i>=0; i--)
{
p = this->mpRowAdr(i)[qcol[0]];
if (p)
{
f1 = mp_PolyWeight(p,_R);
if (f1 < fo)
{
fo = f1;
if (iopt >= 0)
p_Delete(&(this->mpRowAdr(iopt)[qcol[0]]),_R);
iopt = i;
}
else
p_Delete(&(this->mpRowAdr(i)[qcol[0]]),_R);
}
}
if (iopt >= 0)
mpReplace(iopt, s_m, sign, qrow);
return 0;
}
this->mpRowWeight(dr);
this->mpColWeight(dc);
sum = 0.0;
for(i=s_m; i>=0; i--)
sum += dr[i];
for(i=s_m; i>=0; i--)
{
r = dr[i];
a = this->mpRowAdr(i);
for(j=s_n; j>=0; j--)
{
p = a[qcol[j]];
if (p)
{
lp = mp_PolyWeight(p,_R);
ro = r - lp;
f1 = ro * (dc[j]-lp);
if (f1 != 0.0)
{
f2 = lp * (sum - ro - dc[j]);
f2 += f1;
}
else
f2 = lp-r-dc[j];
if (f2 < fo)
{
fo = f2;
iopt = i;
jopt = j;
}
}
}
}
if (iopt < 0)
return 0;
mpReplace(iopt, s_m, sign, qrow);
mpReplace(jopt, s_n, sign, qcol);
return 1;
}
mp_permmatrix::mpColWeight
void mpColWeight(float *)
Definition matpol.cc:1011
mp_permmatrix::mpRowWeight
void mpRowWeight(float *)
Definition matpol.cc:1030
row_col_weight::wcol
float * wcol
Definition matpol.cc:887
row_col_weight::wrow
float * wrow
Definition matpol.cc:887
mpReplace
static void mpReplace(int j, int n, int &sign, int *perm)
Definition matpol.cc:1138

## mpPivotRow()

int mp_permmatrix::mpPivotRow | ( | row_col_weight * | ,
|  | int | )

## mpRowAdr()

poly * mp_permmatrix::mpRowAdr | ( | int | r | ) |

inline private

Definition at line 927 of file matpol.cc.

{ return &(Xarray[a_n*qrow[r]]); }

## mpRowReorder()

void mp_permmatrix::mpRowReorder | ( |  | ) |

Definition at line 1113 of file matpol.cc.

{
int k, i, i1, i2;
if (a_m > a_n)
k = a_m - a_n;
else
k = 0;
for (i=a_m-1; i>=k; i--)
{
i1 = qrow[i];
if (i1 != i)
{
this->mpRowSwap(i1, i);
i2 = 0;
while (qrow[i2] != i) i2++;
qrow[i2] = i1;
}
}
}
mp_permmatrix::mpRowSwap
void mpRowSwap(int, int)
Definition matpol.cc:1050

## mpRowSwap()

void mp_permmatrix::mpRowSwap | ( | int | i1,
|  | int | i2 )

private

Definition at line 1050 of file matpol.cc.

{
poly p, *a1, *a2;
int j;
a1 = &(Xarray[a_n*i1]);
a2 = &(Xarray[a_n*i2]);
for (j=a_n-1; j>= 0; j--)
{
p = a1[j];
a1[j] = a2[j];
a2[j] = p;
}
}

## mpRowWeight()

void mp_permmatrix::mpRowWeight | ( | float * | wrow | ) |

private

Definition at line 1030 of file matpol.cc.

{
poly p, *a;
int i, j;
float count;
for (i=s_m; i>=0; i--)
{
a = this->mpRowAdr(i);
count = 0.0;
for(j=s_n; j>=0; j--)
{
p = a[qcol[j]];
if (p)
count += mp_PolyWeight(p,_R);
}
wrow[i] = count;
}
}

## mpSaveArray()

void mp_permmatrix::mpSaveArray | ( |  | ) |

inline

Definition at line 946 of file matpol.cc.

{ Xarray = NULL; }

## mpSetElem()

void mp_permmatrix::mpSetElem | ( | poly | ,
|  | int | ,
|  | int | )

## mpSetSearch()

void mp_permmatrix::mpSetSearch | ( | int | s | ) |

## mpToIntvec()

void mp_permmatrix::mpToIntvec | ( | intvec * |  | ) |

## Field Documentation

## _R

ring mp_permmatrix::_R

private

Definition at line 925 of file matpol.cc.

## a_m

int mp_permmatrix::a_m

private

Definition at line 922 of file matpol.cc.

## a_n

int mp_permmatrix::a_n

private

Definition at line 922 of file matpol.cc.

## piv_s

int mp_permmatrix::piv_s

private

Definition at line 922 of file matpol.cc.

## qcol

int * mp_permmatrix::qcol

private

Definition at line 923 of file matpol.cc.

## qrow

int* mp_permmatrix::qrow

private

Definition at line 923 of file matpol.cc.

## s_m

int mp_permmatrix::s_m

private

Definition at line 922 of file matpol.cc.

## s_n

int mp_permmatrix::s_n

private

Definition at line 922 of file matpol.cc.

## sign

int mp_permmatrix::sign

private

Definition at line 922 of file matpol.cc.

## Xarray

poly* mp_permmatrix::Xarray

private

Definition at line 924 of file matpol.cc.

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

- libpolys/polys/matpol.cc