My Project  UNKNOWN_GIT_VERSION
Public Member Functions | Private Attributes
bigintmat Class Reference

#include <coeffs/bigintmat.h>

Public Member Functions

 bigintmat ()
 
bigintmattranspose ()
 
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)
 
bigintmatelim (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)
 
bigintmatmodhnf (number p, coeffs c)
 computes HNF(this | p*I) More...
 
bigintmatmodgauss (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...
 
bigintmatinpmod (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
 

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.

60 : m_coeffs(NULL), v(NULL), row(1), col(0){}

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

70  : m_coeffs(n), v(NULL), row(r), col(c)
71  {
72  assume (rows() >= 0);
73  assume (cols() >= 0);
74 
75  const int l = r*c;
76 
77  if (l>0) /*(r>0) && (c>0) */
78  {
79  v = (number *)omAlloc(sizeof(number)*l);
80 
81  assume (basecoeffs() != NULL);
82  for (int i = l - 1; i>=0; i--)
83  {
84  v[i] = n_Init(0, basecoeffs());
85  }
86  }

◆ bigintmat() [3/3]

bigintmat::bigintmat ( const bigintmat m)
inline

copy constructor

Definition at line 89 of file bigintmat.h.

90  : m_coeffs(m->basecoeffs()), v(NULL), row(m->rows()), col(m->cols())
91  {
92  const int l = row*col;
93 
94  if (l > 0)
95  {
96  assume (rows() > 0);
97  assume (cols() > 0);
98 
99  assume (m->v != NULL);
100 
101  v = (number *)omAlloc(sizeof(number)*row*col);
102 
103  assume (basecoeffs() != NULL);
104 
105  for (int i = l-1; i>=0; i--)
106  {
107  v[i] = n_Copy((*m)[i], basecoeffs());
108  }
109  }

◆ ~bigintmat()

bigintmat::~bigintmat ( )
inline

canonical destructor.

Definition at line 149 of file bigintmat.h.

151  {
152  if (v!=NULL)
153  {
154  for (int i=row*col-1;i>=0; i--) { n_Delete(&(v[i]), basecoeffs()); }
155  omFreeSize((ADDRESS)v, sizeof(number)*row*col);
156  v=NULL;
157  }

Member Function Documentation

◆ add()

bool bigintmat::add ( bigintmat b)

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

Definition at line 895 of file bigintmat.cc.

896 {
897  if ((b->rows() != row) || (b->cols() != col))
898  {
899  WerrorS("Error in bigintmat::add. Dimensions do not agree!");
900  return false;
901  }
902  if (!nCoeffs_are_equal(basecoeffs(), b->basecoeffs()))
903  {
904  WerrorS("Error in bigintmat::add. coeffs do not agree!");
905  return false;
906  }
907  for (int i=1; i<=row; i++)
908  {
909  for (int j=1; j<=col; j++)
910  {
911  rawset(i, j, n_Add(b->view(i,j), view(i,j), basecoeffs()));
912  }
913  }
914  return true;
915 }

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

961 {
962  if ((i>col) || (j>col) || (i<1) || (j<1))
963  {
964  WerrorS("Error in addcol: Index out of range!");
965  return false;
966  }
967  if (!nCoeffs_are_equal(c, basecoeffs()))
968  {
969  WerrorS("Error in addcol: coeffs do not agree!");
970  return false;
971  }
972  number t1, t2, t3;
973  for (int k=1; k<=row; k++)
974  {
975  t1 = view(k, j);
976  t2 = view(k, i);
977  t3 = n_Mult(t1, a, basecoeffs());
978  n_InpAdd(t3, t2, basecoeffs());
979  rawset(k, i, t3);
980  }
981  return true;
982 }

◆ addrow()

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

... Zeile ...

Definition at line 984 of file bigintmat.cc.

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

◆ appendCol()

void bigintmat::appendCol ( bigintmat a)

horizontally join the matrices, m <- m|a

Definition at line 1084 of file bigintmat.cc.

1085 {
1086  coeffs R = basecoeffs();
1087  int ay = a->cols();
1088  int ax = a->rows();
1089  assume(row == ax);
1090 
1092 
1093  bigintmat * tmp = new bigintmat(rows(), cols() + ay, R);
1094  tmp->concatcol(this, a);
1095  this->swapMatrix(tmp);
1096  delete tmp;
1097 }

◆ basecoeffs()

coeffs bigintmat::basecoeffs ( ) const
inline

Definition at line 146 of file bigintmat.h.

146 { return row; }

◆ colIsZero()

int bigintmat::colIsZero ( int  i)

Definition at line 1578 of file bigintmat.cc.

1579 {
1580  coeffs R = basecoeffs();
1581  for(int i=1; i<=rows(); i++)
1582  if (!n_IsZero(view(i, j), R)) return FALSE;
1583  return TRUE;
1584 }

◆ cols()

int bigintmat::cols ( ) const
inline

Definition at line 144 of file bigintmat.h.

144 { return col*row; }

◆ colskaldiv()

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

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

Definition at line 1877 of file bigintmat.cc.

1878 {
1879  number tmp1, tmp2;
1880  for (int i=1; i<=row; i++)
1881  {
1882  tmp1 = view(i, j);
1883  tmp2 = n_Div(tmp1, b, basecoeffs());
1884  rawset(i, j, tmp2);
1885  }
1886 }

◆ colskalmult()

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

Multipliziert zur i-ten Spalte den Skalar a hinzu.

Definition at line 1008 of file bigintmat.cc.

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

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

1891 {
1892  number tmp1, tmp2, tmp3, tmp4;
1893  for (int i=1; i<=row; i++)
1894  {
1895  tmp1 = get(i, j);
1896  tmp2 = get(i, k);
1897  tmp3 = n_Mult(tmp1, a, basecoeffs());
1898  tmp4 = n_Mult(tmp2, b, basecoeffs());
1899  n_InpAdd(tmp3, tmp4, basecoeffs());
1900  n_Delete(&tmp4, basecoeffs());
1901 
1902  n_InpMult(tmp1, c, basecoeffs());
1903  n_InpMult(tmp2, d, basecoeffs());
1905  n_Delete(&tmp2, basecoeffs());
1906 
1907  set(i, j, tmp3);
1908  set(i, k, tmp1);
1909  n_Delete(&tmp1, basecoeffs());
1910  n_Delete(&tmp3, basecoeffs());
1911  }
1912 }

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

◆ concatcol()

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

Definition at line 1099 of file bigintmat.cc.

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

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

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

◆ content()

number bigintmat::content ( )

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

Definition at line 2676 of file bigintmat.cc.

2677 {
2678  coeffs r = basecoeffs();
2679  number g = get(1,1), h;
2680  int n=rows()*cols();
2681  for(int i=1; i<n && !n_IsOne(g, r); i++)
2682  {
2683  h = n_Gcd(g, view(i), r);
2684  n_Delete(&g, r);
2685  g=h;
2686  }
2687  return g;
2688 }

◆ copy()

bool bigintmat::copy ( bigintmat b)

Kopiert Einträge von b auf Bigintmat.

Definition at line 1260 of file bigintmat.cc.

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

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

1289 {
1290  number t1;
1291  for (int i=1; i<=n; i++)
1292  {
1293  for (int j=1; j<=m; j++)
1294  {
1295  t1 = B->view(a+i-1, b+j-1);
1296  set(c+i-1, d+j-1, t1);
1297  }
1298  }
1299 }

◆ det()

number bigintmat::det ( )

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

Definition at line 1513 of file bigintmat.cc.

1514 {
1515  assume (row==col);
1516 
1517  if (col == 1)
1518  return get(1, 1);
1519  // should work as well in Z/pZ of type n_Zp?
1520  // relies on XExtGcd and the other euc. functinos.
1521  if ( getCoeffType(basecoeffs())== n_Z || getCoeffType(basecoeffs() )== n_Zn) {
1522  return hnfdet();
1523  }
1524  number sum = n_Init(0, basecoeffs());
1525  number t1, t2, t3, t4;
1526  bigintmat *b;
1527  for (int i=1; i<=row; i++) {
1528  b = elim(i, 1);
1529  t1 = get(i, 1);
1530  t2 = b->det();
1531  t3 = n_Mult(t1, t2, basecoeffs());
1532  t4 = n_Copy(sum, basecoeffs());
1533  n_Delete(&sum, basecoeffs());
1534  if ((i+1)>>1<<1==(i+1))
1535  sum = n_Add(t4, t3, basecoeffs());
1536  else
1537  sum = n_Sub(t4, t3, basecoeffs());
1538  n_Delete(&t1, basecoeffs());
1539  n_Delete(&t2, basecoeffs());
1540  n_Delete(&t3, basecoeffs());
1541  n_Delete(&t4, basecoeffs());
1542  }
1543  return sum;
1544 }

◆ elim()

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

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

Definition at line 1382 of file bigintmat.cc.

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

◆ extendCols()

void bigintmat::extendCols ( int  i)

append i zero-columns to the matrix

Definition at line 1077 of file bigintmat.cc.

1078 {
1079  bigintmat * tmp = new bigintmat(rows(), i, basecoeffs());
1080  appendCol(tmp);
1081  delete tmp;
1082 }

◆ findcolnonzero()

int bigintmat::findcolnonzero ( int  j)

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

Definition at line 736 of file bigintmat.cc.

737 {
738  for (int i=row; i>=1; i--)
739  {
740  if (!n_IsZero(view(i,j), basecoeffs()))
741  {
742  return i;
743  }
744  }
745  return 0;
746 }

◆ findnonzero()

int bigintmat::findnonzero ( int  i)

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

Definition at line 724 of file bigintmat.cc.

725 {
726  for (int j=1; j<=col; j++)
727  {
728  if (!n_IsZero(view(i,j), basecoeffs()))
729  {
730  return j;
731  }
732  }
733  return 0;
734 }

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

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

749 {
750  assume((j<=col) && (j>=1));
751  if (((a->rows() != row) || (a->cols() != 1)) && ((a->rows() != 1) || (a->cols() != row)))
752  {
753  assume(0);
754  WerrorS("Error in getcol. Dimensions must agree!");
755  return;
756  }
758  {
760  number t1, t2;
761  for (int i=1; i<=row;i++)
762  {
763  t1 = get(i,j);
764  t2 = f(t1, basecoeffs(), a->basecoeffs());
765  a->set(i-1,t1);
766  n_Delete(&t1, basecoeffs());
767  n_Delete(&t2, a->basecoeffs());
768  }
769  return;
770  }
771  number t1;
772  for (int i=1; i<=row;i++)
773  {
774  t1 = view(i,j);
775  a->set(i-1,t1);
776  }
777 }

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

780 {
781  number t1;
782  for(int ii=0; ii< no; ii++)
783  {
784  for (int i=1; i<=row;i++)
785  {
786  t1 = view(i, ii+j);
787  a->set(i, ii+1, t1);
788  }
789  }
790 }

◆ getrow()

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

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

Definition at line 792 of file bigintmat.cc.

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

◆ getwid()

int * bigintmat::getwid ( int  maxwid)

Definition at line 580 of file bigintmat.cc.

581 {
582  int const c = /*2**/(col-1)+1;
583  int * wv = (int*)omAlloc(sizeof(int)*col*row);
584  int * cwv = (int*)omAlloc(sizeof(int)*col);
585  for (int j=0; j<col; j++)
586  {
587  cwv[j] = 0;
588  for (int i=0; i<row; i++)
589  {
590  StringSetS("");
591  n_Write(v[col*i+j], basecoeffs());
592  char * tmp = StringEndS();
593  const int _nl = strlen(tmp);
594  wv[col*i+j] = _nl;
595  if (_nl > cwv[j])
596  cwv[j]=_nl;
597  omFree(tmp);
598  }
599  }
600 
601  // Groesse verkleinern, bis < maxwid
602  if (intArrSum(cwv, col)+c > maxwid)
603  {
604  int j = findLongest(cwv, col);
605  cwv[j] = getShorter(wv, cwv[j], j, col, row);
606  }
607  omFree(wv);
608  return cwv;
609 }

◆ hnf()

void bigintmat::hnf ( )

transforms INPLACE to HNF

Definition at line 1661 of file bigintmat.cc.

1662 {
1663  // Laufen von unten nach oben und von links nach rechts
1664  // CF: TODO: for n_Z: write a recursive version. This one will
1665  // have exponential blow-up. Look at Michianchio
1666  // Alternatively, do p-adic det and modular method
1667 
1668 #if 0
1669  char * s;
1670  ::PrintS("mat over Z is \n");
1671  ::Print("%s\n", s = nCoeffString(basecoeffs()));
1672  omFree(s);
1673  Print();
1674  ::Print("\n(%d x %d)\n", rows(), cols());
1675 #endif
1676 
1677  int i = rows();
1678  int j = cols();
1679  number q = n_Init(0, basecoeffs());
1680  number one = n_Init(1, basecoeffs());
1681  number minusone = n_Init(-1, basecoeffs());
1682  number tmp1 = n_Init(0, basecoeffs());
1683  number tmp2 = n_Init(0, basecoeffs());
1684  number co1, co2, co3, co4;
1685  number ggt = n_Init(0, basecoeffs());
1686 
1687  while ((i>0) && (j>0))
1688  {
1689  // Falls erstes Nicht-Null-Element in Zeile i nicht existiert, oder hinter Spalte j vorkommt, gehe in nächste Zeile
1690  if ((findnonzero(i)==0) || (findnonzero(i)>j))
1691  {
1692  i--;
1693  }
1694  else
1695  {
1696  // Laufe von links nach rechts durch die Zeile:
1697  for (int l=1; l<=j-1; l++)
1698  {
1699  n_Delete(&tmp1, basecoeffs());
1700  tmp1 = get(i, l);
1701  // Falls Eintrag (im folgenden x genannt) gleich 0, gehe eine Spalte weiter. Ansonsten...
1702  if (!n_IsZero(tmp1, basecoeffs()))
1703  {
1704  n_Delete(&tmp2, basecoeffs());
1705  tmp2 = get(i, l+1);
1706  // Falls Eintrag (i.f. y g.) rechts daneben gleich 0, tausche beide Spalten, sonst...
1707  if (!n_IsZero(tmp2, basecoeffs()))
1708  {
1709  n_Delete(&ggt, basecoeffs());
1710  ggt = n_XExtGcd(tmp1, tmp2, &co1, &co2, &co3, &co4, basecoeffs());
1711  // 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:
1712  if (n_Equal(tmp1, ggt, basecoeffs()))
1713  {
1714  swap(l, l+1);
1715  n_Delete(&q, basecoeffs());
1716  q = n_Div(tmp2, ggt, basecoeffs());
1717  q = n_InpNeg(q, basecoeffs());
1718  // Dann addiere das -q-fache der (neuen) rechten Spalte zur linken dazu. Damit erhalten wir die gewünschte 0
1719 
1720  addcol(l, l+1, q, basecoeffs());
1721  n_Delete(&q, basecoeffs());
1722  }
1723  else if (n_Equal(tmp1, minusone, basecoeffs()))
1724  {
1725  // 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
1726  // Die Berechnung von q (=y/ggt) entfällt, da ggt=1
1727  swap(l, l+1);
1728  colskalmult(l+1, minusone, basecoeffs());
1729  tmp2 = n_InpNeg(tmp2, basecoeffs());
1730  addcol(l, l+1, tmp2, basecoeffs());
1731  }
1732  else
1733  {
1734  // CF: use the 2x2 matrix (co1, co2)(co3, co4) to
1735  // get the gcd in position and the 0 in the other:
1736 #ifdef CF_DEB
1737  ::PrintS("applying trafo\n");
1738  StringSetS("");
1739  n_Write(co1, basecoeffs()); StringAppendS("\t");
1740  n_Write(co2, basecoeffs()); StringAppendS("\t");
1741  n_Write(co3, basecoeffs()); StringAppendS("\t");
1742  n_Write(co4, basecoeffs()); StringAppendS("\t");
1743  ::Print("%s\nfor l=%d\n", StringEndS(), l);
1744  {char * s = String();
1745  ::Print("to %s\n", s);omFree(s);};
1746 #endif
1747  coltransform(l, l+1, co3, co4, co1, co2);
1748 #ifdef CF_DEB
1749  {char * s = String();
1750  ::Print("gives %s\n", s);}
1751 #endif
1752  }
1753  n_Delete(&co1, basecoeffs());
1754  n_Delete(&co2, basecoeffs());
1755  n_Delete(&co3, basecoeffs());
1756  n_Delete(&co4, basecoeffs());
1757  }
1758  else
1759  {
1760  swap(l, l+1);
1761  }
1762  // Dann betrachte die vormals rechte Spalte als neue linke, und die rechts daneben als neue rechte.
1763  }
1764  }
1765 
1766  #ifdef HAVE_RINGS
1767  // normalize by units:
1768  if (!n_IsZero(view(i, j), basecoeffs()))
1769  {
1770  number u = n_GetUnit(view(i, j), basecoeffs());
1771  if (!n_IsOne(u, basecoeffs()))
1772  {
1773  colskaldiv(j, u);
1774  }
1775  n_Delete(&u, basecoeffs());
1776  }
1777  #endif
1778  // Zum Schluss mache alle Einträge rechts vom Diagonalelement betragsmäßig kleiner als dieses
1779  for (int l=j+1; l<=col; l++)
1780  {
1781  n_Delete(&q, basecoeffs());
1782  q = n_QuotRem(view(i, l), view(i, j), NULL, basecoeffs());
1783  q = n_InpNeg(q, basecoeffs());
1784  addcol(l, j, q, basecoeffs());
1785  }
1786  i--;
1787  j--;
1788  // Dann betrachte die Zeile darüber und gehe dort wie vorher vor
1789  }
1790  }
1791  n_Delete(&q, basecoeffs());
1792  n_Delete(&tmp1, basecoeffs());
1793  n_Delete(&tmp2, basecoeffs());
1794  n_Delete(&ggt, basecoeffs());
1795  n_Delete(&one, basecoeffs());
1796  n_Delete(&minusone, basecoeffs());
1797 
1798 #if 0
1799  ::PrintS("hnf over Z is \n");
1800  Print();
1801  ::Print("\n(%d x %d)\n", rows(), cols());
1802 #endif
1803 }

◆ hnfdet()

number bigintmat::hnfdet ( )

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

Definition at line 1546 of file bigintmat.cc.

1547 {
1548  assume (col == row);
1549 
1550  if (col == 1)
1551  return get(1, 1);
1552  bigintmat *m = new bigintmat(this);
1553  m->hnf();
1554  number prod = n_Init(1, basecoeffs());
1555  number temp, temp2;
1556  for (int i=1; i<=col; i++) {
1557  temp = m->get(i, i);
1558  temp2 = n_Mult(temp, prod, basecoeffs());
1559  n_Delete(&prod, basecoeffs());
1560  prod = temp2;
1561  n_Delete(&temp, basecoeffs());
1562  }
1563  delete m;
1564  return prod;
1565 }

◆ howell()

void bigintmat::howell ( )

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

Definition at line 1586 of file bigintmat.cc.

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

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

163  {
164  assume (rows() >= 0 && cols() >= 0);
165 
166  assume (r > 0 && c > 0);
167  assume (r <= rows() && c <= cols());
168 
169  const int index = ((r-1)*cols() + (c-1));
170 
171  assume (index >= 0 && index < rows() * cols());
172  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 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++)
152  n_InpMult(v[i], bintop, basecoeffs());
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 1301 of file bigintmat.cc.

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

◆ isZero()

int bigintmat::isZero ( )

Definition at line 1364 of file bigintmat.cc.

1365 {
1366  for (int i=1; i<=row; i++) {
1367  for (int j=1; j<=col; j++) {
1368  if (!n_IsZero(view(i,j), basecoeffs()))
1369  return FALSE;
1370  }
1371  }
1372  return TRUE;
1373 }

◆ length()

int bigintmat::length ( )
inline

Definition at line 143 of file bigintmat.h.

144 { return col*row; }

◆ mod()

void bigintmat::mod ( number  p)

Reduziert komplette Matrix modulo p.

Definition at line 1917 of file bigintmat.cc.

1918 {
1919  // produce the matrix in Z/pZ
1920  number tmp1, tmp2;
1921  for (int i=1; i<=row; i++)
1922  {
1923  for (int j=1; j<=col; j++)
1924  {
1925  tmp1 = get(i, j);
1926  tmp2 = n_IntMod(tmp1, p, basecoeffs());
1927  n_Delete(&tmp1, basecoeffs());
1928  set(i, j, tmp2);
1929  }
1930  }
1931 }

◆ modgauss()

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

◆ modhnf()

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

computes HNF(this | p*I)

Definition at line 1833 of file bigintmat.cc.

1834 {
1835  coeffs Rp = numbercoeffs(p, R); // R/pR
1836  bigintmat *m = bimChangeCoeff(this, Rp);
1837  m->howell();
1838  bigintmat *a = bimChangeCoeff(m, R);
1839  delete m;
1840  bigintmat *C = new bigintmat(rows(), rows(), R);
1841  int piv = rows(), i = a->cols();
1842  while (piv)
1843  {
1844  if (!i || n_IsZero(a->view(piv, i), R))
1845  {
1846  C->set(piv, piv, p, R);
1847  }
1848  else
1849  {
1850  C->copySubmatInto(a, 1, i, rows(), 1, 1, piv);
1851  i--;
1852  }
1853  piv--;
1854  }
1855  delete a;
1856  return C;
1857 }

◆ one()

void bigintmat::one ( )

Macht Matrix (Falls quadratisch) zu Einheitsmatrix.

Definition at line 1326 of file bigintmat.cc.

1327 {
1328  if (row==col)
1329  {
1330  number one = n_Init(1, basecoeffs()),
1331  zero = n_Init(0, basecoeffs());
1332  for (int i=1; i<=row; i++)
1333  {
1334  for (int j=1; j<=col; j++)
1335  {
1336  if (i==j)
1337  {
1338  set(i, j, one);
1339  }
1340  else
1341  {
1342  set(i, j, zero);
1343  }
1344  }
1345  }
1346  n_Delete(&one, basecoeffs());
1347  n_Delete(&zero, basecoeffs());
1348  }
1349 }

◆ 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 {
138  number iop = n_Init(intop, basecoeffs());
139 
140  inpMult(iop, basecoeffs());
141 
142  n_Delete(&iop, basecoeffs());
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.

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

◆ operator[]() [2/2]

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

Definition at line 122 of file bigintmat.h.

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

◆ pprint()

void bigintmat::pprint ( int  maxwid)

Definition at line 611 of file bigintmat.cc.

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

◆ Print()

void bigintmat::Print ( )

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

Definition at line 443 of file bigintmat.cc.

444 {
445  char * s = String();
446  PrintS(s);
447  omFree(s);
448 }

◆ pseudoinv()

number bigintmat::pseudoinv ( bigintmat a)

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

Definition at line 1416 of file bigintmat.cc.

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

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

218  {
219  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.

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

◆ rows()

int bigintmat::rows ( ) const
inline

Definition at line 145 of file bigintmat.h.

145 { return col; }

◆ rowskalmult()

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

... Zeile ...

Definition at line 1024 of file bigintmat.cc.

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

◆ 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 
91  rawset(i, n_Copy(n, basecoeffs()), basecoeffs());
92 }

◆ setcol()

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

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

Definition at line 827 of file bigintmat.cc.

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

◆ setrow()

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

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

Definition at line 861 of file bigintmat.cc.

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

◆ simplifyContentDen()

void bigintmat::simplifyContentDen ( number *  den)

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

Definition at line 2689 of file bigintmat.cc.

2690 {
2691  coeffs r = basecoeffs();
2692  number g = n_Copy(*d, r), h;
2693  int n=rows()*cols();
2694  for(int i=0; i<n && !n_IsOne(g, r); i++)
2695  {
2696  h = n_Gcd(g, view(i), r);
2697  n_Delete(&g, r);
2698  g=h;
2699  }
2700  *d = n_Div(*d, g, r);
2701  if (!n_IsOne(g, r))
2702  skaldiv(g);
2703 }

◆ skaldiv()

void bigintmat::skaldiv ( number  b)

Macht Ganzzahldivision aller Matrixeinträge mit b.

Definition at line 1862 of file bigintmat.cc.

1863 {
1864  number tmp1, tmp2;
1865  for (int i=1; i<=row; i++)
1866  {
1867  for (int j=1; j<=col; j++)
1868  {
1869  tmp1 = view(i, j);
1870  tmp2 = n_Div(tmp1, b, basecoeffs());
1871  rawset(i, j, tmp2);
1872  }
1873  }
1874 }

◆ skalmult()

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

Multipliziert zur Matrix den Skalar b hinzu.

Definition at line 939 of file bigintmat.cc.

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

◆ splitcol() [1/2]

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

... linken ... rechten ...

Definition at line 1170 of file bigintmat.cc.

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

◆ splitcol() [2/2]

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

Speichert die ersten i Spalten als Teilmatrix in a.

Definition at line 1210 of file bigintmat.cc.

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

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

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

◆ splitrow() [2/2]

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

... Zeilen ...

Definition at line 1235 of file bigintmat.cc.

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

◆ String()

char * bigintmat::String ( )

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

Definition at line 436 of file bigintmat.cc.

437 {
438  StringSetS("");
439  Write();
440  return StringEndS();
441 }

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

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

◆ sub()

bool bigintmat::sub ( bigintmat b)

Subtrahiert ...

Definition at line 917 of file bigintmat.cc.

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

◆ swap()

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

swap columns i and j

Definition at line 686 of file bigintmat.cc.

687 {
688  if ((i <= col) && (j <= col) && (i>0) && (j>0))
689  {
690  number tmp;
691  number t;
692  for (int k=1; k<=row; k++)
693  {
694  tmp = get(k, i);
695  t = view(k, j);
696  set(k, i, t);
697  set(k, j, tmp);
698  n_Delete(&tmp, basecoeffs());
699  }
700  }
701  else
702  WerrorS("Error in swap");
703 }

◆ swapMatrix()

void bigintmat::swapMatrix ( bigintmat a)

Definition at line 1567 of file bigintmat.cc.

1568 {
1569  int n = rows(), m = cols();
1570  row = a->rows();
1571  col = a->cols();
1572  number * V = v;
1573  v = a->v;
1574  a->v = V;
1575  a->row = n;
1576  a->col = m;
1577 }

◆ swaprow()

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

swap rows i and j

Definition at line 705 of file bigintmat.cc.

706 {
707  if ((i <= row) && (j <= row) && (i>0) && (j>0))
708  {
709  number tmp;
710  number t;
711  for (int k=1; k<=col; k++)
712  {
713  tmp = get(i, k);
714  t = view(j, k);
715  set(i, k, t);
716  set(j, k, tmp);
717  n_Delete(&tmp, basecoeffs());
718  }
719  }
720  else
721  WerrorS("Error in swaprow");
722 }

◆ trace()

number bigintmat::trace ( )

the trace ....

Definition at line 1499 of file bigintmat.cc.

1500 {
1501  assume (col == row);
1502  number t = get(1,1),
1503  h;
1504  coeffs r = basecoeffs();
1505  for(int i=2; i<= col; i++) {
1506  h = n_Add(t, view(i,i), r);
1507  n_Delete(&t, r);
1508  t = h;
1509  }
1510  return t;
1511 }

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

◆ 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  StringAppendS("[ ");
418  for(int i=1; i<= m; i++)
419  {
420  StringAppendS("[ ");
421  for(int j=1; j< n; j++)
422  {
423  n_Write(v[(i-1)*n+j-1], basecoeffs());
424  StringAppendS(", ");
425  }
426  if (n) n_Write(v[i*n-1], basecoeffs());
427  StringAppendS(" ]");
428  if (i<m)
429  {
430  StringAppendS(", ");
431  }
432  }
433  StringAppendS(" ] ");
434 }

◆ zero()

void bigintmat::zero ( )

Setzt alle Einträge auf 0.

Definition at line 1351 of file bigintmat.cc.

1352 {
1353  number tmp = n_Init(0, basecoeffs());
1354  for (int i=1; i<=row; i++)
1355  {
1356  for (int j=1; j<=col; j++)
1357  {
1358  set(i, j, tmp);
1359  }
1360  }
1361  n_Delete(&tmp,basecoeffs());
1362 }

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:
getCoeffType
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:420
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:627
bigintmat::appendCol
void appendCol(bigintmat *a)
horizontally join the matrices, m <- m|a
Definition: bigintmat.cc:1084
si_min
static int si_min(const int a, const int b)
Definition: auxiliary.h:139
findLongest
static int findLongest(int *a, int length)
Definition: bigintmat.cc:537
FALSE
#define FALSE
Definition: auxiliary.h:94
n_Zn
only used if HAVE_RINGS is defined
Definition: coeffs.h:44
bigintmat::elim
bigintmat * elim(int i, int j)
Liefert Streichungsmatrix (i-te Zeile und j-te Spalte gestrichen) zurück.
Definition: bigintmat.cc:1382
StringAppendS
void StringAppendS(const char *st)
Definition: reporter.cc:106
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:960
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:694
j
int j
Definition: facHensel.cc:105
f
FILE * f
Definition: checklibs.c:9
omFree
#define omFree(addr)
Definition: omAllocDecl.h:259
k
int k
Definition: cfEzgcd.cc:92
bigintmat::String
char * String()
IO: String returns a singular string containing the matrix, needs freeing afterwards.
Definition: bigintmat.cc:436
bigintmat::col
int col
Definition: bigintmat.h:56
bigintmat::concatcol
void concatcol(bigintmat *a, bigintmat *b)
Definition: bigintmat.cc:1099
bigintmat
Definition: bigintmat.h:50
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:640
bigintmat::Write
void Write()
IO: writes the matrix into the current internal string buffer which must be started/ allocated before...
Definition: bigintmat.cc:413
intArrSum
static int intArrSum(int *a, int length)
Definition: bigintmat.cc:529
bigintmat::zero
void zero()
Setzt alle Einträge auf 0.
Definition: bigintmat.cc:1351
ADDRESS
void * ADDRESS
Definition: auxiliary.h:133
bigintmat::inpMult
void inpMult(number bintop, const coeffs C=NULL)
inplace version of skalar mult. CHANGES input.
Definition: bigintmat.cc:145
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:980
bigintmat::view
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:127
prod
fq_nmod_poly_t prod
Definition: facHensel.cc:95
bigintmat::m_coeffs
coeffs m_coeffs
Definition: bigintmat.h:53
g
g
Definition: cfModGcd.cc:4031
n_Delete
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:454
bigintmat::rows
int rows() const
Definition: bigintmat.h:145
bigintmat::basecoeffs
coeffs basecoeffs() const
Definition: bigintmat.h:146
nCoeffs_are_equal
bool nCoeffs_are_equal(coeffs r, coeffs s)
Definition: bigintmat.cc:2646
n_IsZero
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
Definition: coeffs.h:463
StringEndS
char * StringEndS()
Definition: reporter.cc:150
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:510
n_IsOne
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff 'n' represents the one element.
Definition: coeffs.h:467
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:531
bigintmat::one
void one()
Macht Matrix (Falls quadratisch) zu Einheitsmatrix.
Definition: bigintmat.cc:1326
b
CanonicalForm b
Definition: cfModGcd.cc:4044
n_QuotRem
static FORCE_INLINE number n_QuotRem(number a, number b, number *q, const coeffs r)
Definition: coeffs.h:702
bigintmat::colskalmult
void colskalmult(int i, number a, coeffs c)
Multipliziert zur i-ten Spalte den Skalar a hinzu.
Definition: bigintmat.cc:1008
bigintmat::det
number det()
det (via LaPlace in general, hnf for euc. rings)
Definition: bigintmat.cc:1513
bigintmat::hnf
void hnf()
transforms INPLACE to HNF
Definition: bigintmat.cc:1661
bigintmat::skaldiv
void skaldiv(number b)
Macht Ganzzahldivision aller Matrixeinträge mit b.
Definition: bigintmat.cc:1862
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:655
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:645
TRUE
#define TRUE
Definition: auxiliary.h:98
i
int i
Definition: cfEzgcd.cc:125
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:700
nMapFunc
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:72
bigintmat::findnonzero
int findnonzero(int i)
find index of 1st non-zero entry in row i
Definition: bigintmat.cc:724
n_Write
static FORCE_INLINE void n_Write(number n, const coeffs r, const BOOLEAN bShortOut=TRUE)
Definition: coeffs.h:590
bigintmat::bigintmat
bigintmat()
Definition: bigintmat.h:59
PrintS
void PrintS(const char *s)
Definition: reporter.cc:283
omFreeSize
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:258
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:95
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
h
static Poly * h
Definition: janet.cc:972
coeffs
n_Z
only used if HAVE_RINGS is defined
Definition: coeffs.h:43
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:635
omAlloc
#define omAlloc(size)
Definition: omAllocDecl.h:208
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:537
bigintmat::Print
void Print()
IO: simply prints the matrix to the current output (screen?)
Definition: bigintmat.cc:443
numbercoeffs
static coeffs numbercoeffs(number n, coeffs c)
create Z/nA of type n_Zn
Definition: bigintmat.cc:21
tmp1
CFList tmp1
Definition: facFqBivar.cc:70
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:556
bigintmat::cols
int cols() const
Definition: bigintmat.h:144
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:668
bigintmat::get
number get(int i, int j) const
get a copy of an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:119
bigintmat::colIsZero
int colIsZero(int i)
Definition: bigintmat.cc:1578
StringSetS
void StringSetS(const char *st)
Definition: reporter.cc:127
getShorter
static int getShorter(int *a, int l, int j, int cols, int rows)
Definition: bigintmat.cc:552
B
b *CanonicalForm B
Definition: facBivar.cc:52
bigintmat::colskaldiv
void colskaldiv(int j, number b)
Macht Ganzzahldivision aller j-ten Spalteneinträge mit b.
Definition: bigintmat.cc:1877
Werror
void Werror(const char *fmt,...)
Definition: reporter.cc:188
bigintmat::swap
void swap(int i, int j)
swap columns i and j
Definition: bigintmat.cc:686
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_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:493
bigintmat::hnfdet
number hnfdet()
det via HNF Primzahlen als long long int, müssen noch in number umgewandelt werden?
Definition: bigintmat.cc:1546
n_Copy
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of 'n'
Definition: coeffs.h:450
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:685
WerrorS
void WerrorS(const char *s)
Definition: feFopen.cc:24
m
int m
Definition: cfEzgcd.cc:121
assume
#define assume(x)
Definition: mod2.h:384
NULL
#define NULL
Definition: omList.c:9
BIMATELEM
#define BIMATELEM(M, I, J)
Definition: bigintmat.h:133
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:1288
l
int l
Definition: cfEzgcd.cc:93
lcm
int lcm(unsigned long *l, unsigned long *a, unsigned long *b, unsigned long p, int dega, int degb)
Definition: minpoly.cc:709
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:1890
R
#define R
Definition: sirandom.c:26
gcd
int gcd(int a, int b)
Definition: walkSupport.cc:836
StringAppend
#define StringAppend
Definition: emacs.cc:78
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:459
p
int p
Definition: cfModGcd.cc:4019
s
const CanonicalForm int s
Definition: facAbsFact.cc:55
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:614
bimChangeCoeff
bigintmat * bimChangeCoeff(bigintmat *a, coeffs cnew)
Liefert Kopier von Matrix a zurück, mit coeffs cnew statt den ursprünglichen.
Definition: bigintmat.cc:1805
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:720
tmp2
CFList tmp2
Definition: facFqBivar.cc:70
bigintmat::row
int row
Definition: bigintmat.h:55
omAlloc0
#define omAlloc0(size)
Definition: omAllocDecl.h:209
bigintmat::getwid
int * getwid(int maxwid)
Definition: bigintmat.cc:580
bigintmat::v
number * v
Definition: bigintmat.h:54
bigintmat::swapMatrix
void swapMatrix(bigintmat *a)
Definition: bigintmat.cc:1567