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

343 {
344  intvec * iv = new intvec(b->rows(), b->cols(), 0);
345  for (int i=0; i<(b->rows())*(b->cols()); i++)
346  (*iv)[i] = n_Int((*b)[i], b->basecoeffs()); // Geht das so?
347  return iv;
348 }
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 1812 of file bigintmat.cc.

1813 {
1814  coeffs cold = a->basecoeffs();
1815  bigintmat *b = new bigintmat(a->rows(), a->cols(), cnew);
1816  // Erzeugt Karte von alten coeffs nach neuen
1817  nMapFunc f = n_SetMap(cold, cnew);
1818  number t1;
1819  number t2;
1820  // apply map to all entries.
1821  for (int i=1; i<=a->rows(); i++)
1822  {
1823  for (int j=1; j<=a->cols(); j++)
1824  {
1825  t1 = a->get(i, j);
1826  t2 = f(t1, cold, cnew);
1827  b->set(i, j, t2);
1828  n_Delete(&t1, cold);
1829  n_Delete(&t2, cnew);
1830  }
1831  }
1832  return b;
1833 }
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:9
int i
Definition: cfEzgcd.cc:123
static FORCE_INLINE nMapFunc n_SetMap(const coeffs src, const coeffs dst)
set the mapping function pointers for translating numbers from src to dst
Definition: coeffs.h:725
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 406 of file bigintmat.cc.

407 {
408  if (b == NULL)
409  return NULL;
410 
411  return new bigintmat(b);
412 }
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  n_InpAdd(sum, prod, basecoeffs);
294 
295  n_Delete(&prod, basecoeffs);
296  }
297  bim->rawset(i, j, sum, basecoeffs);
298  }
299  return bim;
300 }
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
static FORCE_INLINE void n_InpAdd(number &a, number b, const coeffs r)
addition of &#39;a&#39; and &#39;b&#39;; replacement of &#39;a&#39; by the sum a+b
Definition: coeffs.h:650
void rawset(int i, number n, const coeffs C=NULL)
replace an entry with the given number n (only delete old). NOTE: starts at [0]. Should be named set_...
Definition: bigintmat.h:197
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of &#39;a&#39; and &#39;b&#39;, i.e., a*b
Definition: coeffs.h:640
int j
Definition: myNF.cc:70
#define assume(x)
Definition: mod2.h:394
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 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 302 of file bigintmat.cc.

303 {
304 
305  const int mn = a->rows()*a->cols();
306 
307  const coeffs basecoeffs = a->basecoeffs();
308  number bb=n_Init(b,basecoeffs);
309 
310  int i;
311 
312  bigintmat * bim = new bigintmat(a->rows(),a->cols() , basecoeffs);
313 
314  for (i=0; i<mn; i++)
315  bim->rawset(i, n_Mult((*a)[i], bb, basecoeffs), basecoeffs);
316 
317  n_Delete(&bb,basecoeffs);
318  return bim;
319 }
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 321 of file bigintmat.cc.

322 {
323  if (cf!=a->basecoeffs()) return NULL;
324 
325  const int mn = a->rows()*a->cols();
326 
327  const coeffs basecoeffs = a->basecoeffs();
328 
329  int i;
330 
331  bigintmat * bim = new bigintmat(a->rows(),a->cols() , basecoeffs);
332 
333  for (i=0; i<mn; i++)
334  bim->rawset(i, n_Mult((*a)[i], b, basecoeffs), basecoeffs);
335 
336  return bim;
337 }
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 1940 of file bigintmat.cc.

1941 {
1942  if (!nCoeffs_are_equal(a->basecoeffs(), b->basecoeffs()))
1943  {
1944  WerrorS("Error in bimMult. Coeffs do not agree!");
1945  return;
1946  }
1947  if ((a->rows() != c->rows()) || (b->cols() != c->cols()) || (a->cols() != b->rows()))
1948  {
1949  WerrorS("Error in bimMult. Dimensions do not agree!");
1950  return;
1951  }
1952  bigintmat *tmp = bimMult(a, b);
1953  c->copy(tmp);
1954 
1955  delete tmp;
1956 }
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:1267
bool nCoeffs_are_equal(coeffs r, coeffs s)
Definition: bigintmat.cc:2653

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

2484 {
2485  bigintmat * t, *s, *a=A;
2486  coeffs R = a->basecoeffs();
2487  if (T)
2488  {
2489  *T = new bigintmat(a->cols(), a->cols(), R),
2490  (*T)->one();
2491  t = new bigintmat(*T);
2492  }
2493  else
2494  {
2495  t = *T;
2496  }
2497 
2498  if (S)
2499  {
2500  *S = new bigintmat(a->rows(), a->rows(), R);
2501  (*S)->one();
2502  s = new bigintmat(*S);
2503  }
2504  else
2505  {
2506  s = *S;
2507  }
2508 
2509  int flip=0;
2510  do
2511  {
2512  bigintmat * x, *X;
2513  if (flip)
2514  {
2515  x = s;
2516  X = *S;
2517  }
2518  else
2519  {
2520  x = t;
2521  X = *T;
2522  }
2523 
2524  if (x)
2525  {
2526  x->one();
2527  bigintmat * r = new bigintmat(a->rows()+a->cols(), a->cols(), R);
2528  bigintmat * rw = new bigintmat(1, a->cols(), R);
2529  for(int i=0; i<a->cols(); i++)
2530  {
2531  x->getrow(i+1, rw);
2532  r->setrow(i+1, rw);
2533  }
2534  for (int i=0; i<a->rows(); i++)
2535  {
2536  a->getrow(i+1, rw);
2537  r->setrow(i+a->cols()+1, rw);
2538  }
2539  r->hnf();
2540  for(int i=0; i<a->cols(); i++)
2541  {
2542  r->getrow(i+1, rw);
2543  x->setrow(i+1, rw);
2544  }
2545  for(int i=0; i<a->rows(); i++)
2546  {
2547  r->getrow(i+a->cols()+1, rw);
2548  a->setrow(i+1, rw);
2549  }
2550  delete rw;
2551  delete r;
2552 
2553 #if 0
2554  Print("X: %ld\n", X);
2555  X->Print();
2556  Print("\nx: %ld\n", x);
2557  x->Print();
2558 #endif
2559  bimMult(X, x, X);
2560 #if 0
2561  Print("\n2:X: %ld %ld %ld\n", X, *S, *T);
2562  X->Print();
2563  Print("\n2:x: %ld\n", x);
2564  x->Print();
2565  PrintLn();
2566 #endif
2567  }
2568  else
2569  {
2570  a->hnf();
2571  }
2572 
2573  int diag = 1;
2574  for(int i=a->rows(); diag && i>0; i--)
2575  {
2576  for(int j=a->cols(); j>0; j--)
2577  {
2578  if ((a->rows()-i)!=(a->cols()-j) && !n_IsZero(a->view(i, j), R))
2579  {
2580  diag = 0;
2581  break;
2582  }
2583  }
2584  }
2585 #if 0
2586  PrintS("Diag ? %d\n", diag);
2587  a->Print();
2588  PrintLn();
2589 #endif
2590  if (diag) break;
2591 
2592  a = a->transpose(); // leaks - I need to write inpTranspose
2593  flip = 1-flip;
2594  } while (1);
2595  if (flip)
2596  a = a->transpose();
2597 
2598  if (S) *S = (*S)->transpose();
2599  if (s) delete s;
2600  if (t) delete t;
2601  A->copy(a);
2602 }
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:799
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:868
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:1668
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:444
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:18
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:1333

◆ iv2bim()

bigintmat* iv2bim ( intvec b,
const coeffs  C 
)

Definition at line 350 of file bigintmat.cc.

351 {
352  const int l = (b->rows())*(b->cols());
353  bigintmat * bim = new bigintmat(b->rows(), b->cols(), C);
354 
355  for (int i=0; i < l; i++)
356  bim->rawset(i, n_Init((*b)[i], C), C);
357 
358  return bim;
359 }
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 2608 of file bigintmat.cc.

2609 {
2610 #if 0
2611  PrintS("Kernel of ");
2612  a->Print();
2613  PrintS(" modulo ");
2614  n_Print(p, q);
2615  PrintLn();
2616 #endif
2617 
2618  coeffs coe = numbercoeffs(p, q);
2619  bigintmat *m = bimChangeCoeff(a, coe), *U, *V;
2620  diagonalForm(m, &U, &V);
2621 #if 0
2622  PrintS("\ndiag form: ");
2623  m->Print();
2624  PrintS("\nU:\n");
2625  U->Print();
2626  PrintS("\nV:\n");
2627  V->Print();
2628  PrintLn();
2629 #endif
2630 
2631  int rg = 0;
2632 #undef MIN
2633 #define MIN(a,b) (a < b ? a : b)
2634  for(rg=0; rg<MIN(m->rows(), m->cols()) && !n_IsZero(m->view(m->rows()-rg,m->cols()-rg), coe); rg++);
2635 
2636  bigintmat * k = new bigintmat(m->cols(), m->rows(), coe);
2637  for(int i=0; i<rg; i++)
2638  {
2639  number A = n_Ann(m->view(m->rows()-i, m->cols()-i), coe);
2640  k->set(m->cols()-i, i+1, A);
2641  n_Delete(&A, coe);
2642  }
2643  for(int i=rg; i<m->cols(); i++)
2644  {
2645  k->set(m->cols()-i, i+1-rg, n_Init(1, coe));
2646  }
2647  bimMult(V, k, k);
2648  c->copy(bimChangeCoeff(k, q));
2649  return c->cols();
2650 }
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:1812
void diagonalForm(bigintmat *A, bigintmat **S, bigintmat **T)
Definition: bigintmat.cc:2483
void Print()
IO: simply prints the matrix to the current output (screen?)
Definition: bigintmat.cc:444
bool copy(bigintmat *b)
Kopiert Einträge von b auf Bigintmat.
Definition: bigintmat.cc:1267
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:576

◆ nCoeffs_are_equal()

bool nCoeffs_are_equal ( coeffs  r,
coeffs  s 
)

Definition at line 2653 of file bigintmat.cc.

2654 {
2655  if ((r == NULL) || (s == NULL))
2656  return false;
2657  if (r == s)
2658  return true;
2659  if ((getCoeffType(r)==n_Z) && (getCoeffType(s)==n_Z))
2660  return true;
2661  if ((getCoeffType(r)==n_Zp) && (getCoeffType(s)==n_Zp))
2662  {
2663  if (r->ch == s->ch)
2664  return true;
2665  else
2666  return false;
2667  }
2668  // n_Zn stimmt wahrscheinlich noch nicht
2669  if ((getCoeffType(r)==n_Zn) && (getCoeffType(s)==n_Zn))
2670  {
2671  if (r->ch == s->ch)
2672  return true;
2673  else
2674  return false;
2675  }
2676  if ((getCoeffType(r)==n_Q) && (getCoeffType(s)==n_Q))
2677  return true;
2678  // FALL n_Zn FEHLT NOCH!
2679  //if ((getCoeffType(r)==n_Zn) && (getCoeffType(s)==n_Zn))
2680  return false;
2681 }
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 2438 of file bigintmat.cc.

2439 {
2440 #if 0
2441  PrintS("Solve Ax=b for A=\n");
2442  A->Print();
2443  PrintS("\nb = \n");
2444  b->Print();
2445  PrintS("\nx = \n");
2446  x->Print();
2447  PrintLn();
2448 #endif
2449 
2450  coeffs R = A->basecoeffs();
2451  assume (R == b->basecoeffs());
2452  assume (R == x->basecoeffs());
2453  assume ((x->cols() == b->cols()) && (x->rows() == A->cols()) && (A->rows() == b->rows()));
2454 
2455  switch (getCoeffType(R))
2456  {
2457  #ifdef HAVE_RINGS
2458  case n_Z:
2459  return solveAx_dixon(A, b, x, NULL);
2460  case n_Zn:
2461  case n_Znm:
2462  case n_Z2m:
2463  return solveAx_howell(A, b, x, NULL);
2464  #endif
2465  case n_Zp:
2466  case n_Q:
2467  case n_GF:
2468  case n_algExt:
2469  case n_transExt:
2470  WarnS("have field, should use Gauss or better");
2471  break;
2472  default:
2473  if (R->cfXExtGcd && R->cfAnn)
2474  { //assume it's Euclidean
2475  return solveAx_howell(A, b, x, NULL);
2476  }
2477  WerrorS("have no solve algorithm");
2478  break;
2479  }
2480  return NULL;
2481 }
static number solveAx_dixon(bigintmat *A, bigintmat *B, bigintmat *x, bigintmat *kern)
Definition: bigintmat.cc:2116
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:394
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:2306
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:444
#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