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:394
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:394
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:115
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 902 of file bigintmat.cc.

903 {
904  if ((b->rows() != row) || (b->cols() != col))
905  {
906  WerrorS("Error in bigintmat::add. Dimensions do not agree!");
907  return false;
908  }
910  {
911  WerrorS("Error in bigintmat::add. coeffs do not agree!");
912  return false;
913  }
914  for (int i=1; i<=row; i++)
915  {
916  for (int j=1; j<=col; j++)
917  {
918  rawset(i, j, n_Add(b->view(i,j), view(i,j), basecoeffs()));
919  }
920  }
921  return true;
922 }
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:2653

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

968 {
969  if ((i>col) || (j>col) || (i<1) || (j<1))
970  {
971  WerrorS("Error in addcol: Index out of range!");
972  return false;
973  }
974  if (!nCoeffs_are_equal(c, basecoeffs()))
975  {
976  WerrorS("Error in addcol: coeffs do not agree!");
977  return false;
978  }
979  number t1, t2, t3;
980  for (int k=1; k<=row; k++)
981  {
982  t1 = view(k, j);
983  t2 = view(k, i);
984  t3 = n_Mult(t1, a, basecoeffs());
985  n_InpAdd(t3, t2, basecoeffs());
986  rawset(k, i, t3);
987  }
988  return true;
989 }
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:2653

◆ addrow()

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

... Zeile ...

Definition at line 991 of file bigintmat.cc.

992 {
993  if ((i>row) || (j>row) || (i<1) || (j<1))
994  {
995  WerrorS("Error in addrow: Index out of range!");
996  return false;
997  }
998  if (!nCoeffs_are_equal(c, basecoeffs()))
999  {
1000  WerrorS("Error in addrow: coeffs do not agree!");
1001  return false;
1002  }
1003  number t1, t2, t3;
1004  for (int k=1; k<=col; k++)
1005  {
1006  t1 = view(j, k);
1007  t2 = view(i, k);
1008  t3 = n_Mult(t1, a, basecoeffs());
1009  n_InpAdd(t3, t2, basecoeffs());
1010  rawset(i, k, t3);
1011  }
1012  return true;
1013 }
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:2653

◆ appendCol()

void bigintmat::appendCol ( bigintmat a)

horizontally join the matrices, m <- m|a

Definition at line 1091 of file bigintmat.cc.

1092 {
1093  coeffs R = basecoeffs();
1094  int ay = a->cols();
1095  int ax = a->rows();
1096  assume(row == ax);
1097 
1099 
1100  bigintmat * tmp = new bigintmat(rows(), cols() + ay, R);
1101  tmp->concatcol(this, a);
1102  this->swapMatrix(tmp);
1103  delete tmp;
1104 }
void concatcol(bigintmat *a, bigintmat *b)
Definition: bigintmat.cc:1106
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:394
void swapMatrix(bigintmat *a)
Definition: bigintmat.cc:1574
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:2653

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

1586 {
1587  coeffs R = basecoeffs();
1588  for(int i=1; i<=rows(); i++)
1589  if (!n_IsZero(view(i, j), R)) return FALSE;
1590  return TRUE;
1591 }
#define FALSE
Definition: auxiliary.h:94
int rows() const
Definition: bigintmat.h:146
#define TRUE
Definition: auxiliary.h:98
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 1884 of file bigintmat.cc.

1885 {
1886  number tmp1, tmp2;
1887  for (int i=1; i<=row; i++)
1888  {
1889  tmp1 = view(i, j);
1890  tmp2 = n_Div(tmp1, b, basecoeffs());
1891  rawset(i, j, tmp2);
1892  }
1893 }
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 1015 of file bigintmat.cc.

1016 {
1017  if ((i>=1) && (i<=col) && (nCoeffs_are_equal(c, basecoeffs())))
1018  {
1019  number t, tmult;
1020  for (int j=1; j<=row; j++)
1021  {
1022  t = view(j, i);
1023  tmult = n_Mult(a, t, basecoeffs());
1024  rawset(j, i, tmult);
1025  }
1026  }
1027  else
1028  WerrorS("Error in colskalmult");
1029 }
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:2653

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

1898 {
1899  number tmp1, tmp2, tmp3, tmp4;
1900  for (int i=1; i<=row; i++)
1901  {
1902  tmp1 = get(i, j);
1903  tmp2 = get(i, k);
1904  tmp3 = n_Mult(tmp1, a, basecoeffs());
1905  tmp4 = n_Mult(tmp2, b, basecoeffs());
1906  n_InpAdd(tmp3, tmp4, basecoeffs());
1907  n_Delete(&tmp4, basecoeffs());
1908 
1909  n_InpMult(tmp1, c, basecoeffs());
1910  n_InpMult(tmp2, d, basecoeffs());
1911  n_InpAdd(tmp1, tmp2, basecoeffs());
1912  n_Delete(&tmp2, basecoeffs());
1913 
1914  set(i, j, tmp3);
1915  set(i, k, tmp1);
1916  n_Delete(&tmp1, basecoeffs());
1917  n_Delete(&tmp3, basecoeffs());
1918  }
1919 }
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 363 of file bigintmat.cc.

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

1106  {
1107  int ay = a->cols();
1108  int ax = a->rows();
1109  int by = b->cols();
1110  int bx = b->rows();
1111  number tmp;
1112 
1113  assume(row==ax && row == bx && ay+by ==col);
1114 
1116 
1117  for (int i=1; i<=ax; i++)
1118  {
1119  for (int j=1; j<=ay; j++)
1120  {
1121  tmp = a->view(i,j);
1122  set(i, j, tmp);
1123  }
1124  }
1125  for (int i=1; i<=bx; i++)
1126  {
1127  for (int j=1; j<=by; j++)
1128  {
1129  tmp = b->view(i,j);
1130  set(i, j+ay, tmp);
1131  }
1132  }
1133 }
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:394
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:2653

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

1048 {
1049  int ay = a->cols();
1050  int ax = a->rows();
1051  int by = b->cols();
1052  int bx = b->rows();
1053  number tmp;
1054  if (!((col == ay) && (col == by) && (ax+bx == row)))
1055  {
1056  WerrorS("Error in concatrow. Dimensions must agree!");
1057  return;
1058  }
1060  {
1061  WerrorS("Error in concatrow. coeffs do not agree!");
1062  return;
1063  }
1064  for (int i=1; i<=ax; i++)
1065  {
1066  for (int j=1; j<=ay; j++)
1067  {
1068  tmp = a->get(i,j);
1069  set(i, j, tmp);
1070  n_Delete(&tmp, basecoeffs());
1071  }
1072  }
1073  for (int i=1; i<=bx; i++)
1074  {
1075  for (int j=1; j<=by; j++)
1076  {
1077  tmp = b->get(i,j);
1078  set(i+ax, j, tmp);
1079  n_Delete(&tmp, basecoeffs());
1080  }
1081  }
1082 }
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:2653

◆ content()

number bigintmat::content ( )

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

Definition at line 2683 of file bigintmat.cc.

2684 {
2685  coeffs r = basecoeffs();
2686  number g = get(1,1), h;
2687  int n=rows()*cols();
2688  for(int i=1; i<n && !n_IsOne(g, r); i++)
2689  {
2690  h = n_Gcd(g, view(i), r);
2691  n_Delete(&g, r);
2692  g=h;
2693  }
2694  return g;
2695 }
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 1267 of file bigintmat.cc.

1268 {
1269  if ((b->rows() != row) || (b->cols() != col))
1270  {
1271  WerrorS("Error in bigintmat::copy. Dimensions do not agree!");
1272  return false;
1273  }
1274  if (!nCoeffs_are_equal(basecoeffs(), b->basecoeffs()))
1275  {
1276  WerrorS("Error in bigintmat::copy. coeffs do not agree!");
1277  return false;
1278  }
1279  number t1;
1280  for (int i=1; i<=row; i++)
1281  {
1282  for (int j=1; j<=col; j++)
1283  {
1284  t1 = b->view(i, j);
1285  set(i, j, t1);
1286  }
1287  }
1288  return true;
1289 }
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:2653

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

1296 {
1297  number t1;
1298  for (int i=1; i<=n; i++)
1299  {
1300  for (int j=1; j<=m; j++)
1301  {
1302  t1 = B->view(a+i-1, b+j-1);
1303  set(c+i-1, d+j-1, t1);
1304  }
1305  }
1306 }
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 1520 of file bigintmat.cc.

1521 {
1522  assume (row==col);
1523 
1524  if (col == 1)
1525  return get(1, 1);
1526  // should work as well in Z/pZ of type n_Zp?
1527  // relies on XExtGcd and the other euc. functinos.
1528  if ( getCoeffType(basecoeffs())== n_Z || getCoeffType(basecoeffs() )== n_Zn) {
1529  return hnfdet();
1530  }
1531  number sum = n_Init(0, basecoeffs());
1532  number t1, t2, t3, t4;
1533  bigintmat *b;
1534  for (int i=1; i<=row; i++) {
1535  b = elim(i, 1);
1536  t1 = get(i, 1);
1537  t2 = b->det();
1538  t3 = n_Mult(t1, t2, basecoeffs());
1539  t4 = n_Copy(sum, basecoeffs());
1540  n_Delete(&sum, basecoeffs());
1541  if ((i+1)>>1<<1==(i+1))
1542  sum = n_Add(t4, t3, basecoeffs());
1543  else
1544  sum = n_Sub(t4, t3, basecoeffs());
1545  n_Delete(&t1, basecoeffs());
1546  n_Delete(&t2, basecoeffs());
1547  n_Delete(&t3, basecoeffs());
1548  n_Delete(&t4, basecoeffs());
1549  }
1550  return sum;
1551 }
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:1520
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:394
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:1553
bigintmat * elim(int i, int j)
Liefert Streichungsmatrix (i-te Zeile und j-te Spalte gestrichen) zurück.
Definition: bigintmat.cc:1389
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 1389 of file bigintmat.cc.

1390 {
1391  if ((i<=0) || (i>row) || (j<=0) || (j>col))
1392  return NULL;
1393  int cx, cy;
1394  cx=1;
1395  cy=1;
1396  number t;
1397  bigintmat *b = new bigintmat(row-1, col-1, basecoeffs());
1398  for (int k=1; k<=row; k++) {
1399  if (k!=i)
1400  {
1401  cy=1;
1402  for (int l=1; l<=col; l++)
1403  {
1404  if (l!=j)
1405  {
1406  t = get(k, l);
1407  b->set(cx, cy, t);
1408  n_Delete(&t, basecoeffs());
1409  cy++;
1410  }
1411  }
1412  cx++;
1413  }
1414  }
1415  return b;
1416 }
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 1084 of file bigintmat.cc.

1085 {
1086  bigintmat * tmp = new bigintmat(rows(), i, basecoeffs());
1087  appendCol(tmp);
1088  delete tmp;
1089 }
Matrices of numbers.
Definition: bigintmat.h:51
void appendCol(bigintmat *a)
horizontally join the matrices, m <- m|a
Definition: bigintmat.cc:1091
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 743 of file bigintmat.cc.

744 {
745  for (int i=row; i>=1; i--)
746  {
747  if (!n_IsZero(view(i,j), basecoeffs()))
748  {
749  return i;
750  }
751  }
752  return 0;
753 }
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 731 of file bigintmat.cc.

732 {
733  for (int j=1; j<=col; j++)
734  {
735  if (!n_IsZero(view(i,j), basecoeffs()))
736  {
737  return j;
738  }
739  }
740  return 0;
741 }
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:394
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:394
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 755 of file bigintmat.cc.

756 {
757  assume((j<=col) && (j>=1));
758  if (((a->rows() != row) || (a->cols() != 1)) && ((a->rows() != 1) || (a->cols() != row)))
759  {
760  assume(0);
761  WerrorS("Error in getcol. Dimensions must agree!");
762  return;
763  }
765  {
767  number t1, t2;
768  for (int i=1; i<=row;i++)
769  {
770  t1 = get(i,j);
771  t2 = f(t1, basecoeffs(), a->basecoeffs());
772  a->set(i-1,t1);
773  n_Delete(&t1, basecoeffs());
774  n_Delete(&t2, a->basecoeffs());
775  }
776  return;
777  }
778  number t1;
779  for (int i=1; i<=row;i++)
780  {
781  t1 = view(i,j);
782  a->set(i-1,t1);
783  }
784 }
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:394
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:9
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:2653

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

787 {
788  number t1;
789  for(int ii=0; ii< no; ii++)
790  {
791  for (int i=1; i<=row;i++)
792  {
793  t1 = view(i, ii+j);
794  a->set(i, ii+1, t1);
795  }
796  }
797 }
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 799 of file bigintmat.cc.

800 {
801  if ((i>row) || (i<1))
802  {
803  WerrorS("Error in getrow: Index out of range!");
804  return;
805  }
806  if (((a->rows() != 1) || (a->cols() != col)) && ((a->rows() != col) || (a->cols() != 1)))
807  {
808  WerrorS("Error in getrow. Dimensions must agree!");
809  return;
810  }
812  {
814  number t1, t2;
815  for (int j=1; j<=col;j++)
816  {
817  t1 = get(i,j);
818  t2 = f(t1, basecoeffs(), a->basecoeffs());
819  a->set(j-1,t2);
820  n_Delete(&t1, basecoeffs());
821  n_Delete(&t2, a->basecoeffs());
822  }
823  return;
824  }
825  number t1;
826  for (int j=1; j<=col;j++)
827  {
828  t1 = get(i,j);
829  a->set(j-1,t1);
830  n_Delete(&t1, basecoeffs());
831  }
832 }
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:9
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:2653

◆ getwid()

int * bigintmat::getwid ( int  maxwid)

Definition at line 581 of file bigintmat.cc.

582 {
583  int const c = /*2**/(col-1)+1;
584  if (col + c > maxwid-1) return NULL;
585  int * wv = (int*)omAlloc(sizeof(int)*col*row);
586  int * cwv = (int*)omAlloc(sizeof(int)*col);
587  for (int j=0; j<col; j++)
588  {
589  cwv[j] = 0;
590  for (int i=0; i<row; i++)
591  {
592  StringSetS("");
593  n_Write(v[col*i+j], basecoeffs());
594  char * tmp = StringEndS();
595  const int _nl = strlen(tmp);
596  wv[col*i+j] = _nl;
597  if (_nl > cwv[j])
598  cwv[j]=_nl;
599  omFree(tmp);
600  }
601  }
602 
603  // Groesse verkleinern, bis < maxwid
604  while (intArrSum(cwv, col)+c > maxwid)
605  {
606  int j = findLongest(cwv, col);
607  cwv[j] = getShorter(wv, cwv[j], j, col, row);
608  }
609  omFree(wv);
610  return cwv;
611 }
static int findLongest(int *a, int length)
Definition: bigintmat.cc:538
int row
Definition: bigintmat.h:56
static int intArrSum(int *a, int length)
Definition: bigintmat.cc:530
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:553
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 1668 of file bigintmat.cc.

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

1554 {
1555  assume (col == row);
1556 
1557  if (col == 1)
1558  return get(1, 1);
1559  bigintmat *m = new bigintmat(this);
1560  m->hnf();
1561  number prod = n_Init(1, basecoeffs());
1562  number temp, temp2;
1563  for (int i=1; i<=col; i++) {
1564  temp = m->get(i, i);
1565  temp2 = n_Mult(temp, prod, basecoeffs());
1566  n_Delete(&prod, basecoeffs());
1567  prod = temp2;
1568  n_Delete(&temp, basecoeffs());
1569  }
1570  delete m;
1571  return prod;
1572 }
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:394
int m
Definition: cfEzgcd.cc:119
void hnf()
transforms INPLACE to HNF
Definition: bigintmat.cc:1668
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 1593 of file bigintmat.cc.

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

1309 {
1310  coeffs r = basecoeffs();
1311  if (row==col)
1312  {
1313  for (int i=1; i<=row; i++)
1314  {
1315  for (int j=1; j<=col; j++)
1316  {
1317  if (i==j)
1318  {
1319  if (!n_IsOne(view(i, j), r))
1320  return 0;
1321  }
1322  else
1323  {
1324  if (!n_IsZero(view(i,j), r))
1325  return 0;
1326  }
1327  }
1328  }
1329  }
1330  return 1;
1331 }
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 1371 of file bigintmat.cc.

1372 {
1373  for (int i=1; i<=row; i++) {
1374  for (int j=1; j<=col; j++) {
1375  if (!n_IsZero(view(i,j), basecoeffs()))
1376  return FALSE;
1377  }
1378  }
1379  return TRUE;
1380 }
#define FALSE
Definition: auxiliary.h:94
int row
Definition: bigintmat.h:56
#define TRUE
Definition: auxiliary.h:98
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 1924 of file bigintmat.cc.

1925 {
1926  // produce the matrix in Z/pZ
1927  number tmp1, tmp2;
1928  for (int i=1; i<=row; i++)
1929  {
1930  for (int j=1; j<=col; j++)
1931  {
1932  tmp1 = get(i, j);
1933  tmp2 = n_IntMod(tmp1, p, basecoeffs());
1934  n_Delete(&tmp1, basecoeffs());
1935  set(i, j, tmp2);
1936  }
1937  }
1938 }
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 1840 of file bigintmat.cc.

1841 {
1842  coeffs Rp = numbercoeffs(p, R); // R/pR
1843  bigintmat *m = bimChangeCoeff(this, Rp);
1844  m->howell();
1845  bigintmat *a = bimChangeCoeff(m, R);
1846  delete m;
1847  bigintmat *C = new bigintmat(rows(), rows(), R);
1848  int piv = rows(), i = a->cols();
1849  while (piv)
1850  {
1851  if (!i || n_IsZero(a->view(piv, i), R))
1852  {
1853  C->set(piv, piv, p, R);
1854  }
1855  else
1856  {
1857  C->copySubmatInto(a, 1, i, rows(), 1, 1, piv);
1858  i--;
1859  }
1860  piv--;
1861  }
1862  delete a;
1863  return C;
1864 }
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:1295
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:1812
bigintmat()
Definition: bigintmat.h:60
void howell()
dito, but Howell form (only different for zero-divsors)
Definition: bigintmat.cc:1593

◆ one()

void bigintmat::one ( )

Macht Matrix (Falls quadratisch) zu Einheitsmatrix.

Definition at line 1333 of file bigintmat.cc.

1334 {
1335  if (row==col)
1336  {
1337  number one = n_Init(1, basecoeffs()),
1338  zero = n_Init(0, basecoeffs());
1339  for (int i=1; i<=row; i++)
1340  {
1341  for (int j=1; j<=col; j++)
1342  {
1343  if (i==j)
1344  {
1345  set(i, j, one);
1346  }
1347  else
1348  {
1349  set(i, j, zero);
1350  }
1351  }
1352  }
1353  n_Delete(&one, basecoeffs());
1354  n_Delete(&zero, basecoeffs());
1355  }
1356 }
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:1358
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:1333

◆ 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:394
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:394
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 613 of file bigintmat.cc.

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

445 {
446  char * s = String();
447  PrintS(s);
448  omFree(s);
449 }
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:437

◆ pseudoinv()

number bigintmat::pseudoinv ( bigintmat a)

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

Definition at line 1423 of file bigintmat.cc.

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

◆ 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:394
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 1031 of file bigintmat.cc.

1032 {
1033  if ((i>=1) && (i<=row) && (nCoeffs_are_equal(c, basecoeffs())))
1034  {
1035  number t, tmult;
1036  for (int j=1; j<=col; j++)
1037  {
1038  t = view(i, j);
1039  tmult = n_Mult(a, t, basecoeffs());
1040  rawset(i, j, tmult);
1041  }
1042  }
1043  else
1044  WerrorS("Error in rowskalmult");
1045 }
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:2653

◆ 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:394
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:394
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 834 of file bigintmat.cc.

835 {
836  if ((j>col) || (j<1))
837  {
838  WerrorS("Error in setcol: Index out of range!");
839  return;
840  }
841  if (((m->rows() != row) || (m->cols() != 1)) && ((m->rows() != 1) || (m->cols() != row)))
842  {
843  WerrorS("Error in setcol. Dimensions must agree!");
844  return;
845  }
847  {
849  number t1,t2;
850  for (int i=1; i<=row; i++)
851  {
852  t1 = m->get(i-1);
853  t2 = f(t1, m->basecoeffs(),basecoeffs());
854  set(i, j, t2);
855  n_Delete(&t2, basecoeffs());
856  n_Delete(&t1, m->basecoeffs());
857  }
858  return;
859  }
860  number t1;
861  for (int i=1; i<=row; i++)
862  {
863  t1 = m->view(i-1);
864  set(i, j, t1);
865  }
866 }
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:9
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:2653

◆ setrow()

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

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

Definition at line 868 of file bigintmat.cc.

869 {
870  if ((j>row) || (j<1))
871  {
872  WerrorS("Error in setrow: Index out of range!");
873  return;
874  }
875  if (((m->rows() != 1) || (m->cols() != col)) && ((m->rows() != col) || (m->cols() != 1)))
876  {
877  WerrorS("Error in setrow. Dimensions must agree!");
878  return;
879  }
881  {
883  number tmp1,tmp2;
884  for (int i=1; i<=col; i++)
885  {
886  tmp1 = m->get(i-1);
887  tmp2 = f(tmp1, m->basecoeffs(),basecoeffs());
888  set(j, i, tmp2);
889  n_Delete(&tmp2, basecoeffs());
890  n_Delete(&tmp1, m->basecoeffs());
891  }
892  return;
893  }
894  number tmp;
895  for (int i=1; i<=col; i++)
896  {
897  tmp = m->view(i-1);
898  set(j, i, tmp);
899  }
900 }
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:9
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:2653

◆ simplifyContentDen()

void bigintmat::simplifyContentDen ( number *  den)

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

Definition at line 2696 of file bigintmat.cc.

2697 {
2698  coeffs r = basecoeffs();
2699  number g = n_Copy(*d, r), h;
2700  int n=rows()*cols();
2701  for(int i=0; i<n && !n_IsOne(g, r); i++)
2702  {
2703  h = n_Gcd(g, view(i), r);
2704  n_Delete(&g, r);
2705  g=h;
2706  }
2707  *d = n_Div(*d, g, r);
2708  if (!n_IsOne(g, r))
2709  skaldiv(g);
2710 }
void skaldiv(number b)
Macht Ganzzahldivision aller Matrixeinträge mit b.
Definition: bigintmat.cc:1869
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 1869 of file bigintmat.cc.

1870 {
1871  number tmp1, tmp2;
1872  for (int i=1; i<=row; i++)
1873  {
1874  for (int j=1; j<=col; j++)
1875  {
1876  tmp1 = view(i, j);
1877  tmp2 = n_Div(tmp1, b, basecoeffs());
1878  rawset(i, j, tmp2);
1879  }
1880  }
1881 }
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 946 of file bigintmat.cc.

947 {
948  if (!nCoeffs_are_equal(c, basecoeffs()))
949  {
950  WerrorS("Wrong coeffs\n");
951  return false;
952  }
953  number t1, t2;
954  if ( n_IsOne(b,c)) return true;
955  for (int i=1; i<=row; i++)
956  {
957  for (int j=1; j<=col; j++)
958  {
959  t1 = view(i, j);
960  t2 = n_Mult(t1, b, basecoeffs());
961  rawset(i, j, t2);
962  }
963  }
964  return true;
965 }
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:2653

◆ splitcol() [1/2]

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

... linken ... rechten ...

Definition at line 1177 of file bigintmat.cc.

1178 {
1179  int ay = a->cols();
1180  int ax = a->rows();
1181  int by = b->cols();
1182  int bx = b->rows();
1183  number tmp;
1184  if (!((row == ax) && (row == bx)))
1185  {
1186  WerrorS("Error in splitcol. Dimensions must agree!");
1187  }
1188  else if (!(ay+by == col))
1189  {
1190  WerrorS("Error in splitcol. Dimensions must agree!");
1191  }
1193  {
1194  WerrorS("Error in splitcol. coeffs do not agree!");
1195  }
1196  else
1197  {
1198  for (int i=1; i<=ax; i++)
1199  {
1200  for (int j=1; j<=ay; j++)
1201  {
1202  tmp = view(i,j);
1203  a->set(i,j,tmp);
1204  }
1205  }
1206  for (int i=1; i<=bx; i++)
1207  {
1208  for (int j=1; j<=by; j++)
1209  {
1210  tmp = view(i,j+ay);
1211  b->set(i,j,tmp);
1212  }
1213  }
1214  }
1215 }
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:2653

◆ splitcol() [2/2]

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

Speichert die ersten i Spalten als Teilmatrix in a.

Definition at line 1217 of file bigintmat.cc.

1218 {
1219  number tmp;
1220  if ((a->rows() != row) || (a->cols()+i-1 > col) || (i<1))
1221  {
1222  WerrorS("Error in splitcol. Dimensions must agree!");
1223  return;
1224  }
1225  if (!(nCoeffs_are_equal(a->basecoeffs(), basecoeffs())))
1226  {
1227  WerrorS("Error in splitcol. coeffs do not agree!");
1228  return;
1229  }
1230  int width = a->cols();
1231  for (int j=1; j<=width; j++)
1232  {
1233  for (int k=1; k<=row; k++)
1234  {
1235  tmp = get(k, j+i-1);
1236  a->set(k, j, tmp);
1237  n_Delete(&tmp, basecoeffs());
1238  }
1239  }
1240 }
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:2653

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

1136 {
1137  int ay = a->cols();
1138  int ax = a->rows();
1139  int by = b->cols();
1140  int bx = b->rows();
1141  number tmp;
1142  if (!(ax + bx == row))
1143  {
1144  WerrorS("Error in splitrow. Dimensions must agree!");
1145  }
1146  else if (!((col == ay) && (col == by)))
1147  {
1148  WerrorS("Error in splitrow. Dimensions must agree!");
1149  }
1151  {
1152  WerrorS("Error in splitrow. coeffs do not agree!");
1153  }
1154  else
1155  {
1156  for(int i = 1; i<=ax; i++)
1157  {
1158  for(int j = 1; j<=ay;j++)
1159  {
1160  tmp = get(i,j);
1161  a->set(i,j,tmp);
1162  n_Delete(&tmp, basecoeffs());
1163  }
1164  }
1165  for (int i =1; i<=bx; i++)
1166  {
1167  for (int j=1;j<=col;j++)
1168  {
1169  tmp = get(i+ax, j);
1170  b->set(i,j,tmp);
1171  n_Delete(&tmp, basecoeffs());
1172  }
1173  }
1174  }
1175 }
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:2653

◆ splitrow() [2/2]

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

... Zeilen ...

Definition at line 1242 of file bigintmat.cc.

1243 {
1244  number tmp;
1245  if ((a->cols() != col) || (a->rows()+i-1 > row) || (i<1))
1246  {
1247  WerrorS("Error in Marco-splitrow");
1248  return;
1249  }
1250 
1251  if (!(nCoeffs_are_equal(a->basecoeffs(), basecoeffs())))
1252  {
1253  WerrorS("Error in splitrow. coeffs do not agree!");
1254  return;
1255  }
1256  int height = a->rows();
1257  for (int j=1; j<=height; j++)
1258  {
1259  for (int k=1; k<=col; k++)
1260  {
1261  tmp = view(j+i-1, k);
1262  a->set(j, k, tmp);
1263  }
1264  }
1265 }
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:2653

◆ String()

char * bigintmat::String ( )

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

Definition at line 437 of file bigintmat.cc.

438 {
439  StringSetS("");
440  Write();
441  return StringEndS();
442 }
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:414
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 452 of file bigintmat.cc.

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

925 {
926  if ((b->rows() != row) || (b->cols() != col))
927  {
928  WerrorS("Error in bigintmat::sub. Dimensions do not agree!");
929  return false;
930  }
932  {
933  WerrorS("Error in bigintmat::sub. coeffs do not agree!");
934  return false;
935  }
936  for (int i=1; i<=row; i++)
937  {
938  for (int j=1; j<=col; j++)
939  {
940  rawset(i, j, n_Sub(view(i,j), b->view(i,j), basecoeffs()));
941  }
942  }
943  return true;
944 }
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:2653

◆ swap()

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

swap columns i and j

Definition at line 693 of file bigintmat.cc.

694 {
695  if ((i <= col) && (j <= col) && (i>0) && (j>0))
696  {
697  number tmp;
698  number t;
699  for (int k=1; k<=row; k++)
700  {
701  tmp = get(k, i);
702  t = view(k, j);
703  set(k, i, t);
704  set(k, j, tmp);
705  n_Delete(&tmp, basecoeffs());
706  }
707  }
708  else
709  WerrorS("Error in swap");
710 }
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 1574 of file bigintmat.cc.

1575 {
1576  int n = rows(), m = cols();
1577  row = a->rows();
1578  col = a->cols();
1579  number * V = v;
1580  v = a->v;
1581  a->v = V;
1582  a->row = n;
1583  a->col = m;
1584 }
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 712 of file bigintmat.cc.

713 {
714  if ((i <= row) && (j <= row) && (i>0) && (j>0))
715  {
716  number tmp;
717  number t;
718  for (int k=1; k<=col; k++)
719  {
720  tmp = get(i, k);
721  t = view(j, k);
722  set(i, k, t);
723  set(j, k, tmp);
724  n_Delete(&tmp, basecoeffs());
725  }
726  }
727  else
728  WerrorS("Error in swaprow");
729 }
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 1506 of file bigintmat.cc.

1507 {
1508  assume (col == row);
1509  number t = get(1,1),
1510  h;
1511  coeffs r = basecoeffs();
1512  for(int i=2; i<= col; i++) {
1513  h = n_Add(t, view(i,i), r);
1514  n_Delete(&t, r);
1515  t = h;
1516  }
1517  return t;
1518 }
int row
Definition: bigintmat.h:56
const ring r
Definition: syzextra.cc:208
#define assume(x)
Definition: mod2.h:394
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:394
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:394
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 414 of file bigintmat.cc.

415 {
416  int n = cols(), m=rows();
417 
418  StringAppendS("[ ");
419  for(int i=1; i<= m; i++)
420  {
421  StringAppendS("[ ");
422  for(int j=1; j< n; j++)
423  {
424  n_Write(v[(i-1)*n+j-1], basecoeffs());
425  StringAppendS(", ");
426  }
427  if (n) n_Write(v[i*n-1], basecoeffs());
428  StringAppendS(" ]");
429  if (i<m)
430  {
431  StringAppendS(", ");
432  }
433  }
434  StringAppendS(" ] ");
435 }
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 1358 of file bigintmat.cc.

1359 {
1360  number tmp = n_Init(0, basecoeffs());
1361  for (int i=1; i<=row; i++)
1362  {
1363  for (int j=1; j<=col; j++)
1364  {
1365  set(i, j, tmp);
1366  }
1367  }
1368  n_Delete(&tmp,basecoeffs());
1369 }
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: