My Project
|
Matrices of numbers. More...
#include <coeffs/bigintmat.h>
Public Member Functions | |
bigintmat () | |
bigintmat * | transpose () |
void | inpTranspose () |
transpose in place More... | |
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. More... | |
bigintmat (const bigintmat *m) | |
copy constructor More... | |
number & | operator[] (int i) |
dubious: 1-dim access to 2-dim array. Entries are read row by row. More... | |
const number & | operator[] (int i) const |
void | operator*= (int intop) |
UEberladener *=-Operator (fuer int und bigint) Frage hier: *= verwenden oder lieber = und * einzeln? problem: what about non-commuting rings. Is this from left or right? More... | |
void | inpMult (number bintop, const coeffs C=NULL) |
inplace version of skalar mult. CHANGES input. More... | |
int | length () |
int | cols () const |
int | rows () const |
coeffs | basecoeffs () const |
~bigintmat () | |
canonical destructor. More... | |
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 More... | |
number | get (int i, int j) const |
get a copy of an entry. NOTE: starts at [1,1] More... | |
number | view (int i, int j) const |
view an entry an entry. NOTE: starts at [1,1] More... | |
number | get (int i) const |
get a copy of an entry. NOTE: starts at [0] More... | |
number | view (int i) const |
view an entry. NOTE: starts at [0] More... | |
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] More... | |
void | set (int i, number n, const coeffs C=NULL) |
replace an entry with a copy (delete old + copy new!). NOTE: starts at [0] More... | |
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 More... | |
void | rawset (int i, int j, number n, const coeffs C=NULL) |
as above, but the 2-dim version More... | |
char * | String () |
IO: String returns a singular string containing the matrix, needs freeing afterwards. More... | |
void | Write () |
IO: writes the matrix into the current internal string buffer which must be started/ allocated before (e.g. StringSetS) More... | |
void | Print () |
IO: simply prints the matrix to the current output (screen?) More... | |
char * | StringAsPrinted () |
Returns a string as it would have been printed in the interpreter. More... | |
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 More... | |
void | swaprow (int i, int j) |
swap rows i and j More... | |
int | findnonzero (int i) |
find index of 1st non-zero entry in row i More... | |
int | findcolnonzero (int j) |
find index of 1st non-zero entry in column j More... | |
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. More... | |
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 More... | |
void | getrow (int i, bigintmat *a) |
Schreibt i-te Zeile in Vektor (Matrix) a. More... | |
void | setcol (int j, bigintmat *m) |
Setzt j-te Spalte gleich übergebenem Vektor (Matrix) m. More... | |
void | setrow (int i, bigintmat *m) |
Setzt i-te Zeile gleich übergebenem Vektor (Matrix) m. More... | |
void | appendCol (bigintmat *a) |
horizontally join the matrices, m <- m|a More... | |
void | extendCols (int i) |
append i zero-columns to the matrix More... | |
bool | add (bigintmat *b) |
Addiert zur Matrix die Matrix b dazu. Return false => an error occurred. More... | |
bool | sub (bigintmat *b) |
Subtrahiert ... More... | |
bool | skalmult (number b, coeffs c) |
Multipliziert zur Matrix den Skalar b hinzu. More... | |
bool | addcol (int i, int j, number a, coeffs c) |
addiert a-faches der j-ten Spalte zur i-ten dazu More... | |
bool | addrow (int i, int j, number a, coeffs c) |
... Zeile ... More... | |
void | colskalmult (int i, number a, coeffs c) |
Multipliziert zur i-ten Spalte den Skalar a hinzu. More... | |
void | rowskalmult (int i, number a, coeffs c) |
... Zeile ... More... | |
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) More... | |
void | concatrow (bigintmat *a, bigintmat *b) |
Fügt zwei Matrixen untereinander/nebeneinander in gegebene Matrix ein, bzw spaltet gegebenen Matrix auf. More... | |
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. More... | |
void | splitcol (bigintmat *a, bigintmat *b) |
... linken ... rechten ... More... | |
void | splitcol (bigintmat *a, int i) |
Speichert die ersten i Spalten als Teilmatrix in a. More... | |
void | splitrow (bigintmat *a, int i) |
... Zeilen ... More... | |
bool | copy (bigintmat *b) |
Kopiert Einträge von b auf Bigintmat. More... | |
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() More... | |
void | one () |
Macht Matrix (Falls quadratisch) zu Einheitsmatrix. More... | |
int | isOne () |
is matrix is identity More... | |
void | zero () |
Setzt alle Einträge auf 0. More... | |
int | isZero () |
int | colIsZero (int i) |
bigintmat * | elim (int i, int j) |
Liefert Streichungsmatrix (i-te Zeile und j-te Spalte gestrichen) zurück. More... | |
number | pseudoinv (bigintmat *a) |
Speichert in Matrix a die Pseudoinverse, liefert den Nenner zurück. More... | |
number | trace () |
the trace .... More... | |
number | det () |
det (via LaPlace in general, hnf for euc. rings) More... | |
number | hnfdet () |
det via HNF Primzahlen als long long int, müssen noch in number umgewandelt werden? More... | |
void | hnf () |
transforms INPLACE to HNF More... | |
void | howell () |
dito, but Howell form (only different for zero-divsors) More... | |
void | swapMatrix (bigintmat *a) |
bigintmat * | modhnf (number p, coeffs c) |
computes HNF(this | p*I) More... | |
bigintmat * | modgauss (number p, coeffs c) |
void | skaldiv (number b) |
Macht Ganzzahldivision aller Matrixeinträge mit b. More... | |
void | colskaldiv (int j, number b) |
Macht Ganzzahldivision aller j-ten Spalteneinträge mit b. More... | |
void | mod (number p) |
Reduziert komplette Matrix modulo p. More... | |
bigintmat * | inpmod (number p, coeffs c) |
Liefert Kopie der Matrix zurück, allerdings im Ring Z modulo p. More... | |
number | content () |
the content, the gcd of all entries. Only makes sense for Euclidean rings (or possibly constructive PIR) More... | |
void | simplifyContentDen (number *den) |
ensures that Gcd(den, content)=1 enden hier wieder More... | |
Private Attributes | |
coeffs | m_coeffs |
number * | v |
int | row |
int | col |
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 adressing 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.
|
inline |
Definition at line 59 of file bigintmat.h.
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.
copy constructor
Definition at line 89 of file bigintmat.h.
|
inline |
canonical destructor.
Definition at line 149 of file bigintmat.h.
bool bigintmat::add | ( | bigintmat * | b | ) |
Addiert zur Matrix die Matrix b dazu. Return false => an error occurred.
Definition at line 894 of file bigintmat.cc.
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 959 of file bigintmat.cc.
bool bigintmat::addrow | ( | int | i, |
int | j, | ||
number | a, | ||
coeffs | c | ||
) |
... Zeile ...
Definition at line 983 of file bigintmat.cc.
void bigintmat::appendCol | ( | bigintmat * | a | ) |
horizontally join the matrices, m <- m|a
Definition at line 1083 of file bigintmat.cc.
|
inline |
Definition at line 146 of file bigintmat.h.
int bigintmat::colIsZero | ( | int | i | ) |
Definition at line 1577 of file bigintmat.cc.
|
inline |
Definition at line 144 of file bigintmat.h.
void bigintmat::colskaldiv | ( | int | j, |
number | b | ||
) |
Macht Ganzzahldivision aller j-ten Spalteneinträge mit b.
Definition at line 1876 of file bigintmat.cc.
void bigintmat::colskalmult | ( | int | i, |
number | a, | ||
coeffs | c | ||
) |
Multipliziert zur i-ten Spalte den Skalar a hinzu.
Definition at line 1007 of file bigintmat.cc.
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 1889 of file bigintmat.cc.
Definition at line 362 of file bigintmat.cc.
Definition at line 1098 of file bigintmat.cc.
Fügt zwei Matrixen untereinander/nebeneinander in gegebene Matrix ein, bzw spaltet gegebenen Matrix auf.
Definition at line 1039 of file bigintmat.cc.
number bigintmat::content | ( | ) |
the content, the gcd of all entries. Only makes sense for Euclidean rings (or possibly constructive PIR)
Definition at line 2675 of file bigintmat.cc.
bool bigintmat::copy | ( | bigintmat * | b | ) |
Kopiert Einträge von b auf Bigintmat.
Definition at line 1259 of file bigintmat.cc.
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 1287 of file bigintmat.cc.
number bigintmat::det | ( | ) |
det (via LaPlace in general, hnf for euc. rings)
Definition at line 1512 of file bigintmat.cc.
bigintmat * bigintmat::elim | ( | int | i, |
int | j | ||
) |
Liefert Streichungsmatrix (i-te Zeile und j-te Spalte gestrichen) zurück.
Definition at line 1381 of file bigintmat.cc.
void bigintmat::extendCols | ( | int | i | ) |
append i zero-columns to the matrix
Definition at line 1076 of file bigintmat.cc.
int bigintmat::findcolnonzero | ( | int | j | ) |
int bigintmat::findnonzero | ( | int | i | ) |
number bigintmat::get | ( | int | i | ) | const |
number bigintmat::get | ( | int | i, |
int | j | ||
) | const |
get a copy of an entry. NOTE: starts at [1,1]
Definition at line 119 of file bigintmat.cc.
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 747 of file bigintmat.cc.
void bigintmat::getColRange | ( | int | j, |
int | no, | ||
bigintmat * | a | ||
) |
void bigintmat::getrow | ( | int | i, |
bigintmat * | a | ||
) |
Schreibt i-te Zeile in Vektor (Matrix) a.
Definition at line 791 of file bigintmat.cc.
int * bigintmat::getwid | ( | int | maxwid | ) |
Definition at line 580 of file bigintmat.cc.
void bigintmat::hnf | ( | ) |
transforms INPLACE to HNF
Definition at line 1660 of file bigintmat.cc.
number bigintmat::hnfdet | ( | ) |
det via HNF Primzahlen als long long int, müssen noch in number umgewandelt werden?
Definition at line 1545 of file bigintmat.cc.
void bigintmat::howell | ( | ) |
dito, but Howell form (only different for zero-divsors)
Definition at line 1585 of file bigintmat.cc.
|
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.
void bigintmat::inpTranspose | ( | ) |
transpose in place
Definition at line 50 of file bigintmat.cc.
int bigintmat::isOne | ( | ) |
is matrix is identity
Definition at line 1300 of file bigintmat.cc.
int bigintmat::isZero | ( | ) |
|
inline |
Definition at line 143 of file bigintmat.h.
void bigintmat::mod | ( | number | p | ) |
Reduziert komplette Matrix modulo p.
Definition at line 1916 of file bigintmat.cc.
computes HNF(this | p*I)
Definition at line 1832 of file bigintmat.cc.
void bigintmat::one | ( | ) |
Macht Matrix (Falls quadratisch) zu Einheitsmatrix.
Definition at line 1325 of file bigintmat.cc.
void bigintmat::operator*= | ( | int | intop | ) |
UEberladener *=-Operator (fuer int und bigint) Frage hier: *= verwenden oder lieber = und * einzeln? problem: what about non-commuting rings. Is this from left or right?
Definition at line 136 of file bigintmat.cc.
|
inline |
dubious: 1-dim access to 2-dim array. Entries are read row by row.
Definition at line 111 of file bigintmat.h.
|
inline |
void bigintmat::pprint | ( | int | maxwid | ) |
Definition at line 610 of file bigintmat.cc.
void bigintmat::Print | ( | ) |
number bigintmat::pseudoinv | ( | bigintmat * | a | ) |
Speichert in Matrix a die Pseudoinverse, liefert den Nenner zurück.
Definition at line 1415 of file bigintmat.cc.
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.
|
inline |
Definition at line 145 of file bigintmat.h.
void bigintmat::rowskalmult | ( | int | i, |
number | a, | ||
coeffs | c | ||
) |
... Zeile ...
Definition at line 1023 of file bigintmat.cc.
replace an entry with a copy (delete old + copy new!). NOTE: starts at [0]
Definition at line 87 of file bigintmat.cc.
void bigintmat::setcol | ( | int | j, |
bigintmat * | m | ||
) |
Setzt j-te Spalte gleich übergebenem Vektor (Matrix) m.
Definition at line 826 of file bigintmat.cc.
void bigintmat::setrow | ( | int | i, |
bigintmat * | m | ||
) |
Setzt i-te Zeile gleich übergebenem Vektor (Matrix) m.
Definition at line 860 of file bigintmat.cc.
void bigintmat::simplifyContentDen | ( | number * | den | ) |
ensures that Gcd(den, content)=1 enden hier wieder
Definition at line 2688 of file bigintmat.cc.
void bigintmat::skaldiv | ( | number | b | ) |
Macht Ganzzahldivision aller Matrixeinträge mit b.
Definition at line 1861 of file bigintmat.cc.
bool bigintmat::skalmult | ( | number | b, |
coeffs | c | ||
) |
Multipliziert zur Matrix den Skalar b hinzu.
Definition at line 938 of file bigintmat.cc.
... linken ... rechten ...
Definition at line 1169 of file bigintmat.cc.
void bigintmat::splitcol | ( | bigintmat * | a, |
int | i | ||
) |
Speichert die ersten i Spalten als Teilmatrix in a.
Definition at line 1209 of file bigintmat.cc.
Speichert in Matrix a den oberen, in b den unteren Teil der Matrix, vorausgesetzt die Dimensionen stimmen überein.
Definition at line 1127 of file bigintmat.cc.
void bigintmat::splitrow | ( | bigintmat * | a, |
int | i | ||
) |
... Zeilen ...
Definition at line 1234 of file bigintmat.cc.
char * bigintmat::String | ( | ) |
IO: String returns a singular string containing the matrix, needs freeing afterwards.
Definition at line 436 of file bigintmat.cc.
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 451 of file bigintmat.cc.
bool bigintmat::sub | ( | bigintmat * | b | ) |
Subtrahiert ...
Definition at line 916 of file bigintmat.cc.
void bigintmat::swap | ( | int | i, |
int | j | ||
) |
swap columns i and j
Definition at line 685 of file bigintmat.cc.
void bigintmat::swapMatrix | ( | bigintmat * | a | ) |
void bigintmat::swaprow | ( | int | i, |
int | j | ||
) |
swap rows i and j
Definition at line 704 of file bigintmat.cc.
number bigintmat::trace | ( | ) |
bigintmat * bigintmat::transpose | ( | ) |
Definition at line 37 of file bigintmat.cc.
number bigintmat::view | ( | int | i | ) | const |
number bigintmat::view | ( | int | i, |
int | j | ||
) | const |
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 413 of file bigintmat.cc.
void bigintmat::zero | ( | ) |
|
private |
Definition at line 56 of file bigintmat.h.
|
private |
Definition at line 53 of file bigintmat.h.
|
private |
Definition at line 55 of file bigintmat.h.
|
private |
Definition at line 54 of file bigintmat.h.