My Project
Data Structures | Macros | Functions
bigintmat.h File Reference
#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+/-/* ? @Note: 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 133 of file bigintmat.h.

Function Documentation

◆ bim2iv()

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 }
int i
Definition: cfEzgcd.cc:132
CanonicalForm b
Definition: cfModGcd.cc:4105
Definition: intvec.h:23
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

◆ bimAdd() [1/2]

bigintmat* bimAdd ( bigintmat a,
bigintmat b 
)

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

Definition at line 182 of file bigintmat.cc.

183 {
184  if (a->cols() != b->cols()) return NULL;
185  if (a->rows() != b->rows()) return NULL;
186  if (a->basecoeffs() != b->basecoeffs()) { return NULL; }
187 
188  const coeffs basecoeffs = a->basecoeffs();
189 
190  int i;
191 
192  bigintmat * bim = new bigintmat(a->rows(), a->cols(), basecoeffs);
193 
194  for (i=a->rows()*a->cols()-1;i>=0; i--)
195  bim->rawset(i, n_Add((*a)[i], (*b)[i], basecoeffs), basecoeffs);
196 
197  return bim;
198 }
Matrices of numbers.
Definition: bigintmat.h:51
int cols() const
Definition: bigintmat.h:144
int rows() const
Definition: bigintmat.h:145
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:196
coeffs basecoeffs() const
Definition: bigintmat.h:146
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:657
The main handler for Singular numbers which are suitable for Singular polynomials.
#define NULL
Definition: omList.c:12

◆ bimAdd() [2/2]

bigintmat* bimAdd ( bigintmat a,
int  b 
)

Definition at line 199 of file bigintmat.cc.

200 {
201 
202  const int mn = si_min(a->rows(),a->cols());
203 
204  const coeffs basecoeffs = a->basecoeffs();
205  number bb=n_Init(b,basecoeffs);
206 
207  int i;
208 
209  bigintmat * bim = new bigintmat(a->rows(),a->cols() , basecoeffs);
210 
211  for (i=1; i<=mn; i++)
212  BIMATELEM(*bim,i,i)=n_Add(BIMATELEM(*a,i,i), bb, basecoeffs);
213 
214  n_Delete(&bb,basecoeffs);
215  return bim;
216 }
static int si_min(const int a, const int b)
Definition: auxiliary.h:125
#define BIMATELEM(M, I, J)
Definition: bigintmat.h:133
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:456
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

◆ bimChangeCoeff()

bigintmat* bimChangeCoeff ( bigintmat a,
coeffs  cnew 
)

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

Definition at line 1805 of file bigintmat.cc.

1806 {
1807  coeffs cold = a->basecoeffs();
1808  bigintmat *b = new bigintmat(a->rows(), a->cols(), cnew);
1809  // Erzeugt Karte von alten coeffs nach neuen
1810  nMapFunc f = n_SetMap(cold, cnew);
1811  number t1;
1812  number t2;
1813  // apply map to all entries.
1814  for (int i=1; i<=a->rows(); i++)
1815  {
1816  for (int j=1; j<=a->cols(); j++)
1817  {
1818  t1 = a->get(i, j);
1819  t2 = f(t1, cold, cnew);
1820  b->set(i, j, t2);
1821  n_Delete(&t1, cold);
1822  n_Delete(&t2, cnew);
1823  }
1824  }
1825  return b;
1826 }
FILE * f
Definition: checklibs.c:9
number get(int i, int j) const
get a copy of an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:119
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:723
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:74
int j
Definition: facHensel.cc:110

◆ bimCopy()

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 }

◆ bimMult() [1/4]

bigintmat* bimMult ( bigintmat a,
bigintmat b 
)

Definition at line 255 of file bigintmat.cc.

256 {
257  const int ca = a->cols();
258  const int cb = b->cols();
259 
260  const int ra = a->rows();
261  const int rb = b->rows();
262 
263  if (ca != rb)
264  {
265 #ifndef SING_NDEBUG
266  Werror("wrong bigintmat sizes at multiplication a * b: acols: %d != brows: %d\n", ca, rb);
267 #endif
268  return NULL;
269  }
270 
271  assume (ca == rb);
272 
273  if (a->basecoeffs() != b->basecoeffs()) { return NULL; }
274 
275  const coeffs basecoeffs = a->basecoeffs();
276 
277  int i, j, k;
278 
279  number sum;
280 
281  bigintmat * bim = new bigintmat(ra, cb, basecoeffs);
282 
283  for (i=1; i<=ra; i++)
284  for (j=1; j<=cb; j++)
285  {
286  sum = n_Init(0, basecoeffs);
287 
288  for (k=1; k<=ca; k++)
289  {
290  number prod = n_Mult( BIMATELEM(*a, i, k), BIMATELEM(*b, k, j), basecoeffs);
291 
292  n_InpAdd(sum, prod, basecoeffs);
293 
294  n_Delete(&prod, basecoeffs);
295  }
296  bim->rawset(i, j, sum, basecoeffs);
297  }
298  return bim;
299 }
int k
Definition: cfEzgcd.cc:99
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:637
static FORCE_INLINE void n_InpAdd(number &a, number b, const coeffs r)
addition of 'a' and 'b'; replacement of 'a' by the sum a+b
Definition: coeffs.h:647
fq_nmod_poly_t prod
Definition: facHensel.cc:100
#define assume(x)
Definition: mod2.h:387
void Werror(const char *fmt,...)
Definition: reporter.cc:189

◆ bimMult() [2/4]

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

Multipliziert Matrix a und b und speichert Ergebnis in c.

Definition at line 1933 of file bigintmat.cc.

1934 {
1935  if (!nCoeffs_are_equal(a->basecoeffs(), b->basecoeffs()))
1936  {
1937  WerrorS("Error in bimMult. Coeffs do not agree!");
1938  return;
1939  }
1940  if ((a->rows() != c->rows()) || (b->cols() != c->cols()) || (a->cols() != b->rows()))
1941  {
1942  WerrorS("Error in bimMult. Dimensions do not agree!");
1943  return;
1944  }
1945  bigintmat *tmp = bimMult(a, b);
1946  c->copy(tmp);
1947 
1948  delete tmp;
1949 }
bool nCoeffs_are_equal(coeffs r, coeffs s)
Definition: bigintmat.cc:2646
bigintmat * bimMult(bigintmat *a, bigintmat *b)
Definition: bigintmat.cc:255
bool copy(bigintmat *b)
Kopiert Einträge von b auf Bigintmat.
Definition: bigintmat.cc:1260
void WerrorS(const char *s)
Definition: feFopen.cc:24

◆ bimMult() [3/4]

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 }

◆ bimMult() [4/4]

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 }
CanonicalForm cf
Definition: cfModGcd.cc:4085

◆ bimSub() [1/2]

bigintmat* bimSub ( bigintmat a,
bigintmat b 
)

Definition at line 218 of file bigintmat.cc.

219 {
220  if (a->cols() != b->cols()) return NULL;
221  if (a->rows() != b->rows()) return NULL;
222  if (a->basecoeffs() != b->basecoeffs()) { return NULL; }
223 
224  const coeffs basecoeffs = a->basecoeffs();
225 
226  int i;
227 
228  bigintmat * bim = new bigintmat(a->rows(), a->cols(), basecoeffs);
229 
230  for (i=a->rows()*a->cols()-1;i>=0; i--)
231  bim->rawset(i, n_Sub((*a)[i], (*b)[i], basecoeffs), basecoeffs);
232 
233  return bim;
234 }
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:670

◆ bimSub() [2/2]

bigintmat* bimSub ( bigintmat a,
int  b 
)

Definition at line 236 of file bigintmat.cc.

237 {
238  const int mn = si_min(a->rows(),a->cols());
239 
240  const coeffs basecoeffs = a->basecoeffs();
241  number bb=n_Init(b,basecoeffs);
242 
243  int i;
244 
245  bigintmat * bim = new bigintmat(a->rows(),a->cols() , basecoeffs);
246 
247  for (i=1; i<=mn; i++)
248  BIMATELEM(*bim,i,i)=n_Sub(BIMATELEM(*a,i,i), bb, basecoeffs);
249 
250  n_Delete(&bb,basecoeffs);
251  return bim;
252 }

◆ diagonalForm()

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

Definition at line 2476 of file bigintmat.cc.

2477 {
2478  bigintmat * t, *s, *a=A;
2479  coeffs R = a->basecoeffs();
2480  if (T)
2481  {
2482  *T = new bigintmat(a->cols(), a->cols(), R),
2483  (*T)->one();
2484  t = new bigintmat(*T);
2485  }
2486  else
2487  {
2488  t = *T;
2489  }
2490 
2491  if (S)
2492  {
2493  *S = new bigintmat(a->rows(), a->rows(), R);
2494  (*S)->one();
2495  s = new bigintmat(*S);
2496  }
2497  else
2498  {
2499  s = *S;
2500  }
2501 
2502  int flip=0;
2503  do
2504  {
2505  bigintmat * x, *X;
2506  if (flip)
2507  {
2508  x = s;
2509  X = *S;
2510  }
2511  else
2512  {
2513  x = t;
2514  X = *T;
2515  }
2516 
2517  if (x)
2518  {
2519  x->one();
2520  bigintmat * r = new bigintmat(a->rows()+a->cols(), a->cols(), R);
2521  bigintmat * rw = new bigintmat(1, a->cols(), R);
2522  for(int i=0; i<a->cols(); i++)
2523  {
2524  x->getrow(i+1, rw);
2525  r->setrow(i+1, rw);
2526  }
2527  for (int i=0; i<a->rows(); i++)
2528  {
2529  a->getrow(i+1, rw);
2530  r->setrow(i+a->cols()+1, rw);
2531  }
2532  r->hnf();
2533  for(int i=0; i<a->cols(); i++)
2534  {
2535  r->getrow(i+1, rw);
2536  x->setrow(i+1, rw);
2537  }
2538  for(int i=0; i<a->rows(); i++)
2539  {
2540  r->getrow(i+a->cols()+1, rw);
2541  a->setrow(i+1, rw);
2542  }
2543  delete rw;
2544  delete r;
2545 
2546 #if 0
2547  Print("X: %ld\n", X);
2548  X->Print();
2549  Print("\nx: %ld\n", x);
2550  x->Print();
2551 #endif
2552  bimMult(X, x, X);
2553 #if 0
2554  Print("\n2:X: %ld %ld %ld\n", X, *S, *T);
2555  X->Print();
2556  Print("\n2:x: %ld\n", x);
2557  x->Print();
2558  PrintLn();
2559 #endif
2560  }
2561  else
2562  {
2563  a->hnf();
2564  }
2565 
2566  int diag = 1;
2567  for(int i=a->rows(); diag && i>0; i--)
2568  {
2569  for(int j=a->cols(); j>0; j--)
2570  {
2571  if ((a->rows()-i)!=(a->cols()-j) && !n_IsZero(a->view(i, j), R))
2572  {
2573  diag = 0;
2574  break;
2575  }
2576  }
2577  }
2578 #if 0
2579  PrintS("Diag ? %d\n", diag);
2580  a->Print();
2581  PrintLn();
2582 #endif
2583  if (diag) break;
2584 
2585  a = a->transpose(); // leaks - I need to write inpTranspose
2586  flip = 1-flip;
2587  } while (1);
2588  if (flip)
2589  a = a->transpose();
2590 
2591  if (S) *S = (*S)->transpose();
2592  if (s) delete s;
2593  if (t) delete t;
2594  A->copy(a);
2595 }
Variable x
Definition: cfModGcd.cc:4084
void Print()
IO: simply prints the matrix to the current output (screen?)
Definition: bigintmat.cc:443
void hnf()
transforms INPLACE to HNF
Definition: bigintmat.cc:1661
bigintmat * transpose()
Definition: bigintmat.cc:37
void setrow(int i, bigintmat *m)
Setzt i-te Zeile gleich übergebenem Vektor (Matrix) m.
Definition: bigintmat.cc:861
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:127
void one()
Macht Matrix (Falls quadratisch) zu Einheitsmatrix.
Definition: bigintmat.cc:1326
void getrow(int i, bigintmat *a)
Schreibt i-te Zeile in Vektor (Matrix) a.
Definition: bigintmat.cc:792
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
Definition: coeffs.h:465
#define Print
Definition: emacs.cc:80
const CanonicalForm int s
Definition: facAbsFact.cc:51
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:17
STATIC_VAR jList * T
Definition: janet.cc:30
void PrintS(const char *s)
Definition: reporter.cc:284
void PrintLn()
Definition: reporter.cc:310
#define R
Definition: sirandom.c:27
#define A
Definition: sirandom.c:24

◆ iv2bim()

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 }
int l
Definition: cfEzgcd.cc:100

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

2602 {
2603 #if 0
2604  PrintS("Kernel of ");
2605  a->Print();
2606  PrintS(" modulo ");
2607  n_Print(p, q);
2608  PrintLn();
2609 #endif
2610 
2611  coeffs coe = numbercoeffs(p, q);
2612  bigintmat *m = bimChangeCoeff(a, coe), *U, *V;
2613  diagonalForm(m, &U, &V);
2614 #if 0
2615  PrintS("\ndiag form: ");
2616  m->Print();
2617  PrintS("\nU:\n");
2618  U->Print();
2619  PrintS("\nV:\n");
2620  V->Print();
2621  PrintLn();
2622 #endif
2623 
2624  int rg = 0;
2625 #undef MIN
2626 #define MIN(a,b) (a < b ? a : b)
2627  for(rg=0; rg<MIN(m->rows(), m->cols()) && !n_IsZero(m->view(m->rows()-rg,m->cols()-rg), coe); rg++);
2628 
2629  bigintmat * k = new bigintmat(m->cols(), m->rows(), coe);
2630  for(int i=0; i<rg; i++)
2631  {
2632  number A = n_Ann(m->view(m->rows()-i, m->cols()-i), coe);
2633  k->set(m->cols()-i, i+1, A);
2634  n_Delete(&A, coe);
2635  }
2636  for(int i=rg; i<m->cols(); i++)
2637  {
2638  k->set(m->cols()-i, i+1-rg, n_Init(1, coe));
2639  }
2640  bimMult(V, k, k);
2641  c->copy(bimChangeCoeff(k, q));
2642  return c->cols();
2643 }
#define MIN(a, b)
bigintmat * bimChangeCoeff(bigintmat *a, coeffs cnew)
Liefert Kopier von Matrix a zurück, mit coeffs cnew statt den ursprünglichen.
Definition: bigintmat.cc:1805
void diagonalForm(bigintmat *A, bigintmat **S, bigintmat **T)
Definition: bigintmat.cc:2476
static coeffs numbercoeffs(number n, coeffs c)
create Z/nA of type n_Zn
Definition: bigintmat.cc:21
int m
Definition: cfEzgcd.cc:128
int p
Definition: cfModGcd.cc:4080
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:702
void n_Print(number &a, const coeffs r)
print a number (BEWARE of string buffers!) mostly for debugging
Definition: numbers.cc:613

◆ nCoeffs_are_equal()

bool nCoeffs_are_equal ( coeffs  r,
coeffs  s 
)

Definition at line 2646 of file bigintmat.cc.

2647 {
2648  if ((r == NULL) || (s == NULL))
2649  return false;
2650  if (r == s)
2651  return true;
2652  if ((getCoeffType(r)==n_Z) && (getCoeffType(s)==n_Z))
2653  return true;
2654  if ((getCoeffType(r)==n_Zp) && (getCoeffType(s)==n_Zp))
2655  {
2656  if (r->ch == s->ch)
2657  return true;
2658  else
2659  return false;
2660  }
2661  // n_Zn stimmt wahrscheinlich noch nicht
2662  if ((getCoeffType(r)==n_Zn) && (getCoeffType(s)==n_Zn))
2663  {
2664  if (r->ch == s->ch)
2665  return true;
2666  else
2667  return false;
2668  }
2669  if ((getCoeffType(r)==n_Q) && (getCoeffType(s)==n_Q))
2670  return true;
2671  // FALL n_Zn FEHLT NOCH!
2672  //if ((getCoeffType(r)==n_Zn) && (getCoeffType(s)==n_Zn))
2673  return false;
2674 }
@ n_Q
rational (GMP) numbers
Definition: coeffs.h:31
@ n_Zn
only used if HAVE_RINGS is defined
Definition: coeffs.h:45
@ n_Zp
\F{p < 2^31}
Definition: coeffs.h:30
@ n_Z
only used if HAVE_RINGS is defined
Definition: coeffs.h:44
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:422

◆ operator!=()

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

Definition at line 176 of file bigintmat.cc.

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

◆ operator==()

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

Definition at line 159 of file bigintmat.cc.

160 {
161  if (&lhr == &rhr) { return true; }
162  if (lhr.cols() != rhr.cols()) { return false; }
163  if (lhr.rows() != rhr.rows()) { return false; }
164  if (lhr.basecoeffs() != rhr.basecoeffs()) { return false; }
165 
166  const int l = (lhr.rows())*(lhr.cols());
167 
168  for (int i=0; i < l; i++)
169  {
170  if (!n_Equal(lhr[i], rhr[i], lhr.basecoeffs())) { return false; }
171  }
172 
173  return true;
174 }
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:461

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

2432 {
2433 #if 0
2434  PrintS("Solve Ax=b for A=\n");
2435  A->Print();
2436  PrintS("\nb = \n");
2437  b->Print();
2438  PrintS("\nx = \n");
2439  x->Print();
2440  PrintLn();
2441 #endif
2442 
2443  coeffs R = A->basecoeffs();
2444  assume (R == b->basecoeffs());
2445  assume (R == x->basecoeffs());
2446  assume ((x->cols() == b->cols()) && (x->rows() == A->cols()) && (A->rows() == b->rows()));
2447 
2448  switch (getCoeffType(R))
2449  {
2450  #ifdef HAVE_RINGS
2451  case n_Z:
2452  return solveAx_dixon(A, b, x, NULL);
2453  case n_Zn:
2454  case n_Znm:
2455  case n_Z2m:
2456  return solveAx_howell(A, b, x, NULL);
2457  #endif
2458  case n_Zp:
2459  case n_Q:
2460  case n_GF:
2461  case n_algExt:
2462  case n_transExt:
2463  WarnS("have field, should use Gauss or better");
2464  break;
2465  default:
2466  if (R->cfXExtGcd && R->cfAnn)
2467  { //assume it's Euclidean
2468  return solveAx_howell(A, b, x, NULL);
2469  }
2470  WerrorS("have no solve algorithm");
2471  break;
2472  }
2473  return NULL;
2474 }
static number solveAx_dixon(bigintmat *A, bigintmat *B, bigintmat *x, bigintmat *kern)
Definition: bigintmat.cc:2109
static number solveAx_howell(bigintmat *A, bigintmat *b, bigintmat *x, bigintmat *kern)
Definition: bigintmat.cc:2299
@ n_GF
\GF{p^n < 2^16}
Definition: coeffs.h:33
@ n_Znm
only used if HAVE_RINGS is defined
Definition: coeffs.h:46
@ n_algExt
used for all algebraic extensions, i.e., the top-most extension in an extension tower is algebraic
Definition: coeffs.h:36
@ n_Z2m
only used if HAVE_RINGS is defined
Definition: coeffs.h:47
@ n_transExt
used for all transcendental extensions, i.e., the top-most extension in an extension tower is transce...
Definition: coeffs.h:39
#define WarnS
Definition: emacs.cc:78