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 117 of file bigintmat.h.

Function Documentation

intvec* bim2iv ( bigintmat b)

Definition at line 339 of file bigintmat.cc.

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

179 {
180  if (a->cols() != b->cols()) return NULL;
181  if (a->rows() != b->rows()) return NULL;
182  if (a->basecoeffs() != b->basecoeffs()) { return NULL; }
183 
184  const coeffs basecoeffs = a->basecoeffs();
185 
186  int i;
187 
188  bigintmat * bim = new bigintmat(a->rows(), a->cols(), basecoeffs);
189 
190  for (i=a->rows()*a->cols()-1;i>=0; i--)
191  bim->rawset(i, n_Add((*a)[i], (*b)[i], basecoeffs), basecoeffs);
192 
193  return bim;
194 }
Matrices of numbers.
Definition: bigintmat.h:32
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
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 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
bigintmat* bimAdd ( bigintmat a,
int  b 
)

Definition at line 195 of file bigintmat.cc.

196 {
197 
198  const int mn = a->rows()*a->cols();
199 
200  const coeffs basecoeffs = a->basecoeffs();
201  number bb=n_Init(b,basecoeffs);
202 
203  int i;
204 
205  bigintmat * bim = new bigintmat(a->rows(),a->cols() , basecoeffs);
206 
207  for (i=0; i<mn; i++)
208  bim->rawset(i, n_Add((*a)[i], bb, basecoeffs), basecoeffs);
209 
210  n_Delete(&bb,basecoeffs);
211  return bim;
212 }
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
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
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 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
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 1688 of file bigintmat.cc.

1689 {
1690  coeffs cold = a->basecoeffs();
1691  bigintmat *b = new bigintmat(a->rows(), a->cols(), cnew);
1692  // Erzeugt Karte von alten coeffs nach neuen
1693  nMapFunc f = n_SetMap(cold, cnew);
1694  number t1;
1695  number t2;
1696  // apply map to all entries.
1697  for (int i=1; i<=a->rows(); i++)
1698  {
1699  for (int j=1; j<=a->cols(); j++)
1700  {
1701  t1 = a->get(i, j);
1702  t2 = f(t1, cold, cnew);
1703  b->set(i, j, t2);
1704  n_Delete(&t1, cold);
1705  n_Delete(&t2, cnew);
1706  }
1707  }
1708  return b;
1709 }
Matrices of numbers.
Definition: bigintmat.h:32
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:91
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
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
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:115
bigintmat* bimCopy ( const bigintmat b)

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

Definition at line 403 of file bigintmat.cc.

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

Definition at line 251 of file bigintmat.cc.

252 {
253  const int ca = a->cols();
254  const int cb = b->cols();
255 
256  const int ra = a->rows();
257  const int rb = b->rows();
258 
259  if (ca != rb)
260  {
261 #ifndef SING_NDEBUG
262  Werror("wrong bigintmat sizes at multiplication a * b: acols: %d != brows: %d\n", ca, rb);
263 #endif
264  return NULL;
265  }
266 
267  assume (ca == rb);
268 
269  if (a->basecoeffs() != b->basecoeffs()) { return NULL; }
270 
271  const coeffs basecoeffs = a->basecoeffs();
272 
273  int i, j, k;
274 
275  number sum;
276 
277  bigintmat * bim = new bigintmat(ra, cb, basecoeffs);
278 
279  for (i=1; i<=ra; i++)
280  for (j=1; j<=cb; j++)
281  {
282  sum = n_Init(0, basecoeffs);
283 
284  for (k=1; k<=ca; k++)
285  {
286  number prod = n_Mult( BIMATELEM(*a, i, k), BIMATELEM(*b, k, j), basecoeffs);
287 
288  number sum2 = n_Add(sum, prod, basecoeffs); // no inplace add :(
289 
290  n_Delete(&sum, basecoeffs); n_Delete(&prod, basecoeffs);
291 
292  sum = sum2;
293  }
294  bim->rawset(i, j, sum, basecoeffs);
295  }
296  return bim;
297 }
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 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
#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 cols() const
Definition: bigintmat.h:128
#define BIMATELEM(M, I, J)
Definition: bigintmat.h:117
int rows() const
Definition: bigintmat.h:129
#define NULL
Definition: omList.c:10
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
void Werror(const char *fmt,...)
Definition: reporter.cc:199
bigintmat* bimMult ( bigintmat a,
int  b 
)

Definition at line 299 of file bigintmat.cc.

300 {
301 
302  const int mn = a->rows()*a->cols();
303 
304  const coeffs basecoeffs = a->basecoeffs();
305  number bb=n_Init(b,basecoeffs);
306 
307  int i;
308 
309  bigintmat * bim = new bigintmat(a->rows(),a->cols() , basecoeffs);
310 
311  for (i=0; i<mn; i++)
312  bim->rawset(i, n_Mult((*a)[i], bb, basecoeffs), basecoeffs);
313 
314  n_Delete(&bb,basecoeffs);
315  return bim;
316 }
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
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
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
const poly b
Definition: syzextra.cc:213
bigintmat* bimMult ( bigintmat a,
number  b,
const coeffs  cf 
)

Definition at line 318 of file bigintmat.cc.

319 {
320  if (cf!=a->basecoeffs()) return NULL;
321 
322  const int mn = a->rows()*a->cols();
323 
324  const coeffs basecoeffs = a->basecoeffs();
325 
326  int i;
327 
328  bigintmat * bim = new bigintmat(a->rows(),a->cols() , basecoeffs);
329 
330  for (i=0; i<mn; i++)
331  bim->rawset(i, n_Mult((*a)[i], b, basecoeffs), basecoeffs);
332 
333  return bim;
334 }
Matrices of numbers.
Definition: bigintmat.h:32
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
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
#define NULL
Definition: omList.c:10
coeffs basecoeffs() const
Definition: bigintmat.h:130
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 1818 of file bigintmat.cc.

1819 {
1820  if (!nCoeffs_are_equal(a->basecoeffs(), b->basecoeffs())) {
1821  Werror("Error in bimMult. Coeffs do not agree!");
1822  return;
1823  }
1824  if ((a->rows() != c->rows()) || (b->cols() != c->cols()) || (a->cols() != b->rows())) {
1825  Werror("Error in bimMult. Dimensions do not agree!");
1826  return;
1827  }
1828  bigintmat *tmp = bimMult(a, b);
1829  c->copy(tmp);
1830 
1831  delete tmp;
1832 }
Matrices of numbers.
Definition: bigintmat.h:32
bigintmat * bimMult(bigintmat *a, bigintmat *b)
Definition: bigintmat.cc:251
int cols() const
Definition: bigintmat.h:128
int rows() const
Definition: bigintmat.h:129
coeffs basecoeffs() const
Definition: bigintmat.h:130
bool copy(bigintmat *b)
Kopiert Einträge von b auf Bigintmat.
Definition: bigintmat.cc:1176
void Werror(const char *fmt,...)
Definition: reporter.cc:199
bool nCoeffs_are_equal(coeffs r, coeffs s)
Definition: bigintmat.cc:2449
bigintmat* bimSub ( bigintmat a,
bigintmat b 
)

Definition at line 214 of file bigintmat.cc.

215 {
216  if (a->cols() != b->cols()) return NULL;
217  if (a->rows() != b->rows()) return NULL;
218  if (a->basecoeffs() != b->basecoeffs()) { return NULL; }
219 
220  const coeffs basecoeffs = a->basecoeffs();
221 
222  int i;
223 
224  bigintmat * bim = new bigintmat(a->rows(), a->cols(), basecoeffs);
225 
226  for (i=a->rows()*a->cols()-1;i>=0; i--)
227  bim->rawset(i, n_Sub((*a)[i], (*b)[i], basecoeffs), basecoeffs);
228 
229  return bim;
230 }
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
Matrices of numbers.
Definition: bigintmat.h:32
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
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
#define NULL
Definition: omList.c:10
coeffs basecoeffs() const
Definition: bigintmat.h:130
bigintmat* bimSub ( bigintmat a,
int  b 
)

Definition at line 232 of file bigintmat.cc.

233 {
234  const int mn = a->rows()*a->cols();
235 
236  const coeffs basecoeffs = a->basecoeffs();
237  number bb=n_Init(b,basecoeffs);
238 
239  int i;
240 
241  bigintmat * bim = new bigintmat(a->rows(),a->cols() , basecoeffs);
242 
243  for (i=0; i<mn; i++)
244  bim->rawset(i, n_Sub((*a)[i], bb, basecoeffs), basecoeffs);
245 
246  n_Delete(&bb,basecoeffs);
247  return bim;
248 }
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
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
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
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
const poly b
Definition: syzextra.cc:213
void diagonalForm ( bigintmat a,
bigintmat **  b,
bigintmat **  c 
)

Definition at line 2301 of file bigintmat.cc.

2302 {
2303  bigintmat * t, *s, *a=A;
2304  coeffs R = a->basecoeffs();
2305  if (T) {
2306  *T = new bigintmat(a->cols(), a->cols(), R),
2307  (*T)->one();
2308  t = new bigintmat(*T);
2309  } else {
2310  t = *T;
2311  }
2312 
2313  if (S) {
2314  *S = new bigintmat(a->rows(), a->rows(), R);
2315  (*S)->one();
2316  s = new bigintmat(*S);
2317  } else {
2318  s = *S;
2319  }
2320 
2321  int flip=0;
2322  do {
2323  bigintmat * x, *X;
2324  if (flip) {
2325  x = s;
2326  X = *S;
2327  } else {
2328  x = t;
2329  X = *T;
2330  }
2331 
2332  if (x) {
2333  x->one();
2334  bigintmat * r = new bigintmat(a->rows()+a->cols(), a->cols(), R);
2335  bigintmat * rw = new bigintmat(1, a->cols(), R);
2336  for(int i=0; i<a->cols(); i++) {
2337  x->getrow(i+1, rw);
2338  r->setrow(i+1, rw);
2339  }
2340  for (int i=0; i<a->rows(); i++) {
2341  a->getrow(i+1, rw);
2342  r->setrow(i+a->cols()+1, rw);
2343  }
2344  r->hnf();
2345  for(int i=0; i<a->cols(); i++) {
2346  r->getrow(i+1, rw);
2347  x->setrow(i+1, rw);
2348  }
2349  for(int i=0; i<a->rows(); i++) {
2350  r->getrow(i+a->cols()+1, rw);
2351  a->setrow(i+1, rw);
2352  }
2353  delete rw;
2354  delete r;
2355 
2356 #if 0
2357  Print("X: %ld\n", X);
2358  X->Print();
2359  Print("\nx: %ld\n", x);
2360  x->Print();
2361 #endif
2362  bimMult(X, x, X);
2363 #if 0
2364  Print("\n2:X: %ld %ld %ld\n", X, *S, *T);
2365  X->Print();
2366  Print("\n2:x: %ld\n", x);
2367  x->Print();
2368  Print("\n");
2369 #endif
2370  } else {
2371  a->hnf();
2372  }
2373 
2374  int diag = 1;
2375  for(int i=a->rows(); diag && i>0; i--) {
2376  for(int j=a->cols(); j>0; j--) {
2377  if ((a->rows()-i)!=(a->cols()-j) && !n_IsZero(a->view(i, j), R)) {
2378  diag = 0;
2379  break;
2380  }
2381  }
2382  }
2383 #if 0
2384  Print("Diag ? %d\n", diag);
2385  a->Print();
2386  Print("\n");
2387 #endif
2388  if (diag) break;
2389 
2390  a = a->transpose(); // leaks - I need to write inpTranspose
2391  flip = 1-flip;
2392  } while (1);
2393  if (flip)
2394  a = a->transpose();
2395 
2396  if (S) *S = (*S)->transpose();
2397  if (s) delete s;
2398  if (t) delete t;
2399  A->copy(a);
2400 }
bigintmat * transpose()
Definition: bigintmat.cc:36
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:123
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:779
Matrices of numbers.
Definition: bigintmat.h:32
void setrow(int i, bigintmat *m)
Setzt i-te Zeile gleich übergebenem Vektor (Matrix) m.
Definition: bigintmat.cc:839
const ring r
Definition: syzextra.cc:208
int j
Definition: myNF.cc:70
bigintmat * bimMult(bigintmat *a, bigintmat *b)
Definition: bigintmat.cc:251
The main handler for Singular numbers which are suitable for Singular polynomials.
#define A
Definition: sirandom.c:23
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
void Print()
IO: simply prints the matrix to the current output (screen?)
Definition: bigintmat.cc:438
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:129
coeffs basecoeffs() const
Definition: bigintmat.h:130
#define R
Definition: sirandom.c:26
Variable x
Definition: cfModGcd.cc:4023
static jList * T
Definition: janet.cc:37
void one()
Macht Matrix (Falls quadratisch) zu Einheitsmatrix.
Definition: bigintmat.cc:1236
bigintmat* iv2bim ( intvec b,
const coeffs  C 
)

Definition at line 347 of file bigintmat.cc.

348 {
349  const int l = (b->rows())*(b->cols());
350  bigintmat * bim = new bigintmat(b->rows(), b->cols(), C);
351 
352  for (int i=0; i < l; i++)
353  bim->rawset(i, n_Init((*b)[i], C), C);
354 
355  return bim;
356 }
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
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 i
Definition: cfEzgcd.cc:123
int cols() const
Definition: intvec.h:86
int rows() const
Definition: intvec.h:87
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 2405 of file bigintmat.cc.

2405  {
2406 #if 0
2407  Print("Kernel of ");
2408  a->Print();
2409  Print(" modulo ");
2410  n_Print(p, q);
2411  Print("\n");
2412 #endif
2413 
2414  coeffs coe = numbercoeffs(p, q);
2415  bigintmat *m = bimChangeCoeff(a, coe), *U, *V;
2416  diagonalForm(m, &U, &V);
2417 #if 0
2418  Print("\ndiag form: ");
2419  m->Print();
2420  Print("\nU:\n");
2421  U->Print();
2422  Print("\nV:\n");
2423  V->Print();
2424  Print("\n");
2425 #endif
2426 
2427  int rg = 0;
2428 #undef MIN
2429 #define MIN(a,b) (a < b ? a : b)
2430  for(rg=0; rg<MIN(m->rows(), m->cols()) && !n_IsZero(m->view(m->rows()-rg,m->cols()-rg), coe); rg++);
2431 
2432 #undef MAX
2433 #define MAX(a,b) (a > b ? a : b)
2434  bigintmat * k = new bigintmat(m->cols(), m->rows(), coe);
2435  for(int i=0; i<rg; i++) {
2436  number A = n_Ann(m->view(m->rows()-i, m->cols()-i), coe);
2437  k->set(m->cols()-i, i+1, A);
2438  n_Delete(&A, coe);
2439  }
2440  for(int i=rg; i<m->cols(); i++) {
2441  k->set(m->cols()-i, i+1-rg, n_Init(1, coe));
2442  }
2443  bimMult(V, k, k);
2444  c->copy(bimChangeCoeff(k, q));
2445  return c->cols();
2446 }
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:123
#define Print
Definition: emacs.cc:83
return P p
Definition: myNF.cc:203
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 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:698
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
bigintmat * bimMult(bigintmat *a, bigintmat *b)
Definition: bigintmat.cc:251
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 '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
void diagonalForm(bigintmat *A, bigintmat **S, bigintmat **T)
Definition: bigintmat.cc:2301
void Print()
IO: simply prints the matrix to the current output (screen?)
Definition: bigintmat.cc:438
int rows() const
Definition: bigintmat.h:129
bool copy(bigintmat *b)
Kopiert Einträge von b auf Bigintmat.
Definition: bigintmat.cc:1176
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:455
void n_Print(number &a, const coeffs r)
print a number (BEWARE of string buffers!) mostly for debugging
Definition: numbers.cc:538
bool nCoeffs_are_equal ( coeffs  r,
coeffs  s 
)

Definition at line 2449 of file bigintmat.cc.

2449  {
2450  if ((r == NULL) || (s == NULL))
2451  return false;
2452  if ((getCoeffType(r)==n_Z) && (getCoeffType(s)==n_Z))
2453  return true;
2454  if ((getCoeffType(r)==n_Zp) && (getCoeffType(s)==n_Zp)) {
2455  if (r->ch == s->ch)
2456  return true;
2457  else
2458  return false;
2459  }
2460  // n_Zn stimmt wahrscheinlich noch nicht
2461  if ((getCoeffType(r)==n_Zn) && (getCoeffType(s)==n_Zn)) {
2462  if (r->ch == s->ch)
2463  return true;
2464  else
2465  return false;
2466  }
2467  if ((getCoeffType(r)==n_Q) && (getCoeffType(s)==n_Q))
2468  return true;
2469  // FALL n_Zn FEHLT NOCH!
2470  //if ((getCoeffType(r)==n_Zn) && (getCoeffType(s)==n_Zn))
2471  return false;
2472 }
only used if HAVE_RINGS is defined: ?
Definition: coeffs.h:42
rational (GMP) numbers
Definition: coeffs.h:30
{p < 2^31}
Definition: coeffs.h:29
only used if HAVE_RINGS is defined: ?
Definition: coeffs.h:41
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:421
#define NULL
Definition: omList.c:10
bool operator!= ( const bigintmat lhr,
const bigintmat rhr 
)

Definition at line 172 of file bigintmat.cc.

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

Definition at line 155 of file bigintmat.cc.

156 {
157  if (&lhr == &rhr) { return true; }
158  if (lhr.cols() != rhr.cols()) { return false; }
159  if (lhr.rows() != rhr.rows()) { return false; }
160  if (lhr.basecoeffs() != rhr.basecoeffs()) { return false; }
161 
162  const int l = (lhr.rows())*(lhr.cols());
163 
164  for (int i=0; i < l; i++)
165  {
166  if (!n_Equal(lhr[i], rhr[i], lhr.basecoeffs())) { return false; }
167  }
168 
169  return true;
170 }
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 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
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 2263 of file bigintmat.cc.

2263  {
2264 #if 0
2265  Print("Solve Ax=b for A=\n");
2266  A->Print();
2267  Print("\nb = \n");
2268  b->Print();
2269  Print("\nx = \n");
2270  x->Print();
2271  Print("\n");
2272 #endif
2273 
2274  coeffs R = A->basecoeffs();
2275  assume (R == b->basecoeffs());
2276  assume (R == x->basecoeffs());
2277  assume ((x->cols() == b->cols()) && (x->rows() == A->cols()) && (A->rows() == b->rows()));
2278 
2279  switch (getCoeffType(R)) {
2280  case n_Z:
2281  return solveAx_dixon(A, b, x, NULL);
2282  case n_Zn:
2283  case n_Znm:
2284  case n_Z2m:
2285  return solveAx_howell(A, b, x, NULL);
2286  case n_Zp:
2287  case n_Q:
2288  case n_GF:
2289  case n_algExt:
2290  case n_transExt:
2291  Warn("have field, should use Gauss or better");
2292  default:
2293  if (R->cfXExtGcd && R->cfAnn) { //assume it's Euclidean
2294  return solveAx_howell(A, b, x, NULL);
2295  }
2296  Werror("have no solve algorithm");
2297  }
2298  return NULL;
2299 }
static number solveAx_dixon(bigintmat *A, bigintmat *B, bigintmat *x, bigintmat *kern)
Definition: bigintmat.cc:1973
#define Print
Definition: emacs.cc:83
only used if HAVE_RINGS is defined: ?
Definition: coeffs.h:42
only used if HAVE_RINGS is defined: ?
Definition: coeffs.h:44
used for all transcendental extensions, i.e., the top-most extension in an extension tower is transce...
Definition: coeffs.h:37
rational (GMP) numbers
Definition: coeffs.h:30
{p < 2^31}
Definition: coeffs.h:29
only used if HAVE_RINGS is defined: ?
Definition: coeffs.h:43
#define assume(x)
Definition: mod2.h:405
The main handler for Singular numbers which are suitable for Singular polynomials.
only used if HAVE_RINGS is defined: ?
Definition: coeffs.h:41
static number solveAx_howell(bigintmat *A, bigintmat *b, bigintmat *x, bigintmat *kern)
Definition: bigintmat.cc:2150
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
void Print()
IO: simply prints the matrix to the current output (screen?)
Definition: bigintmat.cc:438
int rows() const
Definition: bigintmat.h:129
#define NULL
Definition: omList.c:10
{p^n < 2^16}
Definition: coeffs.h:32
used for all algebraic extensions, i.e., the top-most extension in an extension tower is algebraic ...
Definition: coeffs.h:34
coeffs basecoeffs() const
Definition: bigintmat.h:130
#define R
Definition: sirandom.c:26
void Werror(const char *fmt,...)
Definition: reporter.cc:199
#define Warn
Definition: emacs.cc:80