Loading...
Searching...
No Matches
bigintmat Class Reference

Matrices of numbers. More...

`#include <coeffs/bigintmat.h>`

## Public Member Functions

| bigintmat ()
bigintmat * | transpose ()
void | inpTranspose ()
| transpose in place
| bigintmat (int r, int c, const coeffs n)
| constructor: the r times c zero-matrix. Beware that the creation of a large zero matrix is expensive in terms of time and memory.
| bigintmat (const bigintmat *m)
| copy constructor
number & | operator[] (int i)
| dubious: 1-dim access to 2-dim array. Entries are read row by row.
const number & | operator[] (int i) const
void | operator*= (int intop)
| UEberladener *=-Operator (fuer int und bigint) Frage hier: *= verwenden oder lieber = und * einzeln? (coeffs in Singular are always commutative).
void | inpMult (number bintop, const coeffs C=NULL)
| inplace version of skalar mult. CHANGES input.
int | length ()
int | cols () const
int | rows () const
coeffs | basecoeffs () const
| ~bigintmat ()
| canonical destructor.
int | index (int r, int c) const
| helper function to map from 2-dim coordinates, starting by 1 to 1-dim coordinate, starting by 0
number | get (int i, int j) const
| get a copy of an entry. NOTE: starts at [1,1]
number | view (int i, int j) const
| view an entry an entry. NOTE: starts at [1,1]
number | get (int i) const
| get a copy of an entry. NOTE: starts at [0]
number | view (int i) const
| view an entry. NOTE: starts at [0]
void | set (int i, int j, number n, const coeffs C=NULL)
| replace an entry with a copy (delete old + copy new!). NOTE: starts at [1,1]
void | set (int i, number n, const coeffs C=NULL)
| replace an entry with a copy (delete old + copy new!). NOTE: starts at [0]
void | rawset (int i, number n, const coeffs C=NULL)
| replace an entry with the given number n (only delete old). NOTE: starts at [0]. Should be named set_transfer
void | rawset (int i, int j, number n, const coeffs C=NULL)
| as above, but the 2-dim version
char * | String ()
| IO: String returns a singular string containing the matrix, needs freeing afterwards.
void | Write ()
| IO: writes the matrix into the current internal string buffer which must be started/ allocated before (e.g. StringSetS).
void | Print ()
| IO: simply prints the matrix to the current output (screen?).
char * | StringAsPrinted ()
| Returns a string as it would have been printed in the interpreter.
void | pprint (int maxwid)
int | compare (const bigintmat *op) const
int * | getwid (int maxwid)
void | swap (int i, int j)
| swap columns i and j
void | swaprow (int i, int j)
| swap rows i and j
int | findnonzero (int i)
| find index of 1st non-zero entry in row i
int | findcolnonzero (int j)
| find index of 1st non-zero entry in column j
void | getcol (int j, bigintmat *a)
| copies the j-th column into the matrix a - which needs to be pre-allocated with the correct size.
void | getColRange (int j, int no, bigintmat *a)
| copies the no-columns staring by j (so j...j+no-1) into the pre-allocated a
void | getrow (int i, bigintmat *a)
| Schreibt i-te Zeile in Vektor (Matrix) a.
void | setcol (int j, bigintmat *m)
| Setzt j-te Spalte gleich übergebenem Vektor (Matrix) m.
void | setrow (int i, bigintmat *m)
| Setzt i-te Zeile gleich übergebenem Vektor (Matrix) m.
void | appendCol (bigintmat *a)
| horizontally join the matrices, m <- m|a
void | extendCols (int i)
| append i zero-columns to the matrix
bool | add (bigintmat *b)
| Addiert zur Matrix die Matrix b dazu. Return false => an error occurred.
bool | sub (bigintmat *b)
| Subtrahiert ...
bool | skalmult (number b, coeffs c)
| Multipliziert zur Matrix den Skalar b hinzu.
bool | addcol (int i, int j, number a, coeffs c)
| addiert a-faches der j-ten Spalte zur i-ten dazu
bool | addrow (int i, int j, number a, coeffs c)
| ... Zeile ...
void | colskalmult (int i, number a, coeffs c)
| Multipliziert zur i-ten Spalte den Skalar a hinzu.
void | rowskalmult (int i, number a, coeffs c)
| ... Zeile ...
void | coltransform (int i, int j, number a, number b, number c, number d)
| transforms cols (i,j) using the 2x2 matrix ((a,b)(c,d)) (hopefully)
void | concatrow (bigintmat *a, bigintmat *b)
| Fügt zwei Matrixen untereinander/nebeneinander in gegebene Matrix ein, bzw spaltet gegebenen Matrix auf.
void | concatcol (bigintmat *a, bigintmat *b)
void | splitrow (bigintmat *a, bigintmat *b)
| Speichert in Matrix a den oberen, in b den unteren Teil der Matrix, vorausgesetzt die Dimensionen stimmen überein.
void | splitcol (bigintmat *a, bigintmat *b)
| ... linken ... rechten ...
void | splitcol (bigintmat *a, int i)
| Speichert die ersten i Spalten als Teilmatrix in a.
void | splitrow (bigintmat *a, int i)
| ... Zeilen ...
bool | copy (bigintmat *b)
| Kopiert Einträge von b auf Bigintmat.
void | copySubmatInto (bigintmat *, int sr, int sc, int nr, int nc, int tr, int tc)
| copy the submatrix of b, staring at (a,b) having n rows, m cols into the given matrix at pos. (c,d) needs c+n, d+m <= rows, cols a+n, b+m <= b.rows(), b.cols()
void | one ()
| Macht Matrix (Falls quadratisch) zu Einheitsmatrix.
int | isOne ()
| is matrix is identity
void | zero ()
| Setzt alle Einträge auf 0.
int | isZero ()
int | colIsZero (int i)
bigintmat * | elim (int i, int j)
| Liefert Streichungsmatrix (i-te Zeile und j-te Spalte gestrichen) zurück.
number | pseudoinv (bigintmat *a)
| Speichert in Matrix a die Pseudoinverse, liefert den Nenner zurück.
number | trace ()
| the trace ....
number | det ()
| det (via LaPlace in general, hnf for euc. rings)
number | hnfdet ()
| det via HNF Primzahlen als long long int, müssen noch in number umgewandelt werden?
void | hnf ()
| transforms INPLACE to HNF
void | howell ()
| dito, but Howell form (only different for zero-divsors)
void | swapMatrix (bigintmat *a)
bigintmat * | modhnf (number p, coeffs c)
| computes HNF(this | p*I)
bigintmat * | modgauss (number p, coeffs c)
void | skaldiv (number b)
| Macht Ganzzahldivision aller Matrixeinträge mit b.
void | colskaldiv (int j, number b)
| Macht Ganzzahldivision aller j-ten Spalteneinträge mit b.
void | mod (number p)
| Reduziert komplette Matrix modulo p.
bigintmat * | inpmod (number p, coeffs c)
| Liefert Kopie der Matrix zurück, allerdings im Ring Z modulo p.
number | content ()
| the content, the gcd of all entries. Only makes sense for Euclidean rings (or possibly constructive PIR)
void | simplifyContentDen (number *den)
| ensures that Gcd(den, content)=1 enden hier wieder

## Private Attributes

coeffs | m_coeffs
number * | v
int | row
int | col

## Detailed Description

Matrices of numbers.

Matrices are stored as 1-dim c-arrays but interpreted 2-dim as matrices. Both modes of addressing are supported, note however, that the 1-dim addressing starts at 0, the 2-dim at 1.

Matrices are meant to represent column modules, thus the default operations are always by column.

While basic operations are supported over any ring (coeff), some more advanced ones require more special rings: eg. echelon forms, solving of linear equations is only effective over principal ideal or even Euclidean rings.

Be careful with the get/set/view/rawset functions to understand which arguments are copied/ deleted or only assigned.

@Note: no reference counting here!

Definition at line 50 of file bigintmat.h.

## Constructor & Destructor Documentation

## bigintmat() [1/3]

bigintmat::bigintmat | ( |  | ) |

inline

Definition at line 59 of file bigintmat.h.

: m_coeffs(NULL), v(NULL), row(1), col(0){}
bigintmat::m_coeffs
coeffs m_coeffs
Definition bigintmat.h:53
bigintmat::v
number * v
Definition bigintmat.h:54
bigintmat::col
int col
Definition bigintmat.h:56
bigintmat::row
int row
Definition bigintmat.h:55
NULL
#define NULL
Definition omList.c:12

## bigintmat() [2/3]

bigintmat::bigintmat | ( | int | r,
|  | int | c,
|  | const coeffs | n )

inline

constructor: the r times c zero-matrix. Beware that the creation of a large zero matrix is expensive in terms of time and memory.

Definition at line 69 of file bigintmat.h.

: m_coeffs(n), v(NULL), row(r), col(c)
{
assume (rows() >= 0);
assume (cols() >= 0);
const int l = r*c;
if (l>0) /*(r>0) && (c>0) */
{
v = (number *)omAlloc(sizeof(number)*l);
assume (basecoeffs() != NULL);
for (int i = l - 1; i>=0; i--)
{
v[i] = n_Init(0, basecoeffs());
}
}
}
l
int l
Definition cfEzgcd.cc:100
i
int i
Definition cfEzgcd.cc:132
bigintmat::cols
int cols() const
Definition bigintmat.h:144
bigintmat::rows
int rows() const
Definition bigintmat.h:145
bigintmat::basecoeffs
coeffs basecoeffs() const
Definition bigintmat.h:146
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
assume
#define assume(x)
Definition mod2.h:389
omAlloc
#define omAlloc(size)
Definition omAllocDecl.h:210

## bigintmat() [3/3]

bigintmat::bigintmat | ( | const bigintmat * | m | ) |

inline

copy constructor

Definition at line 89 of file bigintmat.h.

: m_coeffs(m->basecoeffs()), v(NULL), row(m->rows()), col(m->cols())
{
const int l = row*col;
if (l > 0)
{
assume (rows() > 0);
assume (cols() > 0);
assume (m->v != NULL);
v = (number *)omAlloc(sizeof(number)*row*col);
assume (basecoeffs() != NULL);
for (int i = l-1; i>=0; i--)
{
v[i] = n_Copy((*m)[i], basecoeffs());
}
}
}
m
int m
Definition cfEzgcd.cc:128
n_Copy
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of 'n'
Definition coeffs.h:457

## ~bigintmat()

bigintmat::~bigintmat | ( |  | ) |

inline

canonical destructor.

Definition at line 149 of file bigintmat.h.

{
if (v!=NULL)
{
for (int i=row*col-1;i>=0; i--) { n_Delete(&(v[i]), basecoeffs()); }
omFreeSize((ADDRESS)v, sizeof(number)*row*col);
v=NULL;
}
}
ADDRESS
void * ADDRESS
Definition auxiliary.h:120
n_Delete
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition coeffs.h:461
omFreeSize
#define omFreeSize(addr, size)
Definition omAllocDecl.h:260

## Member Function Documentation

## add()

bool bigintmat::add | ( | bigintmat * | b | ) |

Addiert zur Matrix die Matrix b dazu. Return false => an error occurred.

Definition at line 889 of file bigintmat.cc.

{
if ((b->rows() != row) || (b->cols() != col))
{
WerrorS("Error in bigintmat::add. Dimensions do not agree!");
return false;
}
if (!nCoeffs_are_equal(basecoeffs(), b->basecoeffs()))
{
WerrorS("Error in bigintmat::add. coeffs do not agree!");
return false;
}
for (int i=1; i<=row; i++)
{
for (int j=1; j<=col; j++)
{
rawset(i, j, n_Add(b->view(i,j), view(i,j), basecoeffs()));
}
}
return true;
}
nCoeffs_are_equal
bool nCoeffs_are_equal(coeffs r, coeffs s)
Definition bigintmat.cc:2629
b
CanonicalForm b
Definition cfModGcd.cc:4111
bigintmat::view
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition bigintmat.cc:125
bigintmat::rawset
void rawset(int i, number n, const coeffs C=NULL)
replace an entry with the given number n (only delete old). NOTE: starts at [0]. Should be named set_...
Definition bigintmat.h:196
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
j
int j
Definition facHensel.cc:110
WerrorS
void WerrorS(const char *s)
Definition feFopen.cc:24

## addcol()

bool bigintmat::addcol | ( | int | i,
|  | int | j,
|  | number | a,
|  | coeffs | c )

addiert a-faches der j-ten Spalte zur i-ten dazu

Definition at line 954 of file bigintmat.cc.

{
if ((i>col) || (j>col) || (i<1) || (j<1))
{
WerrorS("Error in addcol: Index out of range!");
return false;
}
if (!nCoeffs_are_equal(c, basecoeffs()))
{
WerrorS("Error in addcol: coeffs do not agree!");
return false;
}
number t1, t2, t3;
for (int k=1; k<=row; k++)
{
t1 = view(k, j);
t2 = view(k, i);
t3 = n_Mult(t1, a, basecoeffs());
n_InpAdd(t3, t2, basecoeffs());
rawset(k, i, t3);
}
return true;
}
k
int k
Definition cfEzgcd.cc:99
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_InpAdd
static FORCE_INLINE void n_InpAdd(number &a, number b, const coeffs r)
addition of 'a' and 'b'; replacement of 'a' by the sum a+b
Definition coeffs.h:649

## addrow()

bool bigintmat::addrow | ( | int | i,
|  | int | j,
|  | number | a,
|  | coeffs | c )

... Zeile ...

Definition at line 978 of file bigintmat.cc.

{
if ((i>row) || (j>row) || (i<1) || (j<1))
{
WerrorS("Error in addrow: Index out of range!");
return false;
}
if (!nCoeffs_are_equal(c, basecoeffs()))
{
WerrorS("Error in addrow: coeffs do not agree!");
return false;
}
number t1, t2, t3;
for (int k=1; k<=col; k++)
{
t1 = view(j, k);
t2 = view(i, k);
t3 = n_Mult(t1, a, basecoeffs());
n_InpAdd(t3, t2, basecoeffs());
rawset(i, k, t3);
}
return true;
}

## appendCol()

void bigintmat::appendCol | ( | bigintmat * | a | ) |

horizontally join the matrices, m <- m|a

Definition at line 1078 of file bigintmat.cc.

{
coeffs R = basecoeffs();
int ay = a->cols();
int ax = a->rows();
assume(row == ax);
assume(nCoeffs_are_equal(a->basecoeffs(), R));
bigintmat * tmp = new bigintmat(rows(), cols() + ay, R);
tmp->concatcol(this, a);
this->swapMatrix(tmp);
delete tmp;
}
bigintmat::swapMatrix
void swapMatrix(bigintmat *a)
Definition bigintmat.cc:1561
bigintmat::concatcol
void concatcol(bigintmat *a, bigintmat *b)
Definition bigintmat.cc:1093
bigintmat::bigintmat
bigintmat()
Definition bigintmat.h:59
R
#define R
Definition sirandom.c:27

## basecoeffs()

coeffs bigintmat::basecoeffs | ( |  | ) | const

inline

Definition at line 146 of file bigintmat.h.

{ return m_coeffs; }

## colIsZero()

int bigintmat::colIsZero | ( | int | i | ) |

Definition at line 1572 of file bigintmat.cc.

{
coeffs R = basecoeffs();
for(int i=1; i<=rows(); i++)
if (!n_IsZero(view(i, j), R)) return FALSE;
return TRUE;
}
TRUE
#define TRUE
Definition auxiliary.h:101
FALSE
#define FALSE
Definition auxiliary.h:97
n_IsZero
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
Definition coeffs.h:470

## cols()

int bigintmat::cols | ( |  | ) | const

inline

Definition at line 144 of file bigintmat.h.

{ return col; }

## colskaldiv()

void bigintmat::colskaldiv | ( | int | j,
|  | number | b )

Macht Ganzzahldivision aller j-ten Spalteneinträge mit b.

Definition at line 1866 of file bigintmat.cc.

{
number tmp1, tmp2;
for (int i=1; i<=row; i++)
{
tmp1 = view(i, j);
tmp2 = n_Div(tmp1, b, basecoeffs());
rawset(i, j, tmp2);
}
}
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
tmp1
CFList tmp1
Definition facFqBivar.cc:75
tmp2
CFList tmp2
Definition facFqBivar.cc:75

## colskalmult()

void bigintmat::colskalmult | ( | int | i,
|  | number | a,
|  | coeffs | c )

Multipliziert zur i-ten Spalte den Skalar a hinzu.

Definition at line 1002 of file bigintmat.cc.

{
if ((i>=1) && (i<=col) && (nCoeffs_are_equal(c, basecoeffs())))
{
number t, tmult;
for (int j=1; j<=row; j++)
{
t = view(j, i);
tmult = n_Mult(a, t, basecoeffs());
rawset(j, i, tmult);
}
}
else
WerrorS("Error in colskalmult");
}

## coltransform()

void bigintmat::coltransform | ( | int | i,
|  | int | j,
|  | number | a,
|  | number | b,
|  | number | c,
|  | number | d )

transforms cols (i,j) using the 2x2 matrix ((a,b)(c,d)) (hopefully)

Definition at line 1879 of file bigintmat.cc.

{
number tmp1, tmp2, tmp3, tmp4;
for (int i=1; i<=row; i++)
{
tmp1 = get(i, j);
tmp2 = get(i, k);
tmp3 = n_Mult(tmp1, a, basecoeffs());
tmp4 = n_Mult(tmp2, b, basecoeffs());
n_InpAdd(tmp3, tmp4, basecoeffs());
n_Delete(&tmp4, basecoeffs());
n_InpMult(tmp1, c, basecoeffs());
n_InpMult(tmp2, d, basecoeffs());
n_InpAdd(tmp1, tmp2, basecoeffs());
n_Delete(&tmp2, basecoeffs());
set(i, j, tmp3);
set(i, k, tmp1);
n_Delete(&tmp1, basecoeffs());
n_Delete(&tmp3, basecoeffs());
}
}
bigintmat::get
number get(int i, int j) const
get a copy of an entry. NOTE: starts at [1,1]
Definition bigintmat.cc:117
bigintmat::set
void set(int i, int j, number n, const coeffs C=NULL)
replace an entry with a copy (delete old + copy new!). NOTE: starts at [1,1]
Definition bigintmat.cc:93
n_InpMult
static FORCE_INLINE void n_InpMult(number &a, number b, const coeffs r)
multiplication of 'a' and 'b'; replacement of 'a' by the product a*b
Definition coeffs.h:644

## compare()

int bigintmat::compare | ( | const bigintmat * | op | ) | const

Definition at line 360 of file bigintmat.cc.

{
assume (basecoeffs() == op->basecoeffs() );
#ifndef SING_NDEBUG
if (basecoeffs() != op->basecoeffs() )
WerrorS("wrong bigintmat comparison: different basecoeffs!\n");
#endif
if ((col!=1) ||(op->cols()!=1))
{
if((col!=op->cols())
|| (row!=op->rows()))
return -2;
}
int i;
for (i=0; i<si_min(row*col,op->rows()*op->cols()); i++)
{
if ( n_Greater(v[i], (*op)[i], basecoeffs()) )
return 1;
else if (! n_Equal(v[i], (*op)[i], basecoeffs()))
return -1;
}
for (; i<row; i++)
{
if ( n_GreaterZero(v[i], basecoeffs()) )
return 1;
else if (! n_IsZero(v[i], basecoeffs()) )
return -1;
}
for (; i<op->rows(); i++)
{
if ( n_GreaterZero((*op)[i], basecoeffs()) )
return -1;
else if (! n_IsZero((*op)[i], basecoeffs()) )
return 1;
}
return 0;
}
si_min
static int si_min(const int a, const int b)
Definition auxiliary.h:126
n_GreaterZero
static FORCE_INLINE BOOLEAN n_GreaterZero(number n, const coeffs r)
ordered fields: TRUE iff 'n' is positive; in Z/pZ: TRUE iff 0 < m <= roundedBelow(p/2),...
Definition coeffs.h:500
n_Greater
static FORCE_INLINE BOOLEAN n_Greater(number a, number b, const coeffs r)
ordered fields: TRUE iff 'a' is larger than 'b'; in Z/pZ: TRUE iff la > lb, where la and lb are the l...
Definition coeffs.h:517
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

## concatcol()

void bigintmat::concatcol | ( | bigintmat * | a,
|  | bigintmat * | b )

Definition at line 1093 of file bigintmat.cc.

{
int ay = a->cols();
int ax = a->rows();
int by = b->cols();
int bx = b->rows();
number tmp;
assume(row==ax && row == bx && ay+by ==col);
assume(nCoeffs_are_equal(a->basecoeffs(), basecoeffs()) && nCoeffs_are_equal(b->basecoeffs(), basecoeffs()));
for (int i=1; i<=ax; i++)
{
for (int j=1; j<=ay; j++)
{
tmp = a->view(i,j);
set(i, j, tmp);
}
}
for (int i=1; i<=bx; i++)
{
for (int j=1; j<=by; j++)
{
tmp = b->view(i,j);
set(i, j+ay, tmp);
}
}
}

## concatrow()

void bigintmat::concatrow | ( | bigintmat * | a,
|  | bigintmat * | b )

Fügt zwei Matrixen untereinander/nebeneinander in gegebene Matrix ein, bzw spaltet gegebenen Matrix auf.

Definition at line 1034 of file bigintmat.cc.

{
int ay = a->cols();
int ax = a->rows();
int by = b->cols();
int bx = b->rows();
number tmp;
if (!((col == ay) && (col == by) && (ax+bx == row)))
{
WerrorS("Error in concatrow. Dimensions must agree!");
return;
}
if (!(nCoeffs_are_equal(a->basecoeffs(), basecoeffs()) && nCoeffs_are_equal(b->basecoeffs(), basecoeffs())))
{
WerrorS("Error in concatrow. coeffs do not agree!");
return;
}
for (int i=1; i<=ax; i++)
{
for (int j=1; j<=ay; j++)
{
tmp = a->get(i,j);
set(i, j, tmp);
n_Delete(&tmp, basecoeffs());
}
}
for (int i=1; i<=bx; i++)
{
for (int j=1; j<=by; j++)
{
tmp = b->get(i,j);
set(i+ax, j, tmp);
n_Delete(&tmp, basecoeffs());
}
}
}

## content()

number bigintmat::content | ( |  | ) |

the content, the gcd of all entries. Only makes sense for Euclidean rings (or possibly constructive PIR)

Definition at line 2659 of file bigintmat.cc.

{
coeffs r = basecoeffs();
number g = get(1,1), h;
int n=rows()*cols();
for(int i=1; i<n && !n_IsOne(g, r); i++)
{
h = n_Gcd(g, view(i), r);
n_Delete(&g, r);
g=h;
}
return g;
}
g
g
Definition cfModGcd.cc:4098
n_Gcd
static FORCE_INLINE number n_Gcd(number a, number b, const coeffs r)
in Z: return the gcd of 'a' and 'b' in Z/nZ, Z/2^kZ: computed as in the case Z in Z/pZ,...
Definition coeffs.h:667
n_IsOne
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff 'n' represents the one element.
Definition coeffs.h:474
h
STATIC_VAR Poly * h
Definition janet.cc:971

## copy()

bool bigintmat::copy | ( | bigintmat * | b | ) |

Kopiert Einträge von b auf Bigintmat.

Definition at line 1254 of file bigintmat.cc.

{
if ((b->rows() != row) || (b->cols() != col))
{
WerrorS("Error in bigintmat::copy. Dimensions do not agree!");
return false;
}
if (!nCoeffs_are_equal(basecoeffs(), b->basecoeffs()))
{
WerrorS("Error in bigintmat::copy. coeffs do not agree!");
return false;
}
number t1;
for (int i=1; i<=row; i++)
{
for (int j=1; j<=col; j++)
{
t1 = b->view(i, j);
set(i, j, t1);
}
}
return true;
}

## copySubmatInto()

void bigintmat::copySubmatInto | ( | bigintmat * | B,
|  | int | sr,
|  | int | sc,
|  | int | nr,
|  | int | nc,
|  | int | tr,
|  | int | tc )

copy the submatrix of b, staring at (a,b) having n rows, m cols into the given matrix at pos. (c,d) needs c+n, d+m <= rows, cols a+n, b+m <= b.rows(), b.cols()

Definition at line 1282 of file bigintmat.cc.

{
number t1;
for (int i=1; i<=n; i++)
{
for (int j=1; j<=m; j++)
{
t1 = B->view(a+i-1, b+j-1);
set(c+i-1, d+j-1, t1);
}
}
}
B
b *CanonicalForm B
Definition facBivar.cc:52

## det()

number bigintmat::det | ( |  | ) |

det (via LaPlace in general, hnf for euc. rings)

Definition at line 1507 of file bigintmat.cc.

{
assume (row==col);
if (col == 1)
return get(1, 1);
// should work as well in Z/pZ of type n_Zp?
// relies on XExtGcd and the other euc. functions.
if ( getCoeffType(basecoeffs())== n_Z || getCoeffType(basecoeffs() )== n_Zn) {
return hnfdet();
}
number sum = n_Init(0, basecoeffs());
number t1, t2, t3, t4;
bigintmat *b;
for (int i=1; i<=row; i++) {
b = elim(i, 1);
t1 = get(i, 1);
t2 = b->det();
t3 = n_Mult(t1, t2, basecoeffs());
t4 = n_Copy(sum, basecoeffs());
n_Delete(&sum, basecoeffs());
if ((i+1)>>1<<1==(i+1))
sum = n_Add(t4, t3, basecoeffs());
else
sum = n_Sub(t4, t3, basecoeffs());
n_Delete(&t1, basecoeffs());
n_Delete(&t2, basecoeffs());
n_Delete(&t3, basecoeffs());
n_Delete(&t4, basecoeffs());
}
return sum;
}
bigintmat::hnfdet
number hnfdet()
det via HNF Primzahlen als long long int, müssen noch in number umgewandelt werden?
Definition bigintmat.cc:1540
bigintmat::elim
bigintmat * elim(int i, int j)
Liefert Streichungsmatrix (i-te Zeile und j-te Spalte gestrichen) zurück.
Definition bigintmat.cc:1376
n_Zn
@ n_Zn
only used if HAVE_RINGS is defined
Definition coeffs.h:44
n_Z
@ n_Z
only used if HAVE_RINGS is defined
Definition coeffs.h:43
n_Sub
static FORCE_INLINE number n_Sub(number a, number b, const coeffs r)
return the difference of 'a' and 'b', i.e., a-b
Definition coeffs.h:658
getCoeffType
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition coeffs.h:431

## elim()

bigintmat * bigintmat::elim | ( | int | i,
|  | int | j )

Liefert Streichungsmatrix (i-te Zeile und j-te Spalte gestrichen) zurück.

Definition at line 1376 of file bigintmat.cc.

{
if ((i<=0) || (i>row) || (j<=0) || (j>col))
return NULL;
int cx, cy;
cx=1;
cy=1;
number t;
bigintmat *b = new bigintmat(row-1, col-1, basecoeffs());
for (int k=1; k<=row; k++) {
if (k!=i)
{
cy=1;
for (int l=1; l<=col; l++)
{
if (l!=j)
{
t = get(k, l);
b->set(cx, cy, t);
n_Delete(&t, basecoeffs());
cy++;
}
}
cx++;
}
}
return b;
}

## extendCols()

void bigintmat::extendCols | ( | int | i | ) |

append i zero-columns to the matrix

Definition at line 1071 of file bigintmat.cc.

{
bigintmat * tmp = new bigintmat(rows(), i, basecoeffs());
appendCol(tmp);
delete tmp;
}
bigintmat::appendCol
void appendCol(bigintmat *a)
horizontally join the matrices, m <- m|a
Definition bigintmat.cc:1078

## findcolnonzero()

int bigintmat::findcolnonzero | ( | int | j | ) |

find index of 1st non-zero entry in column j

Definition at line 730 of file bigintmat.cc.

{
for (int i=row; i>=1; i--)
{
if (!n_IsZero(view(i,j), basecoeffs()))
{
return i;
}
}
return 0;
}

## findnonzero()

int bigintmat::findnonzero | ( | int | i | ) |

find index of 1st non-zero entry in row i

Definition at line 718 of file bigintmat.cc.

{
for (int j=1; j<=col; j++)
{
if (!n_IsZero(view(i,j), basecoeffs()))
{
return j;
}
}
return 0;
}

## get() [1/2]

number bigintmat::get | ( | int | i | ) | const

get a copy of an entry. NOTE: starts at [0]

Definition at line 101 of file bigintmat.cc.

{
assume (i >= 0);
assume (i<rows()*cols());
return n_Copy(v[i], basecoeffs());
}

## get() [2/2]

number bigintmat::get | ( | int | i,
|  | int | j ) const

get a copy of an entry. NOTE: starts at [1,1]

Definition at line 117 of file bigintmat.cc.

{
assume (i > 0 && j > 0);
assume (i <= rows() && j <= cols());
return get(index(i, j));
}
bigintmat::index
int index(int r, int c) const
helper function to map from 2-dim coordinates, starting by 1 to 1-dim coordinate, starting by 0
Definition bigintmat.h:161

## getcol()

void bigintmat::getcol | ( | int | j,
|  | bigintmat * | a )

copies the j-th column into the matrix a - which needs to be pre-allocated with the correct size.

Definition at line 742 of file bigintmat.cc.

{
assume((j<=col) && (j>=1));
if (((a->rows() != row) || (a->cols() != 1)) && ((a->rows() != 1) || (a->cols() != row)))
{
assume(0);
WerrorS("Error in getcol. Dimensions must agree!");
return;
}
if (!nCoeffs_are_equal(basecoeffs(), a->basecoeffs()))
{
nMapFunc f = n_SetMap(basecoeffs(), a->basecoeffs());
number t1, t2;
for (int i=1; i<=row;i++)
{
t1 = get(i,j);
t2 = f(t1, basecoeffs(), a->basecoeffs());
a->set(i-1,t1);
n_Delete(&t1, basecoeffs());
n_Delete(&t2, a->basecoeffs());
}
return;
}
number t1;
for (int i=1; i<=row;i++)
{
t1 = view(i,j);
a->set(i-1,t1);
}
}
f
FILE * f
Definition checklibs.c:9
n_SetMap
static FORCE_INLINE nMapFunc n_SetMap(const coeffs src, const coeffs dst)
set the mapping function pointers for translating numbers from src to dst
Definition coeffs.h:703
nMapFunc
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition coeffs.h:80

## getColRange()

void bigintmat::getColRange | ( | int | j,
|  | int | no,
|  | bigintmat * | a )

copies the no-columns staring by j (so j...j+no-1) into the pre-allocated a

Definition at line 773 of file bigintmat.cc.

{
number t1;
for(int ii=0; ii< no; ii++)
{
for (int i=1; i<=row;i++)
{
t1 = view(i, ii+j);
a->set(i, ii+1, t1);
}
}
}

## getrow()

void bigintmat::getrow | ( | int | i,
|  | bigintmat * | a )

Schreibt i-te Zeile in Vektor (Matrix) a.

Definition at line 786 of file bigintmat.cc.

{
if ((i>row) || (i<1))
{
WerrorS("Error in getrow: Index out of range!");
return;
}
if (((a->rows() != 1) || (a->cols() != col)) && ((a->rows() != col) || (a->cols() != 1)))
{
WerrorS("Error in getrow. Dimensions must agree!");
return;
}
if (!nCoeffs_are_equal(basecoeffs(), a->basecoeffs()))
{
nMapFunc f = n_SetMap(basecoeffs(), a->basecoeffs());
number t1, t2;
for (int j=1; j<=col;j++)
{
t1 = get(i,j);
t2 = f(t1, basecoeffs(), a->basecoeffs());
a->set(j-1,t2);
n_Delete(&t1, basecoeffs());
n_Delete(&t2, a->basecoeffs());
}
return;
}
number t1;
for (int j=1; j<=col;j++)
{
t1 = get(i,j);
a->set(j-1,t1);
n_Delete(&t1, basecoeffs());
}
}

## getwid()

int * bigintmat::getwid | ( | int | maxwid | ) |

Definition at line 574 of file bigintmat.cc.

{
int const c = /*2**/(col-1)+1;
int * wv = (int*)omAlloc(sizeof(int)*col*row);
int * cwv = (int*)omAlloc(sizeof(int)*col);
for (int j=0; j<col; j++)
{
cwv[j] = 0;
for (int i=0; i<row; i++)
{
StringSetS("");
n_Write(v[col*i+j], basecoeffs());
char * tmp = StringEndS();
const int _nl = strlen(tmp);
wv[col*i+j] = _nl;
if (_nl > cwv[j]) cwv[j]=_nl;
omFree(tmp);
}
}
// Groesse verkleinern, bis < maxwid
if (intArrSum(cwv, col)+c > maxwid)
{
int j = findLongest(cwv, col);
cwv[j] = getShorter(wv, cwv[j], j, col, row);
}
omFree(wv);
return cwv;
}
intArrSum
static int intArrSum(int *a, int length)
Definition bigintmat.cc:523
findLongest
static int findLongest(int *a, int length)
Definition bigintmat.cc:531
getShorter
static int getShorter(int *a, int l, int j, int cols, int rows)
Definition bigintmat.cc:546
n_Write
static FORCE_INLINE void n_Write(number n, const coeffs r, const BOOLEAN bShortOut=TRUE)
Definition coeffs.h:594
omFree
#define omFree(addr)
Definition omAllocDecl.h:261
StringSetS
void StringSetS(const char *st)
Definition reporter.cc:128
StringEndS
char * StringEndS()
Definition reporter.cc:151

## hnf()

void bigintmat::hnf | ( |  | ) |

transforms INPLACE to HNF

Definition at line 1655 of file bigintmat.cc.

{
// Laufen von unten nach oben und von links nach rechts
// CF: TODO: for n_Z: write a recursive version. This one will
// have exponential blow-up. Look at Michianchio
// Alternatively, do p-adic det and modular method
#if 0
char * s;
::PrintS("mat over Z is \n");
::Print("%s\n", s = nCoeffString(basecoeffs()));
omFree(s);
Print();
::Print("\n(%d x %d)\n", rows(), cols());
#endif
int i = rows();
int j = cols();
number q = n_Init(0, basecoeffs());
number one = n_Init(1, basecoeffs());
number minusone = n_Init(-1, basecoeffs());
number tmp1 = n_Init(0, basecoeffs());
number tmp2 = n_Init(0, basecoeffs());
number co1, co2, co3, co4;
number ggt = n_Init(0, basecoeffs());
while ((i>0) && (j>0))
{
// Falls erstes Nicht-Null-Element in Zeile i nicht existiert, oder hinter Spalte j vorkommt, gehe in nächste Zeile
if ((findnonzero(i)==0) || (findnonzero(i)>j))
{
i--;
}
else
{
// Laufe von links nach rechts durch die Zeile:
for (int l=1; l<=j-1; l++)
{
n_Delete(&tmp1, basecoeffs());
tmp1 = get(i, l);
// Falls Eintrag (im folgenden x genannt) gleich 0, gehe eine Spalte weiter. Ansonsten...
if (!n_IsZero(tmp1, basecoeffs()))
{
n_Delete(&tmp2, basecoeffs());
tmp2 = get(i, l+1);
// Falls Eintrag (i.f. y g.) rechts daneben gleich 0, tausche beide Spalten, sonst...
if (!n_IsZero(tmp2, basecoeffs()))
{
n_Delete(&ggt, basecoeffs());
ggt = n_XExtGcd(tmp1, tmp2, &co1, &co2, &co3, &co4, basecoeffs());
// Falls x=ggT(x, y), tausche die beiden Spalten und ziehe die (neue) rechte Spalte so häufig von der linken ab, dass an der ehemaligen Stelle von x nun eine 0 steht. Dazu:
if (n_Equal(tmp1, ggt, basecoeffs()))
{
swap(l, l+1);
n_Delete(&q, basecoeffs());
q = n_Div(tmp2, ggt, basecoeffs());
q = n_InpNeg(q, basecoeffs());
// Dann addiere das -q-fache der (neuen) rechten Spalte zur linken dazu. Damit erhalten wir die gewünschte 0
addcol(l, l+1, q, basecoeffs());
n_Delete(&q, basecoeffs());
}
else if (n_Equal(tmp1, minusone, basecoeffs()))
{
// Falls x=-1, so ist x=-ggt(x, y). Dann gehe wie oben vor, multipliziere aber zuerst die neue rechte Spalte (die mit x) mit -1
// Die Berechnung von q (=y/ggt) entfällt, da ggt=1
swap(l, l+1);
colskalmult(l+1, minusone, basecoeffs());
tmp2 = n_InpNeg(tmp2, basecoeffs());
addcol(l, l+1, tmp2, basecoeffs());
}
else
{
// CF: use the 2x2 matrix (co1, co2)(co3, co4) to
// get the gcd in position and the 0 in the other:
#ifdef CF_DEB
::PrintS("applying trafo\n");
StringSetS("");
n_Write(co1, basecoeffs()); StringAppendS("\t");
n_Write(co2, basecoeffs()); StringAppendS("\t");
n_Write(co3, basecoeffs()); StringAppendS("\t");
n_Write(co4, basecoeffs()); StringAppendS("\t");
::Print("%s\nfor l=%d\n", StringEndS(), l);
{char * s = String();
::Print("to %s\n", s);omFree(s);};
#endif
coltransform(l, l+1, co3, co4, co1, co2);
#ifdef CF_DEB
{char * s = String();
::Print("gives %s\n", s);}
#endif
}
n_Delete(&co1, basecoeffs());
n_Delete(&co2, basecoeffs());
n_Delete(&co3, basecoeffs());
n_Delete(&co4, basecoeffs());
}
else
{
swap(l, l+1);
}
// Dann betrachte die vormals rechte Spalte als neue linke, und die rechts daneben als neue rechte.
}
}
// normalize by units:
if (!n_IsZero(view(i, j), basecoeffs()))
{
number u = n_GetUnit(view(i, j), basecoeffs());
if (!n_IsOne(u, basecoeffs()))
{
colskaldiv(j, u);
}
n_Delete(&u, basecoeffs());
}
// Zum Schluss mache alle Einträge rechts vom Diagonalelement betragsmäßig kleiner als dieses
for (int l=j+1; l<=col; l++)
{
n_Delete(&q, basecoeffs());
q = n_QuotRem(view(i, l), view(i, j), NULL, basecoeffs());
q = n_InpNeg(q, basecoeffs());
addcol(l, j, q, basecoeffs());
}
i--;
j--;
// Dann betrachte die Zeile darüber und gehe dort wie vorher vor
}
}
n_Delete(&q, basecoeffs());
n_Delete(&tmp1, basecoeffs());
n_Delete(&tmp2, basecoeffs());
n_Delete(&ggt, basecoeffs());
n_Delete(&one, basecoeffs());
n_Delete(&minusone, basecoeffs());
#if 0
::PrintS("hnf over Z is \n");
Print();
::Print("\n(%d x %d)\n", rows(), cols());
#endif
}
swap
#define swap(_i, _j)
bigintmat::Print
void Print()
IO: simply prints the matrix to the current output (screen?).
Definition bigintmat.cc:437
bigintmat::colskaldiv
void colskaldiv(int j, number b)
Macht Ganzzahldivision aller j-ten Spalteneinträge mit b.
Definition bigintmat.cc:1866
bigintmat::coltransform
void coltransform(int i, int j, number a, number b, number c, number d)
transforms cols (i,j) using the 2x2 matrix ((a,b)(c,d)) (hopefully)
Definition bigintmat.cc:1879
bigintmat::addcol
bool addcol(int i, int j, number a, coeffs c)
addiert a-faches der j-ten Spalte zur i-ten dazu
Definition bigintmat.cc:954
bigintmat::findnonzero
int findnonzero(int i)
find index of 1st non-zero entry in row i
Definition bigintmat.cc:718
bigintmat::colskalmult
void colskalmult(int i, number a, coeffs c)
Multipliziert zur i-ten Spalte den Skalar a hinzu.
Definition bigintmat.cc:1002
bigintmat::one
void one()
Macht Matrix (Falls quadratisch) zu Einheitsmatrix.
Definition bigintmat.cc:1320
bigintmat::String
char * String()
IO: String returns a singular string containing the matrix, needs freeing afterwards.
Definition bigintmat.cc:430
n_QuotRem
static FORCE_INLINE number n_QuotRem(number a, number b, number *q, const coeffs r)
Definition coeffs.h:684
nCoeffString
static FORCE_INLINE char * nCoeffString(const coeffs cf)
TODO: make it a virtual method of coeffs, together with: Decompose & Compose, rParameter & rPar.
Definition coeffs.h:958
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
n_GetUnit
static FORCE_INLINE number n_GetUnit(number n, const coeffs r)
in Z: 1 in Z/kZ (where k is not a prime): largest divisor of n (taken in Z) that is co-prime with k i...
Definition coeffs.h:537
n_XExtGcd
static FORCE_INLINE number n_XExtGcd(number a, number b, number *s, number *t, number *u, number *v, const coeffs r)
Definition coeffs.h:676
s
const CanonicalForm int s
Definition facAbsFact.cc:51
StringAppendS
void StringAppendS(const char *st)
Definition reporter.cc:107
PrintS
void PrintS(const char *s)
Definition reporter.cc:288

## hnfdet()

number bigintmat::hnfdet | ( |  | ) |

det via HNF Primzahlen als long long int, müssen noch in number umgewandelt werden?

Definition at line 1540 of file bigintmat.cc.

{
assume (col == row);
if (col == 1)
return get(1, 1);
bigintmat *m = new bigintmat(this);
m->hnf();
number prod = n_Init(1, basecoeffs());
number temp, temp2;
for (int i=1; i<=col; i++) {
temp = m->get(i, i);
temp2 = n_Mult(temp, prod, basecoeffs());
n_Delete(&prod, basecoeffs());
prod = temp2;
n_Delete(&temp, basecoeffs());
}
delete m;
return prod;
}
prod
fq_nmod_poly_t prod
Definition facHensel.cc:100

## howell()

void bigintmat::howell | ( |  | ) |

dito, but Howell form (only different for zero-divsors)

Definition at line 1580 of file bigintmat.cc.

{
coeffs R = basecoeffs();
hnf(); // as a starting point...
if (getCoeffType(R)== n_Z) return; //wrong, need to prune!
int n = cols(), m = rows(), i, j, k;
//make sure, the matrix has enough space. We need no rows+1 columns.
//The resulting Howell form will be pruned to be at most square.
bigintmat * t = new bigintmat(m, m+1, R);
t->copySubmatInto(this, 1, n>m ? n-m+1 : 1, m, n>m ? m : n, 1, n>m ? 2 : m+2-n );
swapMatrix(t);
delete t;
for(i=1; i<= cols(); i++) {
if (!colIsZero(i)) break;
}
assume (i>1);
if (i>cols()) {
t = new bigintmat(rows(), 0, R);
swapMatrix(t);
delete t;
return; // zero matrix found, clearly normal.
}
int last_zero_col = i-1;
for (int c = cols(); c>0; c--) {
for(i=rows(); i>0; i--) {
if (!n_IsZero(view(i, c), R)) break;
}
if (i==0) break; // matrix SHOULD be zero from here on
number a = n_Ann(view(i, c), R);
addcol(last_zero_col, c, a, R);
n_Delete(&a, R);
for(j = c-1; j>last_zero_col; j--) {
for(k=rows(); k>0; k--) {
if (!n_IsZero(view(k, j), R)) break;
if (!n_IsZero(view(k, last_zero_col), R)) break;
}
if (k==0) break;
if (!n_IsZero(view(k, last_zero_col), R)) {
number gcd, co1, co2, co3, co4;
gcd = n_XExtGcd(view(k, last_zero_col), view(k, j), &co1, &co2, &co3, &co4, R);
if (n_Equal(gcd, view(k, j), R)) {
number q = n_Div(view(k, last_zero_col), gcd, R);
q = n_InpNeg(q, R);
addcol(last_zero_col, j, q, R);
n_Delete(&q, R);
} else if (n_Equal(gcd, view(k, last_zero_col), R)) {
swap(last_zero_col, k);
number q = n_Div(view(k, last_zero_col), gcd, R);
q = n_InpNeg(q, R);
addcol(last_zero_col, j, q, R);
n_Delete(&q, R);
} else {
coltransform(last_zero_col, j, co3, co4, co1, co2);
}
n_Delete(&gcd, R);
n_Delete(&co1, R);
n_Delete(&co2, R);
n_Delete(&co3, R);
n_Delete(&co4, R);
}
}
for(k=rows(); k>0; k--) {
if (!n_IsZero(view(k, last_zero_col), R)) break;
}
if (k) last_zero_col--;
}
t = new bigintmat(rows(), cols()-last_zero_col, R);
t->copySubmatInto(this, 1, last_zero_col+1, rows(), cols()-last_zero_col, 1, 1);
swapMatrix(t);
delete t;
}
bigintmat::hnf
void hnf()
transforms INPLACE to HNF
Definition bigintmat.cc:1655
bigintmat::colIsZero
int colIsZero(int i)
Definition bigintmat.cc:1572
bigintmat::copySubmatInto
void copySubmatInto(bigintmat *, int sr, int sc, int nr, int nc, int tr, int tc)
copy the submatrix of b, staring at (a,b) having n rows, m cols into the given matrix at pos....
Definition bigintmat.cc:1282
n_Ann
static FORCE_INLINE number n_Ann(number a, const coeffs r)
if r is a ring with zero divisors, return an annihilator!=0 of b otherwise return NULL
Definition coeffs.h:682
gcd
int gcd(int a, int b)
Definition walkSupport.cc:836

## index()

int bigintmat::index | ( | int | r,
|  | int | c ) const

inline

helper function to map from 2-dim coordinates, starting by 1 to 1-dim coordinate, starting by 0

Definition at line 161 of file bigintmat.h.

{
assume (rows() >= 0 && cols() >= 0);
assume (r > 0 && c > 0);
assume (r <= rows() && c <= cols());
const int index = ((r-1)*cols() + (c-1));
assume (index >= 0 && index < rows() * cols());
return index;
}

## inpmod()

bigintmat * bigintmat::inpmod | ( | number | p,
|  | coeffs | c )

Liefert Kopie der Matrix zurück, allerdings im Ring Z modulo p.

## inpMult()

void bigintmat::inpMult | ( | number | bintop,
|  | const coeffs | C = NULL )

inplace version of skalar mult. CHANGES input.

Definition at line 143 of file bigintmat.cc.

{
assume (C == NULL || C == basecoeffs());
const int l = rows() * cols();
for (int i=0; i < l; i++)
n_InpMult(v[i], bintop, basecoeffs());
}

## inpTranspose()

void bigintmat::inpTranspose | ( |  | ) |

transpose in place

Definition at line 48 of file bigintmat.cc.

{
int n = row,
m = col,
nm = n<m?n : m; // the min, describing the square part of the matrix
//CF: this is not optimal, but so far, it seems to work
#define swap(_i, _j) \
int __i = (_i), __j=(_j); \
number c = v[__i]; \
v[__i] = v[__j]; \
v[__j] = c \
for (int i=0; i< nm; i++)
for (int j=i+1; j< nm; j++)
{
swap(i*m+j, j*n+i);
}
if (n<m)
for (int i=nm; i<m; i++)
for(int j=0; j<n; j++)
{
swap(j*n+i, i*m+j);
}
if (n>m)
for (int i=nm; i<n; i++)
for(int j=0; j<m; j++)
{
swap(i*m+j, j*n+i);
}
#undef swap
row = m;
col = n;
}

## isOne()

int bigintmat::isOne | ( |  | ) |

is matrix is identity

Definition at line 1295 of file bigintmat.cc.

{
coeffs r = basecoeffs();
if (row==col)
{
for (int i=1; i<=row; i++)
{
for (int j=1; j<=col; j++)
{
if (i==j)
{
if (!n_IsOne(view(i, j), r))
return 0;
}
else
{
if (!n_IsZero(view(i,j), r))
return 0;
}
}
}
}
return 1;
}

## isZero()

int bigintmat::isZero | ( |  | ) |

Definition at line 1358 of file bigintmat.cc.

{
for (int i=1; i<=row; i++) {
for (int j=1; j<=col; j++) {
if (!n_IsZero(view(i,j), basecoeffs()))
return FALSE;
}
}
return TRUE;
}

## length()

int bigintmat::length | ( |  | ) |

inline

Definition at line 143 of file bigintmat.h.

{ return col*row; }

## mod()

void bigintmat::mod | ( | number | p | ) |

Reduziert komplette Matrix modulo p.

Definition at line 1906 of file bigintmat.cc.

{
// produce the matrix in Z/pZ
number tmp1, tmp2;
for (int i=1; i<=row; i++)
{
for (int j=1; j<=col; j++)
{
tmp1 = get(i, j);
tmp2 = n_IntMod(tmp1, p, basecoeffs());
n_Delete(&tmp1, basecoeffs());
set(i, j, tmp2);
}
}
}
p
int p
Definition cfModGcd.cc:4086
n_IntMod
static FORCE_INLINE number n_IntMod(number a, number b, const coeffs r)
for r a field, return n_Init(0,r) always: n_Div(a,b,r)*b+n_IntMod(a,b,r)==a n_IntMod(a,...
Definition coeffs.h:631

## modgauss()

bigintmat * bigintmat::modgauss | ( | number | p,
|  | coeffs | c )

## modhnf()

bigintmat * bigintmat::modhnf | ( | number | p,
|  | coeffs | c )

computes HNF(this | p*I)

Definition at line 1824 of file bigintmat.cc.

{
coeffs Rp = numbercoeffs(p, R); // R/pR
bigintmat *m = bimChangeCoeff(this, Rp);
m->howell();
bigintmat *a = bimChangeCoeff(m, R);
delete m;
bigintmat *C = new bigintmat(rows(), rows(), R);
int piv = rows(), i = a->cols();
while (piv)
{
if (!i || n_IsZero(a->view(piv, i), R))
{
C->set(piv, piv, p, R);
}
else
{
C->copySubmatInto(a, 1, i, rows(), 1, 1, piv);
i--;
}
piv--;
}
delete a;
return C;
}
numbercoeffs
static coeffs numbercoeffs(number n, coeffs c)
create Z/nA of type n_Zn
Definition bigintmat.cc:20
bimChangeCoeff
bigintmat * bimChangeCoeff(bigintmat *a, coeffs cnew)
Liefert Kopier von Matrix a zurück, mit coeffs cnew statt den ursprünglichen.
Definition bigintmat.cc:1797

## one()

void bigintmat::one | ( |  | ) |

Macht Matrix (Falls quadratisch) zu Einheitsmatrix.

Definition at line 1320 of file bigintmat.cc.

{
if (row==col)
{
number one = n_Init(1, basecoeffs()),
zero = n_Init(0, basecoeffs());
for (int i=1; i<=row; i++)
{
for (int j=1; j<=col; j++)
{
if (i==j)
{
set(i, j, one);
}
else
{
set(i, j, zero);
}
}
}
n_Delete(&one, basecoeffs());
n_Delete(&zero, basecoeffs());
}
}
bigintmat::zero
void zero()
Setzt alle Einträge auf 0.
Definition bigintmat.cc:1345

## operator*=()

void bigintmat::operator*= | ( | int | intop | ) |

UEberladener *=-Operator (fuer int und bigint) Frage hier: *= verwenden oder lieber = und * einzeln? (coeffs in Singular are always commutative).

Definition at line 134 of file bigintmat.cc.

{
number iop = n_Init(intop, basecoeffs());
inpMult(iop, basecoeffs());
n_Delete(&iop, basecoeffs());
}
bigintmat::inpMult
void inpMult(number bintop, const coeffs C=NULL)
inplace version of skalar mult. CHANGES input.
Definition bigintmat.cc:143

## operator[]() [1/2]

number & bigintmat::operator[] | ( | int | i | ) |

inline

dubious: 1-dim access to 2-dim array. Entries are read row by row.

Definition at line 111 of file bigintmat.h.

{
#ifndef SING_NDEBUG
if((i<0)||(i>=row*col))
{
Werror("wrong bigintmat index:%d\n",i);
}
assume ( !((i<0)||(i>=row*col)) );
#endif
return v[i]; // Hier sollte imho kein nlCopy rein...
}
Werror
void Werror(const char *fmt,...)
Definition reporter.cc:189

## operator[]() [2/2]

const number & bigintmat::operator[] | ( | int | i | ) | const

inline

Definition at line 122 of file bigintmat.h.

{
#ifndef SING_NDEBUG
if((i<0)||(i>=row*col))
{
Werror("wrong bigintmat index:%d\n",i);
}
assume ( !((i<0)||(i>=row*col)) );
#endif
return v[i];
}

## pprint()

void bigintmat::pprint | ( | int | maxwid | ) |

Definition at line 604 of file bigintmat.cc.

{
if ((col==0) || (row==0))
PrintS("");
else
{
int * colwid = getwid(maxwid);
char * ps;
int slength = 0;
for (int j=0; j<col; j++)
slength += colwid[j]*row;
slength += col*row+row;
ps = (char*) omAlloc0(sizeof(char)*(slength));
int pos = 0;
for (int i=0; i<col*row; i++)
{
StringSetS("");
n_Write(v[i], basecoeffs());
char * ts = StringEndS();
const int _nl = strlen(ts);
int cj = i%col;
if (_nl > colwid[cj])
{
StringSetS("");
int ci = i/col;
StringAppend("[%d,%d]", ci+1, cj+1);
char * ph = StringEndS();
int phl = strlen(ph);
if (phl > colwid[cj])
{
for (int j=0; j<colwid[cj]-1; j++)
ps[pos+j] = ' ';
ps[pos+colwid[cj]-1] = '*';
}
else
{
for (int j=0; j<colwid[cj]-phl; j++)
ps[pos+j] = ' ';
for (int j=0; j<phl; j++)
ps[pos+colwid[cj]-phl+j] = ph[j];
}
omFree(ph);
}
else // Mit Leerzeichen auffüllen und zahl reinschreiben
{
for (int j=0; j<colwid[cj]-_nl; j++)
ps[pos+j] = ' ';
for (int j=0; j<_nl; j++)
ps[pos+colwid[cj]-_nl+j] = ts[j];
}
// ", " und (evtl) "\n" einfügen
if ((i+1)%col == 0)
{
if (i != col*row-1)
{
ps[pos+colwid[cj]] = ',';
ps[pos+colwid[cj]+1] = '\n';
pos += colwid[cj]+2;
}
}
else
{
ps[pos+colwid[cj]] = ',';
pos += colwid[cj]+1;
}
omFree(ts); // Hier ts zerstören
}
PrintS(ps);
omFree(ps);
omFree(colwid);
}
}
bigintmat::getwid
int * getwid(int maxwid)
Definition bigintmat.cc:574
StringAppend
#define StringAppend
Definition emacs.cc:79
omAlloc0
#define omAlloc0(size)
Definition omAllocDecl.h:211

## Print()

void bigintmat::Print | ( |  | ) |

IO: simply prints the matrix to the current output (screen?).

Definition at line 437 of file bigintmat.cc.

{
char * s = String();
PrintS(s);
omFree(s);
}

## pseudoinv()

number bigintmat::pseudoinv | ( | bigintmat * | a | ) |

Speichert in Matrix a die Pseudoinverse, liefert den Nenner zurück.

Definition at line 1410 of file bigintmat.cc.

{
// Falls Matrix über reellen Zahlen nicht invertierbar, breche ab
assume((a->rows() == row) && (a->rows() == a->cols()) && (row == col));
number det = this->det(); //computes the HNF, so should e reused.
if ((n_IsZero(det, basecoeffs())))
return det;
// Hänge Einheitsmatrix über Matrix und wendet HNF an. An Stelle der Einheitsmatrix steht im Ergebnis die Transformationsmatrix dazu
a->one();
bigintmat *m = new bigintmat(2*row, col, basecoeffs());
m->concatrow(a,this);
m->hnf();
// Arbeite weiterhin mit der zusammengehängten Matrix
// Laufe durch die Diagonalelemente, und multipliziere jede Spalte rechts davon damit, speichere aber den alten Eintrag der Spalte, temp, der in der Zeile des Diagonalelements liegt, zwischen. Dann addiere das -temp-Fache der Diagonalspalte zur entsprechenenden Spalte rechts davon. Dadurch entsteht überall rechts der Diagonalen eine 0
number diag;
number temp, ttemp;
for (int i=1; i<=col; i++) {
diag = m->get(row+i, i);
for (int j=i+1; j<=col; j++) {
temp = m->get(row+i, j);
m->colskalmult(j, diag, basecoeffs());
temp = n_InpNeg(temp, basecoeffs());
m->addcol(j, i, temp, basecoeffs());
n_Delete(&temp, basecoeffs());
}
n_Delete(&diag, basecoeffs());
}
// Falls wir nicht modulo n arbeiten, können wir die Spalten durch den ggT teilen, um die Einträge kleiner zu bekommen
// Bei Z/n sparen wir uns das, da es hier sinnlos ist
number g;
number gcd;
for (int j=1; j<=col; j++) {
g = n_Init(0, basecoeffs());
for (int i=1; i<=2*row; i++) {
temp = m->get(i,j);
gcd = n_Gcd(g, temp, basecoeffs());
n_Delete(&g, basecoeffs());
n_Delete(&temp, basecoeffs());
g = n_Copy(gcd, basecoeffs());
n_Delete(&gcd, basecoeffs());
}
if (!(n_IsOne(g, basecoeffs())))
m->colskaldiv(j, g);
n_Delete(&g, basecoeffs());
}
// Nun müssen die Diagonalelemente durch Spaltenmultiplikation gleich gesett werden. Bei Z können wir mit dem kgV arbeiten, bei Z/n bringen wir jedes Diagonalelement auf 1 (wir arbeiten immer mit n = Primzahl. Für n != Primzahl muss noch an anderen Stellen etwas geändert werden)
g = n_Init(0, basecoeffs());
number prod = n_Init(1, basecoeffs());
for (int i=1; i<=col; i++) {
gcd = n_Gcd(g, m->get(row+i, i), basecoeffs());
n_Delete(&g, basecoeffs());
g = n_Copy(gcd, basecoeffs());
n_Delete(&gcd, basecoeffs());
ttemp = n_Copy(prod, basecoeffs());
temp = m->get(row+i, i);
n_Delete(&prod, basecoeffs());
prod = n_Mult(ttemp, temp, basecoeffs());
n_Delete(&ttemp, basecoeffs());
n_Delete(&temp, basecoeffs());
}
number lcm;
lcm = n_Div(prod, g, basecoeffs());
for (int j=1; j<=col; j++) {
ttemp = m->get(row+j,j);
temp = n_QuotRem(lcm, ttemp, NULL, basecoeffs());
m->colskalmult(j, temp, basecoeffs());
n_Delete(&ttemp, basecoeffs());
n_Delete(&temp, basecoeffs());
}
n_Delete(&lcm, basecoeffs());
n_Delete(&prod, basecoeffs());
number divisor = m->get(row+1, 1);
m->splitrow(a, 1);
delete m;
n_Delete(&det, basecoeffs());
return divisor;
}
bigintmat::det
number det()
det (via LaPlace in general, hnf for euc. rings)
Definition bigintmat.cc:1507
lcm
int lcm(unsigned long *l, unsigned long *a, unsigned long *b, unsigned long p, int dega, int degb)
Definition minpoly.cc:709

## rawset() [1/2]

void bigintmat::rawset | ( | int | i,
|  | int | j,
|  | number | n,
|  | const coeffs | C = NULL )

inline

as above, but the 2-dim version

Definition at line 216 of file bigintmat.h.

{
rawset( index(i,j), n, C);
}

## rawset() [2/2]

void bigintmat::rawset | ( | int | i,
|  | number | n,
|  | const coeffs | C = NULL )

inline

replace an entry with the given number n (only delete old). NOTE: starts at [0]. Should be named set_transfer

Definition at line 196 of file bigintmat.h.

{
assume (C == NULL || C == basecoeffs());
assume (i >= 0);
const int l = rows() * cols();
assume (i<l);
if (i < l)
{
n_Delete(&(v[i]), basecoeffs()); v[i] = n;
}
#ifndef SING_NDEBUG
else
{
Werror("wrong bigintmat index:%d\n",i);
}
#endif
}

## rows()

int bigintmat::rows | ( |  | ) | const

inline

Definition at line 145 of file bigintmat.h.

{ return row; }

## rowskalmult()

void bigintmat::rowskalmult | ( | int | i,
|  | number | a,
|  | coeffs | c )

... Zeile ...

Definition at line 1018 of file bigintmat.cc.

{
if ((i>=1) && (i<=row) && (nCoeffs_are_equal(c, basecoeffs())))
{
number t, tmult;
for (int j=1; j<=col; j++)
{
t = view(i, j);
tmult = n_Mult(a, t, basecoeffs());
rawset(i, j, tmult);
}
}
else
WerrorS("Error in rowskalmult");
}

## set() [1/2]

void bigintmat::set | ( | int | i,
|  | int | j,
|  | number | n,
|  | const coeffs | C = NULL )

replace an entry with a copy (delete old + copy new!). NOTE: starts at [1,1]

Definition at line 93 of file bigintmat.cc.

{
assume (C == NULL || C == basecoeffs());
assume (i > 0 && j > 0);
assume (i <= rows() && j <= cols());
set(index(i, j), n, C);
}

## set() [2/2]

void bigintmat::set | ( | int | i,
|  | number | n,
|  | const coeffs | C = NULL )

replace an entry with a copy (delete old + copy new!). NOTE: starts at [0]

Definition at line 85 of file bigintmat.cc.

{
assume (C == NULL || C == basecoeffs());
rawset(i, n_Copy(n, basecoeffs()), basecoeffs());
}

## setcol()

void bigintmat::setcol | ( | int | j,
|  | bigintmat * | m )

Setzt j-te Spalte gleich übergebenem Vektor (Matrix) m.

Definition at line 821 of file bigintmat.cc.

{
if ((j>col) || (j<1))
{
WerrorS("Error in setcol: Index out of range!");
return;
}
if (((m->rows() != row) || (m->cols() != 1)) && ((m->rows() != 1) || (m->cols() != row)))
{
WerrorS("Error in setcol. Dimensions must agree!");
return;
}
if (!nCoeffs_are_equal(basecoeffs(), m->basecoeffs()))
{
nMapFunc f = n_SetMap(m->basecoeffs(), basecoeffs());
number t1,t2;
for (int i=1; i<=row; i++)
{
t1 = m->get(i-1);
t2 = f(t1, m->basecoeffs(),basecoeffs());
set(i, j, t2);
n_Delete(&t2, basecoeffs());
n_Delete(&t1, m->basecoeffs());
}
return;
}
number t1;
for (int i=1; i<=row; i++)
{
t1 = m->view(i-1);
set(i, j, t1);
}
}

## setrow()

void bigintmat::setrow | ( | int | i,
|  | bigintmat * | m )

Setzt i-te Zeile gleich übergebenem Vektor (Matrix) m.

Definition at line 855 of file bigintmat.cc.

{
if ((j>row) || (j<1))
{
WerrorS("Error in setrow: Index out of range!");
return;
}
if (((m->rows() != 1) || (m->cols() != col)) && ((m->rows() != col) || (m->cols() != 1)))
{
WerrorS("Error in setrow. Dimensions must agree!");
return;
}
if (!nCoeffs_are_equal(basecoeffs(), m->basecoeffs()))
{
nMapFunc f = n_SetMap(m->basecoeffs(), basecoeffs());
number tmp1,tmp2;
for (int i=1; i<=col; i++)
{
tmp1 = m->get(i-1);
tmp2 = f(tmp1, m->basecoeffs(),basecoeffs());
set(j, i, tmp2);
n_Delete(&tmp2, basecoeffs());
n_Delete(&tmp1, m->basecoeffs());
}
return;
}
number tmp;
for (int i=1; i<=col; i++)
{
tmp = m->view(i-1);
set(j, i, tmp);
}
}

## simplifyContentDen()

void bigintmat::simplifyContentDen | ( | number * | den | ) |

ensures that Gcd(den, content)=1 enden hier wieder

Definition at line 2672 of file bigintmat.cc.

{
coeffs r = basecoeffs();
number g = n_Copy(*d, r), h;
int n=rows()*cols();
for(int i=0; i<n && !n_IsOne(g, r); i++)
{
h = n_Gcd(g, view(i), r);
n_Delete(&g, r);
g=h;
}
*d = n_Div(*d, g, r);
if (!n_IsOne(g, r))
skaldiv(g);
}
bigintmat::skaldiv
void skaldiv(number b)
Macht Ganzzahldivision aller Matrixeinträge mit b.
Definition bigintmat.cc:1851

## skaldiv()

void bigintmat::skaldiv | ( | number | b | ) |

Macht Ganzzahldivision aller Matrixeinträge mit b.

Definition at line 1851 of file bigintmat.cc.

{
number tmp1, tmp2;
for (int i=1; i<=row; i++)
{
for (int j=1; j<=col; j++)
{
tmp1 = view(i, j);
tmp2 = n_Div(tmp1, b, basecoeffs());
rawset(i, j, tmp2);
}
}
}

## skalmult()

bool bigintmat::skalmult | ( | number | b,
|  | coeffs | c )

Multipliziert zur Matrix den Skalar b hinzu.

Definition at line 933 of file bigintmat.cc.

{
if (!nCoeffs_are_equal(c, basecoeffs()))
{
WerrorS("Wrong coeffs\n");
return false;
}
number t1, t2;
if ( n_IsOne(b,c)) return true;
for (int i=1; i<=row; i++)
{
for (int j=1; j<=col; j++)
{
t1 = view(i, j);
t2 = n_Mult(t1, b, basecoeffs());
rawset(i, j, t2);
}
}
return true;
}

## splitcol() [1/2]

void bigintmat::splitcol | ( | bigintmat * | a,
|  | bigintmat * | b )

... linken ... rechten ...

Definition at line 1164 of file bigintmat.cc.

{
int ay = a->cols();
int ax = a->rows();
int by = b->cols();
int bx = b->rows();
number tmp;
if (!((row == ax) && (row == bx)))
{
WerrorS("Error in splitcol. Dimensions must agree!");
}
else if (!(ay+by == col))
{
WerrorS("Error in splitcol. Dimensions must agree!");
}
else if (!(nCoeffs_are_equal(a->basecoeffs(), basecoeffs()) && nCoeffs_are_equal(b->basecoeffs(), basecoeffs())))
{
WerrorS("Error in splitcol. coeffs do not agree!");
}
else
{
for (int i=1; i<=ax; i++)
{
for (int j=1; j<=ay; j++)
{
tmp = view(i,j);
a->set(i,j,tmp);
}
}
for (int i=1; i<=bx; i++)
{
for (int j=1; j<=by; j++)
{
tmp = view(i,j+ay);
b->set(i,j,tmp);
}
}
}
}

## splitcol() [2/2]

void bigintmat::splitcol | ( | bigintmat * | a,
|  | int | i )

Speichert die ersten i Spalten als Teilmatrix in a.

Definition at line 1204 of file bigintmat.cc.

{
number tmp;
if ((a->rows() != row) || (a->cols()+i-1 > col) || (i<1))
{
WerrorS("Error in splitcol. Dimensions must agree!");
return;
}
if (!(nCoeffs_are_equal(a->basecoeffs(), basecoeffs())))
{
WerrorS("Error in splitcol. coeffs do not agree!");
return;
}
int width = a->cols();
for (int j=1; j<=width; j++)
{
for (int k=1; k<=row; k++)
{
tmp = get(k, j+i-1);
a->set(k, j, tmp);
n_Delete(&tmp, basecoeffs());
}
}
}

## splitrow() [1/2]

void bigintmat::splitrow | ( | bigintmat * | a,
|  | bigintmat * | b )

Speichert in Matrix a den oberen, in b den unteren Teil der Matrix, vorausgesetzt die Dimensionen stimmen überein.

Definition at line 1122 of file bigintmat.cc.

{
int ay = a->cols();
int ax = a->rows();
int by = b->cols();
int bx = b->rows();
number tmp;
if (!(ax + bx == row))
{
WerrorS("Error in splitrow. Dimensions must agree!");
}
else if (!((col == ay) && (col == by)))
{
WerrorS("Error in splitrow. Dimensions must agree!");
}
else if (!(nCoeffs_are_equal(a->basecoeffs(), basecoeffs()) && nCoeffs_are_equal(b->basecoeffs(), basecoeffs())))
{
WerrorS("Error in splitrow. coeffs do not agree!");
}
else
{
for(int i = 1; i<=ax; i++)
{
for(int j = 1; j<=ay;j++)
{
tmp = get(i,j);
a->set(i,j,tmp);
n_Delete(&tmp, basecoeffs());
}
}
for (int i =1; i<=bx; i++)
{
for (int j=1;j<=col;j++)
{
tmp = get(i+ax, j);
b->set(i,j,tmp);
n_Delete(&tmp, basecoeffs());
}
}
}
}

## splitrow() [2/2]

void bigintmat::splitrow | ( | bigintmat * | a,
|  | int | i )

... Zeilen ...

Definition at line 1229 of file bigintmat.cc.

{
number tmp;
if ((a->cols() != col) || (a->rows()+i-1 > row) || (i<1))
{
WerrorS("Error in Marco-splitrow");
return;
}
if (!(nCoeffs_are_equal(a->basecoeffs(), basecoeffs())))
{
WerrorS("Error in splitrow. coeffs do not agree!");
return;
}
int height = a->rows();
for (int j=1; j<=height; j++)
{
for (int k=1; k<=col; k++)
{
tmp = view(j+i-1, k);
a->set(j, k, tmp);
}
}
}

## String()

char * bigintmat::String | ( |  | ) |

IO: String returns a singular string containing the matrix, needs freeing afterwards.

Definition at line 430 of file bigintmat.cc.

{
StringSetS("");
Write();
return StringEndS();
}
bigintmat::Write
void Write()
IO: writes the matrix into the current internal string buffer which must be started/ allocated before...
Definition bigintmat.cc:411

## StringAsPrinted()

char * bigintmat::StringAsPrinted | ( |  | ) |

Returns a string as it would have been printed in the interpreter.

Used e.g. in print functions of various blackbox types.

Definition at line 445 of file bigintmat.cc.

{
if ((col==0) || (row==0))
return NULL;
else
{
int * colwid = getwid(80);
if (colwid == NULL)
{
WerrorS("not enough space to print bigintmat");
WerrorS("try string(...) for a unformatted output");
return NULL;
}
char * ps;
int slength = 0;
for (int j=0; j<col; j++)
slength += colwid[j]*row;
slength += col*row+row;
ps = (char*) omAlloc0(sizeof(char)*(slength));
int pos = 0;
for (int i=0; i<col*row; i++)
{
StringSetS("");
n_Write(v[i], basecoeffs());
char * ts = StringEndS();
const int _nl = strlen(ts);
int cj = i%col;
if (_nl > colwid[cj])
{
StringSetS("");
int ci = i/col;
StringAppend("[%d,%d]", ci+1, cj+1);
char * ph = StringEndS();
int phl = strlen(ph);
if (phl > colwid[cj])
{
for (int j=0; j<colwid[cj]-1; j++)
ps[pos+j] = ' ';
ps[pos+colwid[cj]-1] = '*';
}
else
{
for (int j=0; j<colwid[cj]-phl; j++)
ps[pos+j] = ' ';
for (int j=0; j<phl; j++)
ps[pos+colwid[cj]-phl+j] = ph[j];
}
omFree(ph);
}
else // Mit Leerzeichen auffüllen und zahl reinschreiben
{
for (int j=0; j<(colwid[cj]-_nl); j++)
ps[pos+j] = ' ';
for (int j=0; j<_nl; j++)
ps[pos+colwid[cj]-_nl+j] = ts[j];
}
// ", " und (evtl) "\n" einfügen
if ((i+1)%col == 0)
{
if (i != col*row-1)
{
ps[pos+colwid[cj]] = ',';
ps[pos+colwid[cj]+1] = '\n';
pos += colwid[cj]+2;
}
}
else
{
ps[pos+colwid[cj]] = ',';
pos += colwid[cj]+1;
}
omFree(ts); // Hier ts zerstören
}
return(ps);
// omFree(ps);
}
}

## sub()

bool bigintmat::sub | ( | bigintmat * | b | ) |

Subtrahiert ...

Definition at line 911 of file bigintmat.cc.

{
if ((b->rows() != row) || (b->cols() != col))
{
WerrorS("Error in bigintmat::sub. Dimensions do not agree!");
return false;
}
if (!nCoeffs_are_equal(basecoeffs(), b->basecoeffs()))
{
WerrorS("Error in bigintmat::sub. coeffs do not agree!");
return false;
}
for (int i=1; i<=row; i++)
{
for (int j=1; j<=col; j++)
{
rawset(i, j, n_Sub(view(i,j), b->view(i,j), basecoeffs()));
}
}
return true;
}

## swap()

void bigintmat::swap | ( | int | i,
|  | int | j )

swap columns i and j

Definition at line 680 of file bigintmat.cc.

{
if ((i <= col) && (j <= col) && (i>0) && (j>0))
{
number tmp;
number t;
for (int k=1; k<=row; k++)
{
tmp = get(k, i);
t = view(k, j);
set(k, i, t);
set(k, j, tmp);
n_Delete(&tmp, basecoeffs());
}
}
else
WerrorS("Error in swap");
}

## swapMatrix()

void bigintmat::swapMatrix | ( | bigintmat * | a | ) |

Definition at line 1561 of file bigintmat.cc.

{
int n = rows(), m = cols();
row = a->rows();
col = a->cols();
number * V = v;
v = a->v;
a->v = V;
a->row = n;
a->col = m;
}

## swaprow()

void bigintmat::swaprow | ( | int | i,
|  | int | j )

swap rows i and j

Definition at line 699 of file bigintmat.cc.

{
if ((i <= row) && (j <= row) && (i>0) && (j>0))
{
number tmp;
number t;
for (int k=1; k<=col; k++)
{
tmp = get(i, k);
t = view(j, k);
set(i, k, t);
set(j, k, tmp);
n_Delete(&tmp, basecoeffs());
}
}
else
WerrorS("Error in swaprow");
}

## trace()

number bigintmat::trace | ( |  | ) |

the trace ....

Definition at line 1493 of file bigintmat.cc.

{
assume (col == row);
number t = get(1,1),
h;
coeffs r = basecoeffs();
for(int i=2; i<= col; i++) {
h = n_Add(t, view(i,i), r);
n_Delete(&t, r);
t = h;
}
return t;
}

## transpose()

bigintmat * bigintmat::transpose | ( |  | ) |

Definition at line 35 of file bigintmat.cc.

{
bigintmat * t = new bigintmat(col, row, basecoeffs());
for (int i=1; i<=row; i++)
{
for (int j=1; j<=col; j++)
{
t->set(j, i, BIMATELEM(*this,i,j));
}
}
return t;
}
BIMATELEM
#define BIMATELEM(M, I, J)
Definition bigintmat.h:133

## view() [1/2]

number bigintmat::view | ( | int | i | ) | const

view an entry. NOTE: starts at [0]

Definition at line 109 of file bigintmat.cc.

{
assume (i >= 0);
assume (i<rows()*cols());
return v[i];
}

## view() [2/2]

number bigintmat::view | ( | int | i,
|  | int | j ) const

view an entry an entry. NOTE: starts at [1,1]

Definition at line 125 of file bigintmat.cc.

{
assume (i >= 0 && j >= 0);
assume (i <= rows() && j <= cols());
return view(index(i, j));
}

## Write()

void bigintmat::Write | ( |  | ) |

IO: writes the matrix into the current internal string buffer which must be started/ allocated before (e.g. StringSetS).

Definition at line 411 of file bigintmat.cc.

{
int n = cols(), m=rows();
for(int i=1; i<= m; i++)
{
for(int j=1; j< n; j++)
{
n_Write(v[(i-1)*n+j-1], basecoeffs());
StringAppendS(", ");
}
if (n) n_Write(v[i*n-1], basecoeffs());
if (i<m)
{
StringAppendS(", ");
}
}
}

## zero()

void bigintmat::zero | ( |  | ) |

Setzt alle Einträge auf 0.

Definition at line 1345 of file bigintmat.cc.

{
number tmp = n_Init(0, basecoeffs());
for (int i=1; i<=row; i++)
{
for (int j=1; j<=col; j++)
{
set(i, j, tmp);
}
}
n_Delete(&tmp,basecoeffs());
}

## Field Documentation

## col

int bigintmat::col

private

Definition at line 56 of file bigintmat.h.

## m_coeffs

coeffs bigintmat::m_coeffs

private

Definition at line 53 of file bigintmat.h.

## row

int bigintmat::row

private

Definition at line 55 of file bigintmat.h.

## v

number* bigintmat::v

private

Definition at line 54 of file bigintmat.h.

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

- libpolys/coeffs/bigintmat.h
- libpolys/coeffs/bigintmat.cc