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

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

Definition at line 136 of file bigintmat.h.

Function Documentation

intvec* bim2iv ( bigintmat b)

Definition at line 341 of file bigintmat.cc.

342 {
343  intvec * iv = new intvec(b->rows(), b->cols(), 0);
344  for (int i=0; i<(b->rows())*(b->cols()); i++)
345  (*iv)[i] = n_Int((*b)[i], b->basecoeffs()); // Geht das so?
346  return iv;
347 }
Definition: intvec.h:16
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:548
int i
Definition: cfEzgcd.cc:123
int cols() const
Definition: bigintmat.h:147
int rows() const
Definition: bigintmat.h:148
coeffs basecoeffs() const
Definition: bigintmat.h:149
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 180 of file bigintmat.cc.

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

Definition at line 197 of file bigintmat.cc.

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

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

Definition at line 1706 of file bigintmat.cc.

1707 {
1708  coeffs cold = a->basecoeffs();
1709  bigintmat *b = new bigintmat(a->rows(), a->cols(), cnew);
1710  // Erzeugt Karte von alten coeffs nach neuen
1711  nMapFunc f = n_SetMap(cold, cnew);
1712  number t1;
1713  number t2;
1714  // apply map to all entries.
1715  for (int i=1; i<=a->rows(); i++)
1716  {
1717  for (int j=1; j<=a->cols(); j++)
1718  {
1719  t1 = a->get(i, j);
1720  t2 = f(t1, cold, cnew);
1721  b->set(i, j, t2);
1722  n_Delete(&t1, cold);
1723  n_Delete(&t2, cnew);
1724  }
1725  }
1726  return b;
1727 }
Matrices of numbers.
Definition: bigintmat.h:51
f
Definition: cfModGcd.cc:4022
void set(int i, int j, number n, const coeffs C=NULL)
replace an entry with a copy (delete old + copy new!). NOTE: starts at [1,1]
Definition: bigintmat.cc:93
int j
Definition: myNF.cc:70
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:72
int i
Definition: cfEzgcd.cc:123
static FORCE_INLINE nMapFunc n_SetMap(const coeffs src, const coeffs dst)
set the mapping function pointers for translating numbers from src to dst
Definition: coeffs.h:720
int cols() const
Definition: bigintmat.h:147
int rows() const
Definition: bigintmat.h:148
coeffs basecoeffs() const
Definition: bigintmat.h:149
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:456
const poly b
Definition: syzextra.cc:213
number get(int i, int j) const
get a copy of an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:117
bigintmat* bimCopy ( const bigintmat b)

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

Definition at line 405 of file bigintmat.cc.

406 {
407  if (b == NULL)
408  return NULL;
409 
410  return new bigintmat(b);
411 }
Matrices of numbers.
Definition: bigintmat.h:51
#define NULL
Definition: omList.c:10
bigintmat* bimMult ( bigintmat a,
bigintmat b 
)

Definition at line 253 of file bigintmat.cc.

254 {
255  const int ca = a->cols();
256  const int cb = b->cols();
257 
258  const int ra = a->rows();
259  const int rb = b->rows();
260 
261  if (ca != rb)
262  {
263 #ifndef SING_NDEBUG
264  Werror("wrong bigintmat sizes at multiplication a * b: acols: %d != brows: %d\n", ca, rb);
265 #endif
266  return NULL;
267  }
268 
269  assume (ca == rb);
270 
271  if (a->basecoeffs() != b->basecoeffs()) { return NULL; }
272 
273  const coeffs basecoeffs = a->basecoeffs();
274 
275  int i, j, k;
276 
277  number sum;
278 
279  bigintmat * bim = new bigintmat(ra, cb, basecoeffs);
280 
281  for (i=1; i<=ra; i++)
282  for (j=1; j<=cb; j++)
283  {
284  sum = n_Init(0, basecoeffs);
285 
286  for (k=1; k<=ca; k++)
287  {
288  number prod = n_Mult( BIMATELEM(*a, i, k), BIMATELEM(*b, k, j), basecoeffs);
289 
290  number sum2 = n_Add(sum, prod, basecoeffs); // no inplace add :(
291 
292  n_Delete(&sum, basecoeffs); n_Delete(&prod, basecoeffs);
293 
294  sum = sum2;
295  }
296  bim->rawset(i, j, sum, basecoeffs);
297  }
298  return bim;
299 }
Matrices of numbers.
Definition: bigintmat.h:51
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition: coeffs.h:539
int k
Definition: cfEzgcd.cc:93
void rawset(int i, number n, const coeffs C=NULL)
replace an entry with the given number n (only delete old). NOTE: starts at [0]. Should be named set_...
Definition: bigintmat.h:199
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of &#39;a&#39; and &#39;b&#39;, i.e., a*b
Definition: coeffs.h:635
int j
Definition: myNF.cc:70
#define assume(x)
Definition: mod2.h:405
The main handler for Singular numbers which are suitable for Singular polynomials.
static FORCE_INLINE number n_Add(number a, number b, const coeffs r)
return the sum of &#39;a&#39; and &#39;b&#39;, i.e., a+b
Definition: coeffs.h:655
int i
Definition: cfEzgcd.cc:123
int cols() const
Definition: bigintmat.h:147
#define BIMATELEM(M, I, J)
Definition: bigintmat.h:136
int rows() const
Definition: bigintmat.h:148
#define NULL
Definition: omList.c:10
fq_nmod_poly_t prod
Definition: facHensel.cc:95
coeffs basecoeffs() const
Definition: bigintmat.h:149
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:456
void Werror(const char *fmt,...)
Definition: reporter.cc:199
bigintmat* bimMult ( bigintmat a,
int  b 
)

Definition at line 301 of file bigintmat.cc.

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

Definition at line 320 of file bigintmat.cc.

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

Multipliziert Matrix a und b und speichert Ergebnis in c.

Definition at line 1834 of file bigintmat.cc.

1835 {
1836  if (!nCoeffs_are_equal(a->basecoeffs(), b->basecoeffs())) {
1837  Werror("Error in bimMult. Coeffs do not agree!");
1838  return;
1839  }
1840  if ((a->rows() != c->rows()) || (b->cols() != c->cols()) || (a->cols() != b->rows())) {
1841  Werror("Error in bimMult. Dimensions do not agree!");
1842  return;
1843  }
1844  bigintmat *tmp = bimMult(a, b);
1845  c->copy(tmp);
1846 
1847  delete tmp;
1848 }
Matrices of numbers.
Definition: bigintmat.h:51
bigintmat * bimMult(bigintmat *a, bigintmat *b)
Definition: bigintmat.cc:253
int cols() const
Definition: bigintmat.h:147
int rows() const
Definition: bigintmat.h:148
coeffs basecoeffs() const
Definition: bigintmat.h:149
bool copy(bigintmat *b)
Kopiert Einträge von b auf Bigintmat.
Definition: bigintmat.cc:1178
void Werror(const char *fmt,...)
Definition: reporter.cc:199
bool nCoeffs_are_equal(coeffs r, coeffs s)
Definition: bigintmat.cc:2473
bigintmat* bimSub ( bigintmat a,
bigintmat b 
)

Definition at line 216 of file bigintmat.cc.

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

Definition at line 234 of file bigintmat.cc.

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

Definition at line 2323 of file bigintmat.cc.

2324 {
2325  bigintmat * t, *s, *a=A;
2326  coeffs R = a->basecoeffs();
2327  if (T) {
2328  *T = new bigintmat(a->cols(), a->cols(), R),
2329  (*T)->one();
2330  t = new bigintmat(*T);
2331  } else {
2332  t = *T;
2333  }
2334 
2335  if (S) {
2336  *S = new bigintmat(a->rows(), a->rows(), R);
2337  (*S)->one();
2338  s = new bigintmat(*S);
2339  } else {
2340  s = *S;
2341  }
2342 
2343  int flip=0;
2344  do {
2345  bigintmat * x, *X;
2346  if (flip) {
2347  x = s;
2348  X = *S;
2349  } else {
2350  x = t;
2351  X = *T;
2352  }
2353 
2354  if (x) {
2355  x->one();
2356  bigintmat * r = new bigintmat(a->rows()+a->cols(), a->cols(), R);
2357  bigintmat * rw = new bigintmat(1, a->cols(), R);
2358  for(int i=0; i<a->cols(); i++) {
2359  x->getrow(i+1, rw);
2360  r->setrow(i+1, rw);
2361  }
2362  for (int i=0; i<a->rows(); i++) {
2363  a->getrow(i+1, rw);
2364  r->setrow(i+a->cols()+1, rw);
2365  }
2366  r->hnf();
2367  for(int i=0; i<a->cols(); i++) {
2368  r->getrow(i+1, rw);
2369  x->setrow(i+1, rw);
2370  }
2371  for(int i=0; i<a->rows(); i++) {
2372  r->getrow(i+a->cols()+1, rw);
2373  a->setrow(i+1, rw);
2374  }
2375  delete rw;
2376  delete r;
2377 
2378 #if 0
2379  Print("X: %ld\n", X);
2380  X->Print();
2381  Print("\nx: %ld\n", x);
2382  x->Print();
2383 #endif
2384  bimMult(X, x, X);
2385 #if 0
2386  Print("\n2:X: %ld %ld %ld\n", X, *S, *T);
2387  X->Print();
2388  Print("\n2:x: %ld\n", x);
2389  x->Print();
2390  Print("\n");
2391 #endif
2392  } else {
2393  a->hnf();
2394  }
2395 
2396  int diag = 1;
2397  for(int i=a->rows(); diag && i>0; i--) {
2398  for(int j=a->cols(); j>0; j--) {
2399  if ((a->rows()-i)!=(a->cols()-j) && !n_IsZero(a->view(i, j), R)) {
2400  diag = 0;
2401  break;
2402  }
2403  }
2404  }
2405 #if 0
2406  Print("Diag ? %d\n", diag);
2407  a->Print();
2408  Print("\n");
2409 #endif
2410  if (diag) break;
2411 
2412  a = a->transpose(); // leaks - I need to write inpTranspose
2413  flip = 1-flip;
2414  } while (1);
2415  if (flip)
2416  a = a->transpose();
2417 
2418  if (S) *S = (*S)->transpose();
2419  if (s) delete s;
2420  if (t) delete t;
2421  A->copy(a);
2422 }
bigintmat * transpose()
Definition: bigintmat.cc:38
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:125
const CanonicalForm int s
Definition: facAbsFact.cc:55
#define Print
Definition: emacs.cc:83
void getrow(int i, bigintmat *a)
Schreibt i-te Zeile in Vektor (Matrix) a.
Definition: bigintmat.cc:781
Matrices of numbers.
Definition: bigintmat.h:51
void setrow(int i, bigintmat *m)
Setzt i-te Zeile gleich übergebenem Vektor (Matrix) m.
Definition: bigintmat.cc:841
const ring r
Definition: syzextra.cc:208
int j
Definition: myNF.cc:70
bigintmat * bimMult(bigintmat *a, bigintmat *b)
Definition: bigintmat.cc:253
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
void hnf()
transforms INPLACE to HNF
Definition: bigintmat.cc:1562
int i
Definition: cfEzgcd.cc:123
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the zero element.
Definition: coeffs.h:465
int cols() const
Definition: bigintmat.h:147
void Print()
IO: simply prints the matrix to the current output (screen?)
Definition: bigintmat.cc:440
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
int rows() const
Definition: bigintmat.h:148
coeffs basecoeffs() const
Definition: bigintmat.h:149
Variable x
Definition: cfModGcd.cc:4023
static jList * T
Definition: janet.cc:37
void one()
Macht Matrix (Falls quadratisch) zu Einheitsmatrix.
Definition: bigintmat.cc:1238
bigintmat* iv2bim ( intvec b,
const coeffs  C 
)

Definition at line 349 of file bigintmat.cc.

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

2428  {
2429 #if 0
2430  Print("Kernel of ");
2431  a->Print();
2432  Print(" modulo ");
2433  n_Print(p, q);
2434  Print("\n");
2435 #endif
2436 
2437  coeffs coe = numbercoeffs(p, q);
2438  bigintmat *m = bimChangeCoeff(a, coe), *U, *V;
2439  diagonalForm(m, &U, &V);
2440 #if 0
2441  Print("\ndiag form: ");
2442  m->Print();
2443  Print("\nU:\n");
2444  U->Print();
2445  Print("\nV:\n");
2446  V->Print();
2447  Print("\n");
2448 #endif
2449 
2450  int rg = 0;
2451 #undef MIN
2452 #define MIN(a,b) (a < b ? a : b)
2453  for(rg=0; rg<MIN(m->rows(), m->cols()) && !n_IsZero(m->view(m->rows()-rg,m->cols()-rg), coe); rg++);
2454 
2455 #undef MAX
2456 #define MAX(a,b) (a > b ? a : b)
2457  bigintmat * k = new bigintmat(m->cols(), m->rows(), coe);
2458  for(int i=0; i<rg; i++) {
2459  number A = n_Ann(m->view(m->rows()-i, m->cols()-i), coe);
2460  k->set(m->cols()-i, i+1, A);
2461  n_Delete(&A, coe);
2462  }
2463  for(int i=rg; i<m->cols(); i++) {
2464  k->set(m->cols()-i, i+1-rg, n_Init(1, coe));
2465  }
2466  bimMult(V, k, k);
2467  c->copy(bimChangeCoeff(k, q));
2468  return c->cols();
2469 }
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:125
#define Print
Definition: emacs.cc:83
return P p
Definition: myNF.cc:203
Matrices of numbers.
Definition: bigintmat.h:51
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition: coeffs.h:539
int 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:700
void set(int i, int j, number n, const coeffs C=NULL)
replace an entry with a copy (delete old + copy new!). NOTE: starts at [1,1]
Definition: bigintmat.cc:93
static coeffs numbercoeffs(number n, coeffs c)
create Z/nA of type n_Zn
Definition: bigintmat.cc:22
bigintmat * bimMult(bigintmat *a, bigintmat *b)
Definition: bigintmat.cc:253
The main handler for Singular numbers which are suitable for Singular polynomials.
#define A
Definition: sirandom.c:23
int m
Definition: cfEzgcd.cc:119
int i
Definition: cfEzgcd.cc:123
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the zero element.
Definition: coeffs.h:465
bigintmat * bimChangeCoeff(bigintmat *a, coeffs cnew)
Liefert Kopier von Matrix a zurück, mit coeffs cnew statt den ursprünglichen.
Definition: bigintmat.cc:1706
int cols() const
Definition: bigintmat.h:147
void diagonalForm(bigintmat *A, bigintmat **S, bigintmat **T)
Definition: bigintmat.cc:2323
void Print()
IO: simply prints the matrix to the current output (screen?)
Definition: bigintmat.cc:440
int rows() const
Definition: bigintmat.h:148
bool copy(bigintmat *b)
Kopiert Einträge von b auf Bigintmat.
Definition: bigintmat.cc:1178
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:456
void n_Print(number &a, const coeffs r)
print a number (BEWARE of string buffers!) mostly for debugging
Definition: numbers.cc:549
bool nCoeffs_are_equal ( coeffs  r,
coeffs  s 
)

Definition at line 2473 of file bigintmat.cc.

2473  {
2474  if ((r == NULL) || (s == NULL))
2475  return false;
2476  if ((getCoeffType(r)==n_Z) && (getCoeffType(s)==n_Z))
2477  return true;
2478  if ((getCoeffType(r)==n_Zp) && (getCoeffType(s)==n_Zp)) {
2479  if (r->ch == s->ch)
2480  return true;
2481  else
2482  return false;
2483  }
2484  // n_Zn stimmt wahrscheinlich noch nicht
2485  if ((getCoeffType(r)==n_Zn) && (getCoeffType(s)==n_Zn)) {
2486  if (r->ch == s->ch)
2487  return true;
2488  else
2489  return false;
2490  }
2491  if ((getCoeffType(r)==n_Q) && (getCoeffType(s)==n_Q))
2492  return true;
2493  // FALL n_Zn FEHLT NOCH!
2494  //if ((getCoeffType(r)==n_Zn) && (getCoeffType(s)==n_Zn))
2495  return false;
2496 }
only used if HAVE_RINGS is defined: ?
Definition: coeffs.h:43
rational (GMP) numbers
Definition: coeffs.h:31
{p < 2^31}
Definition: coeffs.h:30
only used if HAVE_RINGS is defined: ?
Definition: coeffs.h:42
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:422
#define NULL
Definition: omList.c:10
bool operator!= ( const bigintmat lhr,
const bigintmat rhr 
)

Definition at line 174 of file bigintmat.cc.

175 {
176  return !(lhr==rhr);
177 }
bool operator== ( const bigintmat lhr,
const bigintmat rhr 
)

Definition at line 157 of file bigintmat.cc.

158 {
159  if (&lhr == &rhr) { return true; }
160  if (lhr.cols() != rhr.cols()) { return false; }
161  if (lhr.rows() != rhr.rows()) { return false; }
162  if (lhr.basecoeffs() != rhr.basecoeffs()) { return false; }
163 
164  const int l = (lhr.rows())*(lhr.cols());
165 
166  for (int i=0; i < l; i++)
167  {
168  if (!n_Equal(lhr[i], rhr[i], lhr.basecoeffs())) { return false; }
169  }
170 
171  return true;
172 }
int i
Definition: cfEzgcd.cc:123
int cols() const
Definition: bigintmat.h:147
int rows() const
Definition: bigintmat.h:148
coeffs basecoeffs() const
Definition: bigintmat.h:149
static FORCE_INLINE BOOLEAN n_Equal(number a, number b, const coeffs r)
TRUE iff &#39;a&#39; and &#39;b&#39; represent the same number; they may have different representations.
Definition: coeffs.h:461
int l
Definition: cfEzgcd.cc:94
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 2281 of file bigintmat.cc.

2281  {
2282 #if 0
2283  Print("Solve Ax=b for A=\n");
2284  A->Print();
2285  Print("\nb = \n");
2286  b->Print();
2287  Print("\nx = \n");
2288  x->Print();
2289  Print("\n");
2290 #endif
2291 
2292  coeffs R = A->basecoeffs();
2293  assume (R == b->basecoeffs());
2294  assume (R == x->basecoeffs());
2295  assume ((x->cols() == b->cols()) && (x->rows() == A->cols()) && (A->rows() == b->rows()));
2296 
2297  switch (getCoeffType(R))
2298  {
2299  #ifdef HAVE_RINGS
2300  case n_Z:
2301  return solveAx_dixon(A, b, x, NULL);
2302  case n_Zn:
2303  case n_Znm:
2304  case n_Z2m:
2305  return solveAx_howell(A, b, x, NULL);
2306  #endif
2307  case n_Zp:
2308  case n_Q:
2309  case n_GF:
2310  case n_algExt:
2311  case n_transExt:
2312  Warn("have field, should use Gauss or better");
2313  default:
2314  if (R->cfXExtGcd && R->cfAnn)
2315  { //assume it's Euclidean
2316  return solveAx_howell(A, b, x, NULL);
2317  }
2318  Werror("have no solve algorithm");
2319  }
2320  return NULL;
2321 }
static number solveAx_dixon(bigintmat *A, bigintmat *B, bigintmat *x, bigintmat *kern)
Definition: bigintmat.cc:1990
#define Print
Definition: emacs.cc:83
only used if HAVE_RINGS is defined: ?
Definition: coeffs.h:43
only used if HAVE_RINGS is defined: ?
Definition: coeffs.h:45
used for all transcendental extensions, i.e., the top-most extension in an extension tower is transce...
Definition: coeffs.h:38
rational (GMP) numbers
Definition: coeffs.h:31
{p < 2^31}
Definition: coeffs.h:30
only used if HAVE_RINGS is defined: ?
Definition: coeffs.h:44
#define assume(x)
Definition: mod2.h:405
The main handler for Singular numbers which are suitable for Singular polynomials.
const ring R
Definition: DebugPrint.cc:36
only used if HAVE_RINGS is defined: ?
Definition: coeffs.h:42
static number solveAx_howell(bigintmat *A, bigintmat *b, bigintmat *x, bigintmat *kern)
Definition: bigintmat.cc:2168
int cols() const
Definition: bigintmat.h:147
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:422
void Print()
IO: simply prints the matrix to the current output (screen?)
Definition: bigintmat.cc:440
int rows() const
Definition: bigintmat.h:148
#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:35
coeffs basecoeffs() const
Definition: bigintmat.h:149
void Werror(const char *fmt,...)
Definition: reporter.cc:199
#define Warn
Definition: emacs.cc:80