Data Structures | Macros | Functions
bigintmat.h File Reference
#include <omalloc/omalloc.h>
#include <coeffs/coeffs.h>

Go to the source code of this file.

Data Structures

class  bigintmat
 Matrices of numbers. More...
 

Macros

#define BIMATELEM(M, I, J)   (M)[(I-1)*(M).cols()+J-1]
 

Functions

bool operator== (const bigintmat &lhr, const bigintmat &rhr)
 
bool operator!= (const bigintmat &lhr, const bigintmat &rhr)
 
bigintmatbimAdd (bigintmat *a, bigintmat *b)
 Matrix-Add/-Sub/-Mult so oder mit operator+/-/* ? : NULL as a result means an error (non-compatible matrices?) More...
 
bigintmatbimAdd (bigintmat *a, int b)
 
bigintmatbimSub (bigintmat *a, bigintmat *b)
 
bigintmatbimSub (bigintmat *a, int b)
 
bigintmatbimMult (bigintmat *a, bigintmat *b)
 
bigintmatbimMult (bigintmat *a, int b)
 
bigintmatbimMult (bigintmat *a, number b, const coeffs cf)
 
bigintmatbimCopy (const bigintmat *b)
 same as copy constructor - apart from it being able to accept NULL as input More...
 
intvecbim2iv (bigintmat *b)
 
bigintmativ2bim (intvec *b, const coeffs C)
 
bigintmatbimChangeCoeff (bigintmat *a, coeffs cnew)
 Liefert Kopier von Matrix a zurück, mit coeffs cnew statt den ursprünglichen. More...
 
void bimMult (bigintmat *a, bigintmat *b, bigintmat *c)
 Multipliziert Matrix a und b und speichert Ergebnis in c. More...
 
number solveAx (bigintmat *A, bigintmat *b, bigintmat *x)
 solve Ax=b*d. x needs to be pre-allocated to the same number of columns as b. the minimal denominator d is returned. Currently available for Z, Q and Z/nZ (and possibly for all fields: d=1 there) Beware that the internal functions can find the kernel as well - but the interface is lacking. More...
 
int kernbase (bigintmat *a, bigintmat *c, number p, coeffs q)
 a basis for the nullspace of a mod p: only used internally in Round2. Don't use it. More...
 
bool nCoeffs_are_equal (coeffs r, coeffs s)
 
void diagonalForm (bigintmat *a, bigintmat **b, bigintmat **c)
 

Macro Definition Documentation

§ BIMATELEM

#define BIMATELEM (   M,
  I,
 
)    (M)[(I-1)*(M).cols()+J-1]

Definition at line 134 of file bigintmat.h.

Function Documentation

§ bim2iv()

intvec* bim2iv ( bigintmat b)

Definition at line 344 of file bigintmat.cc.

345 {
346  intvec * iv = new intvec(b->rows(), b->cols(), 0);
347  for (int i=0; i<(b->rows())*(b->cols()); i++)
348  (*iv)[i] = n_Int((*b)[i], b->basecoeffs()); // Geht das so?
349  return iv;
350 }
int rows() const
Definition: bigintmat.h:146
Definition: intvec.h:14
static FORCE_INLINE long n_Int(number &n, const coeffs r)
conversion of n to an int; 0 if not possible in Z/pZ: the representing int lying in (-p/2 ...
Definition: coeffs.h:551
int cols() const
Definition: bigintmat.h:145
int i
Definition: cfEzgcd.cc:123
coeffs basecoeffs() const
Definition: bigintmat.h:147

§ bimAdd() [1/2]

bigintmat* bimAdd ( bigintmat a,
bigintmat b 
)

Matrix-Add/-Sub/-Mult so oder mit operator+/-/* ? : NULL as a result means an error (non-compatible matrices?)

Definition at line 183 of file bigintmat.cc.

184 {
185  if (a->cols() != b->cols()) return NULL;
186  if (a->rows() != b->rows()) return NULL;
187  if (a->basecoeffs() != b->basecoeffs()) { return NULL; }
188 
189  const coeffs basecoeffs = a->basecoeffs();
190 
191  int i;
192 
193  bigintmat * bim = new bigintmat(a->rows(), a->cols(), basecoeffs);
194 
195  for (i=a->rows()*a->cols()-1;i>=0; i--)
196  bim->rawset(i, n_Add((*a)[i], (*b)[i], basecoeffs), basecoeffs);
197 
198  return bim;
199 }
Matrices of numbers.
Definition: bigintmat.h:51
int rows() const
Definition: bigintmat.h:146
void rawset(int i, number n, const coeffs C=NULL)
replace an entry with the given number n (only delete old). NOTE: starts at [0]. Should be named set_...
Definition: bigintmat.h:197
The main handler for Singular numbers which are suitable for Singular polynomials.
static FORCE_INLINE number n_Add(number a, number b, const coeffs r)
return the sum of &#39;a&#39; and &#39;b&#39;, i.e., a+b
Definition: coeffs.h:660
int cols() const
Definition: bigintmat.h:145
int i
Definition: cfEzgcd.cc:123
#define NULL
Definition: omList.c:10
coeffs basecoeffs() const
Definition: bigintmat.h:147

§ bimAdd() [2/2]

bigintmat* bimAdd ( bigintmat a,
int  b 
)

Definition at line 200 of file bigintmat.cc.

201 {
202 
203  const int mn = a->rows()*a->cols();
204 
205  const coeffs basecoeffs = a->basecoeffs();
206  number bb=n_Init(b,basecoeffs);
207 
208  int i;
209 
210  bigintmat * bim = new bigintmat(a->rows(),a->cols() , basecoeffs);
211 
212  for (i=0; i<mn; i++)
213  bim->rawset(i, n_Add((*a)[i], bb, basecoeffs), basecoeffs);
214 
215  n_Delete(&bb,basecoeffs);
216  return bim;
217 }
Matrices of numbers.
Definition: bigintmat.h:51
int rows() const
Definition: bigintmat.h:146
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition: coeffs.h:542
void rawset(int i, number n, const coeffs C=NULL)
replace an entry with the given number n (only delete old). NOTE: starts at [0]. Should be named set_...
Definition: bigintmat.h:197
The main handler for Singular numbers which are suitable for Singular polynomials.
static FORCE_INLINE number n_Add(number a, number b, const coeffs r)
return the sum of &#39;a&#39; and &#39;b&#39;, i.e., a+b
Definition: coeffs.h:660
int cols() const
Definition: bigintmat.h:145
int i
Definition: cfEzgcd.cc:123
coeffs basecoeffs() const
Definition: bigintmat.h:147
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:459
const poly b
Definition: syzextra.cc:213

§ bimChangeCoeff()

bigintmat* bimChangeCoeff ( bigintmat a,
coeffs  cnew 
)

Liefert Kopier von Matrix a zurück, mit coeffs cnew statt den ursprünglichen.

Definition at line 1814 of file bigintmat.cc.

1815 {
1816  coeffs cold = a->basecoeffs();
1817  bigintmat *b = new bigintmat(a->rows(), a->cols(), cnew);
1818  // Erzeugt Karte von alten coeffs nach neuen
1819  nMapFunc f = n_SetMap(cold, cnew);
1820  number t1;
1821  number t2;
1822  // apply map to all entries.
1823  for (int i=1; i<=a->rows(); i++)
1824  {
1825  for (int j=1; j<=a->cols(); j++)
1826  {
1827  t1 = a->get(i, j);
1828  t2 = f(t1, cold, cnew);
1829  b->set(i, j, t2);
1830  n_Delete(&t1, cold);
1831  n_Delete(&t2, cnew);
1832  }
1833  }
1834  return b;
1835 }
Matrices of numbers.
Definition: bigintmat.h:51
int rows() const
Definition: bigintmat.h:146
void set(int i, int j, number n, const coeffs C=NULL)
replace an entry with a copy (delete old + copy new!). NOTE: starts at [1,1]
Definition: bigintmat.cc:96
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:73
int cols() const
Definition: bigintmat.h:145
FILE * f
Definition: checklibs.c:7
int i
Definition: cfEzgcd.cc:123
static FORCE_INLINE nMapFunc n_SetMap(const coeffs src, const coeffs dst)
set the mapping function pointers for translating numbers from src to dst
Definition: coeffs.h:725
coeffs basecoeffs() const
Definition: bigintmat.h:147
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:459
number get(int i, int j) const
get a copy of an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:120
const poly b
Definition: syzextra.cc:213

§ bimCopy()

bigintmat* bimCopy ( const bigintmat b)

same as copy constructor - apart from it being able to accept NULL as input

Definition at line 408 of file bigintmat.cc.

409 {
410  if (b == NULL)
411  return NULL;
412 
413  return new bigintmat(b);
414 }
Matrices of numbers.
Definition: bigintmat.h:51
#define NULL
Definition: omList.c:10

§ bimMult() [1/4]

bigintmat* bimMult ( bigintmat a,
bigintmat b 
)

Definition at line 256 of file bigintmat.cc.

257 {
258  const int ca = a->cols();
259  const int cb = b->cols();
260 
261  const int ra = a->rows();
262  const int rb = b->rows();
263 
264  if (ca != rb)
265  {
266 #ifndef SING_NDEBUG
267  Werror("wrong bigintmat sizes at multiplication a * b: acols: %d != brows: %d\n", ca, rb);
268 #endif
269  return NULL;
270  }
271 
272  assume (ca == rb);
273 
274  if (a->basecoeffs() != b->basecoeffs()) { return NULL; }
275 
276  const coeffs basecoeffs = a->basecoeffs();
277 
278  int i, j, k;
279 
280  number sum;
281 
282  bigintmat * bim = new bigintmat(ra, cb, basecoeffs);
283 
284  for (i=1; i<=ra; i++)
285  for (j=1; j<=cb; j++)
286  {
287  sum = n_Init(0, basecoeffs);
288 
289  for (k=1; k<=ca; k++)
290  {
291  number prod = n_Mult( BIMATELEM(*a, i, k), BIMATELEM(*b, k, j), basecoeffs);
292 
293  number sum2 = n_Add(sum, prod, basecoeffs); // no inplace add :(
294 
295  n_Delete(&sum, basecoeffs); n_Delete(&prod, basecoeffs);
296 
297  sum = sum2;
298  }
299  bim->rawset(i, j, sum, basecoeffs);
300  }
301  return bim;
302 }
Matrices of numbers.
Definition: bigintmat.h:51
int rows() const
Definition: bigintmat.h:146
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition: coeffs.h:542
int 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:197
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of &#39;a&#39; and &#39;b&#39;, i.e., a*b
Definition: coeffs.h:640
int j
Definition: myNF.cc:70
#define assume(x)
Definition: mod2.h:403
The main handler for Singular numbers which are suitable for Singular polynomials.
static FORCE_INLINE number n_Add(number a, number b, const coeffs r)
return the sum of &#39;a&#39; and &#39;b&#39;, i.e., a+b
Definition: coeffs.h:660
int cols() const
Definition: bigintmat.h:145
int i
Definition: cfEzgcd.cc:123
#define BIMATELEM(M, I, J)
Definition: bigintmat.h:134
#define NULL
Definition: omList.c:10
coeffs basecoeffs() const
Definition: bigintmat.h:147
fq_nmod_poly_t prod
Definition: facHensel.cc:95
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:459
void Werror(const char *fmt,...)
Definition: reporter.cc:189

§ bimMult() [2/4]

bigintmat* bimMult ( bigintmat a,
int  b 
)

Definition at line 304 of file bigintmat.cc.

305 {
306 
307  const int mn = a->rows()*a->cols();
308 
309  const coeffs basecoeffs = a->basecoeffs();
310  number bb=n_Init(b,basecoeffs);
311 
312  int i;
313 
314  bigintmat * bim = new bigintmat(a->rows(),a->cols() , basecoeffs);
315 
316  for (i=0; i<mn; i++)
317  bim->rawset(i, n_Mult((*a)[i], bb, basecoeffs), basecoeffs);
318 
319  n_Delete(&bb,basecoeffs);
320  return bim;
321 }
Matrices of numbers.
Definition: bigintmat.h:51
int rows() const
Definition: bigintmat.h:146
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition: coeffs.h:542
void rawset(int i, number n, const coeffs C=NULL)
replace an entry with the given number n (only delete old). NOTE: starts at [0]. Should be named set_...
Definition: bigintmat.h:197
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of &#39;a&#39; and &#39;b&#39;, i.e., a*b
Definition: coeffs.h:640
The main handler for Singular numbers which are suitable for Singular polynomials.
int cols() const
Definition: bigintmat.h:145
int i
Definition: cfEzgcd.cc:123
coeffs basecoeffs() const
Definition: bigintmat.h:147
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:459
const poly b
Definition: syzextra.cc:213

§ bimMult() [3/4]

bigintmat* bimMult ( bigintmat a,
number  b,
const coeffs  cf 
)

Definition at line 323 of file bigintmat.cc.

324 {
325  if (cf!=a->basecoeffs()) return NULL;
326 
327  const int mn = a->rows()*a->cols();
328 
329  const coeffs basecoeffs = a->basecoeffs();
330 
331  int i;
332 
333  bigintmat * bim = new bigintmat(a->rows(),a->cols() , basecoeffs);
334 
335  for (i=0; i<mn; i++)
336  bim->rawset(i, n_Mult((*a)[i], b, basecoeffs), basecoeffs);
337 
338  return bim;
339 }
Matrices of numbers.
Definition: bigintmat.h:51
int rows() const
Definition: bigintmat.h:146
void rawset(int i, number n, const coeffs C=NULL)
replace an entry with the given number n (only delete old). NOTE: starts at [0]. Should be named set_...
Definition: bigintmat.h:197
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of &#39;a&#39; and &#39;b&#39;, i.e., a*b
Definition: coeffs.h:640
The main handler for Singular numbers which are suitable for Singular polynomials.
int cols() const
Definition: bigintmat.h:145
int i
Definition: cfEzgcd.cc:123
#define NULL
Definition: omList.c:10
coeffs basecoeffs() const
Definition: bigintmat.h:147
const poly b
Definition: syzextra.cc:213

§ bimMult() [4/4]

void bimMult ( bigintmat a,
bigintmat b,
bigintmat c 
)

Multipliziert Matrix a und b und speichert Ergebnis in c.

Definition at line 1942 of file bigintmat.cc.

1943 {
1944  if (!nCoeffs_are_equal(a->basecoeffs(), b->basecoeffs()))
1945  {
1946  WerrorS("Error in bimMult. Coeffs do not agree!");
1947  return;
1948  }
1949  if ((a->rows() != c->rows()) || (b->cols() != c->cols()) || (a->cols() != b->rows()))
1950  {
1951  WerrorS("Error in bimMult. Dimensions do not agree!");
1952  return;
1953  }
1954  bigintmat *tmp = bimMult(a, b);
1955  c->copy(tmp);
1956 
1957  delete tmp;
1958 }
Matrices of numbers.
Definition: bigintmat.h:51
int rows() const
Definition: bigintmat.h:146
void WerrorS(const char *s)
Definition: feFopen.cc:24
bigintmat * bimMult(bigintmat *a, bigintmat *b)
Definition: bigintmat.cc:256
int cols() const
Definition: bigintmat.h:145
coeffs basecoeffs() const
Definition: bigintmat.h:147
bool copy(bigintmat *b)
Kopiert Einträge von b auf Bigintmat.
Definition: bigintmat.cc:1269
bool nCoeffs_are_equal(coeffs r, coeffs s)
Definition: bigintmat.cc:2655

§ bimSub() [1/2]

bigintmat* bimSub ( bigintmat a,
bigintmat b 
)

Definition at line 219 of file bigintmat.cc.

220 {
221  if (a->cols() != b->cols()) return NULL;
222  if (a->rows() != b->rows()) return NULL;
223  if (a->basecoeffs() != b->basecoeffs()) { return NULL; }
224 
225  const coeffs basecoeffs = a->basecoeffs();
226 
227  int i;
228 
229  bigintmat * bim = new bigintmat(a->rows(), a->cols(), basecoeffs);
230 
231  for (i=a->rows()*a->cols()-1;i>=0; i--)
232  bim->rawset(i, n_Sub((*a)[i], (*b)[i], basecoeffs), basecoeffs);
233 
234  return bim;
235 }
static FORCE_INLINE number n_Sub(number a, number b, const coeffs r)
return the difference of &#39;a&#39; and &#39;b&#39;, i.e., a-b
Definition: coeffs.h:673
Matrices of numbers.
Definition: bigintmat.h:51
int rows() const
Definition: bigintmat.h:146
void rawset(int i, number n, const coeffs C=NULL)
replace an entry with the given number n (only delete old). NOTE: starts at [0]. Should be named set_...
Definition: bigintmat.h:197
The main handler for Singular numbers which are suitable for Singular polynomials.
int cols() const
Definition: bigintmat.h:145
int i
Definition: cfEzgcd.cc:123
#define NULL
Definition: omList.c:10
coeffs basecoeffs() const
Definition: bigintmat.h:147

§ bimSub() [2/2]

bigintmat* bimSub ( bigintmat a,
int  b 
)

Definition at line 237 of file bigintmat.cc.

238 {
239  const int mn = a->rows()*a->cols();
240 
241  const coeffs basecoeffs = a->basecoeffs();
242  number bb=n_Init(b,basecoeffs);
243 
244  int i;
245 
246  bigintmat * bim = new bigintmat(a->rows(),a->cols() , basecoeffs);
247 
248  for (i=0; i<mn; i++)
249  bim->rawset(i, n_Sub((*a)[i], bb, basecoeffs), basecoeffs);
250 
251  n_Delete(&bb,basecoeffs);
252  return bim;
253 }
static FORCE_INLINE number n_Sub(number a, number b, const coeffs r)
return the difference of &#39;a&#39; and &#39;b&#39;, i.e., a-b
Definition: coeffs.h:673
Matrices of numbers.
Definition: bigintmat.h:51
int rows() const
Definition: bigintmat.h:146
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition: coeffs.h:542
void rawset(int i, number n, const coeffs C=NULL)
replace an entry with the given number n (only delete old). NOTE: starts at [0]. Should be named set_...
Definition: bigintmat.h:197
The main handler for Singular numbers which are suitable for Singular polynomials.
int cols() const
Definition: bigintmat.h:145
int i
Definition: cfEzgcd.cc:123
coeffs basecoeffs() const
Definition: bigintmat.h:147
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:459
const poly b
Definition: syzextra.cc:213

§ diagonalForm()

void diagonalForm ( bigintmat a,
bigintmat **  b,
bigintmat **  c 
)

Definition at line 2485 of file bigintmat.cc.

2486 {
2487  bigintmat * t, *s, *a=A;
2488  coeffs R = a->basecoeffs();
2489  if (T)
2490  {
2491  *T = new bigintmat(a->cols(), a->cols(), R),
2492  (*T)->one();
2493  t = new bigintmat(*T);
2494  }
2495  else
2496  {
2497  t = *T;
2498  }
2499 
2500  if (S)
2501  {
2502  *S = new bigintmat(a->rows(), a->rows(), R);
2503  (*S)->one();
2504  s = new bigintmat(*S);
2505  }
2506  else
2507  {
2508  s = *S;
2509  }
2510 
2511  int flip=0;
2512  do
2513  {
2514  bigintmat * x, *X;
2515  if (flip)
2516  {
2517  x = s;
2518  X = *S;
2519  }
2520  else
2521  {
2522  x = t;
2523  X = *T;
2524  }
2525 
2526  if (x)
2527  {
2528  x->one();
2529  bigintmat * r = new bigintmat(a->rows()+a->cols(), a->cols(), R);
2530  bigintmat * rw = new bigintmat(1, a->cols(), R);
2531  for(int i=0; i<a->cols(); i++)
2532  {
2533  x->getrow(i+1, rw);
2534  r->setrow(i+1, rw);
2535  }
2536  for (int i=0; i<a->rows(); i++)
2537  {
2538  a->getrow(i+1, rw);
2539  r->setrow(i+a->cols()+1, rw);
2540  }
2541  r->hnf();
2542  for(int i=0; i<a->cols(); i++)
2543  {
2544  r->getrow(i+1, rw);
2545  x->setrow(i+1, rw);
2546  }
2547  for(int i=0; i<a->rows(); i++)
2548  {
2549  r->getrow(i+a->cols()+1, rw);
2550  a->setrow(i+1, rw);
2551  }
2552  delete rw;
2553  delete r;
2554 
2555 #if 0
2556  Print("X: %ld\n", X);
2557  X->Print();
2558  Print("\nx: %ld\n", x);
2559  x->Print();
2560 #endif
2561  bimMult(X, x, X);
2562 #if 0
2563  Print("\n2:X: %ld %ld %ld\n", X, *S, *T);
2564  X->Print();
2565  Print("\n2:x: %ld\n", x);
2566  x->Print();
2567  PrintLn();
2568 #endif
2569  }
2570  else
2571  {
2572  a->hnf();
2573  }
2574 
2575  int diag = 1;
2576  for(int i=a->rows(); diag && i>0; i--)
2577  {
2578  for(int j=a->cols(); j>0; j--)
2579  {
2580  if ((a->rows()-i)!=(a->cols()-j) && !n_IsZero(a->view(i, j), R))
2581  {
2582  diag = 0;
2583  break;
2584  }
2585  }
2586  }
2587 #if 0
2588  PrintS("Diag ? %d\n", diag);
2589  a->Print();
2590  PrintLn();
2591 #endif
2592  if (diag) break;
2593 
2594  a = a->transpose(); // leaks - I need to write inpTranspose
2595  flip = 1-flip;
2596  } while (1);
2597  if (flip)
2598  a = a->transpose();
2599 
2600  if (S) *S = (*S)->transpose();
2601  if (s) delete s;
2602  if (t) delete t;
2603  A->copy(a);
2604 }
bigintmat * transpose()
Definition: bigintmat.cc:38
const CanonicalForm int s
Definition: facAbsFact.cc:55
void PrintLn()
Definition: reporter.cc:310
#define Print
Definition: emacs.cc:83
void getrow(int i, bigintmat *a)
Schreibt i-te Zeile in Vektor (Matrix) a.
Definition: bigintmat.cc:801
Matrices of numbers.
Definition: bigintmat.h:51
int rows() const
Definition: bigintmat.h:146
void setrow(int i, bigintmat *m)
Setzt i-te Zeile gleich übergebenem Vektor (Matrix) m.
Definition: bigintmat.cc:870
const ring r
Definition: syzextra.cc:208
int j
Definition: myNF.cc:70
bigintmat * bimMult(bigintmat *a, bigintmat *b)
Definition: bigintmat.cc:256
The main handler for Singular numbers which are suitable for Singular polynomials.
#define A
Definition: sirandom.c:23
const ring R
Definition: DebugPrint.cc:36
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:128
int cols() const
Definition: bigintmat.h:145
void hnf()
transforms INPLACE to HNF
Definition: bigintmat.cc:1670
int i
Definition: cfEzgcd.cc:123
void PrintS(const char *s)
Definition: reporter.cc:284
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the zero element.
Definition: coeffs.h:468
void Print()
IO: simply prints the matrix to the current output (screen?)
Definition: bigintmat.cc:446
std::pair< ideal, ring > flip(const ideal I, const ring r, const gfan::ZVector interiorPoint, const gfan::ZVector facetNormal, const gfan::ZVector adjustedInteriorPoint, const gfan::ZVector adjustedFacetNormal)
Definition: flip.cc:40
coeffs basecoeffs() const
Definition: bigintmat.h:147
Variable x
Definition: cfModGcd.cc:4023
static jList * T
Definition: janet.cc:37
void one()
Macht Matrix (Falls quadratisch) zu Einheitsmatrix.
Definition: bigintmat.cc:1335

§ iv2bim()

bigintmat* iv2bim ( intvec b,
const coeffs  C 
)

Definition at line 352 of file bigintmat.cc.

353 {
354  const int l = (b->rows())*(b->cols());
355  bigintmat * bim = new bigintmat(b->rows(), b->cols(), C);
356 
357  for (int i=0; i < l; i++)
358  bim->rawset(i, n_Init((*b)[i], C), C);
359 
360  return bim;
361 }
Matrices of numbers.
Definition: bigintmat.h:51
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition: coeffs.h:542
int rows() const
Definition: intvec.h:88
void rawset(int i, number n, const coeffs C=NULL)
replace an entry with the given number n (only delete old). NOTE: starts at [0]. Should be named set_...
Definition: bigintmat.h:197
int i
Definition: cfEzgcd.cc:123
int cols() const
Definition: intvec.h:87
int l
Definition: cfEzgcd.cc:94

§ kernbase()

int kernbase ( bigintmat a,
bigintmat c,
number  p,
coeffs  q 
)

a basis for the nullspace of a mod p: only used internally in Round2. Don't use it.

Definition at line 2610 of file bigintmat.cc.

2611 {
2612 #if 0
2613  PrintS("Kernel of ");
2614  a->Print();
2615  PrintS(" modulo ");
2616  n_Print(p, q);
2617  PrintLn();
2618 #endif
2619 
2620  coeffs coe = numbercoeffs(p, q);
2621  bigintmat *m = bimChangeCoeff(a, coe), *U, *V;
2622  diagonalForm(m, &U, &V);
2623 #if 0
2624  PrintS("\ndiag form: ");
2625  m->Print();
2626  PrintS("\nU:\n");
2627  U->Print();
2628  PrintS("\nV:\n");
2629  V->Print();
2630  PrintLn();
2631 #endif
2632 
2633  int rg = 0;
2634 #undef MIN
2635 #define MIN(a,b) (a < b ? a : b)
2636  for(rg=0; rg<MIN(m->rows(), m->cols()) && !n_IsZero(m->view(m->rows()-rg,m->cols()-rg), coe); rg++);
2637 
2638  bigintmat * k = new bigintmat(m->cols(), m->rows(), coe);
2639  for(int i=0; i<rg; i++)
2640  {
2641  number A = n_Ann(m->view(m->rows()-i, m->cols()-i), coe);
2642  k->set(m->cols()-i, i+1, A);
2643  n_Delete(&A, coe);
2644  }
2645  for(int i=rg; i<m->cols(); i++)
2646  {
2647  k->set(m->cols()-i, i+1-rg, n_Init(1, coe));
2648  }
2649  bimMult(V, k, k);
2650  c->copy(bimChangeCoeff(k, q));
2651  return c->cols();
2652 }
void PrintLn()
Definition: reporter.cc:310
return P p
Definition: myNF.cc:203
Matrices of numbers.
Definition: bigintmat.h:51
int rows() const
Definition: bigintmat.h:146
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition: coeffs.h:542
int k
Definition: cfEzgcd.cc:93
#define MIN(a, b)
static FORCE_INLINE number n_Ann(number a, const coeffs r)
if r is a ring with zero divisors, return an annihilator!=0 of b otherwise return NULL ...
Definition: coeffs.h:705
void set(int i, int j, number n, const coeffs C=NULL)
replace an entry with a copy (delete old + copy new!). NOTE: starts at [1,1]
Definition: bigintmat.cc:96
static coeffs numbercoeffs(number n, coeffs c)
create Z/nA of type n_Zn
Definition: bigintmat.cc:22
bigintmat * bimMult(bigintmat *a, bigintmat *b)
Definition: bigintmat.cc:256
The main handler for Singular numbers which are suitable for Singular polynomials.
#define A
Definition: sirandom.c:23
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:128
int cols() const
Definition: bigintmat.h:145
int m
Definition: cfEzgcd.cc:119
int i
Definition: cfEzgcd.cc:123
void PrintS(const char *s)
Definition: reporter.cc:284
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the zero element.
Definition: coeffs.h:468
bigintmat * bimChangeCoeff(bigintmat *a, coeffs cnew)
Liefert Kopier von Matrix a zurück, mit coeffs cnew statt den ursprünglichen.
Definition: bigintmat.cc:1814
void diagonalForm(bigintmat *A, bigintmat **S, bigintmat **T)
Definition: bigintmat.cc:2485
void Print()
IO: simply prints the matrix to the current output (screen?)
Definition: bigintmat.cc:446
bool copy(bigintmat *b)
Kopiert Einträge von b auf Bigintmat.
Definition: bigintmat.cc:1269
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:459
void n_Print(number &a, const coeffs r)
print a number (BEWARE of string buffers!) mostly for debugging
Definition: numbers.cc:562

§ nCoeffs_are_equal()

bool nCoeffs_are_equal ( coeffs  r,
coeffs  s 
)

Definition at line 2655 of file bigintmat.cc.

2656 {
2657  if ((r == NULL) || (s == NULL))
2658  return false;
2659  if (r == s)
2660  return true;
2661  if ((getCoeffType(r)==n_Z) && (getCoeffType(s)==n_Z))
2662  return true;
2663  if ((getCoeffType(r)==n_Zp) && (getCoeffType(s)==n_Zp))
2664  {
2665  if (r->ch == s->ch)
2666  return true;
2667  else
2668  return false;
2669  }
2670  // n_Zn stimmt wahrscheinlich noch nicht
2671  if ((getCoeffType(r)==n_Zn) && (getCoeffType(s)==n_Zn))
2672  {
2673  if (r->ch == s->ch)
2674  return true;
2675  else
2676  return false;
2677  }
2678  if ((getCoeffType(r)==n_Q) && (getCoeffType(s)==n_Q))
2679  return true;
2680  // FALL n_Zn FEHLT NOCH!
2681  //if ((getCoeffType(r)==n_Zn) && (getCoeffType(s)==n_Zn))
2682  return false;
2683 }
only used if HAVE_RINGS is defined
Definition: coeffs.h:44
rational (GMP) numbers
Definition: coeffs.h:31
{p < 2^31}
Definition: coeffs.h:30
only used if HAVE_RINGS is defined
Definition: coeffs.h:43
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425
#define NULL
Definition: omList.c:10

§ operator!=()

bool operator!= ( const bigintmat lhr,
const bigintmat rhr 
)

Definition at line 177 of file bigintmat.cc.

178 {
179  return !(lhr==rhr);
180 }

§ operator==()

bool operator== ( const bigintmat lhr,
const bigintmat rhr 
)

Definition at line 160 of file bigintmat.cc.

161 {
162  if (&lhr == &rhr) { return true; }
163  if (lhr.cols() != rhr.cols()) { return false; }
164  if (lhr.rows() != rhr.rows()) { return false; }
165  if (lhr.basecoeffs() != rhr.basecoeffs()) { return false; }
166 
167  const int l = (lhr.rows())*(lhr.cols());
168 
169  for (int i=0; i < l; i++)
170  {
171  if (!n_Equal(lhr[i], rhr[i], lhr.basecoeffs())) { return false; }
172  }
173 
174  return true;
175 }
int rows() const
Definition: bigintmat.h:146
int cols() const
Definition: bigintmat.h:145
int i
Definition: cfEzgcd.cc:123
coeffs basecoeffs() const
Definition: bigintmat.h:147
static FORCE_INLINE BOOLEAN n_Equal(number a, number b, const coeffs r)
TRUE iff &#39;a&#39; and &#39;b&#39; represent the same number; they may have different representations.
Definition: coeffs.h:464
int l
Definition: cfEzgcd.cc:94

§ solveAx()

number solveAx ( bigintmat A,
bigintmat b,
bigintmat x 
)

solve Ax=b*d. x needs to be pre-allocated to the same number of columns as b. the minimal denominator d is returned. Currently available for Z, Q and Z/nZ (and possibly for all fields: d=1 there) Beware that the internal functions can find the kernel as well - but the interface is lacking.

Definition at line 2440 of file bigintmat.cc.

2441 {
2442 #if 0
2443  PrintS("Solve Ax=b for A=\n");
2444  A->Print();
2445  PrintS("\nb = \n");
2446  b->Print();
2447  PrintS("\nx = \n");
2448  x->Print();
2449  PrintLn();
2450 #endif
2451 
2452  coeffs R = A->basecoeffs();
2453  assume (R == b->basecoeffs());
2454  assume (R == x->basecoeffs());
2455  assume ((x->cols() == b->cols()) && (x->rows() == A->cols()) && (A->rows() == b->rows()));
2456 
2457  switch (getCoeffType(R))
2458  {
2459  #ifdef HAVE_RINGS
2460  case n_Z:
2461  return solveAx_dixon(A, b, x, NULL);
2462  case n_Zn:
2463  case n_Znm:
2464  case n_Z2m:
2465  return solveAx_howell(A, b, x, NULL);
2466  #endif
2467  case n_Zp:
2468  case n_Q:
2469  case n_GF:
2470  case n_algExt:
2471  case n_transExt:
2472  WarnS("have field, should use Gauss or better");
2473  break;
2474  default:
2475  if (R->cfXExtGcd && R->cfAnn)
2476  { //assume it's Euclidean
2477  return solveAx_howell(A, b, x, NULL);
2478  }
2479  WerrorS("have no solve algorithm");
2480  break;
2481  }
2482  return NULL;
2483 }
static number solveAx_dixon(bigintmat *A, bigintmat *B, bigintmat *x, bigintmat *kern)
Definition: bigintmat.cc:2118
void PrintLn()
Definition: reporter.cc:310
only used if HAVE_RINGS is defined
Definition: coeffs.h:44
only used if HAVE_RINGS is defined
Definition: coeffs.h:46
used for all transcendental extensions, i.e., the top-most extension in an extension tower is transce...
Definition: coeffs.h:39
int rows() const
Definition: bigintmat.h:146
rational (GMP) numbers
Definition: coeffs.h:31
{p < 2^31}
Definition: coeffs.h:30
void WerrorS(const char *s)
Definition: feFopen.cc:24
#define WarnS
Definition: emacs.cc:81
only used if HAVE_RINGS is defined
Definition: coeffs.h:45
#define assume(x)
Definition: mod2.h:403
The main handler for Singular numbers which are suitable for Singular polynomials.
const ring R
Definition: DebugPrint.cc:36
int cols() const
Definition: bigintmat.h:145
only used if HAVE_RINGS is defined
Definition: coeffs.h:43
void PrintS(const char *s)
Definition: reporter.cc:284
static number solveAx_howell(bigintmat *A, bigintmat *b, bigintmat *x, bigintmat *kern)
Definition: bigintmat.cc:2308
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425
void Print()
IO: simply prints the matrix to the current output (screen?)
Definition: bigintmat.cc:446
#define NULL
Definition: omList.c:10
{p^n < 2^16}
Definition: coeffs.h:33
used for all algebraic extensions, i.e., the top-most extension in an extension tower is algebraic ...
Definition: coeffs.h:36
coeffs basecoeffs() const
Definition: bigintmat.h:147