My Project
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes
bigintmat Class Reference

Matrices of numbers. More...

#include <coeffs/bigintmat.h>

Public Member Functions

 bigintmat ()
 
bigintmattranspose ()
 
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
 
numberoperator[] (int i)
 dubious: 1-dim access to 2-dim array. Entries are read row by row.
 
const numberoperator[] (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?
 
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
 
charString ()
 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?)
 
charStringAsPrinted ()
 Returns a string as it would have been printed in the interpreter.
 
void pprint (int maxwid)
 
int compare (const bigintmat *op) const
 
intgetwid (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)
 
bigintmatelim (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)
 
bigintmatmodhnf (number p, coeffs c)
 computes HNF(this | p*I)
 
bigintmatmodgauss (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.
 
bigintmatinpmod (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
 
numberv
 
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 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.

Constructor & Destructor Documentation

◆ bigintmat() [1/3]

bigintmat::bigintmat ( )
inline

Definition at line 59 of file bigintmat.h.

59: m_coeffs(NULL), v(NULL), row(1), col(0){}
coeffs m_coeffs
Definition bigintmat.h:53
number * v
Definition bigintmat.h:54
#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.

69 : m_coeffs(n), v(NULL), row(r), col(c)
70 {
71 assume (rows() >= 0);
72 assume (cols() >= 0);
73
74 const int l = r*c;
75
76 if (l>0) /*(r>0) && (c>0) */
77 {
78 v = (number *)omAlloc(sizeof(number)*l);
79
80 assume (basecoeffs() != NULL);
81 for (int i = l - 1; i>=0; i--)
82 {
83 v[i] = n_Init(0, basecoeffs());
84 }
85 }
86 }
int l
Definition cfEzgcd.cc:100
int i
Definition cfEzgcd.cc:132
int cols() const
Definition bigintmat.h:144
int rows() const
Definition bigintmat.h:145
coeffs basecoeffs() const
Definition bigintmat.h:146
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:542
#define assume(x)
Definition mod2.h:387
#define omAlloc(size)

◆ bigintmat() [3/3]

bigintmat::bigintmat ( const bigintmat * m)
inline

copy constructor

Definition at line 89 of file bigintmat.h.

89 : m_coeffs(m->basecoeffs()), v(NULL), row(m->rows()), col(m->cols())
90 {
91 const int l = row*col;
92
93 if (l > 0)
94 {
95 assume (rows() > 0);
96 assume (cols() > 0);
97
98 assume (m->v != NULL);
99
100 v = (number *)omAlloc(sizeof(number)*row*col);
101
102 assume (basecoeffs() != NULL);
103
104 for (int i = l-1; i>=0; i--)
105 {
106 v[i] = n_Copy((*m)[i], basecoeffs());
107 }
108 }
109 }
int m
Definition cfEzgcd.cc:128
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of 'n'
Definition coeffs.h:455

◆ ~bigintmat()

bigintmat::~bigintmat ( )
inline

canonical destructor.

Definition at line 149 of file bigintmat.h.

150 {
151 if (v!=NULL)
152 {
153 for (int i=row*col-1;i>=0; i--) { n_Delete(&(v[i]), basecoeffs()); }
154 omFreeSize((ADDRESS)v, sizeof(number)*row*col);
155 v=NULL;
156 }
157 }
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition coeffs.h:459
#define omFreeSize(addr, size)

Member Function Documentation

◆ add()

bool bigintmat::add ( bigintmat * b)

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

Definition at line 890 of file bigintmat.cc.

891{
892 if ((b->rows() != row) || (b->cols() != col))
893 {
894 WerrorS("Error in bigintmat::add. Dimensions do not agree!");
895 return false;
896 }
897 if (!nCoeffs_are_equal(basecoeffs(), b->basecoeffs()))
898 {
899 WerrorS("Error in bigintmat::add. coeffs do not agree!");
900 return false;
901 }
902 for (int i=1; i<=row; i++)
903 {
904 for (int j=1; j<=col; j++)
905 {
906 rawset(i, j, n_Add(b->view(i,j), view(i,j), basecoeffs()));
907 }
908 }
909 return true;
910}
bool nCoeffs_are_equal(coeffs r, coeffs s)
CanonicalForm b
Definition cfModGcd.cc:4111
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition bigintmat.cc:127
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
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:654
int j
Definition facHensel.cc:110
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 955 of file bigintmat.cc.

956{
957 if ((i>col) || (j>col) || (i<1) || (j<1))
958 {
959 WerrorS("Error in addcol: Index out of range!");
960 return false;
961 }
962 if (!nCoeffs_are_equal(c, basecoeffs()))
963 {
964 WerrorS("Error in addcol: coeffs do not agree!");
965 return false;
966 }
967 number t1, t2, t3;
968 for (int k=1; k<=row; k++)
969 {
970 t1 = view(k, j);
971 t2 = view(k, i);
972 t3 = n_Mult(t1, a, basecoeffs());
973 n_InpAdd(t3, t2, basecoeffs());
974 rawset(k, i, t3);
975 }
976 return true;
977}
int k
Definition cfEzgcd.cc:99
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:640
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:650

◆ addrow()

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

... Zeile ...

Definition at line 979 of file bigintmat.cc.

980{
981 if ((i>row) || (j>row) || (i<1) || (j<1))
982 {
983 WerrorS("Error in addrow: Index out of range!");
984 return false;
985 }
986 if (!nCoeffs_are_equal(c, basecoeffs()))
987 {
988 WerrorS("Error in addrow: coeffs do not agree!");
989 return false;
990 }
991 number t1, t2, t3;
992 for (int k=1; k<=col; k++)
993 {
994 t1 = view(j, k);
995 t2 = view(i, k);
996 t3 = n_Mult(t1, a, basecoeffs());
997 n_InpAdd(t3, t2, basecoeffs());
998 rawset(i, k, t3);
999 }
1000 return true;
1001}

◆ appendCol()

void bigintmat::appendCol ( bigintmat * a)

horizontally join the matrices, m <- m|a

Definition at line 1079 of file bigintmat.cc.

1080{
1081 coeffs R = basecoeffs();
1082 int ay = a->cols();
1083 int ax = a->rows();
1084 assume(row == ax);
1085
1087
1088 bigintmat * tmp = new bigintmat(rows(), cols() + ay, R);
1089 tmp->concatcol(this, a);
1090 this->swapMatrix(tmp);
1091 delete tmp;
1092}
Matrices of numbers.
Definition bigintmat.h:51
void swapMatrix(bigintmat *a)
The main handler for Singular numbers which are suitable for Singular polynomials.
#define R
Definition sirandom.c:27

◆ basecoeffs()

coeffs bigintmat::basecoeffs ( ) const
inline

Definition at line 146 of file bigintmat.h.

146{ return m_coeffs; }

◆ colIsZero()

int bigintmat::colIsZero ( int i)

Definition at line 1573 of file bigintmat.cc.

1574{
1575 coeffs R = basecoeffs();
1576 for(int i=1; i<=rows(); i++)
1577 if (!n_IsZero(view(i, j), R)) return FALSE;
1578 return TRUE;
1579}
#define TRUE
Definition auxiliary.h:100
#define FALSE
Definition auxiliary.h:96
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
Definition coeffs.h:468

◆ cols()

int bigintmat::cols ( ) const
inline

Definition at line 144 of file bigintmat.h.

144{ return col; }

◆ colskaldiv()

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

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

Definition at line 1872 of file bigintmat.cc.

1873{
1874 number tmp1, tmp2;
1875 for (int i=1; i<=row; i++)
1876 {
1877 tmp1 = view(i, j);
1878 tmp2 = n_Div(tmp1, b, basecoeffs());
1879 rawset(i, j, tmp2);
1880 }
1881}
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:619
CFList tmp1
Definition facFqBivar.cc:75
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 1003 of file bigintmat.cc.

1004{
1005 if ((i>=1) && (i<=col) && (nCoeffs_are_equal(c, basecoeffs())))
1006 {
1007 number t, tmult;
1008 for (int j=1; j<=row; j++)
1009 {
1010 t = view(j, i);
1011 tmult = n_Mult(a, t, basecoeffs());
1012 rawset(j, i, tmult);
1013 }
1014 }
1015 else
1016 WerrorS("Error in colskalmult");
1017}

◆ 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 1885 of file bigintmat.cc.

1886{
1888 for (int i=1; i<=row; i++)
1889 {
1890 tmp1 = get(i, j);
1891 tmp2 = get(i, k);
1892 tmp3 = n_Mult(tmp1, a, basecoeffs());
1893 tmp4 = n_Mult(tmp2, b, basecoeffs());
1896
1897 n_InpMult(tmp1, c, basecoeffs());
1898 n_InpMult(tmp2, d, basecoeffs());
1901
1902 set(i, j, tmp3);
1903 set(i, k, tmp1);
1906 }
1907}
number get(int i, int j) const
get a copy of an entry. NOTE: starts at [1,1]
Definition bigintmat.cc:119
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:95
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:645

◆ compare()

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

Definition at line 362 of file bigintmat.cc.

363{
364 assume (basecoeffs() == op->basecoeffs() );
365
366#ifndef SING_NDEBUG
367 if (basecoeffs() != op->basecoeffs() )
368 WerrorS("wrong bigintmat comparison: different basecoeffs!\n");
369#endif
370
371 if ((col!=1) ||(op->cols()!=1))
372 {
373 if((col!=op->cols())
374 || (row!=op->rows()))
375 return -2;
376 }
377
378 int i;
379 for (i=0; i<si_min(row*col,op->rows()*op->cols()); i++)
380 {
381 if ( n_Greater(v[i], (*op)[i], basecoeffs()) )
382 return 1;
383 else if (! n_Equal(v[i], (*op)[i], basecoeffs()))
384 return -1;
385 }
386
387 for (; i<row; i++)
388 {
389 if ( n_GreaterZero(v[i], basecoeffs()) )
390 return 1;
391 else if (! n_IsZero(v[i], basecoeffs()) )
392 return -1;
393 }
394 for (; i<op->rows(); i++)
395 {
396 if ( n_GreaterZero((*op)[i], basecoeffs()) )
397 return -1;
398 else if (! n_IsZero((*op)[i], basecoeffs()) )
399 return 1;
400 }
401 return 0;
402}
static int si_min(const int a, const int b)
Definition auxiliary.h:125
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:498
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:515
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:464

◆ concatcol()

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

Definition at line 1094 of file bigintmat.cc.

1094 {
1095 int ay = a->cols();
1096 int ax = a->rows();
1097 int by = b->cols();
1098 int bx = b->rows();
1099 number tmp;
1100
1101 assume(row==ax && row == bx && ay+by ==col);
1102
1104
1105 for (int i=1; i<=ax; i++)
1106 {
1107 for (int j=1; j<=ay; j++)
1108 {
1109 tmp = a->view(i,j);
1110 set(i, j, tmp);
1111 }
1112 }
1113 for (int i=1; i<=bx; i++)
1114 {
1115 for (int j=1; j<=by; j++)
1116 {
1117 tmp = b->view(i,j);
1118 set(i, j+ay, tmp);
1119 }
1120 }
1121}

◆ 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 1035 of file bigintmat.cc.

1036{
1037 int ay = a->cols();
1038 int ax = a->rows();
1039 int by = b->cols();
1040 int bx = b->rows();
1041 number tmp;
1042 if (!((col == ay) && (col == by) && (ax+bx == row)))
1043 {
1044 WerrorS("Error in concatrow. Dimensions must agree!");
1045 return;
1046 }
1047 if (!(nCoeffs_are_equal(a->basecoeffs(), basecoeffs()) && nCoeffs_are_equal(b->basecoeffs(), basecoeffs())))
1048 {
1049 WerrorS("Error in concatrow. coeffs do not agree!");
1050 return;
1051 }
1052 for (int i=1; i<=ax; i++)
1053 {
1054 for (int j=1; j<=ay; j++)
1055 {
1056 tmp = a->get(i,j);
1057 set(i, j, tmp);
1058 n_Delete(&tmp, basecoeffs());
1059 }
1060 }
1061 for (int i=1; i<=bx; i++)
1062 {
1063 for (int j=1; j<=by; j++)
1064 {
1065 tmp = b->get(i,j);
1066 set(i+ax, j, tmp);
1067 n_Delete(&tmp, basecoeffs());
1068 }
1069 }
1070}

◆ content()

number bigintmat::content ( )

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

Definition at line 2671 of file bigintmat.cc.

2672{
2673 coeffs r = basecoeffs();
2674 number g = get(1,1), h;
2675 int n=rows()*cols();
2676 for(int i=1; i<n && !n_IsOne(g, r); i++)
2677 {
2678 h = n_Gcd(g, view(i), r);
2679 n_Delete(&g, r);
2680 g=h;
2681 }
2682 return g;
2683}
g
Definition cfModGcd.cc:4098
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:668
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff 'n' represents the one element.
Definition coeffs.h:472
STATIC_VAR Poly * h
Definition janet.cc:971

◆ copy()

bool bigintmat::copy ( bigintmat * b)

Kopiert Einträge von b auf Bigintmat.

Definition at line 1255 of file bigintmat.cc.

1256{
1257 if ((b->rows() != row) || (b->cols() != col))
1258 {
1259 WerrorS("Error in bigintmat::copy. Dimensions do not agree!");
1260 return false;
1261 }
1262 if (!nCoeffs_are_equal(basecoeffs(), b->basecoeffs()))
1263 {
1264 WerrorS("Error in bigintmat::copy. coeffs do not agree!");
1265 return false;
1266 }
1267 number t1;
1268 for (int i=1; i<=row; i++)
1269 {
1270 for (int j=1; j<=col; j++)
1271 {
1272 t1 = b->view(i, j);
1273 set(i, j, t1);
1274 }
1275 }
1276 return true;
1277}

◆ 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 1283 of file bigintmat.cc.

1284{
1285 number t1;
1286 for (int i=1; i<=n; i++)
1287 {
1288 for (int j=1; j<=m; j++)
1289 {
1290 t1 = B->view(a+i-1, b+j-1);
1291 set(c+i-1, d+j-1, t1);
1292 }
1293 }
1294}
b *CanonicalForm B
Definition facBivar.cc:52

◆ det()

number bigintmat::det ( )

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

Definition at line 1508 of file bigintmat.cc.

1509{
1510 assume (row==col);
1511
1512 if (col == 1)
1513 return get(1, 1);
1514 // should work as well in Z/pZ of type n_Zp?
1515 // relies on XExtGcd and the other euc. functinos.
1517 return hnfdet();
1518 }
1519 number sum = n_Init(0, basecoeffs());
1520 number t1, t2, t3, t4;
1521 bigintmat *b;
1522 for (int i=1; i<=row; i++) {
1523 b = elim(i, 1);
1524 t1 = get(i, 1);
1525 t2 = b->det();
1526 t3 = n_Mult(t1, t2, basecoeffs());
1527 t4 = n_Copy(sum, basecoeffs());
1528 n_Delete(&sum, basecoeffs());
1529 if ((i+1)>>1<<1==(i+1))
1530 sum = n_Add(t4, t3, basecoeffs());
1531 else
1532 sum = n_Sub(t4, t3, basecoeffs());
1533 n_Delete(&t1, basecoeffs());
1534 n_Delete(&t2, basecoeffs());
1535 n_Delete(&t3, basecoeffs());
1536 n_Delete(&t4, basecoeffs());
1537 }
1538 return sum;
1539}
number hnfdet()
det via HNF Primzahlen als long long int, müssen noch in number umgewandelt werden?
bigintmat * elim(int i, int j)
Liefert Streichungsmatrix (i-te Zeile und j-te Spalte gestrichen) zurück.
@ n_Zn
only used if HAVE_RINGS is defined
Definition coeffs.h:44
@ n_Z
only used if HAVE_RINGS is defined
Definition coeffs.h:43
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:659
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition coeffs.h:429

◆ elim()

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

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

Definition at line 1377 of file bigintmat.cc.

1378{
1379 if ((i<=0) || (i>row) || (j<=0) || (j>col))
1380 return NULL;
1381 int cx, cy;
1382 cx=1;
1383 cy=1;
1384 number t;
1385 bigintmat *b = new bigintmat(row-1, col-1, basecoeffs());
1386 for (int k=1; k<=row; k++) {
1387 if (k!=i)
1388 {
1389 cy=1;
1390 for (int l=1; l<=col; l++)
1391 {
1392 if (l!=j)
1393 {
1394 t = get(k, l);
1395 b->set(cx, cy, t);
1396 n_Delete(&t, basecoeffs());
1397 cy++;
1398 }
1399 }
1400 cx++;
1401 }
1402 }
1403 return b;
1404}

◆ extendCols()

void bigintmat::extendCols ( int i)

append i zero-columns to the matrix

Definition at line 1072 of file bigintmat.cc.

1073{
1074 bigintmat * tmp = new bigintmat(rows(), i, basecoeffs());
1075 appendCol(tmp);
1076 delete tmp;
1077}
void appendCol(bigintmat *a)
horizontally join the matrices, m <- m|a

◆ findcolnonzero()

int bigintmat::findcolnonzero ( int j)

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

Definition at line 731 of file bigintmat.cc.

732{
733 for (int i=row; i>=1; i--)
734 {
735 if (!n_IsZero(view(i,j), basecoeffs()))
736 {
737 return i;
738 }
739 }
740 return 0;
741}

◆ findnonzero()

int bigintmat::findnonzero ( int i)

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

Definition at line 719 of file bigintmat.cc.

720{
721 for (int j=1; j<=col; j++)
722 {
723 if (!n_IsZero(view(i,j), basecoeffs()))
724 {
725 return j;
726 }
727 }
728 return 0;
729}

◆ get() [1/2]

number bigintmat::get ( int i) const

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

Definition at line 103 of file bigintmat.cc.

104{
105 assume (i >= 0);
106 assume (i<rows()*cols());
107
108 return n_Copy(v[i], basecoeffs());
109}

◆ 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 119 of file bigintmat.cc.

120{
121 assume (i > 0 && j > 0);
122 assume (i <= rows() && j <= cols());
123
124 return get(index(i, j));
125}
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 743 of file bigintmat.cc.

744{
745 assume((j<=col) && (j>=1));
746 if (((a->rows() != row) || (a->cols() != 1)) && ((a->rows() != 1) || (a->cols() != row)))
747 {
748 assume(0);
749 WerrorS("Error in getcol. Dimensions must agree!");
750 return;
751 }
753 {
755 number t1, t2;
756 for (int i=1; i<=row;i++)
757 {
758 t1 = get(i,j);
759 t2 = f(t1, basecoeffs(), a->basecoeffs());
760 a->set(i-1,t1);
761 n_Delete(&t1, basecoeffs());
762 n_Delete(&t2, a->basecoeffs());
763 }
764 return;
765 }
766 number t1;
767 for (int i=1; i<=row;i++)
768 {
769 t1 = view(i,j);
770 a->set(i-1,t1);
771 }
772}
FILE * f
Definition checklibs.c:9
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:704
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 774 of file bigintmat.cc.

775{
776 number t1;
777 for(int ii=0; ii< no; ii++)
778 {
779 for (int i=1; i<=row;i++)
780 {
781 t1 = view(i, ii+j);
782 a->set(i, ii+1, t1);
783 }
784 }
785}

◆ getrow()

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

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

Definition at line 787 of file bigintmat.cc.

788{
789 if ((i>row) || (i<1))
790 {
791 WerrorS("Error in getrow: Index out of range!");
792 return;
793 }
794 if (((a->rows() != 1) || (a->cols() != col)) && ((a->rows() != col) || (a->cols() != 1)))
795 {
796 WerrorS("Error in getrow. Dimensions must agree!");
797 return;
798 }
800 {
802 number t1, t2;
803 for (int j=1; j<=col;j++)
804 {
805 t1 = get(i,j);
806 t2 = f(t1, basecoeffs(), a->basecoeffs());
807 a->set(j-1,t2);
808 n_Delete(&t1, basecoeffs());
809 n_Delete(&t2, a->basecoeffs());
810 }
811 return;
812 }
813 number t1;
814 for (int j=1; j<=col;j++)
815 {
816 t1 = get(i,j);
817 a->set(j-1,t1);
818 n_Delete(&t1, basecoeffs());
819 }
820}

◆ getwid()

int * bigintmat::getwid ( int maxwid)

Definition at line 576 of file bigintmat.cc.

577{
578 int const c = /*2**/(col-1)+1;
579 int * wv = (int*)omAlloc(sizeof(int)*col*row);
580 int * cwv = (int*)omAlloc(sizeof(int)*col);
581 for (int j=0; j<col; j++)
582 {
583 cwv[j] = 0;
584 for (int i=0; i<row; i++)
585 {
586 StringSetS("");
587 n_Write(v[col*i+j], basecoeffs());
588 char * tmp = StringEndS();
589 const int _nl = strlen(tmp);
590 wv[col*i+j] = _nl;
591 if (_nl > cwv[j]) cwv[j]=_nl;
592 omFree(tmp);
593 }
594 }
595
596 // Groesse verkleinern, bis < maxwid
597 if (intArrSum(cwv, col)+c > maxwid)
598 {
599 int j = findLongest(cwv, col);
600 cwv[j] = getShorter(wv, cwv[j], j, col, row);
601 }
602 omFree(wv);
603 return cwv;
604}
static int intArrSum(int *a, int length)
Definition bigintmat.cc:525
static int findLongest(int *a, int length)
Definition bigintmat.cc:533
static int getShorter(int *a, int l, int j, int cols, int rows)
Definition bigintmat.cc:548
static FORCE_INLINE void n_Write(number n, const coeffs r, const BOOLEAN bShortOut=TRUE)
Definition coeffs.h:595
#define omFree(addr)
void StringSetS(const char *st)
Definition reporter.cc:128
char * StringEndS()
Definition reporter.cc:151

◆ hnf()

void bigintmat::hnf ( )

transforms INPLACE to HNF

Definition at line 1656 of file bigintmat.cc.

1657{
1658 // Laufen von unten nach oben und von links nach rechts
1659 // CF: TODO: for n_Z: write a recursive version. This one will
1660 // have exponential blow-up. Look at Michianchio
1661 // Alternatively, do p-adic det and modular method
1662
1663#if 0
1664 char * s;
1665 ::PrintS("mat over Z is \n");
1666 ::Print("%s\n", s = nCoeffString(basecoeffs()));
1667 omFree(s);
1668 Print();
1669 ::Print("\n(%d x %d)\n", rows(), cols());
1670#endif
1671
1672 int i = rows();
1673 int j = cols();
1674 number q = n_Init(0, basecoeffs());
1675 number one = n_Init(1, basecoeffs());
1677 number tmp1 = n_Init(0, basecoeffs());
1678 number tmp2 = n_Init(0, basecoeffs());
1679 number co1, co2, co3, co4;
1680 number ggt = n_Init(0, basecoeffs());
1681
1682 while ((i>0) && (j>0))
1683 {
1684 // Falls erstes Nicht-Null-Element in Zeile i nicht existiert, oder hinter Spalte j vorkommt, gehe in nächste Zeile
1685 if ((findnonzero(i)==0) || (findnonzero(i)>j))
1686 {
1687 i--;
1688 }
1689 else
1690 {
1691 // Laufe von links nach rechts durch die Zeile:
1692 for (int l=1; l<=j-1; l++)
1693 {
1695 tmp1 = get(i, l);
1696 // Falls Eintrag (im folgenden x genannt) gleich 0, gehe eine Spalte weiter. Ansonsten...
1697 if (!n_IsZero(tmp1, basecoeffs()))
1698 {
1700 tmp2 = get(i, l+1);
1701 // Falls Eintrag (i.f. y g.) rechts daneben gleich 0, tausche beide Spalten, sonst...
1702 if (!n_IsZero(tmp2, basecoeffs()))
1703 {
1704 n_Delete(&ggt, basecoeffs());
1705 ggt = n_XExtGcd(tmp1, tmp2, &co1, &co2, &co3, &co4, basecoeffs());
1706 // 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:
1707 if (n_Equal(tmp1, ggt, basecoeffs()))
1708 {
1709 swap(l, l+1);
1710 n_Delete(&q, basecoeffs());
1711 q = n_Div(tmp2, ggt, basecoeffs());
1712 q = n_InpNeg(q, basecoeffs());
1713 // Dann addiere das -q-fache der (neuen) rechten Spalte zur linken dazu. Damit erhalten wir die gewünschte 0
1714
1715 addcol(l, l+1, q, basecoeffs());
1716 n_Delete(&q, basecoeffs());
1717 }
1718 else if (n_Equal(tmp1, minusone, basecoeffs()))
1719 {
1720 // 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
1721 // Die Berechnung von q (=y/ggt) entfällt, da ggt=1
1722 swap(l, l+1);
1725 addcol(l, l+1, tmp2, basecoeffs());
1726 }
1727 else
1728 {
1729 // CF: use the 2x2 matrix (co1, co2)(co3, co4) to
1730 // get the gcd in position and the 0 in the other:
1731#ifdef CF_DEB
1732 ::PrintS("applying trafo\n");
1733 StringSetS("");
1738 ::Print("%s\nfor l=%d\n", StringEndS(), l);
1739 {char * s = String();
1740 ::Print("to %s\n", s);omFree(s);};
1741#endif
1742 coltransform(l, l+1, co3, co4, co1, co2);
1743#ifdef CF_DEB
1744 {char * s = String();
1745 ::Print("gives %s\n", s);}
1746#endif
1747 }
1748 n_Delete(&co1, basecoeffs());
1749 n_Delete(&co2, basecoeffs());
1750 n_Delete(&co3, basecoeffs());
1751 n_Delete(&co4, basecoeffs());
1752 }
1753 else
1754 {
1755 swap(l, l+1);
1756 }
1757 // Dann betrachte die vormals rechte Spalte als neue linke, und die rechts daneben als neue rechte.
1758 }
1759 }
1760
1761 #ifdef HAVE_RINGS
1762 // normalize by units:
1763 if (!n_IsZero(view(i, j), basecoeffs()))
1764 {
1765 number u = n_GetUnit(view(i, j), basecoeffs());
1766 if (!n_IsOne(u, basecoeffs()))
1767 {
1768 colskaldiv(j, u);
1769 }
1770 n_Delete(&u, basecoeffs());
1771 }
1772 #endif
1773 // Zum Schluss mache alle Einträge rechts vom Diagonalelement betragsmäßig kleiner als dieses
1774 for (int l=j+1; l<=col; l++)
1775 {
1776 n_Delete(&q, basecoeffs());
1777 q = n_QuotRem(view(i, l), view(i, j), NULL, basecoeffs());
1778 q = n_InpNeg(q, basecoeffs());
1779 addcol(l, j, q, basecoeffs());
1780 }
1781 i--;
1782 j--;
1783 // Dann betrachte die Zeile darüber und gehe dort wie vorher vor
1784 }
1785 }
1786 n_Delete(&q, basecoeffs());
1789 n_Delete(&ggt, basecoeffs());
1790 n_Delete(&one, basecoeffs());
1792
1793#if 0
1794 ::PrintS("hnf over Z is \n");
1795 Print();
1796 ::Print("\n(%d x %d)\n", rows(), cols());
1797#endif
1798}
#define swap(_i, _j)
void Print()
IO: simply prints the matrix to the current output (screen?)
Definition bigintmat.cc:439
void colskaldiv(int j, number b)
Macht Ganzzahldivision aller j-ten Spalteneinträge mit b.
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)
bool addcol(int i, int j, number a, coeffs c)
addiert a-faches der j-ten Spalte zur i-ten dazu
Definition bigintmat.cc:955
int findnonzero(int i)
find index of 1st non-zero entry in row i
Definition bigintmat.cc:719
void colskalmult(int i, number a, coeffs c)
Multipliziert zur i-ten Spalte den Skalar a hinzu.
void one()
Macht Matrix (Falls quadratisch) zu Einheitsmatrix.
char * String()
IO: String returns a singular string containing the matrix, needs freeing afterwards.
Definition bigintmat.cc:432
static FORCE_INLINE number n_QuotRem(number a, number b, number *q, const coeffs r)
Definition coeffs.h:685
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:963
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:561
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:536
static FORCE_INLINE number n_XExtGcd(number a, number b, number *s, number *t, number *u, number *v, const coeffs r)
Definition coeffs.h:677
const CanonicalForm int s
Definition facAbsFact.cc:51
void StringAppendS(const char *st)
Definition reporter.cc:107
void PrintS(const char *s)
Definition reporter.cc:284

◆ hnfdet()

number bigintmat::hnfdet ( )

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

Definition at line 1541 of file bigintmat.cc.

1542{
1543 assume (col == row);
1544
1545 if (col == 1)
1546 return get(1, 1);
1547 bigintmat *m = new bigintmat(this);
1548 m->hnf();
1549 number prod = n_Init(1, basecoeffs());
1550 number temp, temp2;
1551 for (int i=1; i<=col; i++) {
1552 temp = m->get(i, i);
1555 prod = temp2;
1557 }
1558 delete m;
1559 return prod;
1560}
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 1581 of file bigintmat.cc.

1582{
1583 coeffs R = basecoeffs();
1584 hnf(); // as a starting point...
1585 if (getCoeffType(R)== n_Z) return; //wrong, need to prune!
1586
1587 int n = cols(), m = rows(), i, j, k;
1588
1589 //make sure, the matrix has enough space. We need no rows+1 columns.
1590 //The resulting Howell form will be pruned to be at most square.
1591 bigintmat * t = new bigintmat(m, m+1, R);
1592 t->copySubmatInto(this, 1, n>m ? n-m+1 : 1, m, n>m ? m : n, 1, n>m ? 2 : m+2-n );
1593 swapMatrix(t);
1594 delete t;
1595 for(i=1; i<= cols(); i++) {
1596 if (!colIsZero(i)) break;
1597 }
1598 assume (i>1);
1599 if (i>cols()) {
1600 t = new bigintmat(rows(), 0, R);
1601 swapMatrix(t);
1602 delete t;
1603 return; // zero matrix found, clearly normal.
1604 }
1605
1606 int last_zero_col = i-1;
1607 for (int c = cols(); c>0; c--) {
1608 for(i=rows(); i>0; i--) {
1609 if (!n_IsZero(view(i, c), R)) break;
1610 }
1611 if (i==0) break; // matrix SHOULD be zero from here on
1612 number a = n_Ann(view(i, c), R);
1613 addcol(last_zero_col, c, a, R);
1614 n_Delete(&a, R);
1615 for(j = c-1; j>last_zero_col; j--) {
1616 for(k=rows(); k>0; k--) {
1617 if (!n_IsZero(view(k, j), R)) break;
1618 if (!n_IsZero(view(k, last_zero_col), R)) break;
1619 }
1620 if (k==0) break;
1621 if (!n_IsZero(view(k, last_zero_col), R)) {
1622 number gcd, co1, co2, co3, co4;
1623 gcd = n_XExtGcd(view(k, last_zero_col), view(k, j), &co1, &co2, &co3, &co4, R);
1624 if (n_Equal(gcd, view(k, j), R)) {
1625 number q = n_Div(view(k, last_zero_col), gcd, R);
1626 q = n_InpNeg(q, R);
1627 addcol(last_zero_col, j, q, R);
1628 n_Delete(&q, R);
1629 } else if (n_Equal(gcd, view(k, last_zero_col), R)) {
1631 number q = n_Div(view(k, last_zero_col), gcd, R);
1632 q = n_InpNeg(q, R);
1633 addcol(last_zero_col, j, q, R);
1634 n_Delete(&q, R);
1635 } else {
1637 }
1638 n_Delete(&gcd, R);
1639 n_Delete(&co1, R);
1640 n_Delete(&co2, R);
1641 n_Delete(&co3, R);
1642 n_Delete(&co4, R);
1643 }
1644 }
1645 for(k=rows(); k>0; k--) {
1646 if (!n_IsZero(view(k, last_zero_col), R)) break;
1647 }
1648 if (k) last_zero_col--;
1649 }
1650 t = new bigintmat(rows(), cols()-last_zero_col, R);
1651 t->copySubmatInto(this, 1, last_zero_col+1, rows(), cols()-last_zero_col, 1, 1);
1652 swapMatrix(t);
1653 delete t;
1654}
void hnf()
transforms INPLACE to HNF
int colIsZero(int i)
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....
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:683
int gcd(int a, int b)

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

162 {
163 assume (rows() >= 0 && cols() >= 0);
164
165 assume (r > 0 && c > 0);
166 assume (r <= rows() && c <= cols());
167
168 const int index = ((r-1)*cols() + (c-1));
169
170 assume (index >= 0 && index < rows() * cols());
171 return index;
172 }

◆ 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 145 of file bigintmat.cc.

146{
147 assume (C == NULL || C == basecoeffs());
148
149 const int l = rows() * cols();
150
151 for (int i=0; i < l; i++)
153}

◆ inpTranspose()

void bigintmat::inpTranspose ( )

transpose in place

Definition at line 50 of file bigintmat.cc.

51{
52 int n = row,
53 m = col,
54 nm = n<m?n : m; // the min, describing the square part of the matrix
55 //CF: this is not optimal, but so far, it seems to work
56
57#define swap(_i, _j) \
58 int __i = (_i), __j=(_j); \
59 number c = v[__i]; \
60 v[__i] = v[__j]; \
61 v[__j] = c \
62
63 for (int i=0; i< nm; i++)
64 for (int j=i+1; j< nm; j++)
65 {
66 swap(i*m+j, j*n+i);
67 }
68 if (n<m)
69 for (int i=nm; i<m; i++)
70 for(int j=0; j<n; j++)
71 {
72 swap(j*n+i, i*m+j);
73 }
74 if (n>m)
75 for (int i=nm; i<n; i++)
76 for(int j=0; j<m; j++)
77 {
78 swap(i*m+j, j*n+i);
79 }
80#undef swap
81 row = m;
82 col = n;
83}

◆ isOne()

int bigintmat::isOne ( )

is matrix is identity

Definition at line 1296 of file bigintmat.cc.

1297{
1298 coeffs r = basecoeffs();
1299 if (row==col)
1300 {
1301 for (int i=1; i<=row; i++)
1302 {
1303 for (int j=1; j<=col; j++)
1304 {
1305 if (i==j)
1306 {
1307 if (!n_IsOne(view(i, j), r))
1308 return 0;
1309 }
1310 else
1311 {
1312 if (!n_IsZero(view(i,j), r))
1313 return 0;
1314 }
1315 }
1316 }
1317 }
1318 return 1;
1319}

◆ isZero()

int bigintmat::isZero ( )

Definition at line 1359 of file bigintmat.cc.

1360{
1361 for (int i=1; i<=row; i++) {
1362 for (int j=1; j<=col; j++) {
1363 if (!n_IsZero(view(i,j), basecoeffs()))
1364 return FALSE;
1365 }
1366 }
1367 return TRUE;
1368}

◆ length()

int bigintmat::length ( )
inline

Definition at line 143 of file bigintmat.h.

143{ return col*row; }

◆ mod()

void bigintmat::mod ( number p)

Reduziert komplette Matrix modulo p.

Definition at line 1912 of file bigintmat.cc.

1913{
1914 // produce the matrix in Z/pZ
1915 number tmp1, tmp2;
1916 for (int i=1; i<=row; i++)
1917 {
1918 for (int j=1; j<=col; j++)
1919 {
1920 tmp1 = get(i, j);
1921 tmp2 = n_IntMod(tmp1, p, basecoeffs());
1923 set(i, j, tmp2);
1924 }
1925 }
1926}
int p
Definition cfModGcd.cc:4086
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:632

◆ modgauss()

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

◆ modhnf()

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

computes HNF(this | p*I)

Definition at line 1828 of file bigintmat.cc.

1829{
1830 coeffs Rp = numbercoeffs(p, R); // R/pR
1831 bigintmat *m = bimChangeCoeff(this, Rp);
1832 m->howell();
1833 bigintmat *a = bimChangeCoeff(m, R);
1834 delete m;
1835 bigintmat *C = new bigintmat(rows(), rows(), R);
1836 int piv = rows(), i = a->cols();
1837 while (piv)
1838 {
1839 if (!i || n_IsZero(a->view(piv, i), R))
1840 {
1841 C->set(piv, piv, p, R);
1842 }
1843 else
1844 {
1845 C->copySubmatInto(a, 1, i, rows(), 1, 1, piv);
1846 i--;
1847 }
1848 piv--;
1849 }
1850 delete a;
1851 return C;
1852}
static coeffs numbercoeffs(number n, coeffs c)
create Z/nA of type n_Zn
Definition bigintmat.cc:21
bigintmat * bimChangeCoeff(bigintmat *a, coeffs cnew)
Liefert Kopier von Matrix a zurück, mit coeffs cnew statt den ursprünglichen.

◆ one()

void bigintmat::one ( )

Macht Matrix (Falls quadratisch) zu Einheitsmatrix.

Definition at line 1321 of file bigintmat.cc.

1322{
1323 if (row==col)
1324 {
1325 number one = n_Init(1, basecoeffs()),
1326 zero = n_Init(0, basecoeffs());
1327 for (int i=1; i<=row; i++)
1328 {
1329 for (int j=1; j<=col; j++)
1330 {
1331 if (i==j)
1332 {
1333 set(i, j, one);
1334 }
1335 else
1336 {
1337 set(i, j, zero);
1338 }
1339 }
1340 }
1341 n_Delete(&one, basecoeffs());
1343 }
1344}
void zero()
Setzt alle Einträge auf 0.

◆ operator*=()

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.

137{
139
141
143}
void inpMult(number bintop, const coeffs C=NULL)
inplace version of skalar mult. CHANGES input.
Definition bigintmat.cc:145

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

112 {
113#ifndef SING_NDEBUG
114 if((i<0)||(i>=row*col))
115 {
116 Werror("wrong bigintmat index:%d\n",i);
117 }
118 assume ( !((i<0)||(i>=row*col)) );
119#endif
120 return v[i]; // Hier sollte imho kein nlCopy rein...
121 }
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.

123 {
124#ifndef SING_NDEBUG
125 if((i<0)||(i>=row*col))
126 {
127 Werror("wrong bigintmat index:%d\n",i);
128 }
129 assume ( !((i<0)||(i>=row*col)) );
130#endif
131 return v[i];
132 }

◆ pprint()

void bigintmat::pprint ( int maxwid)

Definition at line 606 of file bigintmat.cc.

607{
608 if ((col==0) || (row==0))
609 PrintS("");
610 else
611 {
612 int * colwid = getwid(maxwid);
613 char * ps;
614 int slength = 0;
615 for (int j=0; j<col; j++)
616 slength += colwid[j]*row;
617 slength += col*row+row;
618 ps = (char*) omAlloc0(sizeof(char)*(slength));
619 int pos = 0;
620 for (int i=0; i<col*row; i++)
621 {
622 StringSetS("");
623 n_Write(v[i], basecoeffs());
624 char * ts = StringEndS();
625 const int _nl = strlen(ts);
626 int cj = i%col;
627 if (_nl > colwid[cj])
628 {
629 StringSetS("");
630 int ci = i/col;
631 StringAppend("[%d,%d]", ci+1, cj+1);
632 char * ph = StringEndS();
633 int phl = strlen(ph);
634 if (phl > colwid[cj])
635 {
636 for (int j=0; j<colwid[cj]-1; j++)
637 ps[pos+j] = ' ';
638 ps[pos+colwid[cj]-1] = '*';
639 }
640 else
641 {
642 for (int j=0; j<colwid[cj]-phl; j++)
643 ps[pos+j] = ' ';
644 for (int j=0; j<phl; j++)
645 ps[pos+colwid[cj]-phl+j] = ph[j];
646 }
647 omFree(ph);
648 }
649 else // Mit Leerzeichen auffüllen und zahl reinschreiben
650 {
651 for (int j=0; j<colwid[cj]-_nl; j++)
652 ps[pos+j] = ' ';
653 for (int j=0; j<_nl; j++)
654 ps[pos+colwid[cj]-_nl+j] = ts[j];
655 }
656 // ", " und (evtl) "\n" einfügen
657 if ((i+1)%col == 0)
658 {
659 if (i != col*row-1)
660 {
661 ps[pos+colwid[cj]] = ',';
662 ps[pos+colwid[cj]+1] = '\n';
663 pos += colwid[cj]+2;
664 }
665 }
666 else
667 {
668 ps[pos+colwid[cj]] = ',';
669 pos += colwid[cj]+1;
670 }
671
672 omFree(ts); // Hier ts zerstören
673 }
674 PrintS(ps);
675 omFree(ps);
676 }
677}
int * getwid(int maxwid)
Definition bigintmat.cc:576
#define StringAppend
Definition emacs.cc:79
#define omAlloc0(size)

◆ Print()

void bigintmat::Print ( )

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

Definition at line 439 of file bigintmat.cc.

440{
441 char * s = String();
442 PrintS(s);
443 omFree(s);
444}

◆ pseudoinv()

number bigintmat::pseudoinv ( bigintmat * a)

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

Definition at line 1411 of file bigintmat.cc.

1411 {
1412
1413 // Falls Matrix über reellen Zahlen nicht invertierbar, breche ab
1414 assume((a->rows() == row) && (a->rows() == a->cols()) && (row == col));
1415
1416 number det = this->det(); //computes the HNF, so should e reused.
1417 if ((n_IsZero(det, basecoeffs())))
1418 return det;
1419
1420 // Hänge Einheitsmatrix über Matrix und wendet HNF an. An Stelle der Einheitsmatrix steht im Ergebnis die Transformationsmatrix dazu
1421 a->one();
1422 bigintmat *m = new bigintmat(2*row, col, basecoeffs());
1423 m->concatrow(a,this);
1424 m->hnf();
1425 // Arbeite weiterhin mit der zusammengehängten Matrix
1426 // 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
1427 number diag;
1428 number temp, ttemp;
1429 for (int i=1; i<=col; i++) {
1430 diag = m->get(row+i, i);
1431 for (int j=i+1; j<=col; j++) {
1432 temp = m->get(row+i, j);
1433 m->colskalmult(j, diag, basecoeffs());
1435 m->addcol(j, i, temp, basecoeffs());
1437 }
1439 }
1440 // Falls wir nicht modulo n arbeiten, können wir die Spalten durch den ggT teilen, um die Einträge kleiner zu bekommen
1441 // Bei Z/n sparen wir uns das, da es hier sinnlos ist
1442 number g;
1443 number gcd;
1444 for (int j=1; j<=col; j++) {
1445 g = n_Init(0, basecoeffs());
1446 for (int i=1; i<=2*row; i++) {
1447 temp = m->get(i,j);
1448 gcd = n_Gcd(g, temp, basecoeffs());
1449 n_Delete(&g, basecoeffs());
1451 g = n_Copy(gcd, basecoeffs());
1452 n_Delete(&gcd, basecoeffs());
1453 }
1454 if (!(n_IsOne(g, basecoeffs())))
1455 m->colskaldiv(j, g);
1456 n_Delete(&g, basecoeffs());
1457 }
1458
1459 // 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)
1460
1461 g = n_Init(0, basecoeffs());
1462 number prod = n_Init(1, basecoeffs());
1463 for (int i=1; i<=col; i++) {
1464 gcd = n_Gcd(g, m->get(row+i, i), basecoeffs());
1465 n_Delete(&g, basecoeffs());
1466 g = n_Copy(gcd, basecoeffs());
1467 n_Delete(&gcd, basecoeffs());
1469 temp = m->get(row+i, i);
1474 }
1475 number lcm;
1476 lcm = n_Div(prod, g, basecoeffs());
1477 for (int j=1; j<=col; j++) {
1478 ttemp = m->get(row+j,j);
1480 m->colskalmult(j, temp, basecoeffs());
1483 }
1484 n_Delete(&lcm, basecoeffs());
1486
1487 number divisor = m->get(row+1, 1);
1488 m->splitrow(a, 1);
1489 delete m;
1490 n_Delete(&det, basecoeffs());
1491 return divisor;
1492}
number det()
det (via LaPlace in general, hnf for euc. rings)
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.

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

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

197 {
198 assume (C == NULL || C == basecoeffs());
199 assume (i >= 0);
200 const int l = rows() * cols();
201 assume (i<l);
202
203 if (i < l)
204 {
205 n_Delete(&(v[i]), basecoeffs()); v[i] = n;
206 }
207#ifndef SING_NDEBUG
208 else
209 {
210 Werror("wrong bigintmat index:%d\n",i);
211 }
212#endif
213 }

◆ rows()

int bigintmat::rows ( ) const
inline

Definition at line 145 of file bigintmat.h.

145{ return row; }

◆ rowskalmult()

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

... Zeile ...

Definition at line 1019 of file bigintmat.cc.

1020{
1021 if ((i>=1) && (i<=row) && (nCoeffs_are_equal(c, basecoeffs())))
1022 {
1023 number t, tmult;
1024 for (int j=1; j<=col; j++)
1025 {
1026 t = view(i, j);
1027 tmult = n_Mult(a, t, basecoeffs());
1028 rawset(i, j, tmult);
1029 }
1030 }
1031 else
1032 WerrorS("Error in rowskalmult");
1033}

◆ 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 95 of file bigintmat.cc.

96{
97 assume (C == NULL || C == basecoeffs());
98 assume (i > 0 && j > 0);
99 assume (i <= rows() && j <= cols());
100 set(index(i, j), n, C);
101}

◆ 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 87 of file bigintmat.cc.

88{
89 assume (C == NULL || C == basecoeffs());
90
92}

◆ setcol()

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

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

Definition at line 822 of file bigintmat.cc.

823{
824 if ((j>col) || (j<1))
825 {
826 WerrorS("Error in setcol: Index out of range!");
827 return;
828 }
829 if (((m->rows() != row) || (m->cols() != 1)) && ((m->rows() != 1) || (m->cols() != row)))
830 {
831 WerrorS("Error in setcol. Dimensions must agree!");
832 return;
833 }
834 if (!nCoeffs_are_equal(basecoeffs(), m->basecoeffs()))
835 {
836 nMapFunc f = n_SetMap(m->basecoeffs(), basecoeffs());
837 number t1,t2;
838 for (int i=1; i<=row; i++)
839 {
840 t1 = m->get(i-1);
841 t2 = f(t1, m->basecoeffs(),basecoeffs());
842 set(i, j, t2);
843 n_Delete(&t2, basecoeffs());
844 n_Delete(&t1, m->basecoeffs());
845 }
846 return;
847 }
848 number t1;
849 for (int i=1; i<=row; i++)
850 {
851 t1 = m->view(i-1);
852 set(i, j, t1);
853 }
854}

◆ setrow()

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

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

Definition at line 856 of file bigintmat.cc.

857{
858 if ((j>row) || (j<1))
859 {
860 WerrorS("Error in setrow: Index out of range!");
861 return;
862 }
863 if (((m->rows() != 1) || (m->cols() != col)) && ((m->rows() != col) || (m->cols() != 1)))
864 {
865 WerrorS("Error in setrow. Dimensions must agree!");
866 return;
867 }
868 if (!nCoeffs_are_equal(basecoeffs(), m->basecoeffs()))
869 {
870 nMapFunc f = n_SetMap(m->basecoeffs(), basecoeffs());
872 for (int i=1; i<=col; i++)
873 {
874 tmp1 = m->get(i-1);
875 tmp2 = f(tmp1, m->basecoeffs(),basecoeffs());
876 set(j, i, tmp2);
878 n_Delete(&tmp1, m->basecoeffs());
879 }
880 return;
881 }
882 number tmp;
883 for (int i=1; i<=col; i++)
884 {
885 tmp = m->view(i-1);
886 set(j, i, tmp);
887 }
888}

◆ simplifyContentDen()

void bigintmat::simplifyContentDen ( number * den)

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

Definition at line 2684 of file bigintmat.cc.

2685{
2686 coeffs r = basecoeffs();
2687 number g = n_Copy(*d, r), h;
2688 int n=rows()*cols();
2689 for(int i=0; i<n && !n_IsOne(g, r); i++)
2690 {
2691 h = n_Gcd(g, view(i), r);
2692 n_Delete(&g, r);
2693 g=h;
2694 }
2695 *d = n_Div(*d, g, r);
2696 if (!n_IsOne(g, r))
2697 skaldiv(g);
2698}
void skaldiv(number b)
Macht Ganzzahldivision aller Matrixeinträge mit b.

◆ skaldiv()

void bigintmat::skaldiv ( number b)

Macht Ganzzahldivision aller Matrixeinträge mit b.

Definition at line 1857 of file bigintmat.cc.

1858{
1859 number tmp1, tmp2;
1860 for (int i=1; i<=row; i++)
1861 {
1862 for (int j=1; j<=col; j++)
1863 {
1864 tmp1 = view(i, j);
1865 tmp2 = n_Div(tmp1, b, basecoeffs());
1866 rawset(i, j, tmp2);
1867 }
1868 }
1869}

◆ skalmult()

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

Multipliziert zur Matrix den Skalar b hinzu.

Definition at line 934 of file bigintmat.cc.

935{
936 if (!nCoeffs_are_equal(c, basecoeffs()))
937 {
938 WerrorS("Wrong coeffs\n");
939 return false;
940 }
941 number t1, t2;
942 if ( n_IsOne(b,c)) return true;
943 for (int i=1; i<=row; i++)
944 {
945 for (int j=1; j<=col; j++)
946 {
947 t1 = view(i, j);
948 t2 = n_Mult(t1, b, basecoeffs());
949 rawset(i, j, t2);
950 }
951 }
952 return true;
953}

◆ splitcol() [1/2]

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

... linken ... rechten ...

Definition at line 1165 of file bigintmat.cc.

1166{
1167 int ay = a->cols();
1168 int ax = a->rows();
1169 int by = b->cols();
1170 int bx = b->rows();
1171 number tmp;
1172 if (!((row == ax) && (row == bx)))
1173 {
1174 WerrorS("Error in splitcol. Dimensions must agree!");
1175 }
1176 else if (!(ay+by == col))
1177 {
1178 WerrorS("Error in splitcol. Dimensions must agree!");
1179 }
1180 else if (!(nCoeffs_are_equal(a->basecoeffs(), basecoeffs()) && nCoeffs_are_equal(b->basecoeffs(), basecoeffs())))
1181 {
1182 WerrorS("Error in splitcol. coeffs do not agree!");
1183 }
1184 else
1185 {
1186 for (int i=1; i<=ax; i++)
1187 {
1188 for (int j=1; j<=ay; j++)
1189 {
1190 tmp = view(i,j);
1191 a->set(i,j,tmp);
1192 }
1193 }
1194 for (int i=1; i<=bx; i++)
1195 {
1196 for (int j=1; j<=by; j++)
1197 {
1198 tmp = view(i,j+ay);
1199 b->set(i,j,tmp);
1200 }
1201 }
1202 }
1203}

◆ splitcol() [2/2]

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

Speichert die ersten i Spalten als Teilmatrix in a.

Definition at line 1205 of file bigintmat.cc.

1206{
1207 number tmp;
1208 if ((a->rows() != row) || (a->cols()+i-1 > col) || (i<1))
1209 {
1210 WerrorS("Error in splitcol. Dimensions must agree!");
1211 return;
1212 }
1213 if (!(nCoeffs_are_equal(a->basecoeffs(), basecoeffs())))
1214 {
1215 WerrorS("Error in splitcol. coeffs do not agree!");
1216 return;
1217 }
1218 int width = a->cols();
1219 for (int j=1; j<=width; j++)
1220 {
1221 for (int k=1; k<=row; k++)
1222 {
1223 tmp = get(k, j+i-1);
1224 a->set(k, j, tmp);
1225 n_Delete(&tmp, basecoeffs());
1226 }
1227 }
1228}

◆ 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 1123 of file bigintmat.cc.

1124{
1125 int ay = a->cols();
1126 int ax = a->rows();
1127 int by = b->cols();
1128 int bx = b->rows();
1129 number tmp;
1130 if (!(ax + bx == row))
1131 {
1132 WerrorS("Error in splitrow. Dimensions must agree!");
1133 }
1134 else if (!((col == ay) && (col == by)))
1135 {
1136 WerrorS("Error in splitrow. Dimensions must agree!");
1137 }
1138 else if (!(nCoeffs_are_equal(a->basecoeffs(), basecoeffs()) && nCoeffs_are_equal(b->basecoeffs(), basecoeffs())))
1139 {
1140 WerrorS("Error in splitrow. coeffs do not agree!");
1141 }
1142 else
1143 {
1144 for(int i = 1; i<=ax; i++)
1145 {
1146 for(int j = 1; j<=ay;j++)
1147 {
1148 tmp = get(i,j);
1149 a->set(i,j,tmp);
1150 n_Delete(&tmp, basecoeffs());
1151 }
1152 }
1153 for (int i =1; i<=bx; i++)
1154 {
1155 for (int j=1;j<=col;j++)
1156 {
1157 tmp = get(i+ax, j);
1158 b->set(i,j,tmp);
1159 n_Delete(&tmp, basecoeffs());
1160 }
1161 }
1162 }
1163}

◆ splitrow() [2/2]

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

... Zeilen ...

Definition at line 1230 of file bigintmat.cc.

1231{
1232 number tmp;
1233 if ((a->cols() != col) || (a->rows()+i-1 > row) || (i<1))
1234 {
1235 WerrorS("Error in Marco-splitrow");
1236 return;
1237 }
1238
1239 if (!(nCoeffs_are_equal(a->basecoeffs(), basecoeffs())))
1240 {
1241 WerrorS("Error in splitrow. coeffs do not agree!");
1242 return;
1243 }
1244 int height = a->rows();
1245 for (int j=1; j<=height; j++)
1246 {
1247 for (int k=1; k<=col; k++)
1248 {
1249 tmp = view(j+i-1, k);
1250 a->set(j, k, tmp);
1251 }
1252 }
1253}

◆ String()

char * bigintmat::String ( )

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

Definition at line 432 of file bigintmat.cc.

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

◆ 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 447 of file bigintmat.cc.

448{
449 if ((col==0) || (row==0))
450 return NULL;
451 else
452 {
453 int * colwid = getwid(80);
454 if (colwid == NULL)
455 {
456 WerrorS("not enough space to print bigintmat");
457 WerrorS("try string(...) for a unformatted output");
458 return NULL;
459 }
460 char * ps;
461 int slength = 0;
462 for (int j=0; j<col; j++)
463 slength += colwid[j]*row;
464 slength += col*row+row;
465 ps = (char*) omAlloc0(sizeof(char)*(slength));
466 int pos = 0;
467 for (int i=0; i<col*row; i++)
468 {
469 StringSetS("");
470 n_Write(v[i], basecoeffs());
471 char * ts = StringEndS();
472 const int _nl = strlen(ts);
473 int cj = i%col;
474 if (_nl > colwid[cj])
475 {
476 StringSetS("");
477 int ci = i/col;
478 StringAppend("[%d,%d]", ci+1, cj+1);
479 char * ph = StringEndS();
480 int phl = strlen(ph);
481 if (phl > colwid[cj])
482 {
483 for (int j=0; j<colwid[cj]-1; j++)
484 ps[pos+j] = ' ';
485 ps[pos+colwid[cj]-1] = '*';
486 }
487 else
488 {
489 for (int j=0; j<colwid[cj]-phl; j++)
490 ps[pos+j] = ' ';
491 for (int j=0; j<phl; j++)
492 ps[pos+colwid[cj]-phl+j] = ph[j];
493 }
494 omFree(ph);
495 }
496 else // Mit Leerzeichen auffüllen und zahl reinschreiben
497 {
498 for (int j=0; j<(colwid[cj]-_nl); j++)
499 ps[pos+j] = ' ';
500 for (int j=0; j<_nl; j++)
501 ps[pos+colwid[cj]-_nl+j] = ts[j];
502 }
503 // ", " und (evtl) "\n" einfügen
504 if ((i+1)%col == 0)
505 {
506 if (i != col*row-1)
507 {
508 ps[pos+colwid[cj]] = ',';
509 ps[pos+colwid[cj]+1] = '\n';
510 pos += colwid[cj]+2;
511 }
512 }
513 else
514 {
515 ps[pos+colwid[cj]] = ',';
516 pos += colwid[cj]+1;
517 }
518 omFree(ts); // Hier ts zerstören
519 }
520 return(ps);
521 // omFree(ps);
522}
523}

◆ sub()

bool bigintmat::sub ( bigintmat * b)

Subtrahiert ...

Definition at line 912 of file bigintmat.cc.

913{
914 if ((b->rows() != row) || (b->cols() != col))
915 {
916 WerrorS("Error in bigintmat::sub. Dimensions do not agree!");
917 return false;
918 }
919 if (!nCoeffs_are_equal(basecoeffs(), b->basecoeffs()))
920 {
921 WerrorS("Error in bigintmat::sub. coeffs do not agree!");
922 return false;
923 }
924 for (int i=1; i<=row; i++)
925 {
926 for (int j=1; j<=col; j++)
927 {
928 rawset(i, j, n_Sub(view(i,j), b->view(i,j), basecoeffs()));
929 }
930 }
931 return true;
932}

◆ swap()

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

swap columns i and j

Definition at line 681 of file bigintmat.cc.

682{
683 if ((i <= col) && (j <= col) && (i>0) && (j>0))
684 {
685 number tmp;
686 number t;
687 for (int k=1; k<=row; k++)
688 {
689 tmp = get(k, i);
690 t = view(k, j);
691 set(k, i, t);
692 set(k, j, tmp);
694 }
695 }
696 else
697 WerrorS("Error in swap");
698}

◆ swapMatrix()

void bigintmat::swapMatrix ( bigintmat * a)

Definition at line 1562 of file bigintmat.cc.

1563{
1564 int n = rows(), m = cols();
1565 row = a->rows();
1566 col = a->cols();
1567 number * V = v;
1568 v = a->v;
1569 a->v = V;
1570 a->row = n;
1571 a->col = m;
1572}

◆ swaprow()

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

swap rows i and j

Definition at line 700 of file bigintmat.cc.

701{
702 if ((i <= row) && (j <= row) && (i>0) && (j>0))
703 {
704 number tmp;
705 number t;
706 for (int k=1; k<=col; k++)
707 {
708 tmp = get(i, k);
709 t = view(j, k);
710 set(i, k, t);
711 set(j, k, tmp);
713 }
714 }
715 else
716 WerrorS("Error in swaprow");
717}

◆ trace()

number bigintmat::trace ( )

the trace ....

Definition at line 1494 of file bigintmat.cc.

1495{
1496 assume (col == row);
1497 number t = get(1,1),
1498 h;
1499 coeffs r = basecoeffs();
1500 for(int i=2; i<= col; i++) {
1501 h = n_Add(t, view(i,i), r);
1502 n_Delete(&t, r);
1503 t = h;
1504 }
1505 return t;
1506}

◆ transpose()

bigintmat * bigintmat::transpose ( )

Definition at line 37 of file bigintmat.cc.

38{
39 bigintmat * t = new bigintmat(col, row, basecoeffs());
40 for (int i=1; i<=row; i++)
41 {
42 for (int j=1; j<=col; j++)
43 {
44 t->set(j, i, BIMATELEM(*this,i,j));
45 }
46 }
47 return t;
48}
#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 111 of file bigintmat.cc.

112{
113 assume (i >= 0);
114 assume (i<rows()*cols());
115
116 return v[i];
117}

◆ view() [2/2]

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

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

Definition at line 127 of file bigintmat.cc.

128{
129 assume (i >= 0 && j >= 0);
130 assume (i <= rows() && j <= cols());
131
132 return view(index(i, j));
133}

◆ 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 413 of file bigintmat.cc.

414{
415 int n = cols(), m=rows();
416
417 for(int i=1; i<= m; i++)
418 {
419 for(int j=1; j< n; j++)
420 {
421 n_Write(v[(i-1)*n+j-1], basecoeffs());
422 StringAppendS(", ");
423 }
424 if (n) n_Write(v[i*n-1], basecoeffs());
425 if (i<m)
426 {
427 StringAppendS(", ");
428 }
429 }
430}

◆ zero()

void bigintmat::zero ( )

Setzt alle Einträge auf 0.

Definition at line 1346 of file bigintmat.cc.

1347{
1348 number tmp = n_Init(0, basecoeffs());
1349 for (int i=1; i<=row; i++)
1350 {
1351 for (int j=1; j<=col; j++)
1352 {
1353 set(i, j, tmp);
1354 }
1355 }
1357}

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: