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

: no reference counting here!

Definition at line 51 of file bigintmat.h.

Constructor & Destructor Documentation

§ bigintmat() [1/3]

bigintmat::bigintmat ( )
inline

Definition at line 60 of file bigintmat.h.

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

§ 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 70 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  }
87  }
int rows() 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
int row
Definition: bigintmat.h:56
#define omAlloc(size)
Definition: omAllocDecl.h:210
const ring r
Definition: syzextra.cc:208
#define assume(x)
Definition: mod2.h:403
int cols() const
Definition: bigintmat.h:145
int i
Definition: cfEzgcd.cc:123
int col
Definition: bigintmat.h:57
number * v
Definition: bigintmat.h:55
#define NULL
Definition: omList.c:10
coeffs basecoeffs() const
Definition: bigintmat.h:147
coeffs m_coeffs
Definition: bigintmat.h:54
int l
Definition: cfEzgcd.cc:94

§ bigintmat() [3/3]

bigintmat::bigintmat ( const bigintmat m)
inline

copy constructor

Definition at line 90 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  }
110  }
int rows() const
Definition: bigintmat.h:146
int row
Definition: bigintmat.h:56
#define omAlloc(size)
Definition: omAllocDecl.h:210
#define assume(x)
Definition: mod2.h:403
int cols() const
Definition: bigintmat.h:145
int i
Definition: cfEzgcd.cc:123
int col
Definition: bigintmat.h:57
number * v
Definition: bigintmat.h:55
#define NULL
Definition: omList.c:10
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of &#39;n&#39;
Definition: coeffs.h:455
coeffs basecoeffs() const
Definition: bigintmat.h:147
coeffs m_coeffs
Definition: bigintmat.h:54
int l
Definition: cfEzgcd.cc:94

§ ~bigintmat()

bigintmat::~bigintmat ( )
inline

canonical destructor.

Definition at line 150 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  }
158  }
int row
Definition: bigintmat.h:56
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
void * ADDRESS
Definition: auxiliary.h:116
int i
Definition: cfEzgcd.cc:123
int col
Definition: bigintmat.h:57
number * v
Definition: bigintmat.h:55
#define NULL
Definition: omList.c:10
coeffs basecoeffs() const
Definition: bigintmat.h:147
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:459

Member Function Documentation

§ add()

bool bigintmat::add ( bigintmat b)

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

Definition at line 904 of file bigintmat.cc.

905 {
906  if ((b->rows() != row) || (b->cols() != col))
907  {
908  WerrorS("Error in bigintmat::add. Dimensions do not agree!");
909  return false;
910  }
912  {
913  WerrorS("Error in bigintmat::add. coeffs do not agree!");
914  return false;
915  }
916  for (int i=1; i<=row; i++)
917  {
918  for (int j=1; j<=col; j++)
919  {
920  rawset(i, j, n_Add(b->view(i,j), view(i,j), basecoeffs()));
921  }
922  }
923  return true;
924 }
int rows() const
Definition: bigintmat.h:146
int row
Definition: bigintmat.h:56
void WerrorS(const char *s)
Definition: feFopen.cc:24
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:197
int j
Definition: myNF.cc:70
static FORCE_INLINE number n_Add(number a, number b, const coeffs r)
return the sum of &#39;a&#39; and &#39;b&#39;, i.e., a+b
Definition: coeffs.h:660
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:128
int cols() const
Definition: bigintmat.h:145
int i
Definition: cfEzgcd.cc:123
int col
Definition: bigintmat.h:57
coeffs basecoeffs() const
Definition: bigintmat.h:147
bool nCoeffs_are_equal(coeffs r, coeffs s)
Definition: bigintmat.cc:2655

§ 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 969 of file bigintmat.cc.

970 {
971  if ((i>col) || (j>col) || (i<1) || (j<1))
972  {
973  WerrorS("Error in addcol: Index out of range!");
974  return false;
975  }
976  if (!nCoeffs_are_equal(c, basecoeffs()))
977  {
978  WerrorS("Error in addcol: coeffs do not agree!");
979  return false;
980  }
981  number t1, t2, t3;
982  for (int k=1; k<=row; k++)
983  {
984  t1 = view(k, j);
985  t2 = view(k, i);
986  t3 = n_Mult(t1, a, basecoeffs());
987  n_InpAdd(t3, t2, basecoeffs());
988  rawset(k, i, t3);
989  }
990  return true;
991 }
const poly a
Definition: syzextra.cc:212
int row
Definition: bigintmat.h:56
void WerrorS(const char *s)
Definition: feFopen.cc:24
int k
Definition: cfEzgcd.cc:93
static FORCE_INLINE void n_InpAdd(number &a, number b, const coeffs r)
addition of &#39;a&#39; and &#39;b&#39;; replacement of &#39;a&#39; by the sum a+b
Definition: coeffs.h:650
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:197
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of &#39;a&#39; and &#39;b&#39;, i.e., a*b
Definition: coeffs.h:640
int j
Definition: myNF.cc:70
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:128
int i
Definition: cfEzgcd.cc:123
int col
Definition: bigintmat.h:57
coeffs basecoeffs() const
Definition: bigintmat.h:147
bool nCoeffs_are_equal(coeffs r, coeffs s)
Definition: bigintmat.cc:2655

§ addrow()

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

... Zeile ...

Definition at line 993 of file bigintmat.cc.

994 {
995  if ((i>row) || (j>row) || (i<1) || (j<1))
996  {
997  WerrorS("Error in addrow: Index out of range!");
998  return false;
999  }
1000  if (!nCoeffs_are_equal(c, basecoeffs()))
1001  {
1002  WerrorS("Error in addrow: coeffs do not agree!");
1003  return false;
1004  }
1005  number t1, t2, t3;
1006  for (int k=1; k<=col; k++)
1007  {
1008  t1 = view(j, k);
1009  t2 = view(i, k);
1010  t3 = n_Mult(t1, a, basecoeffs());
1011  n_InpAdd(t3, t2, basecoeffs());
1012  rawset(i, k, t3);
1013  }
1014  return true;
1015 }
const poly a
Definition: syzextra.cc:212
int row
Definition: bigintmat.h:56
void WerrorS(const char *s)
Definition: feFopen.cc:24
int k
Definition: cfEzgcd.cc:93
static FORCE_INLINE void n_InpAdd(number &a, number b, const coeffs r)
addition of &#39;a&#39; and &#39;b&#39;; replacement of &#39;a&#39; by the sum a+b
Definition: coeffs.h:650
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:197
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of &#39;a&#39; and &#39;b&#39;, i.e., a*b
Definition: coeffs.h:640
int j
Definition: myNF.cc:70
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:128
int i
Definition: cfEzgcd.cc:123
int col
Definition: bigintmat.h:57
coeffs basecoeffs() const
Definition: bigintmat.h:147
bool nCoeffs_are_equal(coeffs r, coeffs s)
Definition: bigintmat.cc:2655

§ appendCol()

void bigintmat::appendCol ( bigintmat a)

horizontally join the matrices, m <- m|a

Definition at line 1093 of file bigintmat.cc.

1094 {
1095  coeffs R = basecoeffs();
1096  int ay = a->cols();
1097  int ax = a->rows();
1098  assume(row == ax);
1099 
1101 
1102  bigintmat * tmp = new bigintmat(rows(), cols() + ay, R);
1103  tmp->concatcol(this, a);
1104  this->swapMatrix(tmp);
1105  delete tmp;
1106 }
void concatcol(bigintmat *a, bigintmat *b)
Definition: bigintmat.cc:1108
Matrices of numbers.
Definition: bigintmat.h:51
int rows() const
Definition: bigintmat.h:146
int row
Definition: bigintmat.h:56
#define assume(x)
Definition: mod2.h:403
void swapMatrix(bigintmat *a)
Definition: bigintmat.cc:1576
The main handler for Singular numbers which are suitable for Singular polynomials.
const ring R
Definition: DebugPrint.cc:36
int cols() const
Definition: bigintmat.h:145
bigintmat()
Definition: bigintmat.h:60
coeffs basecoeffs() const
Definition: bigintmat.h:147
bool nCoeffs_are_equal(coeffs r, coeffs s)
Definition: bigintmat.cc:2655

§ basecoeffs()

coeffs bigintmat::basecoeffs ( ) const
inline

Definition at line 147 of file bigintmat.h.

147 { return m_coeffs; }
coeffs m_coeffs
Definition: bigintmat.h:54

§ colIsZero()

int bigintmat::colIsZero ( int  i)

Definition at line 1587 of file bigintmat.cc.

1588 {
1589  coeffs R = basecoeffs();
1590  for(int i=1; i<=rows(); i++)
1591  if (!n_IsZero(view(i, j), R)) return FALSE;
1592  return TRUE;
1593 }
#define FALSE
Definition: auxiliary.h:95
int rows() const
Definition: bigintmat.h:146
#define TRUE
Definition: auxiliary.h:99
int j
Definition: myNF.cc:70
The main handler for Singular numbers which are suitable for Singular polynomials.
const ring R
Definition: DebugPrint.cc:36
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:128
int i
Definition: cfEzgcd.cc:123
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the zero element.
Definition: coeffs.h:468
coeffs basecoeffs() const
Definition: bigintmat.h:147

§ cols()

int bigintmat::cols ( ) const
inline

Definition at line 145 of file bigintmat.h.

145 { return col; }
int col
Definition: bigintmat.h:57

§ colskaldiv()

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

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

Definition at line 1886 of file bigintmat.cc.

1887 {
1888  number tmp1, tmp2;
1889  for (int i=1; i<=row; i++)
1890  {
1891  tmp1 = view(i, j);
1892  tmp2 = n_Div(tmp1, b, basecoeffs());
1893  rawset(i, j, tmp2);
1894  }
1895 }
int row
Definition: bigintmat.h:56
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:197
int j
Definition: myNF.cc:70
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:128
int i
Definition: cfEzgcd.cc:123
CFList tmp2
Definition: facFqBivar.cc:70
static FORCE_INLINE number n_Div(number a, number b, const coeffs r)
return the quotient of &#39;a&#39; and &#39;b&#39;, i.e., a/b; raises an error if &#39;b&#39; is not invertible in r exceptio...
Definition: coeffs.h:619
coeffs basecoeffs() const
Definition: bigintmat.h:147
CFList tmp1
Definition: facFqBivar.cc:70
const poly b
Definition: syzextra.cc:213

§ colskalmult()

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

Multipliziert zur i-ten Spalte den Skalar a hinzu.

Definition at line 1017 of file bigintmat.cc.

1018 {
1019  if ((i>=1) && (i<=col) && (nCoeffs_are_equal(c, basecoeffs())))
1020  {
1021  number t, tmult;
1022  for (int j=1; j<=row; j++)
1023  {
1024  t = view(j, i);
1025  tmult = n_Mult(a, t, basecoeffs());
1026  rawset(j, i, tmult);
1027  }
1028  }
1029  else
1030  WerrorS("Error in colskalmult");
1031 }
const poly a
Definition: syzextra.cc:212
int row
Definition: bigintmat.h:56
void WerrorS(const char *s)
Definition: feFopen.cc:24
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:197
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of &#39;a&#39; and &#39;b&#39;, i.e., a*b
Definition: coeffs.h:640
int j
Definition: myNF.cc:70
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:128
int i
Definition: cfEzgcd.cc:123
int col
Definition: bigintmat.h:57
coeffs basecoeffs() const
Definition: bigintmat.h:147
bool nCoeffs_are_equal(coeffs r, coeffs s)
Definition: bigintmat.cc:2655

§ 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 1899 of file bigintmat.cc.

1900 {
1901  number tmp1, tmp2, tmp3, tmp4;
1902  for (int i=1; i<=row; i++)
1903  {
1904  tmp1 = get(i, j);
1905  tmp2 = get(i, k);
1906  tmp3 = n_Mult(tmp1, a, basecoeffs());
1907  tmp4 = n_Mult(tmp2, b, basecoeffs());
1908  n_InpAdd(tmp3, tmp4, basecoeffs());
1909  n_Delete(&tmp4, basecoeffs());
1910 
1911  n_InpMult(tmp1, c, basecoeffs());
1912  n_InpMult(tmp2, d, basecoeffs());
1913  n_InpAdd(tmp1, tmp2, basecoeffs());
1914  n_Delete(&tmp2, basecoeffs());
1915 
1916  set(i, j, tmp3);
1917  set(i, k, tmp1);
1918  n_Delete(&tmp1, basecoeffs());
1919  n_Delete(&tmp3, basecoeffs());
1920  }
1921 }
const poly a
Definition: syzextra.cc:212
static FORCE_INLINE void n_InpMult(number &a, number b, const coeffs r)
multiplication of &#39;a&#39; and &#39;b&#39;; replacement of &#39;a&#39; by the product a*b
Definition: coeffs.h:645
int row
Definition: bigintmat.h:56
int k
Definition: cfEzgcd.cc:93
static FORCE_INLINE void n_InpAdd(number &a, number b, const coeffs r)
addition of &#39;a&#39; and &#39;b&#39;; replacement of &#39;a&#39; by the sum a+b
Definition: coeffs.h:650
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of &#39;a&#39; and &#39;b&#39;, i.e., a*b
Definition: coeffs.h:640
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
CFList tmp2
Definition: facFqBivar.cc:70
coeffs basecoeffs() const
Definition: bigintmat.h:147
CFList tmp1
Definition: facFqBivar.cc:70
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:459
const poly b
Definition: syzextra.cc:213

§ compare()

int bigintmat::compare ( const bigintmat op) const

Definition at line 365 of file bigintmat.cc.

366 {
367  assume (basecoeffs() == op->basecoeffs() );
368 
369 #ifndef SING_NDEBUG
370  if (basecoeffs() != op->basecoeffs() )
371  WerrorS("wrong bigintmat comparison: different basecoeffs!\n");
372 #endif
373 
374  if ((col!=1) ||(op->cols()!=1))
375  {
376  if((col!=op->cols())
377  || (row!=op->rows()))
378  return -2;
379  }
380 
381  int i;
382  for (i=0; i<si_min(row*col,op->rows()*op->cols()); i++)
383  {
384  if ( n_Greater(v[i], (*op)[i], basecoeffs()) )
385  return 1;
386  else if (! n_Equal(v[i], (*op)[i], basecoeffs()))
387  return -1;
388  }
389 
390  for (; i<row; i++)
391  {
392  if ( n_GreaterZero(v[i], basecoeffs()) )
393  return 1;
394  else if (! n_IsZero(v[i], basecoeffs()) )
395  return -1;
396  }
397  for (; i<op->rows(); i++)
398  {
399  if ( n_GreaterZero((*op)[i], basecoeffs()) )
400  return -1;
401  else if (! n_IsZero((*op)[i], basecoeffs()) )
402  return 1;
403  }
404  return 0;
405 }
static FORCE_INLINE BOOLEAN n_Greater(number a, number b, const coeffs r)
ordered fields: TRUE iff &#39;a&#39; is larger than &#39;b&#39;; in Z/pZ: TRUE iff la > lb, where la and lb are the l...
Definition: coeffs.h:515
static int si_min(const int a, const int b)
Definition: auxiliary.h:122
int rows() const
Definition: bigintmat.h:146
int row
Definition: bigintmat.h:56
void WerrorS(const char *s)
Definition: feFopen.cc:24
#define assume(x)
Definition: mod2.h:403
int cols() const
Definition: bigintmat.h:145
int i
Definition: cfEzgcd.cc:123
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the zero element.
Definition: coeffs.h:468
int col
Definition: bigintmat.h:57
number * v
Definition: bigintmat.h:55
coeffs basecoeffs() const
Definition: bigintmat.h:147
static FORCE_INLINE BOOLEAN n_Equal(number a, number b, const coeffs r)
TRUE iff &#39;a&#39; and &#39;b&#39; represent the same number; they may have different representations.
Definition: coeffs.h:464
static FORCE_INLINE BOOLEAN n_GreaterZero(number n, const coeffs r)
ordered fields: TRUE iff &#39;n&#39; is positive; in Z/pZ: TRUE iff 0 < m <= roundedBelow(p/2), where m is the long representing n in C: TRUE iff (Im(n) != 0 and Im(n) >= 0) or (Im(n) == 0 and Re(n) >= 0) in K(a)/<p(a)>: TRUE iff (n != 0 and (LC(n) > 0 or deg(n) > 0)) in K(t_1, ..., t_n): TRUE iff (LC(numerator(n) is a constant and > 0) or (LC(numerator(n) is not a constant) in Z/2^kZ: TRUE iff 0 < n <= 2^(k-1) in Z/mZ: TRUE iff the internal mpz is greater than zero in Z: TRUE iff n > 0
Definition: coeffs.h:498

§ concatcol()

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

Definition at line 1108 of file bigintmat.cc.

1108  {
1109  int ay = a->cols();
1110  int ax = a->rows();
1111  int by = b->cols();
1112  int bx = b->rows();
1113  number tmp;
1114 
1115  assume(row==ax && row == bx && ay+by ==col);
1116 
1118 
1119  for (int i=1; i<=ax; i++)
1120  {
1121  for (int j=1; j<=ay; j++)
1122  {
1123  tmp = a->view(i,j);
1124  set(i, j, tmp);
1125  }
1126  }
1127  for (int i=1; i<=bx; i++)
1128  {
1129  for (int j=1; j<=by; j++)
1130  {
1131  tmp = b->view(i,j);
1132  set(i, j+ay, tmp);
1133  }
1134  }
1135 }
int rows() const
Definition: bigintmat.h:146
int row
Definition: bigintmat.h:56
int j
Definition: myNF.cc:70
#define assume(x)
Definition: mod2.h:403
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:128
int cols() const
Definition: bigintmat.h:145
int i
Definition: cfEzgcd.cc:123
int col
Definition: bigintmat.h:57
coeffs basecoeffs() const
Definition: bigintmat.h:147
bool nCoeffs_are_equal(coeffs r, coeffs s)
Definition: bigintmat.cc:2655

§ 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 1049 of file bigintmat.cc.

1050 {
1051  int ay = a->cols();
1052  int ax = a->rows();
1053  int by = b->cols();
1054  int bx = b->rows();
1055  number tmp;
1056  if (!((col == ay) && (col == by) && (ax+bx == row)))
1057  {
1058  WerrorS("Error in concatrow. Dimensions must agree!");
1059  return;
1060  }
1062  {
1063  WerrorS("Error in concatrow. coeffs do not agree!");
1064  return;
1065  }
1066  for (int i=1; i<=ax; i++)
1067  {
1068  for (int j=1; j<=ay; j++)
1069  {
1070  tmp = a->get(i,j);
1071  set(i, j, tmp);
1072  n_Delete(&tmp, basecoeffs());
1073  }
1074  }
1075  for (int i=1; i<=bx; i++)
1076  {
1077  for (int j=1; j<=by; j++)
1078  {
1079  tmp = b->get(i,j);
1080  set(i+ax, j, tmp);
1081  n_Delete(&tmp, basecoeffs());
1082  }
1083  }
1084 }
int rows() const
Definition: bigintmat.h:146
int row
Definition: bigintmat.h:56
void WerrorS(const char *s)
Definition: feFopen.cc:24
int j
Definition: myNF.cc:70
int cols() const
Definition: bigintmat.h:145
int i
Definition: cfEzgcd.cc:123
int col
Definition: bigintmat.h:57
coeffs basecoeffs() const
Definition: bigintmat.h:147
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:459
number get(int i, int j) const
get a copy of an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:120
bool nCoeffs_are_equal(coeffs r, coeffs s)
Definition: bigintmat.cc:2655

§ content()

number bigintmat::content ( )

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

Definition at line 2685 of file bigintmat.cc.

2686 {
2687  coeffs r = basecoeffs();
2688  number g = get(1,1), h;
2689  int n=rows()*cols();
2690  for(int i=1; i<n && !n_IsOne(g, r); i++)
2691  {
2692  h = n_Gcd(g, view(i), r);
2693  n_Delete(&g, r);
2694  g=h;
2695  }
2696  return g;
2697 }
static FORCE_INLINE number n_Gcd(number a, number b, const coeffs r)
in Z: return the gcd of &#39;a&#39; and &#39;b&#39; in Z/nZ, Z/2^kZ: computed as in the case Z in Z/pZ...
Definition: coeffs.h:690
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the one element.
Definition: coeffs.h:472
int rows() const
Definition: bigintmat.h:146
g
Definition: cfModGcd.cc:4031
const ring r
Definition: syzextra.cc:208
The main handler for Singular numbers which are suitable for Singular polynomials.
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:128
int cols() const
Definition: bigintmat.h:145
int i
Definition: cfEzgcd.cc:123
coeffs basecoeffs() const
Definition: bigintmat.h:147
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:459
static Poly * h
Definition: janet.cc:978

§ copy()

bool bigintmat::copy ( bigintmat b)

Kopiert Einträge von b auf Bigintmat.

Definition at line 1269 of file bigintmat.cc.

1270 {
1271  if ((b->rows() != row) || (b->cols() != col))
1272  {
1273  WerrorS("Error in bigintmat::copy. Dimensions do not agree!");
1274  return false;
1275  }
1276  if (!nCoeffs_are_equal(basecoeffs(), b->basecoeffs()))
1277  {
1278  WerrorS("Error in bigintmat::copy. coeffs do not agree!");
1279  return false;
1280  }
1281  number t1;
1282  for (int i=1; i<=row; i++)
1283  {
1284  for (int j=1; j<=col; j++)
1285  {
1286  t1 = b->view(i, j);
1287  set(i, j, t1);
1288  }
1289  }
1290  return true;
1291 }
int rows() const
Definition: bigintmat.h:146
int row
Definition: bigintmat.h:56
void WerrorS(const char *s)
Definition: feFopen.cc:24
int j
Definition: myNF.cc:70
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:128
int cols() const
Definition: bigintmat.h:145
int i
Definition: cfEzgcd.cc:123
int col
Definition: bigintmat.h:57
coeffs basecoeffs() const
Definition: bigintmat.h:147
bool nCoeffs_are_equal(coeffs r, coeffs s)
Definition: bigintmat.cc:2655

§ 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 1297 of file bigintmat.cc.

1298 {
1299  number t1;
1300  for (int i=1; i<=n; i++)
1301  {
1302  for (int j=1; j<=m; j++)
1303  {
1304  t1 = B->view(a+i-1, b+j-1);
1305  set(c+i-1, d+j-1, t1);
1306  }
1307  }
1308 }
const poly a
Definition: syzextra.cc:212
int j
Definition: myNF.cc:70
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:128
int m
Definition: cfEzgcd.cc:119
int i
Definition: cfEzgcd.cc:123
const poly b
Definition: syzextra.cc:213

§ det()

number bigintmat::det ( )

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

Definition at line 1522 of file bigintmat.cc.

1523 {
1524  assume (row==col);
1525 
1526  if (col == 1)
1527  return get(1, 1);
1528  // should work as well in Z/pZ of type n_Zp?
1529  // relies on XExtGcd and the other euc. functinos.
1530  if ( getCoeffType(basecoeffs())== n_Z || getCoeffType(basecoeffs() )== n_Zn) {
1531  return hnfdet();
1532  }
1533  number sum = n_Init(0, basecoeffs());
1534  number t1, t2, t3, t4;
1535  bigintmat *b;
1536  for (int i=1; i<=row; i++) {
1537  b = elim(i, 1);
1538  t1 = get(i, 1);
1539  t2 = b->det();
1540  t3 = n_Mult(t1, t2, basecoeffs());
1541  t4 = n_Copy(sum, basecoeffs());
1542  n_Delete(&sum, basecoeffs());
1543  if ((i+1)>>1<<1==(i+1))
1544  sum = n_Add(t4, t3, basecoeffs());
1545  else
1546  sum = n_Sub(t4, t3, basecoeffs());
1547  n_Delete(&t1, basecoeffs());
1548  n_Delete(&t2, basecoeffs());
1549  n_Delete(&t3, basecoeffs());
1550  n_Delete(&t4, basecoeffs());
1551  }
1552  return sum;
1553 }
static FORCE_INLINE number n_Sub(number a, number b, const coeffs r)
return the difference of &#39;a&#39; and &#39;b&#39;, i.e., a-b
Definition: coeffs.h:673
only used if HAVE_RINGS is defined
Definition: coeffs.h:44
number det()
det (via LaPlace in general, hnf for euc. rings)
Definition: bigintmat.cc:1522
Matrices of numbers.
Definition: bigintmat.h:51
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
int row
Definition: bigintmat.h:56
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of &#39;a&#39; and &#39;b&#39;, i.e., a*b
Definition: coeffs.h:640
#define assume(x)
Definition: mod2.h:403
static FORCE_INLINE number n_Add(number a, number b, const coeffs r)
return the sum of &#39;a&#39; and &#39;b&#39;, i.e., a+b
Definition: coeffs.h:660
only used if HAVE_RINGS is defined
Definition: coeffs.h:43
int i
Definition: cfEzgcd.cc:123
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425
int col
Definition: bigintmat.h:57
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of &#39;n&#39;
Definition: coeffs.h:455
coeffs basecoeffs() const
Definition: bigintmat.h:147
number hnfdet()
det via HNF Primzahlen als long long int, müssen noch in number umgewandelt werden?
Definition: bigintmat.cc:1555
bigintmat * elim(int i, int j)
Liefert Streichungsmatrix (i-te Zeile und j-te Spalte gestrichen) zurück.
Definition: bigintmat.cc:1391
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:459
const poly b
Definition: syzextra.cc:213

§ elim()

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

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

Definition at line 1391 of file bigintmat.cc.

1392 {
1393  if ((i<=0) || (i>row) || (j<=0) || (j>col))
1394  return NULL;
1395  int cx, cy;
1396  cx=1;
1397  cy=1;
1398  number t;
1399  bigintmat *b = new bigintmat(row-1, col-1, basecoeffs());
1400  for (int k=1; k<=row; k++) {
1401  if (k!=i)
1402  {
1403  cy=1;
1404  for (int l=1; l<=col; l++)
1405  {
1406  if (l!=j)
1407  {
1408  t = get(k, l);
1409  b->set(cx, cy, t);
1410  n_Delete(&t, basecoeffs());
1411  cy++;
1412  }
1413  }
1414  cx++;
1415  }
1416  }
1417  return b;
1418 }
Matrices of numbers.
Definition: bigintmat.h:51
int row
Definition: bigintmat.h:56
int k
Definition: cfEzgcd.cc:93
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:96
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
int col
Definition: bigintmat.h:57
#define NULL
Definition: omList.c:10
bigintmat()
Definition: bigintmat.h:60
coeffs basecoeffs() const
Definition: bigintmat.h:147
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:459
const poly b
Definition: syzextra.cc:213
int l
Definition: cfEzgcd.cc:94

§ extendCols()

void bigintmat::extendCols ( int  i)

append i zero-columns to the matrix

Definition at line 1086 of file bigintmat.cc.

1087 {
1088  bigintmat * tmp = new bigintmat(rows(), i, basecoeffs());
1089  appendCol(tmp);
1090  delete tmp;
1091 }
Matrices of numbers.
Definition: bigintmat.h:51
void appendCol(bigintmat *a)
horizontally join the matrices, m <- m|a
Definition: bigintmat.cc:1093
int rows() const
Definition: bigintmat.h:146
int i
Definition: cfEzgcd.cc:123
bigintmat()
Definition: bigintmat.h:60
coeffs basecoeffs() const
Definition: bigintmat.h:147

§ findcolnonzero()

int bigintmat::findcolnonzero ( int  j)

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

Definition at line 745 of file bigintmat.cc.

746 {
747  for (int i=row; i>=1; i--)
748  {
749  if (!n_IsZero(view(i,j), basecoeffs()))
750  {
751  return i;
752  }
753  }
754  return 0;
755 }
int row
Definition: bigintmat.h:56
int j
Definition: myNF.cc:70
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:128
int i
Definition: cfEzgcd.cc:123
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the zero element.
Definition: coeffs.h:468
coeffs basecoeffs() const
Definition: bigintmat.h:147

§ findnonzero()

int bigintmat::findnonzero ( int  i)

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

Definition at line 733 of file bigintmat.cc.

734 {
735  for (int j=1; j<=col; j++)
736  {
737  if (!n_IsZero(view(i,j), basecoeffs()))
738  {
739  return j;
740  }
741  }
742  return 0;
743 }
int j
Definition: myNF.cc:70
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:128
int i
Definition: cfEzgcd.cc:123
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the zero element.
Definition: coeffs.h:468
int col
Definition: bigintmat.h:57
coeffs basecoeffs() const
Definition: bigintmat.h:147

§ get() [1/2]

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

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

Definition at line 120 of file bigintmat.cc.

121 {
122  assume (i > 0 && j > 0);
123  assume (i <= rows() && j <= cols());
124 
125  return get(index(i, j));
126 }
int rows() const
Definition: bigintmat.h:146
int j
Definition: myNF.cc:70
#define assume(x)
Definition: mod2.h:403
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:162
int cols() const
Definition: bigintmat.h:145
int i
Definition: cfEzgcd.cc:123

§ get() [2/2]

number bigintmat::get ( int  i) const

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

Definition at line 104 of file bigintmat.cc.

105 {
106  assume (i >= 0);
107  assume (i<rows()*cols());
108 
109  return n_Copy(v[i], basecoeffs());
110 }
int rows() const
Definition: bigintmat.h:146
#define assume(x)
Definition: mod2.h:403
int cols() const
Definition: bigintmat.h:145
int i
Definition: cfEzgcd.cc:123
number * v
Definition: bigintmat.h:55
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of &#39;n&#39;
Definition: coeffs.h:455
coeffs basecoeffs() const
Definition: bigintmat.h:147

§ 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 757 of file bigintmat.cc.

758 {
759  assume((j<=col) && (j>=1));
760  if (((a->rows() != row) || (a->cols() != 1)) && ((a->rows() != 1) || (a->cols() != row)))
761  {
762  assume(0);
763  WerrorS("Error in getcol. Dimensions must agree!");
764  return;
765  }
767  {
769  number t1, t2;
770  for (int i=1; i<=row;i++)
771  {
772  t1 = get(i,j);
773  t2 = f(t1, basecoeffs(), a->basecoeffs());
774  a->set(i-1,t1);
775  n_Delete(&t1, basecoeffs());
776  n_Delete(&t2, a->basecoeffs());
777  }
778  return;
779  }
780  number t1;
781  for (int i=1; i<=row;i++)
782  {
783  t1 = view(i,j);
784  a->set(i-1,t1);
785  }
786 }
int rows() const
Definition: bigintmat.h:146
int row
Definition: bigintmat.h:56
void WerrorS(const char *s)
Definition: feFopen.cc:24
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:96
int j
Definition: myNF.cc:70
#define assume(x)
Definition: mod2.h:403
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:73
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:128
int cols() const
Definition: bigintmat.h:145
FILE * f
Definition: checklibs.c:7
int i
Definition: cfEzgcd.cc:123
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:725
int col
Definition: bigintmat.h:57
coeffs basecoeffs() const
Definition: bigintmat.h:147
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:459
bool nCoeffs_are_equal(coeffs r, coeffs s)
Definition: bigintmat.cc:2655

§ 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 788 of file bigintmat.cc.

789 {
790  number t1;
791  for(int ii=0; ii< no; ii++)
792  {
793  for (int i=1; i<=row;i++)
794  {
795  t1 = view(i, ii+j);
796  a->set(i, ii+1, t1);
797  }
798  }
799 }
int row
Definition: bigintmat.h:56
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:96
int j
Definition: myNF.cc:70
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:128
int i
Definition: cfEzgcd.cc:123

§ getrow()

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

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

Definition at line 801 of file bigintmat.cc.

802 {
803  if ((i>row) || (i<1))
804  {
805  WerrorS("Error in getrow: Index out of range!");
806  return;
807  }
808  if (((a->rows() != 1) || (a->cols() != col)) && ((a->rows() != col) || (a->cols() != 1)))
809  {
810  WerrorS("Error in getrow. Dimensions must agree!");
811  return;
812  }
814  {
816  number t1, t2;
817  for (int j=1; j<=col;j++)
818  {
819  t1 = get(i,j);
820  t2 = f(t1, basecoeffs(), a->basecoeffs());
821  a->set(j-1,t2);
822  n_Delete(&t1, basecoeffs());
823  n_Delete(&t2, a->basecoeffs());
824  }
825  return;
826  }
827  number t1;
828  for (int j=1; j<=col;j++)
829  {
830  t1 = get(i,j);
831  a->set(j-1,t1);
832  n_Delete(&t1, basecoeffs());
833  }
834 }
int rows() const
Definition: bigintmat.h:146
int row
Definition: bigintmat.h:56
void WerrorS(const char *s)
Definition: feFopen.cc:24
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:96
int j
Definition: myNF.cc:70
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:73
int cols() const
Definition: bigintmat.h:145
FILE * f
Definition: checklibs.c:7
int i
Definition: cfEzgcd.cc:123
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:725
int col
Definition: bigintmat.h:57
coeffs basecoeffs() const
Definition: bigintmat.h:147
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:459
bool nCoeffs_are_equal(coeffs r, coeffs s)
Definition: bigintmat.cc:2655

§ getwid()

int * bigintmat::getwid ( int  maxwid)

Definition at line 583 of file bigintmat.cc.

584 {
585  int const c = /*2**/(col-1)+1;
586  if (col + c > maxwid-1) return NULL;
587  int * wv = (int*)omAlloc(sizeof(int)*col*row);
588  int * cwv = (int*)omAlloc(sizeof(int)*col);
589  for (int j=0; j<col; j++)
590  {
591  cwv[j] = 0;
592  for (int i=0; i<row; i++)
593  {
594  StringSetS("");
595  n_Write(v[col*i+j], basecoeffs());
596  char * tmp = StringEndS();
597  const int _nl = strlen(tmp);
598  wv[col*i+j] = _nl;
599  if (_nl > cwv[j])
600  cwv[j]=_nl;
601  omFree(tmp);
602  }
603  }
604 
605  // Groesse verkleinern, bis < maxwid
606  while (intArrSum(cwv, col)+c > maxwid)
607  {
608  int j = findLongest(cwv, col);
609  cwv[j] = getShorter(wv, cwv[j], j, col, row);
610  }
611  omFree(wv);
612  return cwv;
613 }
static int findLongest(int *a, int length)
Definition: bigintmat.cc:540
int row
Definition: bigintmat.h:56
static int intArrSum(int *a, int length)
Definition: bigintmat.cc:532
char * StringEndS()
Definition: reporter.cc:151
#define omAlloc(size)
Definition: omAllocDecl.h:210
static int getShorter(int *a, int l, int j, int cols, int rows)
Definition: bigintmat.cc:555
int j
Definition: myNF.cc:70
#define omFree(addr)
Definition: omAllocDecl.h:261
void StringSetS(const char *st)
Definition: reporter.cc:128
static FORCE_INLINE void n_Write(number n, const coeffs r, const BOOLEAN bShortOut=TRUE)
Definition: coeffs.h:595
int i
Definition: cfEzgcd.cc:123
int col
Definition: bigintmat.h:57
number * v
Definition: bigintmat.h:55
#define NULL
Definition: omList.c:10
coeffs basecoeffs() const
Definition: bigintmat.h:147

§ hnf()

void bigintmat::hnf ( )

transforms INPLACE to HNF

Definition at line 1670 of file bigintmat.cc.

1671 {
1672  // Laufen von unten nach oben und von links nach rechts
1673  // CF: TODO: for n_Z: write a recursive version. This one will
1674  // have exponential blow-up. Look at Michianchio
1675  // Alternatively, do p-adic det and modular method
1676 
1677 #if 0
1678  char * s;
1679  ::PrintS("mat over Z is \n");
1680  ::Print("%s\n", s = nCoeffString(basecoeffs()));
1681  omFree(s);
1682  Print();
1683  ::Print("\n(%d x %d)\n", rows(), cols());
1684 #endif
1685 
1686  int i = rows();
1687  int j = cols();
1688  number q = n_Init(0, basecoeffs());
1689  number one = n_Init(1, basecoeffs());
1690  number minusone = n_Init(-1, basecoeffs());
1691  number tmp1 = n_Init(0, basecoeffs());
1692  number tmp2 = n_Init(0, basecoeffs());
1693  number co1, co2, co3, co4;
1694  number ggt = n_Init(0, basecoeffs());
1695 
1696  while ((i>0) && (j>0))
1697  {
1698  // Falls erstes Nicht-Null-Element in Zeile i nicht existiert, oder hinter Spalte j vorkommt, gehe in nächste Zeile
1699  if ((findnonzero(i)==0) || (findnonzero(i)>j))
1700  {
1701  i--;
1702  }
1703  else
1704  {
1705  // Laufe von links nach rechts durch die Zeile:
1706  for (int l=1; l<=j-1; l++)
1707  {
1708  n_Delete(&tmp1, basecoeffs());
1709  tmp1 = get(i, l);
1710  // Falls Eintrag (im folgenden x genannt) gleich 0, gehe eine Spalte weiter. Ansonsten...
1711  if (!n_IsZero(tmp1, basecoeffs()))
1712  {
1713  n_Delete(&tmp2, basecoeffs());
1714  tmp2 = get(i, l+1);
1715  // Falls Eintrag (i.f. y g.) rechts daneben gleich 0, tausche beide Spalten, sonst...
1716  if (!n_IsZero(tmp2, basecoeffs()))
1717  {
1718  n_Delete(&ggt, basecoeffs());
1719  ggt = n_XExtGcd(tmp1, tmp2, &co1, &co2, &co3, &co4, basecoeffs());
1720  // 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:
1721  if (n_Equal(tmp1, ggt, basecoeffs()))
1722  {
1723  swap(l, l+1);
1724  n_Delete(&q, basecoeffs());
1725  q = n_Div(tmp2, ggt, basecoeffs());
1726  q = n_InpNeg(q, basecoeffs());
1727  // Dann addiere das -q-fache der (neuen) rechten Spalte zur linken dazu. Damit erhalten wir die gewünschte 0
1728 
1729  addcol(l, l+1, q, basecoeffs());
1730  n_Delete(&q, basecoeffs());
1731  }
1732  else if (n_Equal(tmp1, minusone, basecoeffs()))
1733  {
1734  // 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
1735  // Die Berechnung von q (=y/ggt) entfällt, da ggt=1
1736  swap(l, l+1);
1737  colskalmult(l+1, minusone, basecoeffs());
1738  tmp2 = n_InpNeg(tmp2, basecoeffs());
1739  addcol(l, l+1, tmp2, basecoeffs());
1740  }
1741  else
1742  {
1743  // CF: use the 2x2 matrix (co1, co2)(co3, co4) to
1744  // get the gcd in position and the 0 in the other:
1745 #ifdef CF_DEB
1746  ::PrintS("applying trafo\n");
1747  StringSetS("");
1748  n_Write(co1, basecoeffs()); StringAppendS("\t");
1749  n_Write(co2, basecoeffs()); StringAppendS("\t");
1750  n_Write(co3, basecoeffs()); StringAppendS("\t");
1751  n_Write(co4, basecoeffs()); StringAppendS("\t");
1752  ::Print("%s\nfor l=%d\n", StringEndS(), l);
1753  {char * s = String();
1754  ::Print("to %s\n", s);omFree(s);};
1755 #endif
1756  coltransform(l, l+1, co3, co4, co1, co2);
1757 #ifdef CF_DEB
1758  {char * s = String();
1759  ::Print("gives %s\n", s);}
1760 #endif
1761  }
1762  n_Delete(&co1, basecoeffs());
1763  n_Delete(&co2, basecoeffs());
1764  n_Delete(&co3, basecoeffs());
1765  n_Delete(&co4, basecoeffs());
1766  }
1767  else
1768  {
1769  swap(l, l+1);
1770  }
1771  // Dann betrachte die vormals rechte Spalte als neue linke, und die rechts daneben als neue rechte.
1772  }
1773  }
1774 
1775  #ifdef HAVE_RINGS
1776  // normalize by units:
1777  if (!n_IsZero(view(i, j), basecoeffs()))
1778  {
1779  number u = n_GetUnit(view(i, j), basecoeffs());
1780  if (!n_IsOne(u, basecoeffs()))
1781  {
1782  colskaldiv(j, u);
1783  }
1784  n_Delete(&u, basecoeffs());
1785  }
1786  #endif
1787  // Zum Schluss mache alle Einträge rechts vom Diagonalelement betragsmäßig kleiner als dieses
1788  for (int l=j+1; l<=col; l++)
1789  {
1790  n_Delete(&q, basecoeffs());
1791  q = n_QuotRem(view(i, l), view(i, j), NULL, basecoeffs());
1792  q = n_InpNeg(q, basecoeffs());
1793  addcol(l, j, q, basecoeffs());
1794  }
1795  i--;
1796  j--;
1797  // Dann betrachte die Zeile darüber und gehe dort wie vorher vor
1798  }
1799  }
1800  n_Delete(&q, basecoeffs());
1801  n_Delete(&tmp1, basecoeffs());
1802  n_Delete(&tmp2, basecoeffs());
1803  n_Delete(&ggt, basecoeffs());
1804  n_Delete(&one, basecoeffs());
1805  n_Delete(&minusone, basecoeffs());
1806 
1807 #if 0
1808  ::PrintS("hnf over Z is \n");
1809  Print();
1810  ::Print("\n(%d x %d)\n", rows(), cols());
1811 #endif
1812 }
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
const CanonicalForm int s
Definition: facAbsFact.cc:55
static FORCE_INLINE number n_XExtGcd(number a, number b, number *s, number *t, number *u, number *v, const coeffs r)
Definition: coeffs.h:699
bool addcol(int i, int j, number a, coeffs c)
addiert a-faches der j-ten Spalte zur i-ten dazu
Definition: bigintmat.cc:969
void colskaldiv(int j, number b)
Macht Ganzzahldivision aller j-ten Spalteneinträge mit b.
Definition: bigintmat.cc:1886
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the one element.
Definition: coeffs.h:472
int rows() 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
int findnonzero(int i)
find index of 1st non-zero entry in row i
Definition: bigintmat.cc:733
char * StringEndS()
Definition: reporter.cc:151
int j
Definition: myNF.cc:70
#define omFree(addr)
Definition: omAllocDecl.h:261
void StringSetS(const char *st)
Definition: reporter.cc:128
void StringAppendS(const char *st)
Definition: reporter.cc:107
void swap(int i, int j)
swap columns i and j
Definition: bigintmat.cc:695
static FORCE_INLINE void n_Write(number n, const coeffs r, const BOOLEAN bShortOut=TRUE)
Definition: coeffs.h:595
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:128
int cols() const
Definition: bigintmat.h:145
static FORCE_INLINE number n_QuotRem(number a, number b, number *q, const coeffs r)
Definition: coeffs.h:707
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
int i
Definition: cfEzgcd.cc:123
void PrintS(const char *s)
Definition: reporter.cc:284
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the zero element.
Definition: coeffs.h:468
CFList tmp2
Definition: facFqBivar.cc:70
void Print()
IO: simply prints the matrix to the current output (screen?)
Definition: bigintmat.cc:446
int col
Definition: bigintmat.h:57
void colskalmult(int i, number a, coeffs c)
Multipliziert zur i-ten Spalte den Skalar a hinzu.
Definition: bigintmat.cc:1017
#define NULL
Definition: omList.c:10
static FORCE_INLINE number n_Div(number a, number b, const coeffs r)
return the quotient of &#39;a&#39; and &#39;b&#39;, i.e., a/b; raises an error if &#39;b&#39; is not invertible in r exceptio...
Definition: coeffs.h:619
coeffs basecoeffs() const
Definition: bigintmat.h:147
char * String()
IO: String returns a singular string containing the matrix, needs freeing afterwards.
Definition: bigintmat.cc:439
CFList tmp1
Definition: facFqBivar.cc:70
static FORCE_INLINE BOOLEAN n_Equal(number a, number b, const coeffs r)
TRUE iff &#39;a&#39; and &#39;b&#39; represent the same number; they may have different representations.
Definition: coeffs.h:464
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:1899
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:459
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:973
void one()
Macht Matrix (Falls quadratisch) zu Einheitsmatrix.
Definition: bigintmat.cc:1335
int l
Definition: cfEzgcd.cc:94

§ hnfdet()

number bigintmat::hnfdet ( )

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

Definition at line 1555 of file bigintmat.cc.

1556 {
1557  assume (col == row);
1558 
1559  if (col == 1)
1560  return get(1, 1);
1561  bigintmat *m = new bigintmat(this);
1562  m->hnf();
1563  number prod = n_Init(1, basecoeffs());
1564  number temp, temp2;
1565  for (int i=1; i<=col; i++) {
1566  temp = m->get(i, i);
1567  temp2 = n_Mult(temp, prod, basecoeffs());
1568  n_Delete(&prod, basecoeffs());
1569  prod = temp2;
1570  n_Delete(&temp, basecoeffs());
1571  }
1572  delete m;
1573  return prod;
1574 }
Matrices of numbers.
Definition: bigintmat.h:51
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
int row
Definition: bigintmat.h:56
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of &#39;a&#39; and &#39;b&#39;, i.e., a*b
Definition: coeffs.h:640
#define assume(x)
Definition: mod2.h:403
int m
Definition: cfEzgcd.cc:119
void hnf()
transforms INPLACE to HNF
Definition: bigintmat.cc:1670
int i
Definition: cfEzgcd.cc:123
int col
Definition: bigintmat.h:57
bigintmat()
Definition: bigintmat.h:60
coeffs basecoeffs() const
Definition: bigintmat.h:147
fq_nmod_poly_t prod
Definition: facHensel.cc:95
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:459
number get(int i, int j) const
get a copy of an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:120

§ howell()

void bigintmat::howell ( )

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

Definition at line 1595 of file bigintmat.cc.

1596 {
1597  coeffs R = basecoeffs();
1598  hnf(); // as a starting point...
1599  if (getCoeffType(R)== n_Z) return; //wrong, need to prune!
1600 
1601  int n = cols(), m = rows(), i, j, k;
1602 
1603  //make sure, the matrix has enough space. We need no rows+1 columns.
1604  //The resulting Howell form will be pruned to be at most square.
1605  bigintmat * t = new bigintmat(m, m+1, R);
1606  t->copySubmatInto(this, 1, n>m ? n-m+1 : 1, m, n>m ? m : n, 1, n>m ? 2 : m+2-n );
1607  swapMatrix(t);
1608  delete t;
1609  for(i=1; i<= cols(); i++) {
1610  if (!colIsZero(i)) break;
1611  }
1612  assume (i>1);
1613  if (i>cols()) {
1614  t = new bigintmat(rows(), 0, R);
1615  swapMatrix(t);
1616  delete t;
1617  return; // zero matrix found, clearly normal.
1618  }
1619 
1620  int last_zero_col = i-1;
1621  for (int c = cols(); c>0; c--) {
1622  for(i=rows(); i>0; i--) {
1623  if (!n_IsZero(view(i, c), R)) break;
1624  }
1625  if (i==0) break; // matrix SHOULD be zero from here on
1626  number a = n_Ann(view(i, c), R);
1627  addcol(last_zero_col, c, a, R);
1628  n_Delete(&a, R);
1629  for(j = c-1; j>last_zero_col; j--) {
1630  for(k=rows(); k>0; k--) {
1631  if (!n_IsZero(view(k, j), R)) break;
1632  if (!n_IsZero(view(k, last_zero_col), R)) break;
1633  }
1634  if (k==0) break;
1635  if (!n_IsZero(view(k, last_zero_col), R)) {
1636  number gcd, co1, co2, co3, co4;
1637  gcd = n_XExtGcd(view(k, last_zero_col), view(k, j), &co1, &co2, &co3, &co4, R);
1638  if (n_Equal(gcd, view(k, j), R)) {
1639  number q = n_Div(view(k, last_zero_col), gcd, R);
1640  q = n_InpNeg(q, R);
1641  addcol(last_zero_col, j, q, R);
1642  n_Delete(&q, R);
1643  } else if (n_Equal(gcd, view(k, last_zero_col), R)) {
1644  swap(last_zero_col, k);
1645  number q = n_Div(view(k, last_zero_col), gcd, R);
1646  q = n_InpNeg(q, R);
1647  addcol(last_zero_col, j, q, R);
1648  n_Delete(&q, R);
1649  } else {
1650  coltransform(last_zero_col, j, co3, co4, co1, co2);
1651  }
1652  n_Delete(&gcd, R);
1653  n_Delete(&co1, R);
1654  n_Delete(&co2, R);
1655  n_Delete(&co3, R);
1656  n_Delete(&co4, R);
1657  }
1658  }
1659  for(k=rows(); k>0; k--) {
1660  if (!n_IsZero(view(k, last_zero_col), R)) break;
1661  }
1662  if (k) last_zero_col--;
1663  }
1664  t = new bigintmat(rows(), cols()-last_zero_col, R);
1665  t->copySubmatInto(this, 1, last_zero_col+1, rows(), cols()-last_zero_col, 1, 1);
1666  swapMatrix(t);
1667  delete t;
1668 }
int colIsZero(int i)
Definition: bigintmat.cc:1587
const poly a
Definition: syzextra.cc:212
static FORCE_INLINE number n_XExtGcd(number a, number b, number *s, number *t, number *u, number *v, const coeffs r)
Definition: coeffs.h:699
bool addcol(int i, int j, number a, coeffs c)
addiert a-faches der j-ten Spalte zur i-ten dazu
Definition: bigintmat.cc:969
Matrices of numbers.
Definition: bigintmat.h:51
int rows() const
Definition: bigintmat.h:146
int k
Definition: cfEzgcd.cc:93
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:705
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:1297
int j
Definition: myNF.cc:70
#define assume(x)
Definition: mod2.h:403
void swapMatrix(bigintmat *a)
Definition: bigintmat.cc:1576
The main handler for Singular numbers which are suitable for Singular polynomials.
void swap(int i, int j)
swap columns i and j
Definition: bigintmat.cc:695
const ring R
Definition: DebugPrint.cc:36
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:128
int cols() const
Definition: bigintmat.h:145
int m
Definition: cfEzgcd.cc:119
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
void hnf()
transforms INPLACE to HNF
Definition: bigintmat.cc:1670
only used if HAVE_RINGS is defined
Definition: coeffs.h:43
int i
Definition: cfEzgcd.cc:123
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the zero element.
Definition: coeffs.h:468
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425
bigintmat()
Definition: bigintmat.h:60
static FORCE_INLINE number n_Div(number a, number b, const coeffs r)
return the quotient of &#39;a&#39; and &#39;b&#39;, i.e., a/b; raises an error if &#39;b&#39; is not invertible in r exceptio...
Definition: coeffs.h:619
int gcd(int a, int b)
Definition: walkSupport.cc:839
coeffs basecoeffs() const
Definition: bigintmat.h:147
static FORCE_INLINE BOOLEAN n_Equal(number a, number b, const coeffs r)
TRUE iff &#39;a&#39; and &#39;b&#39; represent the same number; they may have different representations.
Definition: coeffs.h:464
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:1899
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:459

§ 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 162 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;
173  }
int rows() const
Definition: bigintmat.h:146
const ring r
Definition: syzextra.cc:208
#define assume(x)
Definition: mod2.h:403
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:162
int cols() const
Definition: bigintmat.h:145

§ 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 146 of file bigintmat.cc.

147 {
148  assume (C == NULL || C == basecoeffs());
149 
150  const int l = rows() * cols();
151 
152  for (int i=0; i < l; i++)
153  n_InpMult(v[i], bintop, basecoeffs());
154 }
static FORCE_INLINE void n_InpMult(number &a, number b, const coeffs r)
multiplication of &#39;a&#39; and &#39;b&#39;; replacement of &#39;a&#39; by the product a*b
Definition: coeffs.h:645
int rows() const
Definition: bigintmat.h:146
#define assume(x)
Definition: mod2.h:403
int cols() const
Definition: bigintmat.h:145
int i
Definition: cfEzgcd.cc:123
number * v
Definition: bigintmat.h:55
#define NULL
Definition: omList.c:10
coeffs basecoeffs() const
Definition: bigintmat.h:147
int l
Definition: cfEzgcd.cc:94

§ inpTranspose()

void bigintmat::inpTranspose ( )

transpose in place

Definition at line 51 of file bigintmat.cc.

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

§ isOne()

int bigintmat::isOne ( )

is matrix is identity

Definition at line 1310 of file bigintmat.cc.

1311 {
1312  coeffs r = basecoeffs();
1313  if (row==col)
1314  {
1315  for (int i=1; i<=row; i++)
1316  {
1317  for (int j=1; j<=col; j++)
1318  {
1319  if (i==j)
1320  {
1321  if (!n_IsOne(view(i, j), r))
1322  return 0;
1323  }
1324  else
1325  {
1326  if (!n_IsZero(view(i,j), r))
1327  return 0;
1328  }
1329  }
1330  }
1331  }
1332  return 1;
1333 }
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the one element.
Definition: coeffs.h:472
int row
Definition: bigintmat.h:56
const ring r
Definition: syzextra.cc:208
int j
Definition: myNF.cc:70
The main handler for Singular numbers which are suitable for Singular polynomials.
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:128
int i
Definition: cfEzgcd.cc:123
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the zero element.
Definition: coeffs.h:468
int col
Definition: bigintmat.h:57
coeffs basecoeffs() const
Definition: bigintmat.h:147

§ isZero()

int bigintmat::isZero ( )

Definition at line 1373 of file bigintmat.cc.

1374 {
1375  for (int i=1; i<=row; i++) {
1376  for (int j=1; j<=col; j++) {
1377  if (!n_IsZero(view(i,j), basecoeffs()))
1378  return FALSE;
1379  }
1380  }
1381  return TRUE;
1382 }
#define FALSE
Definition: auxiliary.h:95
int row
Definition: bigintmat.h:56
#define TRUE
Definition: auxiliary.h:99
int j
Definition: myNF.cc:70
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:128
int i
Definition: cfEzgcd.cc:123
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the zero element.
Definition: coeffs.h:468
int col
Definition: bigintmat.h:57
coeffs basecoeffs() const
Definition: bigintmat.h:147

§ length()

int bigintmat::length ( )
inline

Definition at line 144 of file bigintmat.h.

144 { return col*row; }
int row
Definition: bigintmat.h:56
int col
Definition: bigintmat.h:57

§ mod()

void bigintmat::mod ( number  p)

Reduziert komplette Matrix modulo p.

Definition at line 1926 of file bigintmat.cc.

1927 {
1928  // produce the matrix in Z/pZ
1929  number tmp1, tmp2;
1930  for (int i=1; i<=row; i++)
1931  {
1932  for (int j=1; j<=col; j++)
1933  {
1934  tmp1 = get(i, j);
1935  tmp2 = n_IntMod(tmp1, p, basecoeffs());
1936  n_Delete(&tmp1, basecoeffs());
1937  set(i, j, tmp2);
1938  }
1939  }
1940 }
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,b,r) >=0
Definition: coeffs.h:632
return P p
Definition: myNF.cc:203
int row
Definition: bigintmat.h:56
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
CFList tmp2
Definition: facFqBivar.cc:70
int col
Definition: bigintmat.h:57
coeffs basecoeffs() const
Definition: bigintmat.h:147
CFList tmp1
Definition: facFqBivar.cc:70
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:459

§ modgauss()

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

§ modhnf()

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

computes HNF(this | p*I)

Definition at line 1842 of file bigintmat.cc.

1843 {
1844  coeffs Rp = numbercoeffs(p, R); // R/pR
1845  bigintmat *m = bimChangeCoeff(this, Rp);
1846  m->howell();
1847  bigintmat *a = bimChangeCoeff(m, R);
1848  delete m;
1849  bigintmat *C = new bigintmat(rows(), rows(), R);
1850  int piv = rows(), i = a->cols();
1851  while (piv)
1852  {
1853  if (!i || n_IsZero(a->view(piv, i), R))
1854  {
1855  C->set(piv, piv, p, R);
1856  }
1857  else
1858  {
1859  C->copySubmatInto(a, 1, i, rows(), 1, 1, piv);
1860  i--;
1861  }
1862  piv--;
1863  }
1864  delete a;
1865  return C;
1866 }
const poly a
Definition: syzextra.cc:212
return P p
Definition: myNF.cc:203
Matrices of numbers.
Definition: bigintmat.h:51
int rows() const
Definition: bigintmat.h:146
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:96
static coeffs numbercoeffs(number n, coeffs c)
create Z/nA of type n_Zn
Definition: bigintmat.cc:22
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:1297
The main handler for Singular numbers which are suitable for Singular polynomials.
const ring R
Definition: DebugPrint.cc:36
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:128
int cols() const
Definition: bigintmat.h:145
int m
Definition: cfEzgcd.cc:119
int i
Definition: cfEzgcd.cc:123
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the zero element.
Definition: coeffs.h:468
bigintmat * bimChangeCoeff(bigintmat *a, coeffs cnew)
Liefert Kopier von Matrix a zurück, mit coeffs cnew statt den ursprünglichen.
Definition: bigintmat.cc:1814
bigintmat()
Definition: bigintmat.h:60
void howell()
dito, but Howell form (only different for zero-divsors)
Definition: bigintmat.cc:1595

§ one()

void bigintmat::one ( )

Macht Matrix (Falls quadratisch) zu Einheitsmatrix.

Definition at line 1335 of file bigintmat.cc.

1336 {
1337  if (row==col)
1338  {
1339  number one = n_Init(1, basecoeffs()),
1340  zero = n_Init(0, basecoeffs());
1341  for (int i=1; i<=row; i++)
1342  {
1343  for (int j=1; j<=col; j++)
1344  {
1345  if (i==j)
1346  {
1347  set(i, j, one);
1348  }
1349  else
1350  {
1351  set(i, j, zero);
1352  }
1353  }
1354  }
1355  n_Delete(&one, basecoeffs());
1356  n_Delete(&zero, basecoeffs());
1357  }
1358 }
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
int row
Definition: bigintmat.h:56
void zero()
Setzt alle Einträge auf 0.
Definition: bigintmat.cc:1360
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
int col
Definition: bigintmat.h:57
coeffs basecoeffs() const
Definition: bigintmat.h:147
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:459
void one()
Macht Matrix (Falls quadratisch) zu Einheitsmatrix.
Definition: bigintmat.cc:1335

§ 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 137 of file bigintmat.cc.

138 {
139  number iop = n_Init(intop, basecoeffs());
140 
141  inpMult(iop, basecoeffs());
142 
143  n_Delete(&iop, basecoeffs());
144 }
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
coeffs basecoeffs() const
Definition: bigintmat.h:147
void inpMult(number bintop, const coeffs C=NULL)
inplace version of skalar mult. CHANGES input.
Definition: bigintmat.cc:146
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:459

§ 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 112 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...
122  }
int row
Definition: bigintmat.h:56
#define assume(x)
Definition: mod2.h:403
int i
Definition: cfEzgcd.cc:123
int col
Definition: bigintmat.h:57
number * v
Definition: bigintmat.h:55
void Werror(const char *fmt,...)
Definition: reporter.cc:189

§ operator[]() [2/2]

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

Definition at line 123 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];
133  }
int row
Definition: bigintmat.h:56
#define assume(x)
Definition: mod2.h:403
int i
Definition: cfEzgcd.cc:123
int col
Definition: bigintmat.h:57
number * v
Definition: bigintmat.h:55
void Werror(const char *fmt,...)
Definition: reporter.cc:189

§ pprint()

void bigintmat::pprint ( int  maxwid)

Definition at line 615 of file bigintmat.cc.

616 {
617  if ((col==0) || (row==0))
618  PrintS("");
619  else
620  {
621  int * colwid = getwid(maxwid);
622  if (colwid == NULL)
623  {
624  WerrorS("not enough space to print bigintmat");
625  return;
626  }
627  char * ps;
628  int slength = 0;
629  for (int j=0; j<col; j++)
630  slength += colwid[j]*row;
631  slength += col*row+row;
632  ps = (char*) omAlloc0(sizeof(char)*(slength));
633  int pos = 0;
634  for (int i=0; i<col*row; i++)
635  {
636  StringSetS("");
637  n_Write(v[i], basecoeffs());
638  char * ts = StringEndS();
639  const int _nl = strlen(ts);
640  int cj = i%col;
641  if (_nl > colwid[cj])
642  {
643  StringSetS("");
644  int ci = i/col;
645  StringAppend("[%d,%d]", ci+1, cj+1);
646  char * ph = StringEndS();
647  int phl = strlen(ph);
648  if (phl > colwid[cj])
649  {
650  for (int j=0; j<colwid[cj]-1; j++)
651  ps[pos+j] = ' ';
652  ps[pos+colwid[cj]-1] = '*';
653  }
654  else
655  {
656  for (int j=0; j<colwid[cj]-phl; j++)
657  ps[pos+j] = ' ';
658  for (int j=0; j<phl; j++)
659  ps[pos+colwid[cj]-phl+j] = ph[j];
660  }
661  omFree(ph);
662  }
663  else // Mit Leerzeichen auffüllen und zahl reinschreiben
664  {
665  for (int j=0; j<colwid[cj]-_nl; j++)
666  ps[pos+j] = ' ';
667  for (int j=0; j<_nl; j++)
668  ps[pos+colwid[cj]-_nl+j] = ts[j];
669  }
670  // ", " und (evtl) "\n" einfügen
671  if ((i+1)%col == 0)
672  {
673  if (i != col*row-1)
674  {
675  ps[pos+colwid[cj]] = ',';
676  ps[pos+colwid[cj]+1] = '\n';
677  pos += colwid[cj]+2;
678  }
679  }
680  else
681  {
682  ps[pos+colwid[cj]] = ',';
683  pos += colwid[cj]+1;
684  }
685 
686  omFree(ts); // Hier ts zerstören
687  }
688  PrintS(ps);
689  omFree(ps);
690  }
691 }
int row
Definition: bigintmat.h:56
void WerrorS(const char *s)
Definition: feFopen.cc:24
char * StringEndS()
Definition: reporter.cc:151
int * getwid(int maxwid)
Definition: bigintmat.cc:583
int j
Definition: myNF.cc:70
#define omFree(addr)
Definition: omAllocDecl.h:261
void StringSetS(const char *st)
Definition: reporter.cc:128
static FORCE_INLINE void n_Write(number n, const coeffs r, const BOOLEAN bShortOut=TRUE)
Definition: coeffs.h:595
#define StringAppend
Definition: emacs.cc:82
int i
Definition: cfEzgcd.cc:123
void PrintS(const char *s)
Definition: reporter.cc:284
int col
Definition: bigintmat.h:57
number * v
Definition: bigintmat.h:55
#define NULL
Definition: omList.c:10
coeffs basecoeffs() const
Definition: bigintmat.h:147
#define omAlloc0(size)
Definition: omAllocDecl.h:211

§ Print()

void bigintmat::Print ( )

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

Definition at line 446 of file bigintmat.cc.

447 {
448  char * s = String();
449  PrintS(s);
450  omFree(s);
451 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
#define omFree(addr)
Definition: omAllocDecl.h:261
void PrintS(const char *s)
Definition: reporter.cc:284
char * String()
IO: String returns a singular string containing the matrix, needs freeing afterwards.
Definition: bigintmat.cc:439

§ pseudoinv()

number bigintmat::pseudoinv ( bigintmat a)

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

Definition at line 1425 of file bigintmat.cc.

1425  {
1426 
1427  // Falls Matrix über reellen Zahlen nicht invertierbar, breche ab
1428  assume((a->rows() == row) && (a->rows() == a->cols()) && (row == col));
1429 
1430  number det = this->det(); //computes the HNF, so should e reused.
1431  if ((n_IsZero(det, basecoeffs())))
1432  return det;
1433 
1434  // Hänge Einheitsmatrix über Matrix und wendet HNF an. An Stelle der Einheitsmatrix steht im Ergebnis die Transformationsmatrix dazu
1435  a->one();
1436  bigintmat *m = new bigintmat(2*row, col, basecoeffs());
1437  m->concatrow(a,this);
1438  m->hnf();
1439  // Arbeite weiterhin mit der zusammengehängten Matrix
1440  // 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
1441  number diag;
1442  number temp, ttemp;
1443  for (int i=1; i<=col; i++) {
1444  diag = m->get(row+i, i);
1445  for (int j=i+1; j<=col; j++) {
1446  temp = m->get(row+i, j);
1447  m->colskalmult(j, diag, basecoeffs());
1448  temp = n_InpNeg(temp, basecoeffs());
1449  m->addcol(j, i, temp, basecoeffs());
1450  n_Delete(&temp, basecoeffs());
1451  }
1452  n_Delete(&diag, basecoeffs());
1453  }
1454  // Falls wir nicht modulo n arbeiten, können wir die Spalten durch den ggT teilen, um die Einträge kleiner zu bekommen
1455  // Bei Z/n sparen wir uns das, da es hier sinnlos ist
1456  number g;
1457  number gcd;
1458  for (int j=1; j<=col; j++) {
1459  g = n_Init(0, basecoeffs());
1460  for (int i=1; i<=2*row; i++) {
1461  temp = m->get(i,j);
1462  gcd = n_Gcd(g, temp, basecoeffs());
1463  n_Delete(&g, basecoeffs());
1464  n_Delete(&temp, basecoeffs());
1465  g = n_Copy(gcd, basecoeffs());
1466  n_Delete(&gcd, basecoeffs());
1467  }
1468  if (!(n_IsOne(g, basecoeffs())))
1469  m->colskaldiv(j, g);
1470  n_Delete(&g, basecoeffs());
1471  }
1472 
1473  // 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)
1474 
1475  g = n_Init(0, basecoeffs());
1476  number prod = n_Init(1, basecoeffs());
1477  for (int i=1; i<=col; i++) {
1478  gcd = n_Gcd(g, m->get(row+i, i), basecoeffs());
1479  n_Delete(&g, basecoeffs());
1480  g = n_Copy(gcd, basecoeffs());
1481  n_Delete(&gcd, basecoeffs());
1482  ttemp = n_Copy(prod, basecoeffs());
1483  temp = m->get(row+i, i);
1484  n_Delete(&prod, basecoeffs());
1485  prod = n_Mult(ttemp, temp, basecoeffs());
1486  n_Delete(&ttemp, basecoeffs());
1487  n_Delete(&temp, basecoeffs());
1488  }
1489  number lcm;
1490  lcm = n_Div(prod, g, basecoeffs());
1491  for (int j=1; j<=col; j++) {
1492  ttemp = m->get(row+j,j);
1493  temp = n_QuotRem(lcm, ttemp, NULL, basecoeffs());
1494  m->colskalmult(j, temp, basecoeffs());
1495  n_Delete(&ttemp, basecoeffs());
1496  n_Delete(&temp, basecoeffs());
1497  }
1498  n_Delete(&lcm, basecoeffs());
1499  n_Delete(&prod, basecoeffs());
1500 
1501  number divisor = m->get(row+1, 1);
1502  m->splitrow(a, 1);
1503  delete m;
1504  n_Delete(&det, basecoeffs());
1505  return divisor;
1506 }
static FORCE_INLINE number n_Gcd(number a, number b, const coeffs r)
in Z: return the gcd of &#39;a&#39; and &#39;b&#39; in Z/nZ, Z/2^kZ: computed as in the case Z in Z/pZ...
Definition: coeffs.h:690
void concatrow(bigintmat *a, bigintmat *b)
Fügt zwei Matrixen untereinander/nebeneinander in gegebene Matrix ein, bzw spaltet gegebenen Matrix a...
Definition: bigintmat.cc:1049
int lcm(unsigned long *l, unsigned long *a, unsigned long *b, unsigned long p, int dega, int degb)
Definition: minpoly.cc:711
number det()
det (via LaPlace in general, hnf for euc. rings)
Definition: bigintmat.cc:1522
bool addcol(int i, int j, number a, coeffs c)
addiert a-faches der j-ten Spalte zur i-ten dazu
Definition: bigintmat.cc:969
void colskaldiv(int j, number b)
Macht Ganzzahldivision aller j-ten Spalteneinträge mit b.
Definition: bigintmat.cc:1886
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the one element.
Definition: coeffs.h:472
Matrices of numbers.
Definition: bigintmat.h:51
int rows() 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
int row
Definition: bigintmat.h:56
g
Definition: cfModGcd.cc:4031
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of &#39;a&#39; and &#39;b&#39;, i.e., a*b
Definition: coeffs.h:640
int j
Definition: myNF.cc:70
#define assume(x)
Definition: mod2.h:403
int cols() const
Definition: bigintmat.h:145
int m
Definition: cfEzgcd.cc:119
static FORCE_INLINE number n_QuotRem(number a, number b, number *q, const coeffs r)
Definition: coeffs.h:707
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
void hnf()
transforms INPLACE to HNF
Definition: bigintmat.cc:1670
int i
Definition: cfEzgcd.cc:123
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the zero element.
Definition: coeffs.h:468
int col
Definition: bigintmat.h:57
void colskalmult(int i, number a, coeffs c)
Multipliziert zur i-ten Spalte den Skalar a hinzu.
Definition: bigintmat.cc:1017
#define NULL
Definition: omList.c:10
bigintmat()
Definition: bigintmat.h:60
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of &#39;n&#39;
Definition: coeffs.h:455
static FORCE_INLINE number n_Div(number a, number b, const coeffs r)
return the quotient of &#39;a&#39; and &#39;b&#39;, i.e., a/b; raises an error if &#39;b&#39; is not invertible in r exceptio...
Definition: coeffs.h:619
int gcd(int a, int b)
Definition: walkSupport.cc:839
coeffs basecoeffs() const
Definition: bigintmat.h:147
fq_nmod_poly_t prod
Definition: facHensel.cc:95
void splitrow(bigintmat *a, bigintmat *b)
Speichert in Matrix a den oberen, in b den unteren Teil der Matrix, vorausgesetzt die Dimensionen sti...
Definition: bigintmat.cc:1137
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:459
number get(int i, int j) const
get a copy of an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:120
void one()
Macht Matrix (Falls quadratisch) zu Einheitsmatrix.
Definition: bigintmat.cc:1335

§ rawset() [1/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 197 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
214  }
int rows() const
Definition: bigintmat.h:146
#define assume(x)
Definition: mod2.h:403
int cols() const
Definition: bigintmat.h:145
int i
Definition: cfEzgcd.cc:123
number * v
Definition: bigintmat.h:55
#define NULL
Definition: omList.c:10
coeffs basecoeffs() const
Definition: bigintmat.h:147
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:459
void Werror(const char *fmt,...)
Definition: reporter.cc:189
int l
Definition: cfEzgcd.cc:94

§ rawset() [2/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 217 of file bigintmat.h.

218  {
219  rawset( index(i,j), n, C);
220  }
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:197
int j
Definition: myNF.cc:70
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:162
int i
Definition: cfEzgcd.cc:123

§ rows()

int bigintmat::rows ( ) const
inline

Definition at line 146 of file bigintmat.h.

146 { return row; }
int row
Definition: bigintmat.h:56

§ rowskalmult()

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

... Zeile ...

Definition at line 1033 of file bigintmat.cc.

1034 {
1035  if ((i>=1) && (i<=row) && (nCoeffs_are_equal(c, basecoeffs())))
1036  {
1037  number t, tmult;
1038  for (int j=1; j<=col; j++)
1039  {
1040  t = view(i, j);
1041  tmult = n_Mult(a, t, basecoeffs());
1042  rawset(i, j, tmult);
1043  }
1044  }
1045  else
1046  WerrorS("Error in rowskalmult");
1047 }
const poly a
Definition: syzextra.cc:212
int row
Definition: bigintmat.h:56
void WerrorS(const char *s)
Definition: feFopen.cc:24
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:197
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of &#39;a&#39; and &#39;b&#39;, i.e., a*b
Definition: coeffs.h:640
int j
Definition: myNF.cc:70
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:128
int i
Definition: cfEzgcd.cc:123
int col
Definition: bigintmat.h:57
coeffs basecoeffs() const
Definition: bigintmat.h:147
bool nCoeffs_are_equal(coeffs r, coeffs s)
Definition: bigintmat.cc:2655

§ 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 96 of file bigintmat.cc.

97 {
98  assume (C == NULL || C == basecoeffs());
99  assume (i > 0 && j > 0);
100  assume (i <= rows() && j <= cols());
101  set(index(i, j), n, C);
102 }
int rows() const
Definition: bigintmat.h:146
int j
Definition: myNF.cc:70
#define assume(x)
Definition: mod2.h:403
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:162
int cols() const
Definition: bigintmat.h:145
int i
Definition: cfEzgcd.cc:123
#define NULL
Definition: omList.c:10
coeffs basecoeffs() const
Definition: bigintmat.h:147

§ 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 88 of file bigintmat.cc.

89 {
90  assume (C == NULL || C == basecoeffs());
91 
92  rawset(i, n_Copy(n, basecoeffs()), basecoeffs());
93 }
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:197
#define assume(x)
Definition: mod2.h:403
int i
Definition: cfEzgcd.cc:123
#define NULL
Definition: omList.c:10
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of &#39;n&#39;
Definition: coeffs.h:455
coeffs basecoeffs() const
Definition: bigintmat.h:147

§ setcol()

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

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

Definition at line 836 of file bigintmat.cc.

837 {
838  if ((j>col) || (j<1))
839  {
840  WerrorS("Error in setcol: Index out of range!");
841  return;
842  }
843  if (((m->rows() != row) || (m->cols() != 1)) && ((m->rows() != 1) || (m->cols() != row)))
844  {
845  WerrorS("Error in setcol. Dimensions must agree!");
846  return;
847  }
849  {
851  number t1,t2;
852  for (int i=1; i<=row; i++)
853  {
854  t1 = m->get(i-1);
855  t2 = f(t1, m->basecoeffs(),basecoeffs());
856  set(i, j, t2);
857  n_Delete(&t2, basecoeffs());
858  n_Delete(&t1, m->basecoeffs());
859  }
860  return;
861  }
862  number t1;
863  for (int i=1; i<=row; i++)
864  {
865  t1 = m->view(i-1);
866  set(i, j, t1);
867  }
868 }
int rows() const
Definition: bigintmat.h:146
int row
Definition: bigintmat.h:56
void WerrorS(const char *s)
Definition: feFopen.cc:24
int j
Definition: myNF.cc:70
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:73
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:128
int cols() const
Definition: bigintmat.h:145
FILE * f
Definition: checklibs.c:7
int i
Definition: cfEzgcd.cc:123
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:725
int col
Definition: bigintmat.h:57
coeffs basecoeffs() const
Definition: bigintmat.h:147
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:459
number get(int i, int j) const
get a copy of an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:120
bool nCoeffs_are_equal(coeffs r, coeffs s)
Definition: bigintmat.cc:2655

§ setrow()

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

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

Definition at line 870 of file bigintmat.cc.

871 {
872  if ((j>row) || (j<1))
873  {
874  WerrorS("Error in setrow: Index out of range!");
875  return;
876  }
877  if (((m->rows() != 1) || (m->cols() != col)) && ((m->rows() != col) || (m->cols() != 1)))
878  {
879  WerrorS("Error in setrow. Dimensions must agree!");
880  return;
881  }
883  {
885  number tmp1,tmp2;
886  for (int i=1; i<=col; i++)
887  {
888  tmp1 = m->get(i-1);
889  tmp2 = f(tmp1, m->basecoeffs(),basecoeffs());
890  set(j, i, tmp2);
891  n_Delete(&tmp2, basecoeffs());
892  n_Delete(&tmp1, m->basecoeffs());
893  }
894  return;
895  }
896  number tmp;
897  for (int i=1; i<=col; i++)
898  {
899  tmp = m->view(i-1);
900  set(j, i, tmp);
901  }
902 }
int rows() const
Definition: bigintmat.h:146
int row
Definition: bigintmat.h:56
void WerrorS(const char *s)
Definition: feFopen.cc:24
int j
Definition: myNF.cc:70
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:73
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:128
int cols() const
Definition: bigintmat.h:145
FILE * f
Definition: checklibs.c:7
int i
Definition: cfEzgcd.cc:123
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:725
CFList tmp2
Definition: facFqBivar.cc:70
int col
Definition: bigintmat.h:57
coeffs basecoeffs() const
Definition: bigintmat.h:147
CFList tmp1
Definition: facFqBivar.cc:70
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:459
number get(int i, int j) const
get a copy of an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:120
bool nCoeffs_are_equal(coeffs r, coeffs s)
Definition: bigintmat.cc:2655

§ simplifyContentDen()

void bigintmat::simplifyContentDen ( number *  den)

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

Definition at line 2698 of file bigintmat.cc.

2699 {
2700  coeffs r = basecoeffs();
2701  number g = n_Copy(*d, r), h;
2702  int n=rows()*cols();
2703  for(int i=0; i<n && !n_IsOne(g, r); i++)
2704  {
2705  h = n_Gcd(g, view(i), r);
2706  n_Delete(&g, r);
2707  g=h;
2708  }
2709  *d = n_Div(*d, g, r);
2710  if (!n_IsOne(g, r))
2711  skaldiv(g);
2712 }
void skaldiv(number b)
Macht Ganzzahldivision aller Matrixeinträge mit b.
Definition: bigintmat.cc:1871
static FORCE_INLINE number n_Gcd(number a, number b, const coeffs r)
in Z: return the gcd of &#39;a&#39; and &#39;b&#39; in Z/nZ, Z/2^kZ: computed as in the case Z in Z/pZ...
Definition: coeffs.h:690
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the one element.
Definition: coeffs.h:472
int rows() const
Definition: bigintmat.h:146
g
Definition: cfModGcd.cc:4031
const ring r
Definition: syzextra.cc:208
The main handler for Singular numbers which are suitable for Singular polynomials.
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:128
int cols() const
Definition: bigintmat.h:145
int i
Definition: cfEzgcd.cc:123
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of &#39;n&#39;
Definition: coeffs.h:455
static FORCE_INLINE number n_Div(number a, number b, const coeffs r)
return the quotient of &#39;a&#39; and &#39;b&#39;, i.e., a/b; raises an error if &#39;b&#39; is not invertible in r exceptio...
Definition: coeffs.h:619
coeffs basecoeffs() const
Definition: bigintmat.h:147
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:459
static Poly * h
Definition: janet.cc:978

§ skaldiv()

void bigintmat::skaldiv ( number  b)

Macht Ganzzahldivision aller Matrixeinträge mit b.

Definition at line 1871 of file bigintmat.cc.

1872 {
1873  number tmp1, tmp2;
1874  for (int i=1; i<=row; i++)
1875  {
1876  for (int j=1; j<=col; j++)
1877  {
1878  tmp1 = view(i, j);
1879  tmp2 = n_Div(tmp1, b, basecoeffs());
1880  rawset(i, j, tmp2);
1881  }
1882  }
1883 }
int row
Definition: bigintmat.h:56
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:197
int j
Definition: myNF.cc:70
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:128
int i
Definition: cfEzgcd.cc:123
CFList tmp2
Definition: facFqBivar.cc:70
int col
Definition: bigintmat.h:57
static FORCE_INLINE number n_Div(number a, number b, const coeffs r)
return the quotient of &#39;a&#39; and &#39;b&#39;, i.e., a/b; raises an error if &#39;b&#39; is not invertible in r exceptio...
Definition: coeffs.h:619
coeffs basecoeffs() const
Definition: bigintmat.h:147
CFList tmp1
Definition: facFqBivar.cc:70
const poly b
Definition: syzextra.cc:213

§ skalmult()

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

Multipliziert zur Matrix den Skalar b hinzu.

Definition at line 948 of file bigintmat.cc.

949 {
950  if (!nCoeffs_are_equal(c, basecoeffs()))
951  {
952  WerrorS("Wrong coeffs\n");
953  return false;
954  }
955  number t1, t2;
956  if ( n_IsOne(b,c)) return true;
957  for (int i=1; i<=row; i++)
958  {
959  for (int j=1; j<=col; j++)
960  {
961  t1 = view(i, j);
962  t2 = n_Mult(t1, b, basecoeffs());
963  rawset(i, j, t2);
964  }
965  }
966  return true;
967 }
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the one element.
Definition: coeffs.h:472
int row
Definition: bigintmat.h:56
void WerrorS(const char *s)
Definition: feFopen.cc:24
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:197
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of &#39;a&#39; and &#39;b&#39;, i.e., a*b
Definition: coeffs.h:640
int j
Definition: myNF.cc:70
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:128
int i
Definition: cfEzgcd.cc:123
int col
Definition: bigintmat.h:57
coeffs basecoeffs() const
Definition: bigintmat.h:147
const poly b
Definition: syzextra.cc:213
bool nCoeffs_are_equal(coeffs r, coeffs s)
Definition: bigintmat.cc:2655

§ splitcol() [1/2]

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

... linken ... rechten ...

Definition at line 1179 of file bigintmat.cc.

1180 {
1181  int ay = a->cols();
1182  int ax = a->rows();
1183  int by = b->cols();
1184  int bx = b->rows();
1185  number tmp;
1186  if (!((row == ax) && (row == bx)))
1187  {
1188  WerrorS("Error in splitcol. Dimensions must agree!");
1189  }
1190  else if (!(ay+by == col))
1191  {
1192  WerrorS("Error in splitcol. Dimensions must agree!");
1193  }
1195  {
1196  WerrorS("Error in splitcol. coeffs do not agree!");
1197  }
1198  else
1199  {
1200  for (int i=1; i<=ax; i++)
1201  {
1202  for (int j=1; j<=ay; j++)
1203  {
1204  tmp = view(i,j);
1205  a->set(i,j,tmp);
1206  }
1207  }
1208  for (int i=1; i<=bx; i++)
1209  {
1210  for (int j=1; j<=by; j++)
1211  {
1212  tmp = view(i,j+ay);
1213  b->set(i,j,tmp);
1214  }
1215  }
1216  }
1217 }
int rows() const
Definition: bigintmat.h:146
int row
Definition: bigintmat.h:56
void WerrorS(const char *s)
Definition: feFopen.cc:24
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:96
int j
Definition: myNF.cc:70
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:128
int cols() const
Definition: bigintmat.h:145
int i
Definition: cfEzgcd.cc:123
int col
Definition: bigintmat.h:57
coeffs basecoeffs() const
Definition: bigintmat.h:147
bool nCoeffs_are_equal(coeffs r, coeffs s)
Definition: bigintmat.cc:2655

§ splitcol() [2/2]

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

Speichert die ersten i Spalten als Teilmatrix in a.

Definition at line 1219 of file bigintmat.cc.

1220 {
1221  number tmp;
1222  if ((a->rows() != row) || (a->cols()+i-1 > col) || (i<1))
1223  {
1224  WerrorS("Error in splitcol. Dimensions must agree!");
1225  return;
1226  }
1227  if (!(nCoeffs_are_equal(a->basecoeffs(), basecoeffs())))
1228  {
1229  WerrorS("Error in splitcol. coeffs do not agree!");
1230  return;
1231  }
1232  int width = a->cols();
1233  for (int j=1; j<=width; j++)
1234  {
1235  for (int k=1; k<=row; k++)
1236  {
1237  tmp = get(k, j+i-1);
1238  a->set(k, j, tmp);
1239  n_Delete(&tmp, basecoeffs());
1240  }
1241  }
1242 }
int rows() const
Definition: bigintmat.h:146
int row
Definition: bigintmat.h:56
void WerrorS(const char *s)
Definition: feFopen.cc:24
int k
Definition: cfEzgcd.cc:93
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:96
int j
Definition: myNF.cc:70
int cols() const
Definition: bigintmat.h:145
int i
Definition: cfEzgcd.cc:123
int col
Definition: bigintmat.h:57
coeffs basecoeffs() const
Definition: bigintmat.h:147
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:459
bool nCoeffs_are_equal(coeffs r, coeffs s)
Definition: bigintmat.cc:2655

§ 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 1137 of file bigintmat.cc.

1138 {
1139  int ay = a->cols();
1140  int ax = a->rows();
1141  int by = b->cols();
1142  int bx = b->rows();
1143  number tmp;
1144  if (!(ax + bx == row))
1145  {
1146  WerrorS("Error in splitrow. Dimensions must agree!");
1147  }
1148  else if (!((col == ay) && (col == by)))
1149  {
1150  WerrorS("Error in splitrow. Dimensions must agree!");
1151  }
1153  {
1154  WerrorS("Error in splitrow. coeffs do not agree!");
1155  }
1156  else
1157  {
1158  for(int i = 1; i<=ax; i++)
1159  {
1160  for(int j = 1; j<=ay;j++)
1161  {
1162  tmp = get(i,j);
1163  a->set(i,j,tmp);
1164  n_Delete(&tmp, basecoeffs());
1165  }
1166  }
1167  for (int i =1; i<=bx; i++)
1168  {
1169  for (int j=1;j<=col;j++)
1170  {
1171  tmp = get(i+ax, j);
1172  b->set(i,j,tmp);
1173  n_Delete(&tmp, basecoeffs());
1174  }
1175  }
1176  }
1177 }
int rows() const
Definition: bigintmat.h:146
int row
Definition: bigintmat.h:56
void WerrorS(const char *s)
Definition: feFopen.cc:24
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:96
int j
Definition: myNF.cc:70
int cols() const
Definition: bigintmat.h:145
int i
Definition: cfEzgcd.cc:123
int col
Definition: bigintmat.h:57
coeffs basecoeffs() const
Definition: bigintmat.h:147
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:459
bool nCoeffs_are_equal(coeffs r, coeffs s)
Definition: bigintmat.cc:2655

§ splitrow() [2/2]

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

... Zeilen ...

Definition at line 1244 of file bigintmat.cc.

1245 {
1246  number tmp;
1247  if ((a->cols() != col) || (a->rows()+i-1 > row) || (i<1))
1248  {
1249  WerrorS("Error in Marco-splitrow");
1250  return;
1251  }
1252 
1253  if (!(nCoeffs_are_equal(a->basecoeffs(), basecoeffs())))
1254  {
1255  WerrorS("Error in splitrow. coeffs do not agree!");
1256  return;
1257  }
1258  int height = a->rows();
1259  for (int j=1; j<=height; j++)
1260  {
1261  for (int k=1; k<=col; k++)
1262  {
1263  tmp = view(j+i-1, k);
1264  a->set(j, k, tmp);
1265  }
1266  }
1267 }
int rows() const
Definition: bigintmat.h:146
int row
Definition: bigintmat.h:56
void WerrorS(const char *s)
Definition: feFopen.cc:24
int k
Definition: cfEzgcd.cc:93
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:96
int j
Definition: myNF.cc:70
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:128
int cols() const
Definition: bigintmat.h:145
int i
Definition: cfEzgcd.cc:123
int col
Definition: bigintmat.h:57
coeffs basecoeffs() const
Definition: bigintmat.h:147
bool nCoeffs_are_equal(coeffs r, coeffs s)
Definition: bigintmat.cc:2655

§ String()

char * bigintmat::String ( )

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

Definition at line 439 of file bigintmat.cc.

440 {
441  StringSetS("");
442  Write();
443  return StringEndS();
444 }
char * StringEndS()
Definition: reporter.cc:151
void Write()
IO: writes the matrix into the current internal string buffer which must be started/ allocated before...
Definition: bigintmat.cc:416
void StringSetS(const char *st)
Definition: reporter.cc:128

§ 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 454 of file bigintmat.cc.

455 {
456  if ((col==0) || (row==0))
457  return NULL;
458  else
459  {
460  int * colwid = getwid(80);
461  if (colwid == NULL)
462  {
463  WerrorS("not enough space to print bigintmat");
464  WerrorS("try string(...) for a unformatted output");
465  return NULL;
466  }
467  char * ps;
468  int slength = 0;
469  for (int j=0; j<col; j++)
470  slength += colwid[j]*row;
471  slength += col*row+row;
472  ps = (char*) omAlloc0(sizeof(char)*(slength));
473  int pos = 0;
474  for (int i=0; i<col*row; i++)
475  {
476  StringSetS("");
477  n_Write(v[i], basecoeffs());
478  char * ts = StringEndS();
479  const int _nl = strlen(ts);
480  int cj = i%col;
481  if (_nl > colwid[cj])
482  {
483  StringSetS("");
484  int ci = i/col;
485  StringAppend("[%d,%d]", ci+1, cj+1);
486  char * ph = StringEndS();
487  int phl = strlen(ph);
488  if (phl > colwid[cj])
489  {
490  for (int j=0; j<colwid[cj]-1; j++)
491  ps[pos+j] = ' ';
492  ps[pos+colwid[cj]-1] = '*';
493  }
494  else
495  {
496  for (int j=0; j<colwid[cj]-phl; j++)
497  ps[pos+j] = ' ';
498  for (int j=0; j<phl; j++)
499  ps[pos+colwid[cj]-phl+j] = ph[j];
500  }
501  omFree(ph);
502  }
503  else // Mit Leerzeichen auffüllen und zahl reinschreiben
504  {
505  for (int j=0; j<(colwid[cj]-_nl); j++)
506  ps[pos+j] = ' ';
507  for (int j=0; j<_nl; j++)
508  ps[pos+colwid[cj]-_nl+j] = ts[j];
509  }
510  // ", " und (evtl) "\n" einfügen
511  if ((i+1)%col == 0)
512  {
513  if (i != col*row-1)
514  {
515  ps[pos+colwid[cj]] = ',';
516  ps[pos+colwid[cj]+1] = '\n';
517  pos += colwid[cj]+2;
518  }
519  }
520  else
521  {
522  ps[pos+colwid[cj]] = ',';
523  pos += colwid[cj]+1;
524  }
525  omFree(ts); // Hier ts zerstören
526  }
527  return(ps);
528  // omFree(ps);
529 }
530 }
int row
Definition: bigintmat.h:56
void WerrorS(const char *s)
Definition: feFopen.cc:24
char * StringEndS()
Definition: reporter.cc:151
int * getwid(int maxwid)
Definition: bigintmat.cc:583
int j
Definition: myNF.cc:70
#define omFree(addr)
Definition: omAllocDecl.h:261
void StringSetS(const char *st)
Definition: reporter.cc:128
static FORCE_INLINE void n_Write(number n, const coeffs r, const BOOLEAN bShortOut=TRUE)
Definition: coeffs.h:595
#define StringAppend
Definition: emacs.cc:82
int i
Definition: cfEzgcd.cc:123
int col
Definition: bigintmat.h:57
number * v
Definition: bigintmat.h:55
#define NULL
Definition: omList.c:10
coeffs basecoeffs() const
Definition: bigintmat.h:147
#define omAlloc0(size)
Definition: omAllocDecl.h:211

§ sub()

bool bigintmat::sub ( bigintmat b)

Subtrahiert ...

Definition at line 926 of file bigintmat.cc.

927 {
928  if ((b->rows() != row) || (b->cols() != col))
929  {
930  WerrorS("Error in bigintmat::sub. Dimensions do not agree!");
931  return false;
932  }
934  {
935  WerrorS("Error in bigintmat::sub. coeffs do not agree!");
936  return false;
937  }
938  for (int i=1; i<=row; i++)
939  {
940  for (int j=1; j<=col; j++)
941  {
942  rawset(i, j, n_Sub(view(i,j), b->view(i,j), basecoeffs()));
943  }
944  }
945  return true;
946 }
static FORCE_INLINE number n_Sub(number a, number b, const coeffs r)
return the difference of &#39;a&#39; and &#39;b&#39;, i.e., a-b
Definition: coeffs.h:673
int rows() const
Definition: bigintmat.h:146
int row
Definition: bigintmat.h:56
void WerrorS(const char *s)
Definition: feFopen.cc:24
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:197
int j
Definition: myNF.cc:70
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:128
int cols() const
Definition: bigintmat.h:145
int i
Definition: cfEzgcd.cc:123
int col
Definition: bigintmat.h:57
coeffs basecoeffs() const
Definition: bigintmat.h:147
bool nCoeffs_are_equal(coeffs r, coeffs s)
Definition: bigintmat.cc:2655

§ swap()

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

swap columns i and j

Definition at line 695 of file bigintmat.cc.

696 {
697  if ((i <= col) && (j <= col) && (i>0) && (j>0))
698  {
699  number tmp;
700  number t;
701  for (int k=1; k<=row; k++)
702  {
703  tmp = get(k, i);
704  t = view(k, j);
705  set(k, i, t);
706  set(k, j, tmp);
707  n_Delete(&tmp, basecoeffs());
708  }
709  }
710  else
711  WerrorS("Error in swap");
712 }
int row
Definition: bigintmat.h:56
void WerrorS(const char *s)
Definition: feFopen.cc:24
int k
Definition: cfEzgcd.cc:93
int j
Definition: myNF.cc:70
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:128
int i
Definition: cfEzgcd.cc:123
int col
Definition: bigintmat.h:57
coeffs basecoeffs() const
Definition: bigintmat.h:147
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:459

§ swapMatrix()

void bigintmat::swapMatrix ( bigintmat a)

Definition at line 1576 of file bigintmat.cc.

1577 {
1578  int n = rows(), m = cols();
1579  row = a->rows();
1580  col = a->cols();
1581  number * V = v;
1582  v = a->v;
1583  a->v = V;
1584  a->row = n;
1585  a->col = m;
1586 }
int rows() const
Definition: bigintmat.h:146
int row
Definition: bigintmat.h:56
int cols() const
Definition: bigintmat.h:145
int m
Definition: cfEzgcd.cc:119
int col
Definition: bigintmat.h:57
number * v
Definition: bigintmat.h:55

§ swaprow()

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

swap rows i and j

Definition at line 714 of file bigintmat.cc.

715 {
716  if ((i <= row) && (j <= row) && (i>0) && (j>0))
717  {
718  number tmp;
719  number t;
720  for (int k=1; k<=col; k++)
721  {
722  tmp = get(i, k);
723  t = view(j, k);
724  set(i, k, t);
725  set(j, k, tmp);
726  n_Delete(&tmp, basecoeffs());
727  }
728  }
729  else
730  WerrorS("Error in swaprow");
731 }
int row
Definition: bigintmat.h:56
void WerrorS(const char *s)
Definition: feFopen.cc:24
int k
Definition: cfEzgcd.cc:93
int j
Definition: myNF.cc:70
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:128
int i
Definition: cfEzgcd.cc:123
int col
Definition: bigintmat.h:57
coeffs basecoeffs() const
Definition: bigintmat.h:147
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:459

§ trace()

number bigintmat::trace ( )

the trace ....

Definition at line 1508 of file bigintmat.cc.

1509 {
1510  assume (col == row);
1511  number t = get(1,1),
1512  h;
1513  coeffs r = basecoeffs();
1514  for(int i=2; i<= col; i++) {
1515  h = n_Add(t, view(i,i), r);
1516  n_Delete(&t, r);
1517  t = h;
1518  }
1519  return t;
1520 }
int row
Definition: bigintmat.h:56
const ring r
Definition: syzextra.cc:208
#define assume(x)
Definition: mod2.h:403
The main handler for Singular numbers which are suitable for Singular polynomials.
static FORCE_INLINE number n_Add(number a, number b, const coeffs r)
return the sum of &#39;a&#39; and &#39;b&#39;, i.e., a+b
Definition: coeffs.h:660
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:128
int i
Definition: cfEzgcd.cc:123
int col
Definition: bigintmat.h:57
coeffs basecoeffs() const
Definition: bigintmat.h:147
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:459
static Poly * h
Definition: janet.cc:978

§ transpose()

bigintmat * bigintmat::transpose ( )

Definition at line 38 of file bigintmat.cc.

39 {
40  bigintmat * t = new bigintmat(col, row, basecoeffs());
41  for (int i=1; i<=row; i++)
42  {
43  for (int j=1; j<=col; j++)
44  {
45  t->set(j, i, BIMATELEM(*this,i,j));
46  }
47  }
48  return t;
49 }
Matrices of numbers.
Definition: bigintmat.h:51
int row
Definition: bigintmat.h:56
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:96
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
#define BIMATELEM(M, I, J)
Definition: bigintmat.h:134
int col
Definition: bigintmat.h:57
bigintmat()
Definition: bigintmat.h:60
coeffs basecoeffs() const
Definition: bigintmat.h:147

§ view() [1/2]

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

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

Definition at line 128 of file bigintmat.cc.

129 {
130  assume (i >= 0 && j >= 0);
131  assume (i <= rows() && j <= cols());
132 
133  return view(index(i, j));
134 }
int rows() const
Definition: bigintmat.h:146
int j
Definition: myNF.cc:70
#define assume(x)
Definition: mod2.h:403
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:162
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:128
int cols() const
Definition: bigintmat.h:145
int i
Definition: cfEzgcd.cc:123

§ view() [2/2]

number bigintmat::view ( int  i) const

view an entry. NOTE: starts at [0]

Definition at line 112 of file bigintmat.cc.

113 {
114  assume (i >= 0);
115  assume (i<rows()*cols());
116 
117  return v[i];
118 }
int rows() const
Definition: bigintmat.h:146
#define assume(x)
Definition: mod2.h:403
int cols() const
Definition: bigintmat.h:145
int i
Definition: cfEzgcd.cc:123
number * v
Definition: bigintmat.h:55

§ 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 416 of file bigintmat.cc.

417 {
418  int n = cols(), m=rows();
419 
420  StringAppendS("[ ");
421  for(int i=1; i<= m; i++)
422  {
423  StringAppendS("[ ");
424  for(int j=1; j< n; j++)
425  {
426  n_Write(v[(i-1)*n+j-1], basecoeffs());
427  StringAppendS(", ");
428  }
429  if (n) n_Write(v[i*n-1], basecoeffs());
430  StringAppendS(" ]");
431  if (i<m)
432  {
433  StringAppendS(", ");
434  }
435  }
436  StringAppendS(" ] ");
437 }
int rows() const
Definition: bigintmat.h:146
int j
Definition: myNF.cc:70
void StringAppendS(const char *st)
Definition: reporter.cc:107
static FORCE_INLINE void n_Write(number n, const coeffs r, const BOOLEAN bShortOut=TRUE)
Definition: coeffs.h:595
int cols() const
Definition: bigintmat.h:145
int m
Definition: cfEzgcd.cc:119
int i
Definition: cfEzgcd.cc:123
number * v
Definition: bigintmat.h:55
coeffs basecoeffs() const
Definition: bigintmat.h:147

§ zero()

void bigintmat::zero ( )

Setzt alle Einträge auf 0.

Definition at line 1360 of file bigintmat.cc.

1361 {
1362  number tmp = n_Init(0, basecoeffs());
1363  for (int i=1; i<=row; i++)
1364  {
1365  for (int j=1; j<=col; j++)
1366  {
1367  set(i, j, tmp);
1368  }
1369  }
1370  n_Delete(&tmp,basecoeffs());
1371 }
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
int row
Definition: bigintmat.h:56
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
int col
Definition: bigintmat.h:57
coeffs basecoeffs() const
Definition: bigintmat.h:147
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:459

Field Documentation

§ col

int bigintmat::col
private

Definition at line 57 of file bigintmat.h.

§ m_coeffs

coeffs bigintmat::m_coeffs
private

Definition at line 54 of file bigintmat.h.

§ row

int bigintmat::row
private

Definition at line 56 of file bigintmat.h.

§ v

number* bigintmat::v
private

Definition at line 55 of file bigintmat.h.


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