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 versio 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::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::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  }
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:539
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:405
int i
Definition: cfEzgcd.cc:123
int cols() const
Definition: bigintmat.h:147
int rows() const
Definition: bigintmat.h:148
int col
Definition: bigintmat.h:57
number * v
Definition: bigintmat.h:55
#define NULL
Definition: omList.c:10
coeffs basecoeffs() const
Definition: bigintmat.h:149
coeffs m_coeffs
Definition: bigintmat.h:54
int l
Definition: cfEzgcd.cc:94
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 row
Definition: bigintmat.h:56
#define omAlloc(size)
Definition: omAllocDecl.h:210
#define assume(x)
Definition: mod2.h:405
int i
Definition: cfEzgcd.cc:123
int cols() const
Definition: bigintmat.h:147
int rows() const
Definition: bigintmat.h:148
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:452
coeffs basecoeffs() const
Definition: bigintmat.h:149
coeffs m_coeffs
Definition: bigintmat.h:54
int l
Definition: cfEzgcd.cc:94
bigintmat::~bigintmat ( )
inline

canonical destructor.

Definition at line 152 of file bigintmat.h.

153  {
154  if (v!=NULL)
155  {
156  for (int i=0; i<row*col; i++) { n_Delete(&(v[i]), basecoeffs()); }
157  omFreeSize((ADDRESS)v, sizeof(number)*row*col);
158  v=NULL;
159  }
160  }
int row
Definition: bigintmat.h:56
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
void * ADDRESS
Definition: auxiliary.h:161
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:149
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:456

Member Function Documentation

bool bigintmat::add ( bigintmat b)

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

Definition at line 870 of file bigintmat.cc.

871 {
872  if ((b->rows() != row) || (b->cols() != col)) {
873  Werror("Error in bigintmat::add. Dimensions do not agree!");
874  return false;
875  }
876  if (!nCoeffs_are_equal(basecoeffs(), b->basecoeffs())) {
877  Werror("Error in bigintmat::add. coeffs do not agree!");
878  return false;
879  }
880  for (int i=1; i<=row; i++) {
881  for (int j=1; j<=col; j++) {
882  rawset(i, j, n_Add(b->view(i,j), view(i,j), basecoeffs()));
883  }
884  }
885  return true;
886 }
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:125
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:199
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:655
int i
Definition: cfEzgcd.cc:123
int cols() const
Definition: bigintmat.h:147
int rows() const
Definition: bigintmat.h:148
int col
Definition: bigintmat.h:57
coeffs basecoeffs() const
Definition: bigintmat.h:149
void Werror(const char *fmt,...)
Definition: reporter.cc:199
bool nCoeffs_are_equal(coeffs r, coeffs s)
Definition: bigintmat.cc:2473
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 927 of file bigintmat.cc.

928 {
929  if ((i>col) || (j>col) || (i<1) || (j<1)) {
930  Werror("Error in addcol: Index out of range!");
931  return false;
932  }
933  if (!nCoeffs_are_equal(c, basecoeffs())) {
934  Werror("Error in addcol: coeffs do not agree!");
935  return false;
936  }
937  number t1, t2, t3, t4;
938  for (int k=1; k<=row; k++)
939  {
940  t1 = view(k, j);
941  t2 = view(k, i);
942  t3 = n_Mult(t1, a, basecoeffs());
943  t4 = n_Add(t3, t2, basecoeffs());
944  rawset(k, i, t4);
945  n_Delete(&t3, basecoeffs());
946  }
947  return true;
948 }
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:125
const poly a
Definition: syzextra.cc:212
int row
Definition: bigintmat.h:56
int k
Definition: cfEzgcd.cc: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:199
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:635
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:655
int i
Definition: cfEzgcd.cc:123
int col
Definition: bigintmat.h:57
coeffs basecoeffs() const
Definition: bigintmat.h:149
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:456
void Werror(const char *fmt,...)
Definition: reporter.cc:199
bool nCoeffs_are_equal(coeffs r, coeffs s)
Definition: bigintmat.cc:2473
bool bigintmat::addrow ( int  i,
int  j,
number  a,
coeffs  c 
)

... Zeile ...

Definition at line 950 of file bigintmat.cc.

951 {
952  if ((i>row) || (j>row) || (i<1) || (j<1)) {
953  Werror("Error in addrow: Index out of range!");
954  return false;
955  }
956  if (!nCoeffs_are_equal(c, basecoeffs())) {
957  Werror("Error in addrow: coeffs do not agree!");
958  return false;
959  }
960  number t1, t2, t3, t4;
961  for (int k=1; k<=col; k++)
962  {
963  t1 = view(j, k);
964  t2 = view(i, k);
965  t3 = n_Mult(t1, a, basecoeffs());
966  t4 = n_Add(t3, t2, basecoeffs());
967  rawset(i, k, t4);
968  n_Delete(&t3, basecoeffs());
969  }
970  return true;
971 }
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:125
const poly a
Definition: syzextra.cc:212
int row
Definition: bigintmat.h:56
int k
Definition: cfEzgcd.cc: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:199
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:635
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:655
int i
Definition: cfEzgcd.cc:123
int col
Definition: bigintmat.h:57
coeffs basecoeffs() const
Definition: bigintmat.h:149
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:456
void Werror(const char *fmt,...)
Definition: reporter.cc:199
bool nCoeffs_are_equal(coeffs r, coeffs s)
Definition: bigintmat.cc:2473
void bigintmat::appendCol ( bigintmat a)

horizontally join the matrices, m <- m|a

Definition at line 1034 of file bigintmat.cc.

1034  {
1035  coeffs R = basecoeffs();
1036  int ay = a->cols();
1037  int ax = a->rows();
1038  assume(row == ax);
1039 
1041 
1042  bigintmat * tmp = new bigintmat(rows(), cols() + ay, R);
1043  tmp->concatcol(this, a);
1044  this->swapMatrix(tmp);
1045  delete tmp;
1046 }
void concatcol(bigintmat *a, bigintmat *b)
Definition: bigintmat.cc:1049
Matrices of numbers.
Definition: bigintmat.h:51
int row
Definition: bigintmat.h:56
#define assume(x)
Definition: mod2.h:405
void swapMatrix(bigintmat *a)
Definition: bigintmat.cc:1468
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:147
int rows() const
Definition: bigintmat.h:148
bigintmat()
Definition: bigintmat.h:60
coeffs basecoeffs() const
Definition: bigintmat.h:149
bool nCoeffs_are_equal(coeffs r, coeffs s)
Definition: bigintmat.cc:2473
coeffs bigintmat::basecoeffs ( ) const
inline

Definition at line 149 of file bigintmat.h.

149 { return m_coeffs; }
coeffs m_coeffs
Definition: bigintmat.h:54
int bigintmat::colIsZero ( int  i)

Definition at line 1479 of file bigintmat.cc.

1480 {
1481  coeffs R = basecoeffs();
1482  for(int i=1; i<=rows(); i++)
1483  if (!n_IsZero(view(i, j), R)) return FALSE;
1484  return TRUE;
1485 }
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:125
#define FALSE
Definition: auxiliary.h:140
#define TRUE
Definition: auxiliary.h:144
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
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:465
int rows() const
Definition: bigintmat.h:148
coeffs basecoeffs() const
Definition: bigintmat.h:149
int bigintmat::cols ( ) const
inline

Definition at line 147 of file bigintmat.h.

147 { return col; }
int col
Definition: bigintmat.h:57
void bigintmat::colskaldiv ( int  j,
number  b 
)

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

Definition at line 1778 of file bigintmat.cc.

1779 {
1780  number tmp1, tmp2;
1781  for (int i=1; i<=row; i++)
1782  {
1783  tmp1 = view(i, j);
1784  tmp2 = n_Div(tmp1, b, basecoeffs());
1785  rawset(i, j, tmp2);
1786  }
1787 }
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:125
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:199
int j
Definition: myNF.cc:70
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:615
coeffs basecoeffs() const
Definition: bigintmat.h:149
CFList tmp1
Definition: facFqBivar.cc:70
const poly b
Definition: syzextra.cc:213
void bigintmat::colskalmult ( int  i,
number  a,
coeffs  c 
)

Multipliziert zur i-ten Spalte den Skalar a hinzu.

Definition at line 973 of file bigintmat.cc.

973  {
974  if ((i>=1) && (i<=col) && (nCoeffs_are_equal(c, basecoeffs()))) {
975  number t, tmult;
976  for (int j=1; j<=row; j++) {
977  t = view(j, i);
978  tmult = n_Mult(a, t, basecoeffs());
979  rawset(j, i, tmult);
980  }
981  }
982  else
983  Werror("Error in colskalmult");
984 }
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:125
const poly a
Definition: syzextra.cc:212
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:199
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:635
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
int col
Definition: bigintmat.h:57
coeffs basecoeffs() const
Definition: bigintmat.h:149
void Werror(const char *fmt,...)
Definition: reporter.cc:199
bool nCoeffs_are_equal(coeffs r, coeffs s)
Definition: bigintmat.cc:2473
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 1791 of file bigintmat.cc.

1792 {
1793  number tmp1, tmp2, tmp3, tmp4;
1794  for (int i=1; i<=row; i++)
1795  {
1796  tmp1 = get(i, j);
1797  tmp2 = get(i, k);
1798  tmp3 = n_Mult(tmp1, a, basecoeffs());
1799  tmp4 = n_Mult(tmp2, b, basecoeffs());
1800  n_InpAdd(tmp3, tmp4, basecoeffs());
1801  n_Delete(&tmp4, basecoeffs());
1802 
1803  n_InpMult(tmp1, c, basecoeffs());
1804  n_InpMult(tmp2, d, basecoeffs());
1805  n_InpAdd(tmp1, tmp2, basecoeffs());
1806  n_Delete(&tmp2, basecoeffs());
1807 
1808  set(i, j, tmp3);
1809  set(i, k, tmp1);
1810  n_Delete(&tmp1, basecoeffs());
1811  n_Delete(&tmp3, basecoeffs());
1812  }
1813 }
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:640
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:645
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:635
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
CFList tmp2
Definition: facFqBivar.cc:70
coeffs basecoeffs() const
Definition: bigintmat.h:149
CFList tmp1
Definition: facFqBivar.cc:70
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:456
const poly b
Definition: syzextra.cc:213
int bigintmat::compare ( const bigintmat op) const

Definition at line 362 of file bigintmat.cc.

363 {
364  assume (basecoeffs() == op->basecoeffs() );
365 
366 #ifndef SING_NDEBUG
367  if (basecoeffs() != op->basecoeffs() )
368  WerrorS("wrong bigintmat comparison: different basecoeffs!\n");
369 #endif
370 
371  if ((col!=1) ||(op->cols()!=1))
372  {
373  if((col!=op->cols())
374  || (row!=op->rows()))
375  return -2;
376  }
377 
378  int i;
379  for (i=0; i<si_min(row*col,op->rows()*op->cols()); i++)
380  {
381  if ( n_Greater(v[i], (*op)[i], basecoeffs()) )
382  return 1;
383  else if (! n_Equal(v[i], (*op)[i], basecoeffs()))
384  return -1;
385  }
386 
387  for (; i<row; i++)
388  {
389  if ( n_GreaterZero(v[i], basecoeffs()) )
390  return 1;
391  else if (! n_IsZero(v[i], basecoeffs()) )
392  return -1;
393  }
394  for (; i<op->rows(); i++)
395  {
396  if ( n_GreaterZero((*op)[i], basecoeffs()) )
397  return -1;
398  else if (! n_IsZero((*op)[i], basecoeffs()) )
399  return 1;
400  }
401  return 0;
402 }
static 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:512
static int si_min(const int a, const int b)
Definition: auxiliary.h:167
int row
Definition: bigintmat.h:56
void WerrorS(const char *s)
Definition: feFopen.cc:24
#define assume(x)
Definition: mod2.h:405
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:465
int cols() const
Definition: bigintmat.h:147
int rows() const
Definition: bigintmat.h:148
int col
Definition: bigintmat.h:57
number * v
Definition: bigintmat.h:55
coeffs basecoeffs() const
Definition: bigintmat.h:149
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:461
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:495
void bigintmat::concatcol ( bigintmat a,
bigintmat b 
)

Definition at line 1049 of file bigintmat.cc.

1049  {
1050  int ay = a->cols();
1051  int ax = a->rows();
1052  int by = b->cols();
1053  int bx = b->rows();
1054  number tmp;
1055 
1056  assume(row==ax && row == bx && ay+by ==col);
1057 
1059 
1060  for (int i=1; i<=ax; i++) {
1061  for (int j=1; j<=ay; j++) {
1062  tmp = a->view(i,j);
1063  set(i, j, tmp);
1064  }
1065  }
1066  for (int i=1; i<=bx; i++) {
1067  for (int j=1; j<=by; j++) {
1068  tmp = b->view(i,j);
1069  set(i, j+ay, tmp);
1070  }
1071  }
1072 }
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:125
int row
Definition: bigintmat.h:56
int j
Definition: myNF.cc:70
#define assume(x)
Definition: mod2.h:405
int i
Definition: cfEzgcd.cc:123
int cols() const
Definition: bigintmat.h:147
int rows() const
Definition: bigintmat.h:148
int col
Definition: bigintmat.h:57
coeffs basecoeffs() const
Definition: bigintmat.h:149
bool nCoeffs_are_equal(coeffs r, coeffs s)
Definition: bigintmat.cc:2473
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 999 of file bigintmat.cc.

999  {
1000  int ay = a->cols();
1001  int ax = a->rows();
1002  int by = b->cols();
1003  int bx = b->rows();
1004  number tmp;
1005  if (!((col == ay) && (col == by) && (ax+bx == row))) {
1006  Werror("Error in concatrow. Dimensions must agree!");
1007  return;
1008  }
1010  Werror("Error in concatrow. coeffs do not agree!");
1011  return;
1012  }
1013  for (int i=1; i<=ax; i++) {
1014  for (int j=1; j<=ay; j++) {
1015  tmp = a->get(i,j);
1016  set(i, j, tmp);
1017  n_Delete(&tmp, basecoeffs());
1018  }
1019  }
1020  for (int i=1; i<=bx; i++) {
1021  for (int j=1; j<=by; j++) {
1022  tmp = b->get(i,j);
1023  set(i+ax, j, tmp);
1024  n_Delete(&tmp, basecoeffs());
1025  }
1026  }
1027 }
int row
Definition: bigintmat.h:56
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
int cols() const
Definition: bigintmat.h:147
int rows() const
Definition: bigintmat.h:148
int col
Definition: bigintmat.h:57
coeffs basecoeffs() const
Definition: bigintmat.h:149
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:456
void Werror(const char *fmt,...)
Definition: reporter.cc:199
number get(int i, int j) const
get a copy of an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:117
bool nCoeffs_are_equal(coeffs r, coeffs s)
Definition: bigintmat.cc:2473
number bigintmat::content ( )

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

Definition at line 2498 of file bigintmat.cc.

2499 {
2500  coeffs r = basecoeffs();
2501  number g = get(1,1), h;
2502  int n=rows()*cols();
2503  for(int i=1; i<n && !n_IsOne(g, r); i++) {
2504  h = n_Gcd(g, view(i), r);
2505  n_Delete(&g, r);
2506  g=h;
2507  }
2508  return g;
2509 }
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:125
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:685
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the one element.
Definition: coeffs.h:469
g
Definition: cfModGcd.cc:4031
const ring r
Definition: syzextra.cc:208
The main handler for Singular numbers which are suitable for Singular polynomials.
int i
Definition: cfEzgcd.cc:123
int cols() const
Definition: bigintmat.h:147
int rows() const
Definition: bigintmat.h:148
coeffs basecoeffs() const
Definition: bigintmat.h:149
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:456
static Poly * h
Definition: janet.cc:978
bool bigintmat::copy ( bigintmat b)

Kopiert Einträge von b auf Bigintmat.

Definition at line 1178 of file bigintmat.cc.

1179 {
1180  if ((b->rows() != row) || (b->cols() != col)) {
1181  Werror("Error in bigintmat::copy. Dimensions do not agree!");
1182  return false;
1183  }
1184  if (!nCoeffs_are_equal(basecoeffs(), b->basecoeffs())) {
1185  Werror("Error in bigintmat::copy. coeffs do not agree!");
1186  return false;
1187  }
1188  number t1;
1189  for (int i=1; i<=row; i++)
1190  {
1191  for (int j=1; j<=col; j++)
1192  {
1193  t1 = b->view(i, j);
1194  set(i, j, t1);
1195  }
1196  }
1197  return true;
1198 }
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:125
int row
Definition: bigintmat.h:56
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
int cols() const
Definition: bigintmat.h:147
int rows() const
Definition: bigintmat.h:148
int col
Definition: bigintmat.h:57
coeffs basecoeffs() const
Definition: bigintmat.h:149
void Werror(const char *fmt,...)
Definition: reporter.cc:199
bool nCoeffs_are_equal(coeffs r, coeffs s)
Definition: bigintmat.cc:2473
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 1204 of file bigintmat.cc.

1205 {
1206  number t1;
1207  for (int i=1; i<=n; i++)
1208  {
1209  for (int j=1; j<=m; j++)
1210  {
1211  t1 = B->view(a+i-1, b+j-1);
1212  set(c+i-1, d+j-1, t1);
1213  }
1214  }
1215 }
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:125
const poly a
Definition: syzextra.cc:212
int j
Definition: myNF.cc:70
int m
Definition: cfEzgcd.cc:119
int i
Definition: cfEzgcd.cc:123
const poly b
Definition: syzextra.cc:213
number bigintmat::det ( )

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

Definition at line 1414 of file bigintmat.cc.

1415 {
1416  assume (row==col);
1417 
1418  if (col == 1)
1419  return get(1, 1);
1420  // should work as well in Z/pZ of type n_Zp?
1421  // relies on XExtGcd and the other euc. functinos.
1422  if ( getCoeffType(basecoeffs())== n_Z || getCoeffType(basecoeffs() )== n_Zn) {
1423  return hnfdet();
1424  }
1425  number sum = n_Init(0, basecoeffs());
1426  number t1, t2, t3, t4;
1427  bigintmat *b;
1428  for (int i=1; i<=row; i++) {
1429  b = elim(i, 1);
1430  t1 = get(i, 1);
1431  t2 = b->det();
1432  t3 = n_Mult(t1, t2, basecoeffs());
1433  t4 = n_Copy(sum, basecoeffs());
1434  n_Delete(&sum, basecoeffs());
1435  if ((i+1)>>1<<1==(i+1))
1436  sum = n_Add(t4, t3, basecoeffs());
1437  else
1438  sum = n_Sub(t4, t3, basecoeffs());
1439  n_Delete(&t1, basecoeffs());
1440  n_Delete(&t2, basecoeffs());
1441  n_Delete(&t3, basecoeffs());
1442  n_Delete(&t4, basecoeffs());
1443  }
1444  return sum;
1445 }
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:668
only used if HAVE_RINGS is defined: ?
Definition: coeffs.h:43
number det()
det (via LaPlace in general, hnf for euc. rings)
Definition: bigintmat.cc:1414
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:539
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:635
#define assume(x)
Definition: mod2.h:405
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:655
only used if HAVE_RINGS is defined: ?
Definition: coeffs.h:42
int i
Definition: cfEzgcd.cc:123
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:422
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:452
coeffs basecoeffs() const
Definition: bigintmat.h:149
number hnfdet()
det via HNF Primzahlen als long long int, müssen noch in number umgewandelt werden?
Definition: bigintmat.cc:1447
bigintmat * elim(int i, int j)
Liefert Streichungsmatrix (i-te Zeile und j-te Spalte gestrichen) zurück.
Definition: bigintmat.cc:1283
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:456
const poly b
Definition: syzextra.cc:213
bigintmat * bigintmat::elim ( int  i,
int  j 
)

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

Definition at line 1283 of file bigintmat.cc.

1284 {
1285  if ((i<=0) || (i>row) || (j<=0) || (j>col))
1286  return NULL;
1287  int cx, cy;
1288  cx=1;
1289  cy=1;
1290  number t;
1291  bigintmat *b = new bigintmat(row-1, col-1, basecoeffs());
1292  for (int k=1; k<=row; k++) {
1293  if (k!=i)
1294  {
1295  cy=1;
1296  for (int l=1; l<=col; l++)
1297  {
1298  if (l!=j)
1299  {
1300  t = get(k, l);
1301  b->set(cx, cy, t);
1302  n_Delete(&t, basecoeffs());
1303  cy++;
1304  }
1305  }
1306  cx++;
1307  }
1308  }
1309  return b;
1310 }
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:93
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:149
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:456
const poly b
Definition: syzextra.cc:213
int l
Definition: cfEzgcd.cc:94
void bigintmat::extendCols ( int  i)

append i zero-columns to the matrix

Definition at line 1029 of file bigintmat.cc.

1029  {
1030  bigintmat * tmp = new bigintmat(rows(), i, basecoeffs());
1031  appendCol(tmp);
1032  delete tmp;
1033 }
Matrices of numbers.
Definition: bigintmat.h:51
void appendCol(bigintmat *a)
horizontally join the matrices, m <- m|a
Definition: bigintmat.cc:1034
int i
Definition: cfEzgcd.cc:123
int rows() const
Definition: bigintmat.h:148
bigintmat()
Definition: bigintmat.h:60
coeffs basecoeffs() const
Definition: bigintmat.h:149
int bigintmat::findcolnonzero ( int  j)

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

Definition at line 732 of file bigintmat.cc.

733 {
734  for (int i=row; i>=1; i--) {
735  if (!n_IsZero(view(i,j), basecoeffs()))
736  {
737  return i;
738  }
739  }
740  return 0;
741 }
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:125
int row
Definition: bigintmat.h:56
int j
Definition: myNF.cc:70
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:465
coeffs basecoeffs() const
Definition: bigintmat.h:149
int bigintmat::findnonzero ( int  i)

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

Definition at line 721 of file bigintmat.cc.

722 {
723  for (int j=1; j<=col; j++) {
724  if (!n_IsZero(view(i,j), basecoeffs()))
725  {
726  return j;
727  }
728  }
729  return 0;
730 }
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:125
int j
Definition: myNF.cc:70
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:465
int col
Definition: bigintmat.h:57
coeffs basecoeffs() const
Definition: bigintmat.h:149
number bigintmat::get ( int  i,
int  j 
) const

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

Definition at line 117 of file bigintmat.cc.

118 {
119  assume (i > 0 && j > 0);
120  assume (i <= rows() && j <= cols());
121 
122  return get(index(i, j));
123 }
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:164
int j
Definition: myNF.cc:70
#define assume(x)
Definition: mod2.h:405
int i
Definition: cfEzgcd.cc:123
int cols() const
Definition: bigintmat.h:147
int rows() const
Definition: bigintmat.h:148
number bigintmat::get ( int  i) const

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

Definition at line 101 of file bigintmat.cc.

102 {
103  assume (i >= 0);
104  assume (i<rows()*cols());
105 
106  return n_Copy(v[i], basecoeffs());
107 }
#define assume(x)
Definition: mod2.h:405
int i
Definition: cfEzgcd.cc:123
int cols() const
Definition: bigintmat.h:147
int rows() const
Definition: bigintmat.h:148
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:452
coeffs basecoeffs() const
Definition: bigintmat.h:149
void bigintmat::getcol ( int  j,
bigintmat a 
)

copies the j-th column into the matrix a - which needs to be pre-allocated with the correct size.

Definition at line 743 of file bigintmat.cc.

744 {
745  assume((j<=col) && (j>=1));
746  if (((a->rows() != row) || (a->cols() != 1)) && ((a->rows() != 1) || (a->cols() != row))) {
747  assume(0);
748  Werror("Error in getcol. Dimensions must agree!");
749  return;
750  }
751  if (!nCoeffs_are_equal(basecoeffs(), a->basecoeffs())) {
753  number t1, t2;
754  for (int i=1; i<=row;i++) {
755  t1 = get(i,j);
756  t2 = f(t1, basecoeffs(), a->basecoeffs());
757  a->set(i-1,t1);
758  n_Delete(&t1, basecoeffs());
759  n_Delete(&t2, a->basecoeffs());
760  }
761  return;
762  }
763  number t1;
764  for (int i=1; i<=row;i++) {
765  t1 = view(i,j);
766  a->set(i-1,t1);
767  }
768 }
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:125
f
Definition: cfModGcd.cc:4022
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:93
int j
Definition: myNF.cc:70
#define assume(x)
Definition: mod2.h:405
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:72
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:720
int cols() const
Definition: bigintmat.h:147
int rows() const
Definition: bigintmat.h:148
int col
Definition: bigintmat.h:57
coeffs basecoeffs() const
Definition: bigintmat.h:149
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:456
void Werror(const char *fmt,...)
Definition: reporter.cc:199
bool nCoeffs_are_equal(coeffs r, coeffs s)
Definition: bigintmat.cc:2473
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 770 of file bigintmat.cc.

771 {
772  number t1;
773  for(int ii=0; ii< no; ii++) {
774  for (int i=1; i<=row;i++) {
775  t1 = view(i, ii+j);
776  a->set(i, ii+1, t1);
777  }
778  }
779 }
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:125
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:93
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
void bigintmat::getrow ( int  i,
bigintmat a 
)

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

Definition at line 781 of file bigintmat.cc.

782 {
783  if ((i>row) || (i<1)) {
784  Werror("Error in getrow: Index out of range!");
785  return;
786  }
787  if (((a->rows() != 1) || (a->cols() != col)) && ((a->rows() != col) || (a->cols() != 1))) {
788  Werror("Error in getrow. Dimensions must agree!");
789  return;
790  }
791  if (!nCoeffs_are_equal(basecoeffs(), a->basecoeffs())) {
793  number t1, t2;
794  for (int j=1; j<=col;j++) {
795  t1 = get(i,j);
796  t2 = f(t1, basecoeffs(), a->basecoeffs());
797  a->set(j-1,t2);
798  n_Delete(&t1, basecoeffs());
799  n_Delete(&t2, a->basecoeffs());
800  }
801  return;
802  }
803  number t1;
804  for (int j=1; j<=col;j++) {
805  t1 = get(i,j);
806  a->set(j-1,t1);
807  n_Delete(&t1, basecoeffs());
808  }
809 }
f
Definition: cfModGcd.cc:4022
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:93
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:72
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:720
int cols() const
Definition: bigintmat.h:147
int rows() const
Definition: bigintmat.h:148
int col
Definition: bigintmat.h:57
coeffs basecoeffs() const
Definition: bigintmat.h:149
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:456
void Werror(const char *fmt,...)
Definition: reporter.cc:199
bool nCoeffs_are_equal(coeffs r, coeffs s)
Definition: bigintmat.cc:2473
int * bigintmat::getwid ( int  maxwid)

Definition at line 578 of file bigintmat.cc.

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

transforms INPLACE to HNF

Definition at line 1562 of file bigintmat.cc.

1563 {
1564  // Laufen von unten nach oben und von links nach rechts
1565  // CF: TODO: for n_Z: write a recursive version. This one will
1566  // have exponential blow-up. Look at Michianchio
1567  // Alternatively, do p-adic det and modular method
1568 
1569 #if 0
1570  char * s;
1571  ::Print("mat over Z is \n");
1572  ::Print("%s\n", s = nCoeffString(basecoeffs()));
1573  omFree(s);
1574  Print();
1575  ::Print("\n(%d x %d)\n", rows(), cols());
1576 #endif
1577 
1578  int i = rows();
1579  int j = cols();
1580  number q = n_Init(0, basecoeffs());
1581  number one = n_Init(1, basecoeffs());
1582  number minusone = n_Init(-1, basecoeffs());
1583  number tmp1 = n_Init(0, basecoeffs());
1584  number tmp2 = n_Init(0, basecoeffs());
1585  number co1, co2, co3, co4;
1586  number ggt = n_Init(0, basecoeffs());
1587 
1588  while ((i>0) && (j>0))
1589  {
1590  // Falls erstes Nicht-Null-Element in Zeile i nicht existiert, oder hinter Spalte j vorkommt, gehe in nächste Zeile
1591  if ((findnonzero(i)==0) || (findnonzero(i)>j))
1592  {
1593  i--;
1594  }
1595  else
1596  {
1597  // Laufe von links nach rechts durch die Zeile:
1598  for (int l=1; l<=j-1; l++)
1599  {
1600  n_Delete(&tmp1, basecoeffs());
1601  tmp1 = get(i, l);
1602  // Falls Eintrag (im folgenden x genannt) gleich 0, gehe eine Spalte weiter. Ansonsten...
1603  if (!n_IsZero(tmp1, basecoeffs()))
1604  {
1605  n_Delete(&tmp2, basecoeffs());
1606  tmp2 = get(i, l+1);
1607  // Falls Eintrag (i.f. y g.) rechts daneben gleich 0, tausche beide Spalten, sonst...
1608  if (!n_IsZero(tmp2, basecoeffs()))
1609  {
1610  n_Delete(&ggt, basecoeffs());
1611  ggt = n_XExtGcd(tmp1, tmp2, &co1, &co2, &co3, &co4, basecoeffs());
1612  // 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:
1613  if (n_Equal(tmp1, ggt, basecoeffs()))
1614  {
1615  swap(l, l+1);
1616  n_Delete(&q, basecoeffs());
1617  q = n_Div(tmp2, ggt, basecoeffs());
1618  q = n_InpNeg(q, basecoeffs());
1619  // Dann addiere das -q-fache der (neuen) rechten Spalte zur linken dazu. Damit erhalten wir die gewünschte 0
1620 
1621  addcol(l, l+1, q, basecoeffs());
1622  n_Delete(&q, basecoeffs());
1623  }
1624  else if (n_Equal(tmp1, minusone, basecoeffs()))
1625  {
1626  // 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
1627  // Die Berechnung von q (=y/ggt) entfällt, da ggt=1
1628  swap(l, l+1);
1629  colskalmult(l+1, minusone, basecoeffs());
1630  tmp2 = n_InpNeg(tmp2, basecoeffs());
1631  addcol(l, l+1, tmp2, basecoeffs());
1632  }
1633  else
1634  {
1635  // CF: use the 2x2 matrix (co1, co2)(co3, co4) to
1636  // get the gcd in position and the 0 in the other:
1637 #ifdef CF_DEB
1638  ::Print("applying trafo\n");
1639  StringSetS("");
1640  n_Write(co1, basecoeffs()); StringAppendS("\t");
1641  n_Write(co2, basecoeffs()); StringAppendS("\t");
1642  n_Write(co3, basecoeffs()); StringAppendS("\t");
1643  n_Write(co4, basecoeffs()); StringAppendS("\t");
1644  ::Print("%s\nfor l=%d\n", StringEndS(), l);
1645  {char * s = String();
1646  ::Print("to %s\n", s);omFree(s);};
1647 #endif
1648  coltransform(l, l+1, co3, co4, co1, co2);
1649 #ifdef CF_DEB
1650  {char * s = String();
1651  ::Print("gives %s\n", s);}
1652 #endif
1653  }
1654  n_Delete(&co1, basecoeffs());
1655  n_Delete(&co2, basecoeffs());
1656  n_Delete(&co3, basecoeffs());
1657  n_Delete(&co4, basecoeffs());
1658  }
1659  else
1660  {
1661  swap(l, l+1);
1662  }
1663  // Dann betrachte die vormals rechte Spalte als neue linke, und die rechts daneben als neue rechte.
1664  }
1665  }
1666 
1667  #ifdef HAVE_RINGS
1668  // normalize by units:
1669  if (!n_IsZero(view(i, j), basecoeffs()))
1670  {
1671  number u = n_GetUnit(view(i, j), basecoeffs());
1672  if (!n_IsOne(u, basecoeffs()))
1673  {
1674  colskaldiv(j, u);
1675  }
1676  n_Delete(&u, basecoeffs());
1677  }
1678  #endif
1679  // Zum Schluss mache alle Einträge rechts vom Diagonalelement betragsmäßig kleiner als dieses
1680  for (int l=j+1; l<=col; l++)
1681  {
1682  n_Delete(&q, basecoeffs());
1683  q = n_QuotRem(view(i, l), view(i, j), NULL, basecoeffs());
1684  q = n_InpNeg(q, basecoeffs());
1685  addcol(l, j, q, basecoeffs());
1686  }
1687  i--;
1688  j--;
1689  // Dann betrachte die Zeile darüber und gehe dort wie vorher vor
1690  }
1691  }
1692  n_Delete(&q, basecoeffs());
1693  n_Delete(&tmp1, basecoeffs());
1694  n_Delete(&tmp2, basecoeffs());
1695  n_Delete(&ggt, basecoeffs());
1696  n_Delete(&one, basecoeffs());
1697  n_Delete(&minusone, basecoeffs());
1698 
1699 #if 0
1700  ::Print("hnf over Z is \n");
1701  Print();
1702  ::Print("\n(%d x %d)\n", rows(), cols());
1703 #endif
1704 }
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:125
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:533
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:694
bool addcol(int i, int j, number a, coeffs c)
addiert a-faches der j-ten Spalte zur i-ten dazu
Definition: bigintmat.cc:927
void colskaldiv(int j, number b)
Macht Ganzzahldivision aller j-ten Spalteneinträge mit b.
Definition: bigintmat.cc:1778
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the one element.
Definition: coeffs.h:469
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:539
int findnonzero(int i)
find index of 1st non-zero entry in row i
Definition: bigintmat.cc:721
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:690
static FORCE_INLINE void n_Write(number &n, const coeffs r, const BOOLEAN bShortOut=TRUE)
Definition: coeffs.h:592
static FORCE_INLINE number n_QuotRem(number a, number b, number *q, const coeffs r)
Definition: coeffs.h:702
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:558
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:465
CFList tmp2
Definition: facFqBivar.cc:70
int cols() const
Definition: bigintmat.h:147
void Print()
IO: simply prints the matrix to the current output (screen?)
Definition: bigintmat.cc:440
int rows() const
Definition: bigintmat.h:148
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:973
#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:615
char * String()
IO: String returns a singular string containing the matrix, needs freeing afterwards.
Definition: bigintmat.cc:433
coeffs basecoeffs() const
Definition: bigintmat.h:149
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:461
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:1791
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:456
static FORCE_INLINE char * nCoeffString(const coeffs cf)
TODO: make it a virtual method of coeffs, together with: Decompose & Compose, rParameter & rPar...
Definition: coeffs.h:963
void one()
Macht Matrix (Falls quadratisch) zu Einheitsmatrix.
Definition: bigintmat.cc:1238
int l
Definition: cfEzgcd.cc:94
number bigintmat::hnfdet ( )

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

Definition at line 1447 of file bigintmat.cc.

1448 {
1449  assume (col == row);
1450 
1451  if (col == 1)
1452  return get(1, 1);
1453  bigintmat *m = new bigintmat(this);
1454  m->hnf();
1455  number prod = n_Init(1, basecoeffs());
1456  number temp, temp2;
1457  for (int i=1; i<=col; i++) {
1458  temp = m->get(i, i);
1459  temp2 = n_Mult(temp, prod, basecoeffs());
1460  n_Delete(&prod, basecoeffs());
1461  prod = temp2;
1462  n_Delete(&temp, basecoeffs());
1463  }
1464  delete m;
1465  return prod;
1466 }
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:539
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:635
#define assume(x)
Definition: mod2.h:405
int m
Definition: cfEzgcd.cc:119
void hnf()
transforms INPLACE to HNF
Definition: bigintmat.cc:1562
int i
Definition: cfEzgcd.cc:123
int col
Definition: bigintmat.h:57
bigintmat()
Definition: bigintmat.h:60
fq_nmod_poly_t prod
Definition: facHensel.cc:95
coeffs basecoeffs() const
Definition: bigintmat.h:149
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:456
number get(int i, int j) const
get a copy of an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:117
void bigintmat::howell ( )

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

Definition at line 1487 of file bigintmat.cc.

1488 {
1489  coeffs R = basecoeffs();
1490  hnf(); // as a starting point...
1491  if (getCoeffType(R)== n_Z) return; //wrong, need to prune!
1492 
1493  int n = cols(), m = rows(), i, j, k;
1494 
1495  //make sure, the matrix has enough space. We need no rows+1 columns.
1496  //The resulting Howell form will be pruned to be at most square.
1497  bigintmat * t = new bigintmat(m, m+1, R);
1498  t->copySubmatInto(this, 1, n>m ? n-m+1 : 1, m, n>m ? m : n, 1, n>m ? 2 : m+2-n );
1499  swapMatrix(t);
1500  delete t;
1501  for(i=1; i<= cols(); i++) {
1502  if (!colIsZero(i)) break;
1503  }
1504  assume (i>1);
1505  if (i>cols()) {
1506  t = new bigintmat(rows(), 0, R);
1507  swapMatrix(t);
1508  delete t;
1509  return; // zero matrix found, clearly normal.
1510  }
1511 
1512  int last_zero_col = i-1;
1513  for (int c = cols(); c>0; c--) {
1514  for(i=rows(); i>0; i--) {
1515  if (!n_IsZero(view(i, c), R)) break;
1516  }
1517  if (i==0) break; // matrix SHOULD be zero from here on
1518  number a = n_Ann(view(i, c), R);
1519  addcol(last_zero_col, c, a, R);
1520  n_Delete(&a, R);
1521  for(j = c-1; j>last_zero_col; j--) {
1522  for(k=rows(); k>0; k--) {
1523  if (!n_IsZero(view(k, j), R)) break;
1524  if (!n_IsZero(view(k, last_zero_col), R)) break;
1525  }
1526  if (k==0) break;
1527  if (!n_IsZero(view(k, last_zero_col), R)) {
1528  number gcd, co1, co2, co3, co4;
1529  gcd = n_XExtGcd(view(k, last_zero_col), view(k, j), &co1, &co2, &co3, &co4, R);
1530  if (n_Equal(gcd, view(k, j), R)) {
1531  number q = n_Div(view(k, last_zero_col), gcd, R);
1532  q = n_InpNeg(q, R);
1533  addcol(last_zero_col, j, q, R);
1534  n_Delete(&q, R);
1535  } else if (n_Equal(gcd, view(k, last_zero_col), R)) {
1536  swap(last_zero_col, k);
1537  number q = n_Div(view(k, last_zero_col), gcd, R);
1538  q = n_InpNeg(q, R);
1539  addcol(last_zero_col, j, q, R);
1540  n_Delete(&q, R);
1541  } else {
1542  coltransform(last_zero_col, j, co3, co4, co1, co2);
1543  }
1544  n_Delete(&gcd, R);
1545  n_Delete(&co1, R);
1546  n_Delete(&co2, R);
1547  n_Delete(&co3, R);
1548  n_Delete(&co4, R);
1549  }
1550  }
1551  for(k=rows(); k>0; k--) {
1552  if (!n_IsZero(view(k, last_zero_col), R)) break;
1553  }
1554  if (k) last_zero_col--;
1555  }
1556  t = new bigintmat(rows(), cols()-last_zero_col, R);
1557  t->copySubmatInto(this, 1, last_zero_col+1, rows(), cols()-last_zero_col, 1, 1);
1558  swapMatrix(t);
1559  delete t;
1560 }
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:125
int colIsZero(int i)
Definition: bigintmat.cc:1479
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:694
bool addcol(int i, int j, number a, coeffs c)
addiert a-faches der j-ten Spalte zur i-ten dazu
Definition: bigintmat.cc:927
Matrices of numbers.
Definition: bigintmat.h:51
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:700
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:1204
int j
Definition: myNF.cc:70
#define assume(x)
Definition: mod2.h:405
void swapMatrix(bigintmat *a)
Definition: bigintmat.cc:1468
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:690
const ring R
Definition: DebugPrint.cc:36
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:558
void hnf()
transforms INPLACE to HNF
Definition: bigintmat.cc:1562
only used if HAVE_RINGS is defined: ?
Definition: coeffs.h:42
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:465
int cols() const
Definition: bigintmat.h:147
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:422
int rows() const
Definition: bigintmat.h:148
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:615
int gcd(int a, int b)
Definition: walkSupport.cc:839
coeffs basecoeffs() const
Definition: bigintmat.h:149
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:461
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:1791
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:456
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 164 of file bigintmat.h.

165  {
166  assume (rows() >= 0 && cols() >= 0);
167 
168  assume (r > 0 && c > 0);
169  assume (r <= rows() && c <= cols());
170 
171  const int index = ((r-1)*cols() + (c-1));
172 
173  assume (index >= 0 && index < rows() * cols());
174  return index;
175  }
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:164
const ring r
Definition: syzextra.cc:208
#define assume(x)
Definition: mod2.h:405
int cols() const
Definition: bigintmat.h:147
int rows() const
Definition: bigintmat.h:148
bigintmat* bigintmat::inpmod ( number  p,
coeffs  c 
)

Liefert Kopie der Matrix zurück, allerdings im Ring Z modulo p.

void bigintmat::inpMult ( number  bintop,
const coeffs  C = NULL 
)

inplace versio of skalar mult. CHANGES input.

Definition at line 143 of file bigintmat.cc.

144 {
145  assume (C == NULL || C == basecoeffs());
146 
147  const int l = rows() * cols();
148 
149  for (int i=0; i < l; i++)
150  n_InpMult(v[i], bintop, basecoeffs());
151 }
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:640
#define assume(x)
Definition: mod2.h:405
int i
Definition: cfEzgcd.cc:123
int cols() const
Definition: bigintmat.h:147
int rows() const
Definition: bigintmat.h:148
number * v
Definition: bigintmat.h:55
#define NULL
Definition: omList.c:10
coeffs basecoeffs() const
Definition: bigintmat.h:149
int l
Definition: cfEzgcd.cc:94
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  swap(i*m+j, j*n+i);
67  }
68  if (n<m)
69  for (int i=nm; i<m; i++)
70  for(int j=0; j<n; j++) {
71  swap(j*n+i, i*m+j);
72  }
73  if (n>m)
74  for (int i=nm; i<n; i++)
75  for(int j=0; j<m; j++) {
76  swap(i*m+j, j*n+i);
77  }
78 #undef swap
79  row = m;
80  col = n;
81 }
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:690
int m
Definition: cfEzgcd.cc:119
int i
Definition: cfEzgcd.cc:123
int col
Definition: bigintmat.h:57
int bigintmat::isOne ( )

is matrix is identity

Definition at line 1218 of file bigintmat.cc.

1218  {
1219  coeffs r = basecoeffs();
1220  if (row==col) {
1221  for (int i=1; i<=row; i++) {
1222  for (int j=1; j<=col; j++) {
1223  if (i==j) {
1224  if (!n_IsOne(view(i, j), r))
1225  return 0;
1226  }
1227  else {
1228  if (!n_IsZero(view(i,j), r))
1229  return 0;
1230  }
1231  }
1232  }
1233  }
1234  return 1;
1235 }
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:125
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the one element.
Definition: coeffs.h:469
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.
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:465
int col
Definition: bigintmat.h:57
coeffs basecoeffs() const
Definition: bigintmat.h:149
int bigintmat::isZero ( )

Definition at line 1266 of file bigintmat.cc.

1266  {
1267  for (int i=1; i<=row; i++) {
1268  for (int j=1; j<=col; j++) {
1269  if (!n_IsZero(view(i,j), basecoeffs()))
1270  return FALSE;
1271  }
1272  }
1273  return TRUE;
1274 }
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:125
#define FALSE
Definition: auxiliary.h:140
int row
Definition: bigintmat.h:56
#define TRUE
Definition: auxiliary.h:144
int j
Definition: myNF.cc:70
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:465
int col
Definition: bigintmat.h:57
coeffs basecoeffs() const
Definition: bigintmat.h:149
int bigintmat::length ( )
inline

Definition at line 146 of file bigintmat.h.

146 { return col*row; }
int row
Definition: bigintmat.h:56
int col
Definition: bigintmat.h:57
void bigintmat::mod ( number  p)

Reduziert komplette Matrix modulo p.

Definition at line 1818 of file bigintmat.cc.

1819 {
1820  // produce the matrix in Z/pZ
1821  number tmp1, tmp2;
1822  for (int i=1; i<=row; i++)
1823  {
1824  for (int j=1; j<=col; j++)
1825  {
1826  tmp1 = get(i, j);
1827  tmp2 = n_IntMod(tmp1, p, basecoeffs());
1828  n_Delete(&tmp1, basecoeffs());
1829  set(i, j, tmp2);
1830  }
1831  }
1832 }
static FORCE_INLINE number n_IntMod(number a, number b, const coeffs r)
for r a field, return n_Init(0,r) otherwise: n_Div(a,b,r)*b+n_IntMod(a,b,r)==a
Definition: coeffs.h:627
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:149
CFList tmp1
Definition: facFqBivar.cc:70
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:456
bigintmat* bigintmat::modgauss ( number  p,
coeffs  c 
)
bigintmat * bigintmat::modhnf ( number  p,
coeffs  c 
)

computes HNF(this | p*I)

Definition at line 1734 of file bigintmat.cc.

1735 {
1736  coeffs Rp = numbercoeffs(p, R); // R/pR
1737  bigintmat *m = bimChangeCoeff(this, Rp);
1738  m->howell();
1739  bigintmat *a = bimChangeCoeff(m, R);
1740  delete m;
1741  bigintmat *C = new bigintmat(rows(), rows(), R);
1742  int piv = rows(), i = a->cols();
1743  while (piv)
1744  {
1745  if (!i || n_IsZero(a->view(piv, i), R))
1746  {
1747  C->set(piv, piv, p, R);
1748  }
1749  else
1750  {
1751  C->copySubmatInto(a, 1, i, rows(), 1, 1, piv);
1752  i--;
1753  }
1754  piv--;
1755  }
1756  delete a;
1757  return C;
1758 }
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:125
const poly a
Definition: syzextra.cc:212
return P p
Definition: myNF.cc:203
Matrices of numbers.
Definition: bigintmat.h:51
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:93
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:1204
The main handler for Singular numbers which are suitable for Singular polynomials.
const ring R
Definition: DebugPrint.cc:36
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:465
bigintmat * bimChangeCoeff(bigintmat *a, coeffs cnew)
Liefert Kopier von Matrix a zurück, mit coeffs cnew statt den ursprünglichen.
Definition: bigintmat.cc:1706
int cols() const
Definition: bigintmat.h:147
int rows() const
Definition: bigintmat.h:148
bigintmat()
Definition: bigintmat.h:60
void howell()
dito, but Howell form (only different for zero-divsors)
Definition: bigintmat.cc:1487
void bigintmat::one ( )

Macht Matrix (Falls quadratisch) zu Einheitsmatrix.

Definition at line 1238 of file bigintmat.cc.

1238  {
1239  if (row==col) {
1240  number one = n_Init(1, basecoeffs()),
1241  zero = n_Init(0, basecoeffs());
1242  for (int i=1; i<=row; i++) {
1243  for (int j=1; j<=col; j++) {
1244  if (i==j) {
1245  set(i, j, one);
1246  } else {
1247  set(i, j, zero);
1248  }
1249  }
1250  }
1251  n_Delete(&one, basecoeffs());
1252  n_Delete(&zero, basecoeffs());
1253  }
1254 }
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:539
int row
Definition: bigintmat.h:56
void zero()
Setzt alle Einträge auf 0.
Definition: bigintmat.cc:1256
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
int col
Definition: bigintmat.h:57
coeffs basecoeffs() const
Definition: bigintmat.h:149
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:456
void one()
Macht Matrix (Falls quadratisch) zu Einheitsmatrix.
Definition: bigintmat.cc:1238
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 134 of file bigintmat.cc.

135 {
136  number iop = n_Init(intop, basecoeffs());
137 
138  inpMult(iop, basecoeffs());
139 
140  n_Delete(&iop, basecoeffs());
141 }
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:539
coeffs basecoeffs() const
Definition: bigintmat.h:149
void inpMult(number bintop, const coeffs C=NULL)
inplace versio of skalar mult. CHANGES input.
Definition: bigintmat.cc:143
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:456
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 #endif
120  assume ( !((i<0)||(i>=row*col)) );
121 
122  return v[i]; // Hier sollte imho kein nlCopy rein...
123  }
int row
Definition: bigintmat.h:56
#define assume(x)
Definition: mod2.h:405
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:199
const number& bigintmat::operator[] ( int  i) const
inline

Definition at line 124 of file bigintmat.h.

125  {
126 #ifndef SING_NDEBUG
127  if((i<0)||(i>=row*col))
128  {
129  Werror("wrong bigintmat index:%d\n",i);
130  }
131 #endif
132  assume ( !((i<0)||(i>=row*col)) );
133 
134  return v[i];
135  }
int row
Definition: bigintmat.h:56
#define assume(x)
Definition: mod2.h:405
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:199
void bigintmat::pprint ( int  maxwid)

Definition at line 610 of file bigintmat.cc.

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

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

Definition at line 440 of file bigintmat.cc.

441 {
442  char * s = String();
443  PrintS(s);
444  omFree(s);
445 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
#define omFree(addr)
Definition: omAllocDecl.h:261
void PrintS(const char *s)
Definition: reporter.cc:294
char * String()
IO: String returns a singular string containing the matrix, needs freeing afterwards.
Definition: bigintmat.cc:433
number bigintmat::pseudoinv ( bigintmat a)

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

Definition at line 1317 of file bigintmat.cc.

1317  {
1318 
1319  // Falls Matrix über reellen Zahlen nicht invertierbar, breche ab
1320  assume((a->rows() == row) && (a->rows() == a->cols()) && (row == col));
1321 
1322  number det = this->det(); //computes the HNF, so should e reused.
1323  if ((n_IsZero(det, basecoeffs())))
1324  return det;
1325 
1326  // Hänge Einheitsmatrix über Matrix und wendet HNF an. An Stelle der Einheitsmatrix steht im Ergebnis die Transformationsmatrix dazu
1327  a->one();
1328  bigintmat *m = new bigintmat(2*row, col, basecoeffs());
1329  m->concatrow(a,this);
1330  m->hnf();
1331  // Arbeite weiterhin mit der zusammengehängten Matrix
1332  // 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
1333  number diag;
1334  number temp, ttemp;
1335  for (int i=1; i<=col; i++) {
1336  diag = m->get(row+i, i);
1337  for (int j=i+1; j<=col; j++) {
1338  temp = m->get(row+i, j);
1339  m->colskalmult(j, diag, basecoeffs());
1340  temp = n_InpNeg(temp, basecoeffs());
1341  m->addcol(j, i, temp, basecoeffs());
1342  n_Delete(&temp, basecoeffs());
1343  }
1344  n_Delete(&diag, basecoeffs());
1345  }
1346  // Falls wir nicht modulo n arbeiten, können wir die Spalten durch den ggT teilen, um die Einträge kleiner zu bekommen
1347  // Bei Z/n sparen wir uns das, da es hier sinnlos ist
1348  number g;
1349  number gcd;
1350  for (int j=1; j<=col; j++) {
1351  g = n_Init(0, basecoeffs());
1352  for (int i=1; i<=2*row; i++) {
1353  temp = m->get(i,j);
1354  gcd = n_Gcd(g, temp, basecoeffs());
1355  n_Delete(&g, basecoeffs());
1356  n_Delete(&temp, basecoeffs());
1357  g = n_Copy(gcd, basecoeffs());
1358  n_Delete(&gcd, basecoeffs());
1359  }
1360  if (!(n_IsOne(g, basecoeffs())))
1361  m->colskaldiv(j, g);
1362  n_Delete(&g, basecoeffs());
1363  }
1364 
1365  // 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)
1366 
1367  g = n_Init(0, basecoeffs());
1368  number prod = n_Init(1, basecoeffs());
1369  for (int i=1; i<=col; i++) {
1370  gcd = n_Gcd(g, m->get(row+i, i), basecoeffs());
1371  n_Delete(&g, basecoeffs());
1372  g = n_Copy(gcd, basecoeffs());
1373  n_Delete(&gcd, basecoeffs());
1374  ttemp = n_Copy(prod, basecoeffs());
1375  temp = m->get(row+i, i);
1376  n_Delete(&prod, basecoeffs());
1377  prod = n_Mult(ttemp, temp, basecoeffs());
1378  n_Delete(&ttemp, basecoeffs());
1379  n_Delete(&temp, basecoeffs());
1380  }
1381  number lcm;
1382  lcm = n_Div(prod, g, basecoeffs());
1383  for (int j=1; j<=col; j++) {
1384  ttemp = m->get(row+j,j);
1385  temp = n_QuotRem(lcm, ttemp, NULL, basecoeffs());
1386  m->colskalmult(j, temp, basecoeffs());
1387  n_Delete(&ttemp, basecoeffs());
1388  n_Delete(&temp, basecoeffs());
1389  }
1390  n_Delete(&lcm, basecoeffs());
1391  n_Delete(&prod, basecoeffs());
1392 
1393  number divisor = m->get(row+1, 1);
1394  m->splitrow(a, 1);
1395  delete m;
1396  n_Delete(&det, basecoeffs());
1397  return divisor;
1398 }
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:685
void concatrow(bigintmat *a, bigintmat *b)
Fügt zwei Matrixen untereinander/nebeneinander in gegebene Matrix ein, bzw spaltet gegebenen Matrix a...
Definition: bigintmat.cc:999
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:1414
bool addcol(int i, int j, number a, coeffs c)
addiert a-faches der j-ten Spalte zur i-ten dazu
Definition: bigintmat.cc:927
void colskaldiv(int j, number b)
Macht Ganzzahldivision aller j-ten Spalteneinträge mit b.
Definition: bigintmat.cc:1778
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the one element.
Definition: coeffs.h:469
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:539
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:635
int j
Definition: myNF.cc:70
#define assume(x)
Definition: mod2.h:405
int m
Definition: cfEzgcd.cc:119
static FORCE_INLINE number n_QuotRem(number a, number b, number *q, const coeffs r)
Definition: coeffs.h:702
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:558
void hnf()
transforms INPLACE to HNF
Definition: bigintmat.cc:1562
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:465
int cols() const
Definition: bigintmat.h:147
int rows() const
Definition: bigintmat.h:148
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:973
#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:452
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:615
int gcd(int a, int b)
Definition: walkSupport.cc:839
fq_nmod_poly_t prod
Definition: facHensel.cc:95
coeffs basecoeffs() const
Definition: bigintmat.h:149
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:1074
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:456
void one()
Macht Matrix (Falls quadratisch) zu Einheitsmatrix.
Definition: bigintmat.cc:1238
number get(int i, int j) const
get a copy of an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:117
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 199 of file bigintmat.h.

200  {
201  assume (C == NULL || C == basecoeffs());
202  assume (i >= 0);
203  const int l = rows() * cols();
204  assume (i<l);
205 
206  if (i < l)
207  {
208  n_Delete(&(v[i]), basecoeffs()); v[i] = n;
209  }
210 #ifndef SING_NDEBUG
211  else
212  {
213  Werror("wrong bigintmat index:%d\n",i);
214  }
215 #endif
216  }
#define assume(x)
Definition: mod2.h:405
int i
Definition: cfEzgcd.cc:123
int cols() const
Definition: bigintmat.h:147
int rows() const
Definition: bigintmat.h:148
number * v
Definition: bigintmat.h:55
#define NULL
Definition: omList.c:10
coeffs basecoeffs() const
Definition: bigintmat.h:149
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:456
void Werror(const char *fmt,...)
Definition: reporter.cc:199
int l
Definition: cfEzgcd.cc:94
void bigintmat::rawset ( int  i,
int  j,
number  n,
const coeffs  C = NULL 
)
inline

as above, but the 2-dim version

Definition at line 219 of file bigintmat.h.

220  {
221  rawset( index(i,j), n, C);
222  }
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:199
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:164
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
int bigintmat::rows ( ) const
inline

Definition at line 148 of file bigintmat.h.

148 { return row; }
int row
Definition: bigintmat.h:56
void bigintmat::rowskalmult ( int  i,
number  a,
coeffs  c 
)

... Zeile ...

Definition at line 986 of file bigintmat.cc.

986  {
987  if ((i>=1) && (i<=row) && (nCoeffs_are_equal(c, basecoeffs()))) {
988  number t, tmult;
989  for (int j=1; j<=col; j++) {
990  t = view(i, j);
991  tmult = n_Mult(a, t, basecoeffs());
992  rawset(i, j, tmult);
993  }
994  }
995  else
996  Werror("Error in rowskalmult");
997 }
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:125
const poly a
Definition: syzextra.cc:212
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:199
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:635
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
int col
Definition: bigintmat.h:57
coeffs basecoeffs() const
Definition: bigintmat.h:149
void Werror(const char *fmt,...)
Definition: reporter.cc:199
bool nCoeffs_are_equal(coeffs r, coeffs s)
Definition: bigintmat.cc:2473
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 93 of file bigintmat.cc.

94 {
95  assume (C == NULL || C == basecoeffs());
96  assume (i > 0 && j > 0);
97  assume (i <= rows() && j <= cols());
98  set(index(i, j), n, C);
99 }
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:164
int j
Definition: myNF.cc:70
#define assume(x)
Definition: mod2.h:405
int i
Definition: cfEzgcd.cc:123
int cols() const
Definition: bigintmat.h:147
int rows() const
Definition: bigintmat.h:148
#define NULL
Definition: omList.c:10
coeffs basecoeffs() const
Definition: bigintmat.h:149
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 85 of file bigintmat.cc.

86 {
87  assume (C == NULL || C == basecoeffs());
88 
89  rawset(i, n_Copy(n, basecoeffs()), basecoeffs());
90 }
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:199
#define assume(x)
Definition: mod2.h:405
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:452
coeffs basecoeffs() const
Definition: bigintmat.h:149
void bigintmat::setcol ( int  j,
bigintmat m 
)

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

Definition at line 812 of file bigintmat.cc.

813 {
814  if ((j>col) || (j<1)) {
815  Werror("Error in setcol: Index out of range!");
816  return;
817  }
818  if (((m->rows() != row) || (m->cols() != 1)) && ((m->rows() != 1) || (m->cols() != row))) {
819  Werror("Error in setcol. Dimensions must agree!");
820  return;
821  }
822  if (!nCoeffs_are_equal(basecoeffs(), m->basecoeffs())) {
824  number t1,t2;
825  for (int i=1; i<=row; i++) {
826  t1 = m->get(i-1);
827  t2 = f(t1, m->basecoeffs(),basecoeffs());
828  set(i, j, t2);
829  n_Delete(&t2, basecoeffs());
830  n_Delete(&t1, m->basecoeffs());
831  }
832  return;
833  }
834  number t1;
835  for (int i=1; i<=row; i++) {
836  t1 = m->view(i-1);
837  set(i, j, t1);
838  }
839 }
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:125
f
Definition: cfModGcd.cc:4022
int row
Definition: bigintmat.h:56
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:72
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:720
int cols() const
Definition: bigintmat.h:147
int rows() const
Definition: bigintmat.h:148
int col
Definition: bigintmat.h:57
coeffs basecoeffs() const
Definition: bigintmat.h:149
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:456
void Werror(const char *fmt,...)
Definition: reporter.cc:199
number get(int i, int j) const
get a copy of an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:117
bool nCoeffs_are_equal(coeffs r, coeffs s)
Definition: bigintmat.cc:2473
void bigintmat::setrow ( int  i,
bigintmat m 
)

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

Definition at line 841 of file bigintmat.cc.

841  {
842  if ((j>row) || (j<1)) {
843  Werror("Error in setrow: Index out of range!");
844  return;
845  }
846  if (((m->rows() != 1) || (m->cols() != col)) && ((m->rows() != col) || (m->cols() != 1))) {
847  Werror("Error in setrow. Dimensions must agree!");
848  return;
849  }
850  if (!nCoeffs_are_equal(basecoeffs(), m->basecoeffs())) {
852  number tmp1,tmp2;
853  for (int i=1; i<=col; i++) {
854  tmp1 = m->get(i-1);
855  tmp2 = f(tmp1, m->basecoeffs(),basecoeffs());
856  set(j, i, tmp2);
857  n_Delete(&tmp2, basecoeffs());
858  n_Delete(&tmp1, m->basecoeffs());
859  }
860  return;
861  }
862  number tmp;
863  for (int i=1; i<=col; i++) {
864  tmp = m->view(i-1);
865  set(j, i, tmp);
866  }
867 
868 }
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:125
f
Definition: cfModGcd.cc:4022
int row
Definition: bigintmat.h:56
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:72
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:720
CFList tmp2
Definition: facFqBivar.cc:70
int cols() const
Definition: bigintmat.h:147
int rows() const
Definition: bigintmat.h:148
int col
Definition: bigintmat.h:57
coeffs basecoeffs() const
Definition: bigintmat.h:149
CFList tmp1
Definition: facFqBivar.cc:70
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:456
void Werror(const char *fmt,...)
Definition: reporter.cc:199
number get(int i, int j) const
get a copy of an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:117
bool nCoeffs_are_equal(coeffs r, coeffs s)
Definition: bigintmat.cc:2473
void bigintmat::simplifyContentDen ( number *  den)

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

Definition at line 2510 of file bigintmat.cc.

2511 {
2512  coeffs r = basecoeffs();
2513  number g = n_Copy(*d, r), h;
2514  int n=rows()*cols();
2515  for(int i=0; i<n && !n_IsOne(g, r); i++) {
2516  h = n_Gcd(g, view(i), r);
2517  n_Delete(&g, r);
2518  g=h;
2519  }
2520  *d = n_Div(*d, g, r);
2521  if (!n_IsOne(g, r))
2522  skaldiv(g);
2523 }
void skaldiv(number b)
Macht Ganzzahldivision aller Matrixeinträge mit b.
Definition: bigintmat.cc:1763
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:125
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:685
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the one element.
Definition: coeffs.h:469
g
Definition: cfModGcd.cc:4031
const ring r
Definition: syzextra.cc:208
The main handler for Singular numbers which are suitable for Singular polynomials.
int i
Definition: cfEzgcd.cc:123
int cols() const
Definition: bigintmat.h:147
int rows() const
Definition: bigintmat.h:148
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of &#39;n&#39;
Definition: coeffs.h:452
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:615
coeffs basecoeffs() const
Definition: bigintmat.h:149
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:456
static Poly * h
Definition: janet.cc:978
void bigintmat::skaldiv ( number  b)

Macht Ganzzahldivision aller Matrixeinträge mit b.

Definition at line 1763 of file bigintmat.cc.

1764 {
1765  number tmp1, tmp2;
1766  for (int i=1; i<=row; i++)
1767  {
1768  for (int j=1; j<=col; j++)
1769  {
1770  tmp1 = view(i, j);
1771  tmp2 = n_Div(tmp1, b, basecoeffs());
1772  rawset(i, j, tmp2);
1773  }
1774  }
1775 }
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:125
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:199
int j
Definition: myNF.cc:70
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:615
coeffs basecoeffs() const
Definition: bigintmat.h:149
CFList tmp1
Definition: facFqBivar.cc:70
const poly b
Definition: syzextra.cc:213
bool bigintmat::skalmult ( number  b,
coeffs  c 
)

Multipliziert zur Matrix den Skalar b hinzu.

Definition at line 906 of file bigintmat.cc.

907 {
908  if (!nCoeffs_are_equal(c, basecoeffs()))
909  {
910  Werror("Wrong coeffs\n");
911  return false;
912  }
913  number t1, t2;
914  if ( n_IsOne(b,c)) return true;
915  for (int i=1; i<=row; i++)
916  {
917  for (int j=1; j<=col; j++)
918  {
919  t1 = view(i, j);
920  t2 = n_Mult(t1, b, basecoeffs());
921  rawset(i, j, t2);
922  }
923  }
924  return true;
925 }
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:125
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the one element.
Definition: coeffs.h:469
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:199
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:635
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
int col
Definition: bigintmat.h:57
coeffs basecoeffs() const
Definition: bigintmat.h:149
const poly b
Definition: syzextra.cc:213
void Werror(const char *fmt,...)
Definition: reporter.cc:199
bool nCoeffs_are_equal(coeffs r, coeffs s)
Definition: bigintmat.cc:2473
void bigintmat::splitcol ( bigintmat a,
bigintmat b 
)

... linken ... rechten ...

Definition at line 1107 of file bigintmat.cc.

1107  {
1108  int ay = a->cols();
1109  int ax = a->rows();
1110  int by = b->cols();
1111  int bx = b->rows();
1112  number tmp;
1113  if (!((row == ax) && (row == bx))) {
1114  Werror("Error in splitcol. Dimensions must agree!");
1115  }
1116  else if (!(ay+by == col)) {
1117  Werror("Error in splitcol. Dimensions must agree!");
1118  }
1120  Werror("Error in splitcol. coeffs do not agree!");
1121  }
1122  else {
1123  for (int i=1; i<=ax; i++) {
1124  for (int j=1; j<=ay; j++) {
1125  tmp = view(i,j);
1126  a->set(i,j,tmp);
1127  }
1128  }
1129  for (int i=1; i<=bx; i++) {
1130  for (int j=1; j<=by; j++) {
1131  tmp = view(i,j+ay);
1132  b->set(i,j,tmp);
1133  }
1134  }
1135  }
1136 }
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:125
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:93
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
int cols() const
Definition: bigintmat.h:147
int rows() const
Definition: bigintmat.h:148
int col
Definition: bigintmat.h:57
coeffs basecoeffs() const
Definition: bigintmat.h:149
void Werror(const char *fmt,...)
Definition: reporter.cc:199
bool nCoeffs_are_equal(coeffs r, coeffs s)
Definition: bigintmat.cc:2473
void bigintmat::splitcol ( bigintmat a,
int  i 
)

Speichert die ersten i Spalten als Teilmatrix in a.

Definition at line 1138 of file bigintmat.cc.

1138  {
1139  number tmp;
1140  if ((a->rows() != row) || (a->cols()+i-1 > col) || (i<1)) {
1141  Werror("Error in splitcol. Dimensions must agree!");
1142  return;
1143  }
1144  if (!(nCoeffs_are_equal(a->basecoeffs(), basecoeffs()))) {
1145  Werror("Error in splitcol. coeffs do not agree!");
1146  return;
1147  }
1148  int width = a->cols();
1149  for (int j=1; j<=width; j++) {
1150  for (int k=1; k<=row; k++) {
1151  tmp = get(k, j+i-1);
1152  a->set(k, j, tmp);
1153  n_Delete(&tmp, basecoeffs());
1154  }
1155  }
1156 }
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:93
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
int cols() const
Definition: bigintmat.h:147
int rows() const
Definition: bigintmat.h:148
int col
Definition: bigintmat.h:57
coeffs basecoeffs() const
Definition: bigintmat.h:149
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:456
void Werror(const char *fmt,...)
Definition: reporter.cc:199
bool nCoeffs_are_equal(coeffs r, coeffs s)
Definition: bigintmat.cc:2473
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 1074 of file bigintmat.cc.

1074  {
1075  int ay = a->cols();
1076  int ax = a->rows();
1077  int by = b->cols();
1078  int bx = b->rows();
1079  number tmp;
1080  if (!(ax + bx == row)) {
1081  Werror("Error in splitrow. Dimensions must agree!");
1082  }
1083  else if (!((col == ay) && (col == by))) {
1084  Werror("Error in splitrow. Dimensions must agree!");
1085  }
1087  Werror("Error in splitrow. coeffs do not agree!");
1088  }
1089  else {
1090  for(int i = 1; i<=ax; i++) {
1091  for(int j = 1; j<=ay;j++) {
1092  tmp = get(i,j);
1093  a->set(i,j,tmp);
1094  n_Delete(&tmp, basecoeffs());
1095  }
1096  }
1097  for (int i =1; i<=bx; i++) {
1098  for (int j=1;j<=col;j++) {
1099  tmp = get(i+ax, j);
1100  b->set(i,j,tmp);
1101  n_Delete(&tmp, basecoeffs());
1102  }
1103  }
1104  }
1105 }
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:93
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
int cols() const
Definition: bigintmat.h:147
int rows() const
Definition: bigintmat.h:148
int col
Definition: bigintmat.h:57
coeffs basecoeffs() const
Definition: bigintmat.h:149
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:456
void Werror(const char *fmt,...)
Definition: reporter.cc:199
bool nCoeffs_are_equal(coeffs r, coeffs s)
Definition: bigintmat.cc:2473
void bigintmat::splitrow ( bigintmat a,
int  i 
)

... Zeilen ...

Definition at line 1158 of file bigintmat.cc.

1158  {
1159  number tmp;
1160  if ((a->cols() != col) || (a->rows()+i-1 > row) || (i<1)) {
1161  Werror("Error in Marco-splitrow");
1162  return;
1163  }
1164 
1165  if (!(nCoeffs_are_equal(a->basecoeffs(), basecoeffs()))) {
1166  Werror("Error in splitrow. coeffs do not agree!");
1167  return;
1168  }
1169  int height = a->rows();
1170  for (int j=1; j<=height; j++) {
1171  for (int k=1; k<=col; k++) {
1172  tmp = view(j+i-1, k);
1173  a->set(j, k, tmp);
1174  }
1175  }
1176 }
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:125
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:93
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
int cols() const
Definition: bigintmat.h:147
int rows() const
Definition: bigintmat.h:148
int col
Definition: bigintmat.h:57
coeffs basecoeffs() const
Definition: bigintmat.h:149
void Werror(const char *fmt,...)
Definition: reporter.cc:199
bool nCoeffs_are_equal(coeffs r, coeffs s)
Definition: bigintmat.cc:2473
char * bigintmat::String ( )

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

Definition at line 433 of file bigintmat.cc.

434 {
435  StringSetS("");
436  Write();
437  return StringEndS();
438 }
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:413
void StringSetS(const char *st)
Definition: reporter.cc:128
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 448 of file bigintmat.cc.

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

Subtrahiert ...

Definition at line 888 of file bigintmat.cc.

889 {
890  if ((b->rows() != row) || (b->cols() != col)) {
891  Werror("Error in bigintmat::sub. Dimensions do not agree!");
892  return false;
893  }
894  if (!nCoeffs_are_equal(basecoeffs(), b->basecoeffs())) {
895  Werror("Error in bigintmat::sub. coeffs do not agree!");
896  return false;
897  }
898  for (int i=1; i<=row; i++) {
899  for (int j=1; j<=col; j++) {
900  rawset(i, j, n_Sub(view(i,j), b->view(i,j), basecoeffs()));
901  }
902  }
903  return true;
904 }
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:668
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:125
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:199
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
int cols() const
Definition: bigintmat.h:147
int rows() const
Definition: bigintmat.h:148
int col
Definition: bigintmat.h:57
coeffs basecoeffs() const
Definition: bigintmat.h:149
void Werror(const char *fmt,...)
Definition: reporter.cc:199
bool nCoeffs_are_equal(coeffs r, coeffs s)
Definition: bigintmat.cc:2473
void bigintmat::swap ( int  i,
int  j 
)

swap columns i and j

Definition at line 690 of file bigintmat.cc.

690  {
691  if ((i <= col) && (j <= col) && (i>0) && (j>0)) {
692  number tmp;
693  number t;
694  for (int k=1; k<=row; k++) {
695  tmp = get(k, i);
696  t = view(k, j);
697  set(k, i, t);
698  set(k, j, tmp);
699  n_Delete(&tmp, basecoeffs());
700  }
701  } else
702  Werror("Error in swap");
703 }
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:125
int row
Definition: bigintmat.h:56
int k
Definition: cfEzgcd.cc:93
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
int col
Definition: bigintmat.h:57
coeffs basecoeffs() const
Definition: bigintmat.h:149
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:456
void Werror(const char *fmt,...)
Definition: reporter.cc:199
void bigintmat::swapMatrix ( bigintmat a)

Definition at line 1468 of file bigintmat.cc.

1469 {
1470  int n = rows(), m = cols();
1471  row = a->rows();
1472  col = a->cols();
1473  number * V = v;
1474  v = a->v;
1475  a->v = V;
1476  a->row = n;
1477  a->col = m;
1478 }
int row
Definition: bigintmat.h:56
int m
Definition: cfEzgcd.cc:119
int cols() const
Definition: bigintmat.h:147
int rows() const
Definition: bigintmat.h:148
int col
Definition: bigintmat.h:57
number * v
Definition: bigintmat.h:55
void bigintmat::swaprow ( int  i,
int  j 
)

swap rows i and j

Definition at line 705 of file bigintmat.cc.

705  {
706  if ((i <= row) && (j <= row) && (i>0) && (j>0)) {
707  number tmp;
708  number t;
709  for (int k=1; k<=col; k++) {
710  tmp = get(i, k);
711  t = view(j, k);
712  set(i, k, t);
713  set(j, k, tmp);
714  n_Delete(&tmp, basecoeffs());
715  }
716  }
717  else
718  Werror("Error in swaprow");
719 }
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:125
int row
Definition: bigintmat.h:56
int k
Definition: cfEzgcd.cc:93
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
int col
Definition: bigintmat.h:57
coeffs basecoeffs() const
Definition: bigintmat.h:149
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:456
void Werror(const char *fmt,...)
Definition: reporter.cc:199
number bigintmat::trace ( )

the trace ....

Definition at line 1400 of file bigintmat.cc.

1401 {
1402  assume (col == row);
1403  number t = get(1,1),
1404  h;
1405  coeffs r = basecoeffs();
1406  for(int i=2; i<= col; i++) {
1407  h = n_Add(t, view(i,i), r);
1408  n_Delete(&t, r);
1409  t = h;
1410  }
1411  return t;
1412 }
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:125
int row
Definition: bigintmat.h:56
const ring r
Definition: syzextra.cc:208
#define assume(x)
Definition: mod2.h:405
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:655
int i
Definition: cfEzgcd.cc:123
int col
Definition: bigintmat.h:57
coeffs basecoeffs() const
Definition: bigintmat.h:149
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:456
static Poly * h
Definition: janet.cc:978
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:93
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
#define BIMATELEM(M, I, J)
Definition: bigintmat.h:136
int col
Definition: bigintmat.h:57
bigintmat()
Definition: bigintmat.h:60
coeffs basecoeffs() const
Definition: bigintmat.h:149
number bigintmat::view ( int  i,
int  j 
) const

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

Definition at line 125 of file bigintmat.cc.

126 {
127  assume (i >= 0 && j >= 0);
128  assume (i <= rows() && j <= cols());
129 
130  return view(index(i, j));
131 }
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:125
int index(int r, int c) const
helper function to map from 2-dim coordinates, starting by 1 to 1-dim coordinate, starting by 0 ...
Definition: bigintmat.h:164
int j
Definition: myNF.cc:70
#define assume(x)
Definition: mod2.h:405
int i
Definition: cfEzgcd.cc:123
int cols() const
Definition: bigintmat.h:147
int rows() const
Definition: bigintmat.h:148
number bigintmat::view ( int  i) const

view an entry. NOTE: starts at [0]

Definition at line 109 of file bigintmat.cc.

110 {
111  assume (i >= 0);
112  assume (i<rows()*cols());
113 
114  return v[i];
115 }
#define assume(x)
Definition: mod2.h:405
int i
Definition: cfEzgcd.cc:123
int cols() const
Definition: bigintmat.h:147
int rows() const
Definition: bigintmat.h:148
number * v
Definition: bigintmat.h:55
void bigintmat::Write ( )

IO: writes the matrix into the current internal string buffer which must be started/ allocated before (e.g. StringSetS)

Definition at line 413 of file bigintmat.cc.

414 {
415  int n = cols(), m=rows();
416 
417  StringAppendS("[ ");
418  for(int i=1; i<= m; i++) {
419  StringAppendS("[ ");
420  for(int j=1; j< n; j++) {
421  n_Write(v[(i-1)*n+j-1], basecoeffs());
422  StringAppendS(", ");
423  }
424  if (n) n_Write(v[i*n-1], basecoeffs());
425  StringAppendS(" ]");
426  if (i<m) {
427  StringAppendS(", ");
428  }
429  }
430  StringAppendS(" ] ");
431 }
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:592
int m
Definition: cfEzgcd.cc:119
int i
Definition: cfEzgcd.cc:123
int cols() const
Definition: bigintmat.h:147
int rows() const
Definition: bigintmat.h:148
number * v
Definition: bigintmat.h:55
coeffs basecoeffs() const
Definition: bigintmat.h:149
void bigintmat::zero ( )

Setzt alle Einträge auf 0.

Definition at line 1256 of file bigintmat.cc.

1256  {
1257  number tmp = n_Init(0, basecoeffs());
1258  for (int i=1; i<=row; i++) {
1259  for (int j=1; j<=col; j++) {
1260  set(i, j, tmp);
1261  }
1262  }
1263  n_Delete(&tmp,basecoeffs());
1264 }
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:539
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:149
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:456

Field Documentation

int bigintmat::col
private

Definition at line 57 of file bigintmat.h.

coeffs bigintmat::m_coeffs
private

Definition at line 54 of file bigintmat.h.

int bigintmat::row
private

Definition at line 56 of file bigintmat.h.

number* bigintmat::v
private

Definition at line 55 of file bigintmat.h.


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