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
 
intgetwid (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 occured. 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, coeffs c)
 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 32 of file bigintmat.h.

Constructor & Destructor Documentation

bigintmat::bigintmat ( )
inline

Definition at line 41 of file bigintmat.h.

41 : m_coeffs(NULL), v(NULL), row(1), col(0){}
int row
Definition: bigintmat.h:37
int col
Definition: bigintmat.h:38
number * v
Definition: bigintmat.h:36
#define NULL
Definition: omList.c:10
coeffs m_coeffs
Definition: bigintmat.h:35
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 51 of file bigintmat.h.

51  : m_coeffs(n), v(NULL), row(r), col(c)
52  {
53  assume (rows() >= 0);
54  assume (cols() >= 0);
55 
56  const int l = r*c;
57 
58  if (l>0) /*(r>0) && (c>0) */
59  {
60  v = (number *)omAlloc(sizeof(number)*l);
61 
62  assume (basecoeffs() != NULL);
63  for (int i = l - 1; i>=0; i--)
64  {
65  v[i] = n_Init(0, basecoeffs());
66  }
67  }
68  }
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition: coeffs.h:537
int row
Definition: bigintmat.h:37
#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:128
int rows() const
Definition: bigintmat.h:129
int col
Definition: bigintmat.h:38
number * v
Definition: bigintmat.h:36
#define NULL
Definition: omList.c:10
coeffs basecoeffs() const
Definition: bigintmat.h:130
coeffs m_coeffs
Definition: bigintmat.h:35
int l
Definition: cfEzgcd.cc:94
bigintmat::bigintmat ( const bigintmat m)
inline

copy constructor

Definition at line 71 of file bigintmat.h.

71  : m_coeffs(m->basecoeffs()), v(NULL), row(m->rows()), col(m->cols())
72  {
73  const int l = row*col;
74 
75  if (l > 0)
76  {
77  assume (rows() > 0);
78  assume (cols() > 0);
79 
80  assume (m->v != NULL);
81 
82  v = (number *)omAlloc(sizeof(number)*row*col);
83 
84  assume (basecoeffs() != NULL);
85 
86  for (int i = l-1; i>=0; i--)
87  {
88  v[i] = n_Copy((*m)[i], basecoeffs());
89  }
90  }
91  }
int row
Definition: bigintmat.h:37
#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:128
int rows() const
Definition: bigintmat.h:129
int col
Definition: bigintmat.h:38
number * v
Definition: bigintmat.h:36
#define NULL
Definition: omList.c:10
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of 'n'
Definition: coeffs.h:451
coeffs basecoeffs() const
Definition: bigintmat.h:130
coeffs m_coeffs
Definition: bigintmat.h:35
int l
Definition: cfEzgcd.cc:94
bigintmat::~bigintmat ( )
inline

canonical destructor.

Definition at line 133 of file bigintmat.h.

134  {
135  if (v!=NULL)
136  {
137  for (int i=0; i<row*col; i++) { n_Delete(&(v[i]), basecoeffs()); }
138  omFreeSize((ADDRESS)v, sizeof(number)*row*col);
139  v=NULL;
140  }
141  }
int row
Definition: bigintmat.h:37
#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:38
number * v
Definition: bigintmat.h:36
#define NULL
Definition: omList.c:10
coeffs basecoeffs() const
Definition: bigintmat.h:130
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:455

Member Function Documentation

bool bigintmat::add ( bigintmat b)

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

Definition at line 868 of file bigintmat.cc.

869 {
870  if ((b->rows() != row) || (b->cols() != col)) {
871  Werror("Error in bigintmat::add. Dimensions do not agree!");
872  return false;
873  }
874  if (!nCoeffs_are_equal(basecoeffs(), b->basecoeffs())) {
875  Werror("Error in bigintmat::add. coeffs do not agree!");
876  return false;
877  }
878  for (int i=1; i<=row; i++) {
879  for (int j=1; j<=col; j++) {
880  rawset(i, j, n_Add(b->view(i,j), view(i,j), basecoeffs()));
881  }
882  }
883  return true;
884 }
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:123
int row
Definition: bigintmat.h:37
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:180
int j
Definition: myNF.cc:70
static FORCE_INLINE number n_Add(number a, number b, const coeffs r)
return the sum of 'a' and 'b', i.e., a+b
Definition: coeffs.h:653
int i
Definition: cfEzgcd.cc:123
int cols() const
Definition: bigintmat.h:128
int rows() const
Definition: bigintmat.h:129
int col
Definition: bigintmat.h:38
coeffs basecoeffs() const
Definition: bigintmat.h:130
void Werror(const char *fmt,...)
Definition: reporter.cc:199
bool nCoeffs_are_equal(coeffs r, coeffs s)
Definition: bigintmat.cc:2449
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 925 of file bigintmat.cc.

926 {
927  if ((i>col) || (j>col) || (i<1) || (j<1)) {
928  Werror("Error in addcol: Index out of range!");
929  return false;
930  }
931  if (!nCoeffs_are_equal(c, basecoeffs())) {
932  Werror("Error in addcol: coeffs do not agree!");
933  return false;
934  }
935  number t1, t2, t3, t4;
936  for (int k=1; k<=row; k++)
937  {
938  t1 = view(k, j);
939  t2 = view(k, i);
940  t3 = n_Mult(t1, a, basecoeffs());
941  t4 = n_Add(t3, t2, basecoeffs());
942  rawset(k, i, t4);
943  n_Delete(&t3, basecoeffs());
944  }
945  return true;
946 }
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:123
const poly a
Definition: syzextra.cc:212
int row
Definition: bigintmat.h:37
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:180
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of 'a' and 'b', i.e., a*b
Definition: coeffs.h:633
int j
Definition: myNF.cc:70
static FORCE_INLINE number n_Add(number a, number b, const coeffs r)
return the sum of 'a' and 'b', i.e., a+b
Definition: coeffs.h:653
int i
Definition: cfEzgcd.cc:123
int col
Definition: bigintmat.h:38
coeffs basecoeffs() const
Definition: bigintmat.h:130
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:455
void Werror(const char *fmt,...)
Definition: reporter.cc:199
bool nCoeffs_are_equal(coeffs r, coeffs s)
Definition: bigintmat.cc:2449
bool bigintmat::addrow ( int  i,
int  j,
number  a,
coeffs  c 
)

... Zeile ...

Definition at line 948 of file bigintmat.cc.

949 {
950  if ((i>row) || (j>row) || (i<1) || (j<1)) {
951  Werror("Error in addrow: Index out of range!");
952  return false;
953  }
954  if (!nCoeffs_are_equal(c, basecoeffs())) {
955  Werror("Error in addrow: coeffs do not agree!");
956  return false;
957  }
958  number t1, t2, t3, t4;
959  for (int k=1; k<=col; k++)
960  {
961  t1 = view(j, k);
962  t2 = view(i, k);
963  t3 = n_Mult(t1, a, basecoeffs());
964  t4 = n_Add(t3, t2, basecoeffs());
965  rawset(i, k, t4);
966  n_Delete(&t3, basecoeffs());
967  }
968  return true;
969 }
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:123
const poly a
Definition: syzextra.cc:212
int row
Definition: bigintmat.h:37
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:180
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of 'a' and 'b', i.e., a*b
Definition: coeffs.h:633
int j
Definition: myNF.cc:70
static FORCE_INLINE number n_Add(number a, number b, const coeffs r)
return the sum of 'a' and 'b', i.e., a+b
Definition: coeffs.h:653
int i
Definition: cfEzgcd.cc:123
int col
Definition: bigintmat.h:38
coeffs basecoeffs() const
Definition: bigintmat.h:130
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:455
void Werror(const char *fmt,...)
Definition: reporter.cc:199
bool nCoeffs_are_equal(coeffs r, coeffs s)
Definition: bigintmat.cc:2449
void bigintmat::appendCol ( bigintmat a)

horizontally join the matrices, m <- m|a

Definition at line 1032 of file bigintmat.cc.

1032  {
1033  coeffs R = basecoeffs();
1034  int ay = a->cols();
1035  int ax = a->rows();
1036  assume(row == ax);
1037 
1039 
1040  bigintmat * tmp = new bigintmat(rows(), cols() + ay, R);
1041  tmp->concatcol(this, a);
1042  this->swapMatrix(tmp);
1043  delete tmp;
1044 }
void concatcol(bigintmat *a, bigintmat *b)
Definition: bigintmat.cc:1047
Matrices of numbers.
Definition: bigintmat.h:32
int row
Definition: bigintmat.h:37
#define assume(x)
Definition: mod2.h:405
void swapMatrix(bigintmat *a)
Definition: bigintmat.cc:1466
The main handler for Singular numbers which are suitable for Singular polynomials.
int cols() const
Definition: bigintmat.h:128
int rows() const
Definition: bigintmat.h:129
bigintmat()
Definition: bigintmat.h:41
coeffs basecoeffs() const
Definition: bigintmat.h:130
#define R
Definition: sirandom.c:26
bool nCoeffs_are_equal(coeffs r, coeffs s)
Definition: bigintmat.cc:2449
coeffs bigintmat::basecoeffs ( ) const
inline

Definition at line 130 of file bigintmat.h.

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

Definition at line 1477 of file bigintmat.cc.

1478 {
1479  coeffs R = basecoeffs();
1480  for(int i=1; i<=rows(); i++)
1481  if (!n_IsZero(view(i, j), R)) return FALSE;
1482  return TRUE;
1483 }
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:123
#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.
int i
Definition: cfEzgcd.cc:123
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
Definition: coeffs.h:464
int rows() const
Definition: bigintmat.h:129
coeffs basecoeffs() const
Definition: bigintmat.h:130
#define R
Definition: sirandom.c:26
int bigintmat::cols ( ) const
inline

Definition at line 128 of file bigintmat.h.

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

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

Definition at line 1754 of file bigintmat.cc.

1755 {
1756  number tmp1, tmp2;
1757  for (int i=1; i<=row; i++)
1758  {
1759  tmp1 = view(i, j);
1760  tmp2 = n_Div(tmp1, b, basecoeffs());
1761  rawset(i, j, tmp2);
1762  }
1763 }
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:123
int row
Definition: bigintmat.h:37
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:180
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 'a' and 'b', i.e., a/b; raises an error if 'b' is not invertible in r exceptio...
Definition: coeffs.h:613
coeffs basecoeffs() const
Definition: bigintmat.h:130
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 971 of file bigintmat.cc.

971  {
972  if ((i>=1) && (i<=col) && (nCoeffs_are_equal(c, basecoeffs()))) {
973  number t, tmult;
974  for (int j=1; j<=row; j++) {
975  t = view(j, i);
976  tmult = n_Mult(a, t, basecoeffs());
977  rawset(j, i, tmult);
978  }
979  }
980  else
981  Werror("Error in colskalmult");
982 }
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:123
const poly a
Definition: syzextra.cc:212
int row
Definition: bigintmat.h:37
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:180
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of 'a' and 'b', i.e., a*b
Definition: coeffs.h:633
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
int col
Definition: bigintmat.h:38
coeffs basecoeffs() const
Definition: bigintmat.h:130
void Werror(const char *fmt,...)
Definition: reporter.cc:199
bool nCoeffs_are_equal(coeffs r, coeffs s)
Definition: bigintmat.cc:2449
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 1767 of file bigintmat.cc.

1768 {
1769  number tmp1, tmp2, tmp3, tmp4;
1770  for (int i=1; i<=row; i++)
1771  {
1772  tmp1 = get(i, j);
1773  tmp2 = get(i, k);
1774  tmp3 = n_Mult(tmp1, a, basecoeffs());
1775  tmp4 = n_Mult(tmp2, b, basecoeffs());
1776  n_InpAdd(tmp3, tmp4, basecoeffs());
1777  n_Delete(&tmp4, basecoeffs());
1778 
1779  n_InpMult(tmp1, c, basecoeffs());
1780  n_InpMult(tmp2, d, basecoeffs());
1781  n_InpAdd(tmp1, tmp2, basecoeffs());
1782  n_Delete(&tmp2, basecoeffs());
1783 
1784  set(i, j, tmp3);
1785  set(i, k, tmp1);
1786  n_Delete(&tmp1, basecoeffs());
1787  n_Delete(&tmp3, basecoeffs());
1788  }
1789 }
const poly a
Definition: syzextra.cc:212
static FORCE_INLINE void n_InpMult(number &a, number b, const coeffs r)
multiplication of 'a' and 'b'; replacement of 'a' by the product a*b
Definition: coeffs.h:638
int row
Definition: bigintmat.h:37
int k
Definition: cfEzgcd.cc:93
static FORCE_INLINE void n_InpAdd(number &a, number b, const coeffs r)
addition of 'a' and 'b'; replacement of 'a' by the sum a+b
Definition: coeffs.h:643
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:91
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of 'a' and 'b', i.e., a*b
Definition: coeffs.h:633
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
CFList tmp2
Definition: facFqBivar.cc:70
coeffs basecoeffs() const
Definition: bigintmat.h:130
CFList tmp1
Definition: facFqBivar.cc:70
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:455
const poly b
Definition: syzextra.cc:213
int bigintmat::compare ( const bigintmat op) const

Definition at line 360 of file bigintmat.cc.

361 {
362  assume (basecoeffs() == op->basecoeffs() );
363 
364 #ifndef SING_NDEBUG
365  if (basecoeffs() != op->basecoeffs() )
366  WerrorS("wrong bigintmat comparison: different basecoeffs!\n");
367 #endif
368 
369  if ((col!=1) ||(op->cols()!=1))
370  {
371  if((col!=op->cols())
372  || (row!=op->rows()))
373  return -2;
374  }
375 
376  int i;
377  for (i=0; i<si_min(row*col,op->rows()*op->cols()); i++)
378  {
379  if ( n_Greater(v[i], (*op)[i], basecoeffs()) )
380  return 1;
381  else if (! n_Equal(v[i], (*op)[i], basecoeffs()))
382  return -1;
383  }
384 
385  for (; i<row; i++)
386  {
387  if ( n_GreaterZero(v[i], basecoeffs()) )
388  return 1;
389  else if (! n_IsZero(v[i], basecoeffs()) )
390  return -1;
391  }
392  for (; i<op->rows(); i++)
393  {
394  if ( n_GreaterZero((*op)[i], basecoeffs()) )
395  return -1;
396  else if (! n_IsZero((*op)[i], basecoeffs()) )
397  return 1;
398  }
399  return 0;
400 }
static FORCE_INLINE BOOLEAN n_Greater(number a, number b, const coeffs r)
ordered fields: TRUE iff 'a' is larger than 'b'; in Z/pZ: TRUE iff la > lb, where la and lb are the l...
Definition: coeffs.h:511
static int si_min(const int a, const int b)
Definition: auxiliary.h:167
int row
Definition: bigintmat.h:37
void WerrorS(const char *s)
Definition: feFopen.cc:23
#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 'n' represents the zero element.
Definition: coeffs.h:464
int cols() const
Definition: bigintmat.h:128
int rows() const
Definition: bigintmat.h:129
int col
Definition: bigintmat.h:38
number * v
Definition: bigintmat.h:36
coeffs basecoeffs() const
Definition: bigintmat.h:130
static FORCE_INLINE BOOLEAN n_Equal(number a, number b, const coeffs r)
TRUE iff 'a' and 'b' represent the same number; they may have different representations.
Definition: coeffs.h:460
static FORCE_INLINE BOOLEAN n_GreaterZero(number n, const coeffs r)
ordered fields: TRUE iff 'n' is positive; in Z/pZ: TRUE iff 0 < m <= roundedBelow(p/2), 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)/: 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:494
void bigintmat::concatcol ( bigintmat a,
bigintmat b 
)

Definition at line 1047 of file bigintmat.cc.

1047  {
1048  int ay = a->cols();
1049  int ax = a->rows();
1050  int by = b->cols();
1051  int bx = b->rows();
1052  number tmp;
1053 
1054  assume(row==ax && row == bx && ay+by ==col);
1055 
1057 
1058  for (int i=1; i<=ax; i++) {
1059  for (int j=1; j<=ay; j++) {
1060  tmp = a->view(i,j);
1061  set(i, j, tmp);
1062  }
1063  }
1064  for (int i=1; i<=bx; i++) {
1065  for (int j=1; j<=by; j++) {
1066  tmp = b->view(i,j);
1067  set(i, j+ay, tmp);
1068  }
1069  }
1070 }
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:123
int row
Definition: bigintmat.h:37
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:91
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:128
int rows() const
Definition: bigintmat.h:129
int col
Definition: bigintmat.h:38
coeffs basecoeffs() const
Definition: bigintmat.h:130
bool nCoeffs_are_equal(coeffs r, coeffs s)
Definition: bigintmat.cc:2449
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 997 of file bigintmat.cc.

997  {
998  int ay = a->cols();
999  int ax = a->rows();
1000  int by = b->cols();
1001  int bx = b->rows();
1002  number tmp;
1003  if (!((col == ay) && (col == by) && (ax+bx == row))) {
1004  Werror("Error in concatrow. Dimensions must agree!");
1005  return;
1006  }
1008  Werror("Error in concatrow. coeffs do not agree!");
1009  return;
1010  }
1011  for (int i=1; i<=ax; i++) {
1012  for (int j=1; j<=ay; j++) {
1013  tmp = a->get(i,j);
1014  set(i, j, tmp);
1015  n_Delete(&tmp, basecoeffs());
1016  }
1017  }
1018  for (int i=1; i<=bx; i++) {
1019  for (int j=1; j<=by; j++) {
1020  tmp = b->get(i,j);
1021  set(i+ax, j, tmp);
1022  n_Delete(&tmp, basecoeffs());
1023  }
1024  }
1025 }
int row
Definition: bigintmat.h:37
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:91
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
int cols() const
Definition: bigintmat.h:128
int rows() const
Definition: bigintmat.h:129
int col
Definition: bigintmat.h:38
coeffs basecoeffs() const
Definition: bigintmat.h:130
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:455
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:115
bool nCoeffs_are_equal(coeffs r, coeffs s)
Definition: bigintmat.cc:2449
number bigintmat::content ( )

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

Definition at line 2474 of file bigintmat.cc.

2475 {
2476  coeffs r = basecoeffs();
2477  number g = get(1,1), h;
2478  int n=rows()*cols();
2479  for(int i=1; i<n && !n_IsOne(g, r); i++) {
2480  h = n_Gcd(g, view(i), r);
2481  n_Delete(&g, r);
2482  g=h;
2483  }
2484  return g;
2485 }
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:123
static FORCE_INLINE number n_Gcd(number a, number b, const coeffs r)
in Z: return the gcd of 'a' and 'b' in Z/nZ, Z/2^kZ: computed as in the case Z in Z/pZ...
Definition: coeffs.h:683
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff 'n' represents the one element.
Definition: coeffs.h:468
const CanonicalForm CFMap CFMap int &both_non_zero int n
Definition: cfEzgcd.cc:52
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:128
int rows() const
Definition: bigintmat.h:129
coeffs basecoeffs() const
Definition: bigintmat.h:130
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:455
static Poly * h
Definition: janet.cc:978
bool bigintmat::copy ( bigintmat b)

Kopiert Einträge von b auf Bigintmat.

Definition at line 1176 of file bigintmat.cc.

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

1203 {
1204  number t1;
1205  for (int i=1; i<=n; i++)
1206  {
1207  for (int j=1; j<=m; j++)
1208  {
1209  t1 = B->view(a+i-1, b+j-1);
1210  set(c+i-1, d+j-1, t1);
1211  }
1212  }
1213 }
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:123
const poly a
Definition: syzextra.cc:212
const CanonicalForm CFMap CFMap int &both_non_zero int n
Definition: cfEzgcd.cc:52
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:91
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 1412 of file bigintmat.cc.

1413 {
1414  assume (row==col);
1415 
1416  if (col == 1)
1417  return get(1, 1);
1418  // should work as well in Z/pZ of type n_Zp?
1419  // relies on XExtGcd and the other euc. functinos.
1420  if ( getCoeffType(basecoeffs())== n_Z || getCoeffType(basecoeffs() )== n_Zn) {
1421  return hnfdet();
1422  }
1423  number sum = n_Init(0, basecoeffs());
1424  number t1, t2, t3, t4;
1425  bigintmat *b;
1426  for (int i=1; i<=row; i++) {
1427  b = elim(i, 1);
1428  t1 = get(i, 1);
1429  t2 = b->det();
1430  t3 = n_Mult(t1, t2, basecoeffs());
1431  t4 = n_Copy(sum, basecoeffs());
1432  n_Delete(&sum, basecoeffs());
1433  if ((i+1)>>1<<1==(i+1))
1434  sum = n_Add(t4, t3, basecoeffs());
1435  else
1436  sum = n_Sub(t4, t3, basecoeffs());
1437  n_Delete(&t1, basecoeffs());
1438  n_Delete(&t2, basecoeffs());
1439  n_Delete(&t3, basecoeffs());
1440  n_Delete(&t4, basecoeffs());
1441  }
1442  return sum;
1443 }
static FORCE_INLINE number n_Sub(number a, number b, const coeffs r)
return the difference of 'a' and 'b', i.e., a-b
Definition: coeffs.h:666
only used if HAVE_RINGS is defined: ?
Definition: coeffs.h:42
number det()
det (via LaPlace in general, hnf for euc. rings)
Definition: bigintmat.cc:1412
Matrices of numbers.
Definition: bigintmat.h:32
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition: coeffs.h:537
int row
Definition: bigintmat.h:37
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of 'a' and 'b', i.e., a*b
Definition: coeffs.h:633
#define assume(x)
Definition: mod2.h:405
static FORCE_INLINE number n_Add(number a, number b, const coeffs r)
return the sum of 'a' and 'b', i.e., a+b
Definition: coeffs.h:653
only used if HAVE_RINGS is defined: ?
Definition: coeffs.h:41
int i
Definition: cfEzgcd.cc:123
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:421
int col
Definition: bigintmat.h:38
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of 'n'
Definition: coeffs.h:451
coeffs basecoeffs() const
Definition: bigintmat.h:130
number hnfdet()
det via HNF Primzahlen als long long int, müssen noch in number umgewandelt werden?
Definition: bigintmat.cc:1445
bigintmat * elim(int i, int j)
Liefert Streichungsmatrix (i-te Zeile und j-te Spalte gestrichen) zurück.
Definition: bigintmat.cc:1281
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:455
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 1281 of file bigintmat.cc.

1282 {
1283  if ((i<=0) || (i>row) || (j<=0) || (j>col))
1284  return NULL;
1285  int cx, cy;
1286  cx=1;
1287  cy=1;
1288  number t;
1289  bigintmat *b = new bigintmat(row-1, col-1, basecoeffs());
1290  for (int k=1; k<=row; k++) {
1291  if (k!=i)
1292  {
1293  cy=1;
1294  for (int l=1; l<=col; l++)
1295  {
1296  if (l!=j)
1297  {
1298  t = get(k, l);
1299  b->set(cx, cy, t);
1300  n_Delete(&t, basecoeffs());
1301  cy++;
1302  }
1303  }
1304  cx++;
1305  }
1306  }
1307  return b;
1308 }
Matrices of numbers.
Definition: bigintmat.h:32
int row
Definition: bigintmat.h:37
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:91
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
int col
Definition: bigintmat.h:38
#define NULL
Definition: omList.c:10
bigintmat()
Definition: bigintmat.h:41
coeffs basecoeffs() const
Definition: bigintmat.h:130
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:455
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 1027 of file bigintmat.cc.

1027  {
1028  bigintmat * tmp = new bigintmat(rows(), i, basecoeffs());
1029  appendCol(tmp);
1030  delete tmp;
1031 }
Matrices of numbers.
Definition: bigintmat.h:32
void appendCol(bigintmat *a)
horizontally join the matrices, m <- m|a
Definition: bigintmat.cc:1032
int i
Definition: cfEzgcd.cc:123
int rows() const
Definition: bigintmat.h:129
bigintmat()
Definition: bigintmat.h:41
coeffs basecoeffs() const
Definition: bigintmat.h:130
int bigintmat::findcolnonzero ( int  j)

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

Definition at line 730 of file bigintmat.cc.

731 {
732  for (int i=row; i>=1; i--) {
733  if (!n_IsZero(view(i,j), basecoeffs()))
734  {
735  return i;
736  }
737  }
738  return 0;
739 }
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:123
int row
Definition: bigintmat.h:37
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 'n' represents the zero element.
Definition: coeffs.h:464
coeffs basecoeffs() const
Definition: bigintmat.h:130
int bigintmat::findnonzero ( int  i)

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

Definition at line 719 of file bigintmat.cc.

720 {
721  for (int j=1; j<=col; j++) {
722  if (!n_IsZero(view(i,j), basecoeffs()))
723  {
724  return j;
725  }
726  }
727  return 0;
728 }
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:123
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 'n' represents the zero element.
Definition: coeffs.h:464
int col
Definition: bigintmat.h:38
coeffs basecoeffs() const
Definition: bigintmat.h:130
number bigintmat::get ( int  i,
int  j 
) const

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

Definition at line 115 of file bigintmat.cc.

116 {
117  assume (i > 0 && j > 0);
118  assume (i <= rows() && j <= cols());
119 
120  return get(index(i, j));
121 }
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:145
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:128
int rows() const
Definition: bigintmat.h:129
number bigintmat::get ( int  i) const

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

Definition at line 99 of file bigintmat.cc.

100 {
101  assume (i >= 0);
102  assume (i<rows()*cols());
103 
104  return n_Copy(v[i], basecoeffs());
105 }
#define assume(x)
Definition: mod2.h:405
int i
Definition: cfEzgcd.cc:123
int cols() const
Definition: bigintmat.h:128
int rows() const
Definition: bigintmat.h:129
number * v
Definition: bigintmat.h:36
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of 'n'
Definition: coeffs.h:451
coeffs basecoeffs() const
Definition: bigintmat.h:130
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 741 of file bigintmat.cc.

742 {
743  assume((j<=col) && (j>=1));
744  if (((a->rows() != row) || (a->cols() != 1)) && ((a->rows() != 1) || (a->cols() != row))) {
745  assume(0);
746  Werror("Error in getcol. Dimensions must agree!");
747  return;
748  }
749  if (!nCoeffs_are_equal(basecoeffs(), a->basecoeffs())) {
751  number t1, t2;
752  for (int i=1; i<=row;i++) {
753  t1 = get(i,j);
754  t2 = f(t1, basecoeffs(), a->basecoeffs());
755  a->set(i-1,t1);
756  n_Delete(&t1, basecoeffs());
757  n_Delete(&t2, a->basecoeffs());
758  }
759  return;
760  }
761  number t1;
762  for (int i=1; i<=row;i++) {
763  t1 = view(i,j);
764  a->set(i-1,t1);
765  }
766 }
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:123
f
Definition: cfModGcd.cc:4022
int row
Definition: bigintmat.h:37
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:91
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:71
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:718
int cols() const
Definition: bigintmat.h:128
int rows() const
Definition: bigintmat.h:129
int col
Definition: bigintmat.h:38
coeffs basecoeffs() const
Definition: bigintmat.h:130
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:455
void Werror(const char *fmt,...)
Definition: reporter.cc:199
bool nCoeffs_are_equal(coeffs r, coeffs s)
Definition: bigintmat.cc:2449
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 768 of file bigintmat.cc.

769 {
770  number t1;
771  for(int ii=0; ii< no; ii++) {
772  for (int i=1; i<=row;i++) {
773  t1 = view(i, ii+j);
774  a->set(i, ii+1, t1);
775  }
776  }
777 }
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:123
int row
Definition: bigintmat.h:37
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:91
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 779 of file bigintmat.cc.

780 {
781  if ((i>row) || (i<1)) {
782  Werror("Error in getrow: Index out of range!");
783  return;
784  }
785  if (((a->rows() != 1) || (a->cols() != col)) && ((a->rows() != col) || (a->cols() != 1))) {
786  Werror("Error in getrow. Dimensions must agree!");
787  return;
788  }
789  if (!nCoeffs_are_equal(basecoeffs(), a->basecoeffs())) {
791  number t1, t2;
792  for (int j=1; j<=col;j++) {
793  t1 = get(i,j);
794  t2 = f(t1, basecoeffs(), a->basecoeffs());
795  a->set(j-1,t2);
796  n_Delete(&t1, basecoeffs());
797  n_Delete(&t2, a->basecoeffs());
798  }
799  return;
800  }
801  number t1;
802  for (int j=1; j<=col;j++) {
803  t1 = get(i,j);
804  a->set(j-1,t1);
805  n_Delete(&t1, basecoeffs());
806  }
807 }
f
Definition: cfModGcd.cc:4022
int row
Definition: bigintmat.h:37
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:91
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:71
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:718
int cols() const
Definition: bigintmat.h:128
int rows() const
Definition: bigintmat.h:129
int col
Definition: bigintmat.h:38
coeffs basecoeffs() const
Definition: bigintmat.h:130
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:455
void Werror(const char *fmt,...)
Definition: reporter.cc:199
bool nCoeffs_are_equal(coeffs r, coeffs s)
Definition: bigintmat.cc:2449
int * bigintmat::getwid ( int  maxwid)

Definition at line 576 of file bigintmat.cc.

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

transforms INPLACE to HNF

Definition at line 1560 of file bigintmat.cc.

1561 {
1562  // Laufen von unten nach oben und von links nach rechts
1563  // CF: TODO: for n_Z: write a recursive version. This one will
1564  // have exponential blow-up. Look at Michianchio
1565  // Alternatively, do p-adic det and modular method
1566 
1567 #if 0
1568  char * s;
1569  ::Print("mat over Z is \n");
1570  ::Print("%s\n", s = nCoeffString(basecoeffs()));
1571  omFree(s);
1572  Print();
1573  ::Print("\n(%d x %d)\n", rows(), cols());
1574 #endif
1575 
1576  int i = rows();
1577  int j = cols();
1578  number q = n_Init(0, basecoeffs());
1579  number one = n_Init(1, basecoeffs());
1580  number minusone = n_Init(-1, basecoeffs());
1581  number tmp1 = n_Init(0, basecoeffs());
1582  number tmp2 = n_Init(0, basecoeffs());
1583  number co1, co2, co3, co4;
1584  number ggt = n_Init(0, basecoeffs());
1585 
1586  while ((i>0) && (j>0)) {
1587  // Falls erstes Nicht-Null-Element in Zeile i nicht existiert, oder hinter Spalte j vorkommt, gehe in nächste Zeile
1588  if ((findnonzero(i)==0) || (findnonzero(i)>j)) {
1589  i--;
1590  } else {
1591  // Laufe von links nach rechts durch die Zeile:
1592  for (int l=1; l<=j-1; l++) {
1593  n_Delete(&tmp1, basecoeffs());
1594  tmp1 = get(i, l);
1595  // Falls Eintrag (im folgenden x genannt) gleich 0, gehe eine Spalte weiter. Ansonsten...
1596  if (!n_IsZero(tmp1, basecoeffs())) {
1597  n_Delete(&tmp2, basecoeffs());
1598  tmp2 = get(i, l+1);
1599  // Falls Eintrag (i.f. y g.) rechts daneben gleich 0, tausche beide Spalten, sonst...
1600  if (!n_IsZero(tmp2, basecoeffs())) {
1601  n_Delete(&ggt, basecoeffs());
1602  ggt = n_XExtGcd(tmp1, tmp2, &co1, &co2, &co3, &co4, basecoeffs());
1603  // 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:
1604  if (n_Equal(tmp1, ggt, basecoeffs())) {
1605  swap(l, l+1);
1606  n_Delete(&q, basecoeffs());
1607  q = n_Div(tmp2, ggt, basecoeffs());
1608  q = n_InpNeg(q, basecoeffs());
1609  // Dann addiere das -q-fache der (neuen) rechten Spalte zur linken dazu. Damit erhalten wir die gewünschte 0
1610 
1611  addcol(l, l+1, q, basecoeffs());
1612  n_Delete(&q, basecoeffs());
1613  }
1614  else if (n_Equal(tmp1, minusone, basecoeffs())) {
1615  // 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
1616  // Die Berechnung von q (=y/ggt) entfällt, da ggt=1
1617  swap(l, l+1);
1618  colskalmult(l+1, minusone, basecoeffs());
1619  tmp2 = n_InpNeg(tmp2, basecoeffs());
1620  addcol(l, l+1, tmp2, basecoeffs());
1621  }
1622  else {
1623  // CF: use the 2x2 matrix (co1, co2)(co3, co4) to
1624  // get the gcd in position and the 0 in the other:
1625 #ifdef CF_DEB
1626  ::Print("applying trafo\n");
1627  StringSetS("");
1628  n_Write(co1, basecoeffs()); StringAppendS("\t");
1629  n_Write(co2, basecoeffs()); StringAppendS("\t");
1630  n_Write(co3, basecoeffs()); StringAppendS("\t");
1631  n_Write(co4, basecoeffs()); StringAppendS("\t");
1632  ::Print("%s\nfor l=%d\n", StringEndS(), l);
1633  {char * s = String();
1634  ::Print("to %s\n", s);omFree(s);};
1635 #endif
1636  coltransform(l, l+1, co3, co4, co1, co2);
1637 #ifdef CF_DEB
1638  {char * s = String();
1639  ::Print("gives %s\n", s);}
1640 #endif
1641  }
1642  n_Delete(&co1, basecoeffs());
1643  n_Delete(&co2, basecoeffs());
1644  n_Delete(&co3, basecoeffs());
1645  n_Delete(&co4, basecoeffs());
1646  }
1647  else {
1648  swap(l, l+1);
1649  }
1650  // Dann betrachte die vormals rechte Spalte als neue linke, und die rechts daneben als neue rechte.
1651  }
1652  }
1653 
1654  // normalize by units:
1655  if (!n_IsZero(view(i, j), basecoeffs())) {
1656  number u = n_GetUnit(view(i, j), basecoeffs());
1657  if (!n_IsOne(u, basecoeffs())) {
1658  colskaldiv(j, u);
1659  }
1660  n_Delete(&u, basecoeffs());
1661  }
1662  // Zum Schluss mache alle Einträge rechts vom Diagonalelement betragsmäßig kleiner als dieses
1663  for (int l=j+1; l<=col; l++) {
1664  n_Delete(&q, basecoeffs());
1665  q = n_QuotRem(view(i, l), view(i, j), NULL, basecoeffs());
1666  q = n_InpNeg(q, basecoeffs());
1667  addcol(l, j, q, basecoeffs());
1668  }
1669  i--;
1670  j--;
1671  // Dann betrachte die Zeile darüber und gehe dort wie vorher vor
1672  }
1673  }
1674  n_Delete(&q, basecoeffs());
1675  n_Delete(&tmp1, basecoeffs());
1676  n_Delete(&tmp2, basecoeffs());
1677  n_Delete(&ggt, basecoeffs());
1678  n_Delete(&one, basecoeffs());
1679  n_Delete(&minusone, basecoeffs());
1680 
1681 #if 0
1682  ::Print("hnf over Z is \n");
1683  Print();
1684  ::Print("\n(%d x %d)\n", rows(), cols());
1685 #endif
1686 }
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:123
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:529
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:692
bool addcol(int i, int j, number a, coeffs c)
addiert a-faches der j-ten Spalte zur i-ten dazu
Definition: bigintmat.cc:925
void colskaldiv(int j, number b)
Macht Ganzzahldivision aller j-ten Spalteneinträge mit b.
Definition: bigintmat.cc:1754
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff 'n' represents the one element.
Definition: coeffs.h:468
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition: coeffs.h:537
int findnonzero(int i)
find index of 1st non-zero entry in row i
Definition: bigintmat.cc:719
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:688
static FORCE_INLINE void n_Write(number &n, const coeffs r, const BOOLEAN bShortOut=TRUE)
Definition: coeffs.h:590
static FORCE_INLINE number n_QuotRem(number a, number b, number *q, const coeffs r)
Definition: coeffs.h:700
static FORCE_INLINE number n_InpNeg(number n, const coeffs r)
in-place negation of n MUST BE USED: n = n_InpNeg(n) (no copy is returned)
Definition: coeffs.h:556
int i
Definition: cfEzgcd.cc:123
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
Definition: coeffs.h:464
CFList tmp2
Definition: facFqBivar.cc:70
int cols() const
Definition: bigintmat.h:128
void Print()
IO: simply prints the matrix to the current output (screen?)
Definition: bigintmat.cc:438
int rows() const
Definition: bigintmat.h:129
int col
Definition: bigintmat.h:38
void colskalmult(int i, number a, coeffs c)
Multipliziert zur i-ten Spalte den Skalar a hinzu.
Definition: bigintmat.cc:971
#define NULL
Definition: omList.c:10
static FORCE_INLINE number n_Div(number a, number b, const coeffs r)
return the quotient of 'a' and 'b', i.e., a/b; raises an error if 'b' is not invertible in r exceptio...
Definition: coeffs.h:613
char * String()
IO: String returns a singular string containing the matrix, needs freeing afterwards.
Definition: bigintmat.cc:431
coeffs basecoeffs() const
Definition: bigintmat.h:130
CFList tmp1
Definition: facFqBivar.cc:70
static FORCE_INLINE BOOLEAN n_Equal(number a, number b, const coeffs r)
TRUE iff 'a' and 'b' represent the same number; they may have different representations.
Definition: coeffs.h:460
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:1767
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:455
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:958
void one()
Macht Matrix (Falls quadratisch) zu Einheitsmatrix.
Definition: bigintmat.cc:1236
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 1445 of file bigintmat.cc.

1446 {
1447  assume (col == row);
1448 
1449  if (col == 1)
1450  return get(1, 1);
1451  bigintmat *m = new bigintmat(this);
1452  m->hnf();
1453  number prod = n_Init(1, basecoeffs());
1454  number temp, temp2;
1455  for (int i=1; i<=col; i++) {
1456  temp = m->get(i, i);
1457  temp2 = n_Mult(temp, prod, basecoeffs());
1458  n_Delete(&prod, basecoeffs());
1459  prod = temp2;
1460  n_Delete(&temp, basecoeffs());
1461  }
1462  delete m;
1463  return prod;
1464 }
Matrices of numbers.
Definition: bigintmat.h:32
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition: coeffs.h:537
int row
Definition: bigintmat.h:37
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of 'a' and 'b', i.e., a*b
Definition: coeffs.h:633
#define assume(x)
Definition: mod2.h:405
int m
Definition: cfEzgcd.cc:119
void hnf()
transforms INPLACE to HNF
Definition: bigintmat.cc:1560
int i
Definition: cfEzgcd.cc:123
int col
Definition: bigintmat.h:38
bigintmat()
Definition: bigintmat.h:41
fq_nmod_poly_t prod
Definition: facHensel.cc:95
coeffs basecoeffs() const
Definition: bigintmat.h:130
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:455
number get(int i, int j) const
get a copy of an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:115
void bigintmat::howell ( )

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

Definition at line 1485 of file bigintmat.cc.

1486 {
1487  coeffs R = basecoeffs();
1488  hnf(); // as a starting point...
1489  if (getCoeffType(R)== n_Z) return; //wrong, need to prune!
1490 
1491  int n = cols(), m = rows(), i, j, k;
1492 
1493  //make sure, the matrix has enough space. We need no rows+1 columns.
1494  //The resulting Howell form will be pruned to be at most square.
1495  bigintmat * t = new bigintmat(m, m+1, R);
1496  t->copySubmatInto(this, 1, n>m ? n-m+1 : 1, m, n>m ? m : n, 1, n>m ? 2 : m+2-n );
1497  swapMatrix(t);
1498  delete t;
1499  for(i=1; i<= cols(); i++) {
1500  if (!colIsZero(i)) break;
1501  }
1502  assume (i>1);
1503  if (i>cols()) {
1504  t = new bigintmat(rows(), 0, R);
1505  swapMatrix(t);
1506  delete t;
1507  return; // zero matrix found, clearly normal.
1508  }
1509 
1510  int last_zero_col = i-1;
1511  for (int c = cols(); c>0; c--) {
1512  for(i=rows(); i>0; i--) {
1513  if (!n_IsZero(view(i, c), R)) break;
1514  }
1515  if (i==0) break; // matrix SHOULD be zero from here on
1516  number a = n_Ann(view(i, c), R);
1517  addcol(last_zero_col, c, a, R);
1518  n_Delete(&a, R);
1519  for(j = c-1; j>last_zero_col; j--) {
1520  for(k=rows(); k>0; k--) {
1521  if (!n_IsZero(view(k, j), R)) break;
1522  if (!n_IsZero(view(k, last_zero_col), R)) break;
1523  }
1524  if (k==0) break;
1525  if (!n_IsZero(view(k, last_zero_col), R)) {
1526  number gcd, co1, co2, co3, co4;
1527  gcd = n_XExtGcd(view(k, last_zero_col), view(k, j), &co1, &co2, &co3, &co4, R);
1528  if (n_Equal(gcd, view(k, j), R)) {
1529  number q = n_Div(view(k, last_zero_col), gcd, R);
1530  q = n_InpNeg(q, R);
1531  addcol(last_zero_col, j, q, R);
1532  n_Delete(&q, R);
1533  } else if (n_Equal(gcd, view(k, last_zero_col), R)) {
1534  swap(last_zero_col, k);
1535  number q = n_Div(view(k, last_zero_col), gcd, R);
1536  q = n_InpNeg(q, R);
1537  addcol(last_zero_col, j, q, R);
1538  n_Delete(&q, R);
1539  } else {
1540  coltransform(last_zero_col, j, co3, co4, co1, co2);
1541  }
1542  n_Delete(&gcd, R);
1543  n_Delete(&co1, R);
1544  n_Delete(&co2, R);
1545  n_Delete(&co3, R);
1546  n_Delete(&co4, R);
1547  }
1548  }
1549  for(k=rows(); k>0; k--) {
1550  if (!n_IsZero(view(k, last_zero_col), R)) break;
1551  }
1552  if (k) last_zero_col--;
1553  }
1554  t = new bigintmat(rows(), cols()-last_zero_col, R);
1555  t->copySubmatInto(this, 1, last_zero_col+1, rows(), cols()-last_zero_col, 1, 1);
1556  swapMatrix(t);
1557  delete t;
1558 }
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:123
int colIsZero(int i)
Definition: bigintmat.cc:1477
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:692
bool addcol(int i, int j, number a, coeffs c)
addiert a-faches der j-ten Spalte zur i-ten dazu
Definition: bigintmat.cc:925
Matrices of numbers.
Definition: bigintmat.h:32
const CanonicalForm CFMap CFMap int &both_non_zero int n
Definition: cfEzgcd.cc:52
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:698
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:1202
int j
Definition: myNF.cc:70
#define assume(x)
Definition: mod2.h:405
void swapMatrix(bigintmat *a)
Definition: bigintmat.cc:1466
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:688
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:556
void hnf()
transforms INPLACE to HNF
Definition: bigintmat.cc:1560
only used if HAVE_RINGS is defined: ?
Definition: coeffs.h:41
int i
Definition: cfEzgcd.cc:123
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
Definition: coeffs.h:464
int cols() const
Definition: bigintmat.h:128
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:421
int rows() const
Definition: bigintmat.h:129
bigintmat()
Definition: bigintmat.h:41
static FORCE_INLINE number n_Div(number a, number b, const coeffs r)
return the quotient of 'a' and 'b', i.e., a/b; raises an error if 'b' is not invertible in r exceptio...
Definition: coeffs.h:613
int gcd(int a, int b)
Definition: walkSupport.cc:839
coeffs basecoeffs() const
Definition: bigintmat.h:130
#define R
Definition: sirandom.c:26
static FORCE_INLINE BOOLEAN n_Equal(number a, number b, const coeffs r)
TRUE iff 'a' and 'b' represent the same number; they may have different representations.
Definition: coeffs.h:460
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:1767
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:455
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 145 of file bigintmat.h.

146  {
147  assume (rows() >= 0 && cols() >= 0);
148 
149  assume (r > 0 && c > 0);
150  assume (r <= rows() && c <= cols());
151 
152  const int index = ((r-1)*cols() + (c-1));
153 
154  assume (index >= 0 && index < rows() * cols());
155  return index;
156  }
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:145
const ring r
Definition: syzextra.cc:208
#define assume(x)
Definition: mod2.h:405
int cols() const
Definition: bigintmat.h:128
int rows() const
Definition: bigintmat.h:129
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 141 of file bigintmat.cc.

142 {
143  assume (C == NULL || C == basecoeffs());
144 
145  const int l = rows() * cols();
146 
147  for (int i=0; i < l; i++)
148  n_InpMult(v[i], bintop, basecoeffs());
149 }
static FORCE_INLINE void n_InpMult(number &a, number b, const coeffs r)
multiplication of 'a' and 'b'; replacement of 'a' by the product a*b
Definition: coeffs.h:638
#define assume(x)
Definition: mod2.h:405
int i
Definition: cfEzgcd.cc:123
int cols() const
Definition: bigintmat.h:128
int rows() const
Definition: bigintmat.h:129
number * v
Definition: bigintmat.h:36
#define NULL
Definition: omList.c:10
coeffs basecoeffs() const
Definition: bigintmat.h:130
int l
Definition: cfEzgcd.cc:94
void bigintmat::inpTranspose ( )

transpose in place

Definition at line 49 of file bigintmat.cc.

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

is matrix is identity

Definition at line 1216 of file bigintmat.cc.

1216  {
1217  coeffs r = basecoeffs();
1218  if (row==col) {
1219  for (int i=1; i<=row; i++) {
1220  for (int j=1; j<=col; j++) {
1221  if (i==j) {
1222  if (!n_IsOne(view(i, j), r))
1223  return 0;
1224  }
1225  else {
1226  if (!n_IsZero(view(i,j), r))
1227  return 0;
1228  }
1229  }
1230  }
1231  }
1232  return 1;
1233 }
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:123
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff 'n' represents the one element.
Definition: coeffs.h:468
int row
Definition: bigintmat.h:37
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 'n' represents the zero element.
Definition: coeffs.h:464
int col
Definition: bigintmat.h:38
coeffs basecoeffs() const
Definition: bigintmat.h:130
int bigintmat::isZero ( )

Definition at line 1264 of file bigintmat.cc.

1264  {
1265  for (int i=1; i<=row; i++) {
1266  for (int j=1; j<=col; j++) {
1267  if (!n_IsZero(view(i,j), basecoeffs()))
1268  return FALSE;
1269  }
1270  }
1271  return TRUE;
1272 }
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:123
#define FALSE
Definition: auxiliary.h:140
int row
Definition: bigintmat.h:37
#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 'n' represents the zero element.
Definition: coeffs.h:464
int col
Definition: bigintmat.h:38
coeffs basecoeffs() const
Definition: bigintmat.h:130
int bigintmat::length ( )
inline

Definition at line 127 of file bigintmat.h.

127 { return col*row; }
int row
Definition: bigintmat.h:37
int col
Definition: bigintmat.h:38
void bigintmat::mod ( number  p,
coeffs  c 
)

Reduziert komplette Matrix modulo p.

Definition at line 1794 of file bigintmat.cc.

1795 {
1796  // produce the matrix in Z/pZ
1797  // CF: TODO rewrite using QuotRem and not the map
1798  coeffs coe = numbercoeffs(p, c);
1799  nMapFunc f1 = n_SetMap(basecoeffs(), coe);
1800  nMapFunc f2 = n_SetMap(coe, basecoeffs());
1801  number tmp1, tmp2;
1802  for (int i=1; i<=row; i++)
1803  {
1804  for (int j=1; j<=col; j++)
1805  {
1806  tmp1 = get(i, j);
1807  tmp2 = f1(tmp1, basecoeffs(), coe);
1808  n_Delete(&tmp1, basecoeffs());
1809  tmp1 = f2(tmp2, coe, basecoeffs());
1810  set(i, j, tmp1);
1811  n_Delete(&tmp1, basecoeffs());
1812  n_Delete(&tmp2, coe);
1813  }
1814  }
1815  nKillChar(coe);
1816 }
return P p
Definition: myNF.cc:203
int row
Definition: bigintmat.h:37
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:91
static coeffs numbercoeffs(number n, coeffs c)
create Z/nA of type n_Zn
Definition: bigintmat.cc:21
int j
Definition: myNF.cc:70
The main handler for Singular numbers which are suitable for Singular polynomials.
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:71
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:718
CFList tmp2
Definition: facFqBivar.cc:70
int col
Definition: bigintmat.h:38
coeffs basecoeffs() const
Definition: bigintmat.h:130
CFList tmp1
Definition: facFqBivar.cc:70
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:455
void nKillChar(coeffs r)
undo all initialisations
Definition: numbers.cc:477
bigintmat* bigintmat::modgauss ( number  p,
coeffs  c 
)
bigintmat * bigintmat::modhnf ( number  p,
coeffs  c 
)

computes HNF(this | p*I)

Definition at line 1715 of file bigintmat.cc.

1716 {
1717  coeffs Rp = numbercoeffs(p, R); // R/pR
1718  bigintmat *m = bimChangeCoeff(this, Rp);
1719  m->howell();
1720  bigintmat *a = bimChangeCoeff(m, R);
1721  delete m;
1722  bigintmat *C = new bigintmat(rows(), rows(), R);
1723  int piv = rows(), i = a->cols();
1724  while (piv) {
1725  if (!i || n_IsZero(a->view(piv, i), R)) {
1726  C->set(piv, piv, p, R);
1727  } else {
1728  C->copySubmatInto(a, 1, i, rows(), 1, 1, piv);
1729  i--;
1730  }
1731  piv--;
1732  }
1733  delete a;
1734  return C;
1735 }
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:123
const poly a
Definition: syzextra.cc:212
return P p
Definition: myNF.cc:203
Matrices of numbers.
Definition: bigintmat.h:32
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:91
static coeffs numbercoeffs(number n, coeffs c)
create Z/nA of type n_Zn
Definition: bigintmat.cc:21
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:1202
The main handler for Singular numbers which are suitable for Singular polynomials.
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 'n' represents the zero element.
Definition: coeffs.h:464
bigintmat * bimChangeCoeff(bigintmat *a, coeffs cnew)
Liefert Kopier von Matrix a zurück, mit coeffs cnew statt den ursprünglichen.
Definition: bigintmat.cc:1688
int cols() const
Definition: bigintmat.h:128
int rows() const
Definition: bigintmat.h:129
bigintmat()
Definition: bigintmat.h:41
#define R
Definition: sirandom.c:26
void howell()
dito, but Howell form (only different for zero-divsors)
Definition: bigintmat.cc:1485
void bigintmat::one ( )

Macht Matrix (Falls quadratisch) zu Einheitsmatrix.

Definition at line 1236 of file bigintmat.cc.

1236  {
1237  if (row==col) {
1238  number one = n_Init(1, basecoeffs()),
1239  zero = n_Init(0, basecoeffs());
1240  for (int i=1; i<=row; i++) {
1241  for (int j=1; j<=col; j++) {
1242  if (i==j) {
1243  set(i, j, one);
1244  } else {
1245  set(i, j, zero);
1246  }
1247  }
1248  }
1249  n_Delete(&one, basecoeffs());
1250  n_Delete(&zero, basecoeffs());
1251  }
1252 }
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition: coeffs.h:537
int row
Definition: bigintmat.h:37
void zero()
Setzt alle Einträge auf 0.
Definition: bigintmat.cc:1254
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:91
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
int col
Definition: bigintmat.h:38
coeffs basecoeffs() const
Definition: bigintmat.h:130
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:455
void one()
Macht Matrix (Falls quadratisch) zu Einheitsmatrix.
Definition: bigintmat.cc:1236
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 132 of file bigintmat.cc.

133 {
134  number iop = n_Init(intop, basecoeffs());
135 
136  inpMult(iop, basecoeffs());
137 
138  n_Delete(&iop, basecoeffs());
139 }
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition: coeffs.h:537
coeffs basecoeffs() const
Definition: bigintmat.h:130
void inpMult(number bintop, const coeffs C=NULL)
inplace versio of skalar mult. CHANGES input.
Definition: bigintmat.cc:141
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:455
number& bigintmat::operator[] ( int  i)
inline

dubious: 1-dim access to 2-dim array. Entries are read row by row.

Definition at line 93 of file bigintmat.h.

94  {
95 #ifndef SING_NDEBUG
96  if((i<0)||(i>=row*col))
97  {
98  Werror("wrong bigintmat index:%d\n",i);
99  }
100 #endif
101  assume ( !((i<0)||(i>=row*col)) );
102 
103  return v[i]; // Hier sollte imho kein nlCopy rein...
104  }
int row
Definition: bigintmat.h:37
#define assume(x)
Definition: mod2.h:405
int i
Definition: cfEzgcd.cc:123
int col
Definition: bigintmat.h:38
number * v
Definition: bigintmat.h:36
void Werror(const char *fmt,...)
Definition: reporter.cc:199
const number& bigintmat::operator[] ( int  i) const
inline

Definition at line 105 of file bigintmat.h.

106  {
107 #ifndef SING_NDEBUG
108  if((i<0)||(i>=row*col))
109  {
110  Werror("wrong bigintmat index:%d\n",i);
111  }
112 #endif
113  assume ( !((i<0)||(i>=row*col)) );
114 
115  return v[i];
116  }
int row
Definition: bigintmat.h:37
#define assume(x)
Definition: mod2.h:405
int i
Definition: cfEzgcd.cc:123
int col
Definition: bigintmat.h:38
number * v
Definition: bigintmat.h:36
void Werror(const char *fmt,...)
Definition: reporter.cc:199
void bigintmat::pprint ( int  maxwid)

Definition at line 608 of file bigintmat.cc.

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

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

Definition at line 438 of file bigintmat.cc.

439 {
440  char * s = String();
441  PrintS(s);
442  omFree(s);
443 }
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:431
number bigintmat::pseudoinv ( bigintmat a)

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

Definition at line 1315 of file bigintmat.cc.

1315  {
1316 
1317  // Falls Matrix über reellen Zahlen nicht invertierbar, breche ab
1318  assume((a->rows() == row) && (a->rows() == a->cols()) && (row == col));
1319 
1320  number det = this->det(); //computes the HNF, so should e reused.
1321  if ((n_IsZero(det, basecoeffs())))
1322  return det;
1323 
1324  // Hänge Einheitsmatrix über Matrix und wendet HNF an. An Stelle der Einheitsmatrix steht im Ergebnis die Transformationsmatrix dazu
1325  a->one();
1326  bigintmat *m = new bigintmat(2*row, col, basecoeffs());
1327  m->concatrow(a,this);
1328  m->hnf();
1329  // Arbeite weiterhin mit der zusammengehängten Matrix
1330  // 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
1331  number diag;
1332  number temp, ttemp;
1333  for (int i=1; i<=col; i++) {
1334  diag = m->get(row+i, i);
1335  for (int j=i+1; j<=col; j++) {
1336  temp = m->get(row+i, j);
1337  m->colskalmult(j, diag, basecoeffs());
1338  temp = n_InpNeg(temp, basecoeffs());
1339  m->addcol(j, i, temp, basecoeffs());
1340  n_Delete(&temp, basecoeffs());
1341  }
1342  n_Delete(&diag, basecoeffs());
1343  }
1344  // Falls wir nicht modulo n arbeiten, können wir die Spalten durch den ggT teilen, um die Einträge kleiner zu bekommen
1345  // Bei Z/n sparen wir uns das, da es hier sinnlos ist
1346  number g;
1347  number gcd;
1348  for (int j=1; j<=col; j++) {
1349  g = n_Init(0, basecoeffs());
1350  for (int i=1; i<=2*row; i++) {
1351  temp = m->get(i,j);
1352  gcd = n_Gcd(g, temp, basecoeffs());
1353  n_Delete(&g, basecoeffs());
1354  n_Delete(&temp, basecoeffs());
1355  g = n_Copy(gcd, basecoeffs());
1356  n_Delete(&gcd, basecoeffs());
1357  }
1358  if (!(n_IsOne(g, basecoeffs())))
1359  m->colskaldiv(j, g);
1360  n_Delete(&g, basecoeffs());
1361  }
1362 
1363  // 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)
1364 
1365  g = n_Init(0, basecoeffs());
1366  number prod = n_Init(1, basecoeffs());
1367  for (int i=1; i<=col; i++) {
1368  gcd = n_Gcd(g, m->get(row+i, i), basecoeffs());
1369  n_Delete(&g, basecoeffs());
1370  g = n_Copy(gcd, basecoeffs());
1371  n_Delete(&gcd, basecoeffs());
1372  ttemp = n_Copy(prod, basecoeffs());
1373  temp = m->get(row+i, i);
1374  n_Delete(&prod, basecoeffs());
1375  prod = n_Mult(ttemp, temp, basecoeffs());
1376  n_Delete(&ttemp, basecoeffs());
1377  n_Delete(&temp, basecoeffs());
1378  }
1379  number lcm;
1380  lcm = n_Div(prod, g, basecoeffs());
1381  for (int j=1; j<=col; j++) {
1382  ttemp = m->get(row+j,j);
1383  temp = n_QuotRem(lcm, ttemp, NULL, basecoeffs());
1384  m->colskalmult(j, temp, basecoeffs());
1385  n_Delete(&ttemp, basecoeffs());
1386  n_Delete(&temp, basecoeffs());
1387  }
1388  n_Delete(&lcm, basecoeffs());
1389  n_Delete(&prod, basecoeffs());
1390 
1391  number divisor = m->get(row+1, 1);
1392  m->splitrow(a, 1);
1393  delete m;
1394  n_Delete(&det, basecoeffs());
1395  return divisor;
1396 }
static FORCE_INLINE number n_Gcd(number a, number b, const coeffs r)
in Z: return the gcd of 'a' and 'b' in Z/nZ, Z/2^kZ: computed as in the case Z in Z/pZ...
Definition: coeffs.h:683
void concatrow(bigintmat *a, bigintmat *b)
Fügt zwei Matrixen untereinander/nebeneinander in gegebene Matrix ein, bzw spaltet gegebenen Matrix a...
Definition: bigintmat.cc:997
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:1412
bool addcol(int i, int j, number a, coeffs c)
addiert a-faches der j-ten Spalte zur i-ten dazu
Definition: bigintmat.cc:925
void colskaldiv(int j, number b)
Macht Ganzzahldivision aller j-ten Spalteneinträge mit b.
Definition: bigintmat.cc:1754
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff 'n' represents the one element.
Definition: coeffs.h:468
Matrices of numbers.
Definition: bigintmat.h:32
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition: coeffs.h:537
int row
Definition: bigintmat.h:37
g
Definition: cfModGcd.cc:4031
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of 'a' and 'b', i.e., a*b
Definition: coeffs.h:633
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:700
static FORCE_INLINE number n_InpNeg(number n, const coeffs r)
in-place negation of n MUST BE USED: n = n_InpNeg(n) (no copy is returned)
Definition: coeffs.h:556
void hnf()
transforms INPLACE to HNF
Definition: bigintmat.cc:1560
int i
Definition: cfEzgcd.cc:123
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
Definition: coeffs.h:464
int cols() const
Definition: bigintmat.h:128
int rows() const
Definition: bigintmat.h:129
int col
Definition: bigintmat.h:38
void colskalmult(int i, number a, coeffs c)
Multipliziert zur i-ten Spalte den Skalar a hinzu.
Definition: bigintmat.cc:971
#define NULL
Definition: omList.c:10
bigintmat()
Definition: bigintmat.h:41
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of 'n'
Definition: coeffs.h:451
static FORCE_INLINE number n_Div(number a, number b, const coeffs r)
return the quotient of 'a' and 'b', i.e., a/b; raises an error if 'b' is not invertible in r exceptio...
Definition: coeffs.h:613
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:130
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:1072
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:455
void one()
Macht Matrix (Falls quadratisch) zu Einheitsmatrix.
Definition: bigintmat.cc:1236
number get(int i, int j) const
get a copy of an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:115
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 180 of file bigintmat.h.

181  {
182  assume (C == NULL || C == basecoeffs());
183  assume (i >= 0);
184  const int l = rows() * cols();
185  assume (i<l);
186 
187  if (i < l)
188  {
189  n_Delete(&(v[i]), basecoeffs()); v[i] = n;
190  }
191 #ifndef SING_NDEBUG
192  else
193  {
194  Werror("wrong bigintmat index:%d\n",i);
195  }
196 #endif
197  }
const CanonicalForm CFMap CFMap int &both_non_zero int n
Definition: cfEzgcd.cc:52
#define assume(x)
Definition: mod2.h:405
int i
Definition: cfEzgcd.cc:123
int cols() const
Definition: bigintmat.h:128
int rows() const
Definition: bigintmat.h:129
number * v
Definition: bigintmat.h:36
#define NULL
Definition: omList.c:10
coeffs basecoeffs() const
Definition: bigintmat.h:130
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:455
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 200 of file bigintmat.h.

201  {
202  rawset( index(i,j), n, C);
203  }
const CanonicalForm CFMap CFMap int &both_non_zero int n
Definition: cfEzgcd.cc:52
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:180
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:145
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
int bigintmat::rows ( ) const
inline

Definition at line 129 of file bigintmat.h.

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

... Zeile ...

Definition at line 984 of file bigintmat.cc.

984  {
985  if ((i>=1) && (i<=row) && (nCoeffs_are_equal(c, basecoeffs()))) {
986  number t, tmult;
987  for (int j=1; j<=col; j++) {
988  t = view(i, j);
989  tmult = n_Mult(a, t, basecoeffs());
990  rawset(i, j, tmult);
991  }
992  }
993  else
994  Werror("Error in rowskalmult");
995 }
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:123
const poly a
Definition: syzextra.cc:212
int row
Definition: bigintmat.h:37
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:180
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of 'a' and 'b', i.e., a*b
Definition: coeffs.h:633
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
int col
Definition: bigintmat.h:38
coeffs basecoeffs() const
Definition: bigintmat.h:130
void Werror(const char *fmt,...)
Definition: reporter.cc:199
bool nCoeffs_are_equal(coeffs r, coeffs s)
Definition: bigintmat.cc:2449
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 91 of file bigintmat.cc.

92 {
93  assume (C == NULL || C == basecoeffs());
94  assume (i > 0 && j > 0);
95  assume (i <= rows() && j <= cols());
96  set(index(i, j), n, C);
97 }
const CanonicalForm CFMap CFMap int &both_non_zero int n
Definition: cfEzgcd.cc:52
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:91
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:145
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:128
int rows() const
Definition: bigintmat.h:129
#define NULL
Definition: omList.c:10
coeffs basecoeffs() const
Definition: bigintmat.h:130
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 83 of file bigintmat.cc.

84 {
85  assume (C == NULL || C == basecoeffs());
86 
88 }
const CanonicalForm CFMap CFMap int &both_non_zero int n
Definition: cfEzgcd.cc:52
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:180
#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 'n'
Definition: coeffs.h:451
coeffs basecoeffs() const
Definition: bigintmat.h:130
void bigintmat::setcol ( int  j,
bigintmat m 
)

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

Definition at line 810 of file bigintmat.cc.

811 {
812  if ((j>col) || (j<1)) {
813  Werror("Error in setcol: Index out of range!");
814  return;
815  }
816  if (((m->rows() != row) || (m->cols() != 1)) && ((m->rows() != 1) || (m->cols() != row))) {
817  Werror("Error in setcol. Dimensions must agree!");
818  return;
819  }
820  if (!nCoeffs_are_equal(basecoeffs(), m->basecoeffs())) {
822  number t1,t2;
823  for (int i=1; i<=row; i++) {
824  t1 = m->get(i-1);
825  t2 = f(t1, m->basecoeffs(),basecoeffs());
826  set(i, j, t2);
827  n_Delete(&t2, basecoeffs());
828  n_Delete(&t1, m->basecoeffs());
829  }
830  return;
831  }
832  number t1;
833  for (int i=1; i<=row; i++) {
834  t1 = m->view(i-1);
835  set(i, j, t1);
836  }
837 }
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:123
f
Definition: cfModGcd.cc:4022
int row
Definition: bigintmat.h:37
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:91
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:71
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:718
int cols() const
Definition: bigintmat.h:128
int rows() const
Definition: bigintmat.h:129
int col
Definition: bigintmat.h:38
coeffs basecoeffs() const
Definition: bigintmat.h:130
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:455
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:115
bool nCoeffs_are_equal(coeffs r, coeffs s)
Definition: bigintmat.cc:2449
void bigintmat::setrow ( int  i,
bigintmat m 
)

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

Definition at line 839 of file bigintmat.cc.

839  {
840  if ((j>row) || (j<1)) {
841  Werror("Error in setrow: Index out of range!");
842  return;
843  }
844  if (((m->rows() != 1) || (m->cols() != col)) && ((m->rows() != col) || (m->cols() != 1))) {
845  Werror("Error in setrow. Dimensions must agree!");
846  return;
847  }
848  if (!nCoeffs_are_equal(basecoeffs(), m->basecoeffs())) {
850  number tmp1,tmp2;
851  for (int i=1; i<=col; i++) {
852  tmp1 = m->get(i-1);
853  tmp2 = f(tmp1, m->basecoeffs(),basecoeffs());
854  set(j, i, tmp2);
855  n_Delete(&tmp2, basecoeffs());
856  n_Delete(&tmp1, m->basecoeffs());
857  }
858  return;
859  }
860  number tmp;
861  for (int i=1; i<=col; i++) {
862  tmp = m->view(i-1);
863  set(j, i, tmp);
864  }
865 
866 }
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:123
f
Definition: cfModGcd.cc:4022
int row
Definition: bigintmat.h:37
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:91
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:71
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:718
CFList tmp2
Definition: facFqBivar.cc:70
int cols() const
Definition: bigintmat.h:128
int rows() const
Definition: bigintmat.h:129
int col
Definition: bigintmat.h:38
coeffs basecoeffs() const
Definition: bigintmat.h:130
CFList tmp1
Definition: facFqBivar.cc:70
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:455
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:115
bool nCoeffs_are_equal(coeffs r, coeffs s)
Definition: bigintmat.cc:2449
void bigintmat::simplifyContentDen ( number *  den)

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

Definition at line 2486 of file bigintmat.cc.

2487 {
2488  coeffs r = basecoeffs();
2489  number g = n_Copy(*d, r), h;
2490  int n=rows()*cols();
2491  for(int i=0; i<n && !n_IsOne(g, r); i++) {
2492  h = n_Gcd(g, view(i), r);
2493  n_Delete(&g, r);
2494  g=h;
2495  }
2496  *d = n_Div(*d, g, r);
2497  if (!n_IsOne(g, r))
2498  skaldiv(g);
2499 }
void skaldiv(number b)
Macht Ganzzahldivision aller Matrixeinträge mit b.
Definition: bigintmat.cc:1739
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:123
static FORCE_INLINE number n_Gcd(number a, number b, const coeffs r)
in Z: return the gcd of 'a' and 'b' in Z/nZ, Z/2^kZ: computed as in the case Z in Z/pZ...
Definition: coeffs.h:683
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff 'n' represents the one element.
Definition: coeffs.h:468
const CanonicalForm CFMap CFMap int &both_non_zero int n
Definition: cfEzgcd.cc:52
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:128
int rows() const
Definition: bigintmat.h:129
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of 'n'
Definition: coeffs.h:451
static FORCE_INLINE number n_Div(number a, number b, const coeffs r)
return the quotient of 'a' and 'b', i.e., a/b; raises an error if 'b' is not invertible in r exceptio...
Definition: coeffs.h:613
coeffs basecoeffs() const
Definition: bigintmat.h:130
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:455
static Poly * h
Definition: janet.cc:978
void bigintmat::skaldiv ( number  b)

Macht Ganzzahldivision aller Matrixeinträge mit b.

Definition at line 1739 of file bigintmat.cc.

1740 {
1741  number tmp1, tmp2;
1742  for (int i=1; i<=row; i++)
1743  {
1744  for (int j=1; j<=col; j++)
1745  {
1746  tmp1 = view(i, j);
1747  tmp2 = n_Div(tmp1, b, basecoeffs());
1748  rawset(i, j, tmp2);
1749  }
1750  }
1751 }
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:123
int row
Definition: bigintmat.h:37
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:180
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
CFList tmp2
Definition: facFqBivar.cc:70
int col
Definition: bigintmat.h:38
static FORCE_INLINE number n_Div(number a, number b, const coeffs r)
return the quotient of 'a' and 'b', i.e., a/b; raises an error if 'b' is not invertible in r exceptio...
Definition: coeffs.h:613
coeffs basecoeffs() const
Definition: bigintmat.h:130
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 904 of file bigintmat.cc.

905 {
906  if (!nCoeffs_are_equal(c, basecoeffs()))
907  {
908  Werror("Wrong coeffs\n");
909  return false;
910  }
911  number t1, t2;
912  if ( n_IsOne(b,c)) return true;
913  for (int i=1; i<=row; i++)
914  {
915  for (int j=1; j<=col; j++)
916  {
917  t1 = view(i, j);
918  t2 = n_Mult(t1, b, basecoeffs());
919  rawset(i, j, t2);
920  }
921  }
922  return true;
923 }
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:123
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff 'n' represents the one element.
Definition: coeffs.h:468
int row
Definition: bigintmat.h:37
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:180
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of 'a' and 'b', i.e., a*b
Definition: coeffs.h:633
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
int col
Definition: bigintmat.h:38
coeffs basecoeffs() const
Definition: bigintmat.h:130
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:2449
void bigintmat::splitcol ( bigintmat a,
bigintmat b 
)

... linken ... rechten ...

Definition at line 1105 of file bigintmat.cc.

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

Speichert die ersten i Spalten als Teilmatrix in a.

Definition at line 1136 of file bigintmat.cc.

1136  {
1137  number tmp;
1138  if ((a->rows() != row) || (a->cols()+i-1 > col) || (i<1)) {
1139  Werror("Error in splitcol. Dimensions must agree!");
1140  return;
1141  }
1142  if (!(nCoeffs_are_equal(a->basecoeffs(), basecoeffs()))) {
1143  Werror("Error in splitcol. coeffs do not agree!");
1144  return;
1145  }
1146  int width = a->cols();
1147  for (int j=1; j<=width; j++) {
1148  for (int k=1; k<=row; k++) {
1149  tmp = get(k, j+i-1);
1150  a->set(k, j, tmp);
1151  n_Delete(&tmp, basecoeffs());
1152  }
1153  }
1154 }
int row
Definition: bigintmat.h:37
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:91
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
int cols() const
Definition: bigintmat.h:128
int rows() const
Definition: bigintmat.h:129
int col
Definition: bigintmat.h:38
coeffs basecoeffs() const
Definition: bigintmat.h:130
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:455
void Werror(const char *fmt,...)
Definition: reporter.cc:199
bool nCoeffs_are_equal(coeffs r, coeffs s)
Definition: bigintmat.cc:2449
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 1072 of file bigintmat.cc.

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

... Zeilen ...

Definition at line 1156 of file bigintmat.cc.

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

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

Definition at line 431 of file bigintmat.cc.

432 {
433  StringSetS("");
434  Write();
435  return StringEndS();
436 }
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:411
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 446 of file bigintmat.cc.

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

Subtrahiert ...

Definition at line 886 of file bigintmat.cc.

887 {
888  if ((b->rows() != row) || (b->cols() != col)) {
889  Werror("Error in bigintmat::sub. Dimensions do not agree!");
890  return false;
891  }
892  if (!nCoeffs_are_equal(basecoeffs(), b->basecoeffs())) {
893  Werror("Error in bigintmat::sub. coeffs do not agree!");
894  return false;
895  }
896  for (int i=1; i<=row; i++) {
897  for (int j=1; j<=col; j++) {
898  rawset(i, j, n_Sub(view(i,j), b->view(i,j), basecoeffs()));
899  }
900  }
901  return true;
902 }
static FORCE_INLINE number n_Sub(number a, number b, const coeffs r)
return the difference of 'a' and 'b', i.e., a-b
Definition: coeffs.h:666
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:123
int row
Definition: bigintmat.h:37
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:180
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
int cols() const
Definition: bigintmat.h:128
int rows() const
Definition: bigintmat.h:129
int col
Definition: bigintmat.h:38
coeffs basecoeffs() const
Definition: bigintmat.h:130
void Werror(const char *fmt,...)
Definition: reporter.cc:199
bool nCoeffs_are_equal(coeffs r, coeffs s)
Definition: bigintmat.cc:2449
void bigintmat::swap ( int  i,
int  j 
)

swap columns i and j

Definition at line 688 of file bigintmat.cc.

688  {
689  if ((i <= col) && (j <= col) && (i>0) && (j>0)) {
690  number tmp;
691  number t;
692  for (int k=1; k<=row; k++) {
693  tmp = get(k, i);
694  t = view(k, j);
695  set(k, i, t);
696  set(k, j, tmp);
697  n_Delete(&tmp, basecoeffs());
698  }
699  } else
700  Werror("Error in swap");
701 }
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:123
int row
Definition: bigintmat.h:37
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:91
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
int col
Definition: bigintmat.h:38
coeffs basecoeffs() const
Definition: bigintmat.h:130
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:455
void Werror(const char *fmt,...)
Definition: reporter.cc:199
void bigintmat::swapMatrix ( bigintmat a)

Definition at line 1466 of file bigintmat.cc.

1467 {
1468  int n = rows(), m = cols();
1469  row = a->rows();
1470  col = a->cols();
1471  number * V = v;
1472  v = a->v;
1473  a->v = V;
1474  a->row = n;
1475  a->col = m;
1476 }
int row
Definition: bigintmat.h:37
const CanonicalForm CFMap CFMap int &both_non_zero int n
Definition: cfEzgcd.cc:52
int m
Definition: cfEzgcd.cc:119
int cols() const
Definition: bigintmat.h:128
int rows() const
Definition: bigintmat.h:129
int col
Definition: bigintmat.h:38
number * v
Definition: bigintmat.h:36
void bigintmat::swaprow ( int  i,
int  j 
)

swap rows i and j

Definition at line 703 of file bigintmat.cc.

703  {
704  if ((i <= row) && (j <= row) && (i>0) && (j>0)) {
705  number tmp;
706  number t;
707  for (int k=1; k<=col; k++) {
708  tmp = get(i, k);
709  t = view(j, k);
710  set(i, k, t);
711  set(j, k, tmp);
712  n_Delete(&tmp, basecoeffs());
713  }
714  }
715  else
716  Werror("Error in swaprow");
717 }
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:123
int row
Definition: bigintmat.h:37
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:91
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
int col
Definition: bigintmat.h:38
coeffs basecoeffs() const
Definition: bigintmat.h:130
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:455
void Werror(const char *fmt,...)
Definition: reporter.cc:199
number bigintmat::trace ( )

the trace ....

Definition at line 1398 of file bigintmat.cc.

1399 {
1400  assume (col == row);
1401  number t = get(1,1),
1402  h;
1403  coeffs r = basecoeffs();
1404  for(int i=2; i<= col; i++) {
1405  h = n_Add(t, view(i,i), r);
1406  n_Delete(&t, r);
1407  t = h;
1408  }
1409  return t;
1410 }
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:123
int row
Definition: bigintmat.h:37
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 'a' and 'b', i.e., a+b
Definition: coeffs.h:653
int i
Definition: cfEzgcd.cc:123
int col
Definition: bigintmat.h:38
coeffs basecoeffs() const
Definition: bigintmat.h:130
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:455
static Poly * h
Definition: janet.cc:978
bigintmat * bigintmat::transpose ( )

Definition at line 36 of file bigintmat.cc.

37 {
38  bigintmat * t = new bigintmat(col, row, basecoeffs());
39  for (int i=1; i<=row; i++)
40  {
41  for (int j=1; j<=col; j++)
42  {
43  t->set(j, i, BIMATELEM(*this,i,j));
44  }
45  }
46  return t;
47 }
Matrices of numbers.
Definition: bigintmat.h:32
int row
Definition: bigintmat.h:37
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:91
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
#define BIMATELEM(M, I, J)
Definition: bigintmat.h:117
int col
Definition: bigintmat.h:38
bigintmat()
Definition: bigintmat.h:41
coeffs basecoeffs() const
Definition: bigintmat.h:130
number bigintmat::view ( int  i,
int  j 
) const

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

Definition at line 123 of file bigintmat.cc.

124 {
125  assume (i >= 0 && j >= 0);
126  assume (i <= rows() && j <= cols());
127 
128  return view(index(i, j));
129 }
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc: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:145
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:128
int rows() const
Definition: bigintmat.h:129
number bigintmat::view ( int  i) const

view an entry. NOTE: starts at [0]

Definition at line 107 of file bigintmat.cc.

108 {
109  assume (i >= 0);
110  assume (i<rows()*cols());
111 
112  return v[i];
113 }
#define assume(x)
Definition: mod2.h:405
int i
Definition: cfEzgcd.cc:123
int cols() const
Definition: bigintmat.h:128
int rows() const
Definition: bigintmat.h:129
number * v
Definition: bigintmat.h:36
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 411 of file bigintmat.cc.

412 {
413  int n = cols(), m=rows();
414 
415  StringAppendS("[ ");
416  for(int i=1; i<= m; i++) {
417  StringAppendS("[ ");
418  for(int j=1; j< n; j++) {
419  n_Write(v[(i-1)*n+j-1], basecoeffs());
420  StringAppendS(", ");
421  }
422  if (n) n_Write(v[i*n-1], basecoeffs());
423  StringAppendS(" ]");
424  if (i<m) {
425  StringAppendS(", ");
426  }
427  }
428  StringAppendS(" ] ");
429 }
const CanonicalForm CFMap CFMap int &both_non_zero int n
Definition: cfEzgcd.cc:52
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:590
int m
Definition: cfEzgcd.cc:119
int i
Definition: cfEzgcd.cc:123
int cols() const
Definition: bigintmat.h:128
int rows() const
Definition: bigintmat.h:129
number * v
Definition: bigintmat.h:36
coeffs basecoeffs() const
Definition: bigintmat.h:130
void bigintmat::zero ( )

Setzt alle Einträge auf 0.

Definition at line 1254 of file bigintmat.cc.

1254  {
1255  number tmp = n_Init(0, basecoeffs());
1256  for (int i=1; i<=row; i++) {
1257  for (int j=1; j<=col; j++) {
1258  set(i, j, tmp);
1259  }
1260  }
1261  n_Delete(&tmp,basecoeffs());
1262 }
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition: coeffs.h:537
int row
Definition: bigintmat.h:37
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:91
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
int col
Definition: bigintmat.h:38
coeffs basecoeffs() const
Definition: bigintmat.h:130
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:455

Field Documentation

int bigintmat::col
private

Definition at line 38 of file bigintmat.h.

coeffs bigintmat::m_coeffs
private

Definition at line 35 of file bigintmat.h.

int bigintmat::row
private

Definition at line 37 of file bigintmat.h.

number* bigintmat::v
private

Definition at line 36 of file bigintmat.h.


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