Macros | Functions
bigintmat.cc File Reference
#include <misc/auxiliary.h>
#include "bigintmat.h"
#include <misc/intvec.h>
#include "rmodulon.h"
#include <math.h>
#include <string.h>

Go to the source code of this file.

Macros

#define swap(_i, _j)
 
#define MIN(a, b)   (a < b ? a : b)
 

Functions

static coeffs numbercoeffs (number n, coeffs c)
 create Z/nA of type n_Zn More...
 
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)
 
intvecbim2iv (bigintmat *b)
 
bigintmativ2bim (intvec *b, const coeffs C)
 
bigintmatbimCopy (const bigintmat *b)
 same as copy constructor - apart from it being able to accept NULL as input More...
 
static int intArrSum (int *a, int length)
 
static int findLongest (int *a, int length)
 
static int getShorter (int *a, int l, int j, int cols, int rows)
 
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...
 
static void reduce_mod_howell (bigintmat *A, bigintmat *b, bigintmat *eps, bigintmat *x)
 
static bigintmatprependIdentity (bigintmat *A)
 
static number bimFarey (bigintmat *A, number N, bigintmat *L)
 
static number solveAx_dixon (bigintmat *A, bigintmat *B, bigintmat *x, bigintmat *kern)
 
static number solveAx_howell (bigintmat *A, bigintmat *b, bigintmat *x, bigintmat *kern)
 
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...
 
void diagonalForm (bigintmat *A, bigintmat **S, bigintmat **T)
 
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)
 

Macro Definition Documentation

◆ MIN

#define MIN (   a,
  b 
)    (a < b ? a : b)

◆ swap

#define swap (   _i,
  _j 
)
Value:
int __i = (_i), __j=(_j); \
number c = v[__i]; \
v[__i] = v[__j]; \
v[__j] = c \
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37

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 }
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 i
Definition: cfEzgcd.cc:123
const poly b
Definition: syzextra.cc:213

◆ 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 }
const poly a
Definition: syzextra.cc:212
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: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 i
Definition: cfEzgcd.cc:123
#define NULL
Definition: omList.c:10
const poly b
Definition: syzextra.cc:213

◆ 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 }
const poly a
Definition: syzextra.cc:212
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
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 i
Definition: cfEzgcd.cc:123
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 }
const poly a
Definition: syzextra.cc:212
Matrices of numbers.
Definition: bigintmat.h:51
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
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
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

◆ 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
const poly b
Definition: syzextra.cc:213

◆ bimFarey()

static number bimFarey ( bigintmat A,
number  N,
bigintmat L 
)
static

Definition at line 2056 of file bigintmat.cc.

2057 {
2058  coeffs Z = A->basecoeffs(),
2059  Q = nInitChar(n_Q, 0);
2060  number den = n_Init(1, Z);
2061  nMapFunc f = n_SetMap(Q, Z);
2062 
2063  for(int i=1; i<= A->rows(); i++)
2064  {
2065  for(int j=1; j<= A->cols(); j++)
2066  {
2067  number ad = n_Mult(den, A->view(i, j), Z);
2068  number re = n_IntMod(ad, N, Z);
2069  n_Delete(&ad, Z);
2070  number q = n_Farey(re, N, Z);
2071  n_Delete(&re, Z);
2072  if (!q)
2073  {
2074  n_Delete(&ad, Z);
2075  n_Delete(&den, Z);
2076  return NULL;
2077  }
2078 
2079  number d = n_GetDenom(q, Q),
2080  n = n_GetNumerator(q, Q);
2081 
2082  n_Delete(&q, Q);
2083  n_Delete(&ad, Z);
2084  number dz = f(d, Q, Z),
2085  nz = f(n, Q, Z);
2086  n_Delete(&d, Q);
2087  n_Delete(&n, Q);
2088 
2089  if (!n_IsOne(dz, Z))
2090  {
2091  L->skalmult(dz, Z);
2092  n_InpMult(den, dz, Z);
2093 #if 0
2094  PrintS("den increasing to ");
2095  n_Print(den, Z);
2096  PrintLn();
2097 #endif
2098  }
2099  n_Delete(&dz, Z);
2100  L->rawset(i, j, nz);
2101  }
2102  }
2103 
2104  nKillChar(Q);
2105  PrintS("bimFarey worked\n");
2106 #if 0
2107  L->Print();
2108  PrintS("\n * 1/");
2109  n_Print(den, Z);
2110  PrintLn();
2111 #endif
2112  return den;
2113 }
static FORCE_INLINE number n_IntMod(number a, number b, const coeffs r)
for r a field, return n_Init(0,r) always: n_Div(a,b,r)*b+n_IntMod(a,b,r)==a n_IntMod(a,b,r) >=0
Definition: coeffs.h:632
static FORCE_INLINE number n_GetNumerator(number &n, const coeffs r)
return the numerator of n (if elements of r are by nature not fractional, result is n) ...
Definition: coeffs.h:612
void PrintLn()
Definition: reporter.cc:310
static FORCE_INLINE void n_InpMult(number &a, number b, const coeffs r)
multiplication of &#39;a&#39; and &#39;b&#39;; replacement of &#39;a&#39; by the product a*b
Definition: coeffs.h:645
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the one element.
Definition: coeffs.h:472
rational (GMP) numbers
Definition: coeffs.h:31
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
#define Q
Definition: sirandom.c:25
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
const CanonicalForm CFMap CFMap & N
Definition: cfEzgcd.cc:49
int j
Definition: myNF.cc:70
The main handler for Singular numbers which are suitable for Singular polynomials.
#define A
Definition: sirandom.c:23
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:73
bool skalmult(number b, coeffs c)
Multipliziert zur Matrix den Skalar b hinzu.
Definition: bigintmat.cc:946
FILE * f
Definition: checklibs.c:9
int i
Definition: cfEzgcd.cc:123
void PrintS(const char *s)
Definition: reporter.cc:284
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
void Print()
IO: simply prints the matrix to the current output (screen?)
Definition: bigintmat.cc:444
static FORCE_INLINE number n_Farey(number a, number b, const coeffs r)
Definition: coeffs.h:801
#define NULL
Definition: omList.c:10
CanonicalForm den(const CanonicalForm &f)
static FORCE_INLINE number n_GetDenom(number &n, const coeffs r)
return the denominator of n (if elements of r are by nature not fractional, result is 1) ...
Definition: coeffs.h:607
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:459
void nKillChar(coeffs r)
undo all initialisations
Definition: numbers.cc:504
void n_Print(number &a, const coeffs r)
print a number (BEWARE of string buffers!) mostly for debugging
Definition: numbers.cc:576
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
Definition: numbers.cc:341

◆ 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 }
const poly a
Definition: syzextra.cc:212
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 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 i
Definition: cfEzgcd.cc:123
#define BIMATELEM(M, I, J)
Definition: bigintmat.h:134
#define NULL
Definition: omList.c:10
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
const poly b
Definition: syzextra.cc:213
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 }
const poly a
Definition: syzextra.cc:212
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
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 i
Definition: cfEzgcd.cc:123
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 }
const poly a
Definition: syzextra.cc:212
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: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 i
Definition: cfEzgcd.cc:123
CanonicalForm cf
Definition: cfModGcd.cc:4024
#define NULL
Definition: omList.c:10
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 }
const poly a
Definition: syzextra.cc:212
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
bool copy(bigintmat *b)
Kopiert Einträge von b auf Bigintmat.
Definition: bigintmat.cc:1267
const poly b
Definition: syzextra.cc:213
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
const poly a
Definition: syzextra.cc:212
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:197
The main handler for Singular numbers which are suitable for Singular polynomials.
int i
Definition: cfEzgcd.cc:123
#define NULL
Definition: omList.c:10
const poly b
Definition: syzextra.cc:213

◆ 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
const poly a
Definition: syzextra.cc:212
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
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 i
Definition: cfEzgcd.cc:123
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 **  S,
bigintmat **  T 
)

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
const poly a
Definition: syzextra.cc:212
void PrintLn()
Definition: reporter.cc:310
#define Print
Definition: emacs.cc:83
Matrices of numbers.
Definition: bigintmat.h:51
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
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
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

◆ findLongest()

static int findLongest ( int *  a,
int  length 
)
static

Definition at line 538 of file bigintmat.cc.

539 {
540  int l = 0;
541  int index;
542  for (int i=0; i<length; i++)
543  {
544  if (a[i] > l)
545  {
546  l = a[i];
547  index = i;
548  }
549  }
550  return index;
551 }
const poly a
Definition: syzextra.cc:212
int i
Definition: cfEzgcd.cc:123
static int index(p_Length length, p_Ord ord)
Definition: p_Procs_Impl.h:592
int l
Definition: cfEzgcd.cc:94

◆ getShorter()

static int getShorter ( int *  a,
int  l,
int  j,
int  cols,
int  rows 
)
static

Definition at line 553 of file bigintmat.cc.

554 {
555  int sndlong = 0;
556  int min;
557  for (int i=0; i<rows; i++)
558  {
559  int index = cols*i+j;
560  if ((a[index] > sndlong) && (a[index] < l))
561  {
562  min = floor(log10((double)cols))+floor(log10((double)rows))+5;
563  if ((a[index] < min) && (min < l))
564  sndlong = min;
565  else
566  sndlong = a[index];
567  }
568  }
569  if (sndlong == 0)
570  {
571  min = floor(log10((double)cols))+floor(log10((double)rows))+5;
572  if (min < l)
573  sndlong = min;
574  else
575  sndlong = 1;
576  }
577  return sndlong;
578 }
const poly a
Definition: syzextra.cc:212
static int min(int a, int b)
Definition: fast_mult.cc:268
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
static int index(p_Length length, p_Ord ord)
Definition: p_Procs_Impl.h:592
int l
Definition: cfEzgcd.cc:94

◆ intArrSum()

static int intArrSum ( int *  a,
int  length 
)
static

Definition at line 530 of file bigintmat.cc.

531 {
532  int sum = 0;
533  for (int i=0; i<length; i++)
534  sum += a[i];
535  return sum;
536 }
const poly a
Definition: syzextra.cc:212
int i
Definition: cfEzgcd.cc:123

◆ 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
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
const poly b
Definition: syzextra.cc:213
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 }
const poly a
Definition: syzextra.cc:212
void PrintLn()
Definition: reporter.cc:310
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: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
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
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
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 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
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
const ring r
Definition: syzextra.cc:208
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

◆ numbercoeffs()

static coeffs numbercoeffs ( number  n,
coeffs  c 
)
static

create Z/nA of type n_Zn

Definition at line 22 of file bigintmat.cc.

23 {
24  mpz_t p;
25  number2mpz(n, c, p);
26  ZnmInfo *pp = new ZnmInfo;
27  pp->base = p;
28  pp->exp = 1;
29  coeffs nc = nInitChar(n_Zn, (void*)pp);
30  mpz_clear(p);
31  delete pp;
32  return nc;
33 }
only used if HAVE_RINGS is defined
Definition: coeffs.h:44
return P p
Definition: myNF.cc:203
poly pp
Definition: myNF.cc:296
static FORCE_INLINE void number2mpz(number n, coeffs c, mpz_t m)
Definition: coeffs.h:1004
The main handler for Singular numbers which are suitable for Singular polynomials.
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
Definition: numbers.cc:341

◆ 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

◆ prependIdentity()

static bigintmat* prependIdentity ( bigintmat A)
static

Definition at line 2044 of file bigintmat.cc.

2045 {
2046  coeffs R = A->basecoeffs();
2047  bigintmat *m = new bigintmat(A->rows()+A->cols(), A->cols(), R);
2048  m->copySubmatInto(A, 1, 1, A->rows(), A->cols(), A->cols()+1, 1);
2049  number one = n_Init(1, R);
2050  for(int i=1; i<= A->cols(); i++)
2051  m->set(i,i,one);
2052  n_Delete(&one, R);
2053  return m;
2054 }
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
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
int m
Definition: cfEzgcd.cc:119
int i
Definition: cfEzgcd.cc:123
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:459

◆ reduce_mod_howell()

static void reduce_mod_howell ( bigintmat A,
bigintmat b,
bigintmat eps,
bigintmat x 
)
static

Definition at line 1958 of file bigintmat.cc.

1959 {
1960  //write b = Ax + eps where eps is "small" in the sense of bounded by the
1961  //pivot entries in H. H does not need to be Howell (or HNF) but need
1962  //to be triagonal in the same direction.
1963  //b can have multiple columns.
1964 #if 0
1965  PrintS("reduce_mod_howell: A:\n");
1966  A->Print();
1967  PrintS("\nb:\n");
1968  b->Print();
1969 #endif
1970 
1971  coeffs R = A->basecoeffs();
1972  assume(x->basecoeffs() == R);
1973  assume(b->basecoeffs() == R);
1974  assume(eps->basecoeffs() == R);
1975  if (!A->cols())
1976  {
1977  x->zero();
1978  eps->copy(b);
1979 
1980 #if 0
1981  PrintS("\nx:\n");
1982  x->Print();
1983  PrintS("\neps:\n");
1984  eps->Print();
1985  PrintS("\n****************************************\n");
1986 #endif
1987  return;
1988  }
1989 
1990  bigintmat * B = new bigintmat(b->rows(), 1, R);
1991  for(int i=1; i<= b->cols(); i++)
1992  {
1993  int A_col = A->cols();
1994  b->getcol(i, B);
1995  for(int j = B->rows(); j>0; j--)
1996  {
1997  number Ai = A->view(A->rows() - B->rows() + j, A_col);
1998  if (n_IsZero(Ai, R) &&
1999  n_IsZero(B->view(j, 1), R))
2000  {
2001  continue; //all is fine: 0*x = 0
2002  }
2003  else if (n_IsZero(B->view(j, 1), R))
2004  {
2005  x->rawset(x->rows() - B->rows() + j, i, n_Init(0, R));
2006  A_col--;
2007  }
2008  else if (n_IsZero(Ai, R))
2009  {
2010  A_col--;
2011  }
2012  else
2013  {
2014  // "solve" ax=b, possibly enlarging d
2015  number Bj = B->view(j, 1);
2016  number q = n_Div(Bj, Ai, R);
2017  x->rawset(x->rows() - B->rows() + j, i, q);
2018  for(int k=j; k>B->rows() - A->rows(); k--)
2019  {
2020  //B[k] = B[k] - x[k]A[k][j]
2021  number s = n_Mult(q, A->view(A->rows() - B->rows() + k, A_col), R);
2022  B->rawset(k, 1, n_Sub(B->view(k, 1), s, R));
2023  n_Delete(&s, R);
2024  }
2025  A_col--;
2026  }
2027  if (!A_col)
2028  {
2029  break;
2030  }
2031  }
2032  eps->setcol(i, B);
2033  }
2034  delete B;
2035 #if 0
2036  PrintS("\nx:\n");
2037  x->Print();
2038  PrintS("\neps:\n");
2039  eps->Print();
2040  PrintS("\n****************************************\n");
2041 #endif
2042 }
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
const CanonicalForm int s
Definition: facAbsFact.cc:55
Matrices of numbers.
Definition: bigintmat.h:51
void setcol(int j, bigintmat *m)
Setzt j-te Spalte gleich übergebenem Vektor (Matrix) m.
Definition: bigintmat.cc:834
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 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.
#define A
Definition: sirandom.c:23
const ring R
Definition: DebugPrint.cc:36
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
static FORCE_INLINE number n_Div(number a, number b, const coeffs r)
return the quotient of &#39;a&#39; and &#39;b&#39;, i.e., a/b; raises an error if &#39;b&#39; is not invertible in r exceptio...
Definition: coeffs.h:619
b *CanonicalForm B
Definition: facBivar.cc:51
coeffs basecoeffs() const
Definition: bigintmat.h:147
bool copy(bigintmat *b)
Kopiert Einträge von b auf Bigintmat.
Definition: bigintmat.cc:1267
Variable x
Definition: cfModGcd.cc:4023
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

◆ 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
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.
#define A
Definition: sirandom.c:23
const ring R
Definition: DebugPrint.cc:36
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
#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
Variable x
Definition: cfModGcd.cc:4023
const poly b
Definition: syzextra.cc:213

◆ solveAx_dixon()

static number solveAx_dixon ( bigintmat A,
bigintmat B,
bigintmat x,
bigintmat kern 
)
static

Definition at line 2116 of file bigintmat.cc.

2116  {
2117  coeffs R = A->basecoeffs();
2118 
2119  assume(getCoeffType(R) == n_Z);
2120 
2121  number p = n_Init(536870909, R); // PreviousPrime(2^29); not clever
2122  coeffs Rp = numbercoeffs(p, R); // R/pR
2123  bigintmat *Ap = bimChangeCoeff(A, Rp),
2124  *m = prependIdentity(Ap),
2125  *Tp, *Hp;
2126  delete Ap;
2127 
2128  m->howell();
2129  Hp = new bigintmat(A->rows(), A->cols(), Rp);
2130  Hp->copySubmatInto(m, A->cols()+1, 1, A->rows(), A->cols(), 1, 1);
2131  Tp = new bigintmat(A->cols(), A->cols(), Rp);
2132  Tp->copySubmatInto(m, 1, 1, A->cols(), A->cols(), 1, 1);
2133 
2134  int i, j;
2135 
2136  for(i=1; i<= A->cols(); i++)
2137  {
2138  for(j=m->rows(); j>A->cols(); j--)
2139  {
2140  if (!n_IsZero(m->view(j, i), Rp)) break;
2141  }
2142  if (j>A->cols()) break;
2143  }
2144 // Print("Found nullity (kern dim) of %d\n", i-1);
2145  bigintmat * kp = new bigintmat(A->cols(), i-1, Rp);
2146  kp->copySubmatInto(Tp, 1, 1, A->cols(), i-1, 1, 1);
2147  kp->howell();
2148 
2149  delete m;
2150 
2151  //Hp is the mod-p howell form
2152  //Tp the transformation, mod p
2153  //kp a basis for the kernel, in howell form, mod p
2154 
2155  bigintmat * eps_p = new bigintmat(B->rows(), B->cols(), Rp),
2156  * x_p = new bigintmat(A->cols(), B->cols(), Rp),
2157  * fps_p = new bigintmat(kp->cols(), B->cols(), Rp);
2158 
2159  //initial solution
2160 
2161  number zero = n_Init(0, R);
2162  x->skalmult(zero, R);
2163  n_Delete(&zero, R);
2164 
2165  bigintmat * b = new bigintmat(B);
2166  number pp = n_Init(1, R);
2167  i = 1;
2168  do
2169  {
2170  bigintmat * b_p = bimChangeCoeff(b, Rp), * s;
2171  bigintmat * t1, *t2;
2172  reduce_mod_howell(Hp, b_p, eps_p, x_p);
2173  delete b_p;
2174  if (!eps_p->isZero())
2175  {
2176  PrintS("no solution, since no modular solution\n");
2177 
2178  delete eps_p;
2179  delete x_p;
2180  delete Hp;
2181  delete kp;
2182  delete Tp;
2183  delete b;
2184  n_Delete(&pp, R);
2185  n_Delete(&p, R);
2186  nKillChar(Rp);
2187 
2188  return NULL;
2189  }
2190  t1 = bimMult(Tp, x_p);
2191  delete x_p;
2192  x_p = t1;
2193  reduce_mod_howell(kp, x_p, x_p, fps_p); //we're not all interested in fps_p
2194  s = bimChangeCoeff(x_p, R);
2195  t1 = bimMult(A, s);
2196  t2 = bimSub(b, t1);
2197  t2->skaldiv(p);
2198  delete b;
2199  delete t1;
2200  b = t2;
2201  s->skalmult(pp, R);
2202  t1 = bimAdd(x, s);
2203  delete s;
2204  x->swapMatrix(t1);
2205  delete t1;
2206 
2207  if(kern && i==1)
2208  {
2209  bigintmat * ker = bimChangeCoeff(kp, R);
2210  t1 = bimMult(A, ker);
2211  t1->skaldiv(p);
2212  t1->skalmult(n_Init(-1, R), R);
2213  b->appendCol(t1);
2214  delete t1;
2215  x->appendCol(ker);
2216  delete ker;
2217  x_p->extendCols(kp->cols());
2218  eps_p->extendCols(kp->cols());
2219  fps_p->extendCols(kp->cols());
2220  }
2221 
2222  n_InpMult(pp, p, R);
2223 
2224  if (b->isZero())
2225  {
2226  //exact solution found, stop
2227  delete eps_p;
2228  delete fps_p;
2229  delete x_p;
2230  delete Hp;
2231  delete kp;
2232  delete Tp;
2233  delete b;
2234  n_Delete(&pp, R);
2235  n_Delete(&p, R);
2236  nKillChar(Rp);
2237 
2238  return n_Init(1, R);
2239  }
2240  else
2241  {
2242  bigintmat *y = new bigintmat(x->rows(), x->cols(), R);
2243  number d = bimFarey(x, pp, y);
2244  if (d)
2245  {
2246  bigintmat *c = bimMult(A, y);
2247  bigintmat *bd = new bigintmat(B);
2248  bd->skalmult(d, R);
2249  if (kern)
2250  {
2251  bd->extendCols(kp->cols());
2252  }
2253  if (*c == *bd)
2254  {
2255  x->swapMatrix(y);
2256  delete y;
2257  delete c;
2258  if (kern)
2259  {
2260  y = new bigintmat(x->rows(), B->cols(), R);
2261  c = new bigintmat(x->rows(), kp->cols(), R);
2262  x->splitcol(y, c);
2263  x->swapMatrix(y);
2264  delete y;
2265  kern->swapMatrix(c);
2266  delete c;
2267  }
2268 
2269  delete bd;
2270 
2271  delete eps_p;
2272  delete fps_p;
2273  delete x_p;
2274  delete Hp;
2275  delete kp;
2276  delete Tp;
2277  delete b;
2278  n_Delete(&pp, R);
2279  n_Delete(&p, R);
2280  nKillChar(Rp);
2281 
2282  return d;
2283  }
2284  delete c;
2285  delete bd;
2286  n_Delete(&d, R);
2287  }
2288  delete y;
2289  }
2290  i++;
2291  } while (1);
2292  delete eps_p;
2293  delete fps_p;
2294  delete x_p;
2295  delete Hp;
2296  delete kp;
2297  delete Tp;
2298  n_Delete(&pp, R);
2299  n_Delete(&p, R);
2300  nKillChar(Rp);
2301  return NULL;
2302 }
void skaldiv(number b)
Macht Ganzzahldivision aller Matrixeinträge mit b.
Definition: bigintmat.cc:1869
const CanonicalForm int s
Definition: facAbsFact.cc:55
const CanonicalForm int const CFList const Variable & y
Definition: facAbsFact.cc:57
bigintmat * bimSub(bigintmat *a, bigintmat *b)
Definition: bigintmat.cc:219
static bigintmat * prependIdentity(bigintmat *A)
Definition: bigintmat.cc:2044
static FORCE_INLINE void n_InpMult(number &a, number b, const coeffs r)
multiplication of &#39;a&#39; and &#39;b&#39;; replacement of &#39;a&#39; by the product a*b
Definition: coeffs.h:645
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:542
bigintmat * bimAdd(bigintmat *a, bigintmat *b)
Matrix-Add/-Sub/-Mult so oder mit operator+/-/* ? : NULL as a result means an error (non-compatible m...
Definition: bigintmat.cc:183
poly pp
Definition: myNF.cc:296
static coeffs numbercoeffs(number n, coeffs c)
create Z/nA of type n_Zn
Definition: bigintmat.cc:22
void copySubmatInto(bigintmat *, int sr, int sc, int nr, int nc, int tr, int tc)
copy the submatrix of b, staring at (a,b) having n rows, m cols into the given matrix at pos...
Definition: bigintmat.cc:1295
int j
Definition: myNF.cc:70
bigintmat * bimMult(bigintmat *a, bigintmat *b)
Definition: bigintmat.cc:256
static number bimFarey(bigintmat *A, number N, bigintmat *L)
Definition: bigintmat.cc:2056
static void reduce_mod_howell(bigintmat *A, bigintmat *b, bigintmat *eps, bigintmat *x)
Definition: bigintmat.cc:1958
void extendCols(int i)
append i zero-columns to the matrix
Definition: bigintmat.cc:1084
#define assume(x)
Definition: mod2.h:394
void swapMatrix(bigintmat *a)
Definition: bigintmat.cc:1574
The main handler for Singular numbers which are suitable for Singular polynomials.
#define A
Definition: sirandom.c:23
bool skalmult(number b, coeffs c)
Multipliziert zur Matrix den Skalar b hinzu.
Definition: bigintmat.cc:946
const ring R
Definition: DebugPrint.cc:36
int cols() const
Definition: bigintmat.h:145
int m
Definition: cfEzgcd.cc:119
only used if HAVE_RINGS is defined
Definition: coeffs.h:43
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
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
b *CanonicalForm B
Definition: facBivar.cc:51
Variable x
Definition: cfModGcd.cc:4023
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:459
int isZero()
Definition: bigintmat.cc:1371
const poly b
Definition: syzextra.cc:213
void howell()
dito, but Howell form (only different for zero-divsors)
Definition: bigintmat.cc:1593
void nKillChar(coeffs r)
undo all initialisations
Definition: numbers.cc:504

◆ solveAx_howell()

static number solveAx_howell ( bigintmat A,
bigintmat b,
bigintmat x,
bigintmat kern 
)
static

Definition at line 2306 of file bigintmat.cc.

2307 {
2308  // try to solve Ax=b, more precisely, find
2309  // number d
2310  // bigintmat x
2311  // sth. Ax=db
2312  // where d is small-ish (divides the determinant of A if this makes sense)
2313  // return 0 if there is no solution.
2314  //
2315  // if kern is non-NULL, return a basis for the kernel
2316 
2317  //Algo: we do row-howell (triangular matrix). The idea is
2318  // Ax = b <=> AT T^-1x = b
2319  // y := T^-1 x, solve AT y = b
2320  // and return Ty.
2321  //Howell does not compute the trafo, hence we need to cheat:
2322  //B := (I_n | A^t)^t, then the top part of the Howell form of
2323  //B will give a useful trafo
2324  //Then we can find x by back-substitution and lcm/gcd to find the denominator
2325  //The defining property of Howell makes this work.
2326 
2327  coeffs R = A->basecoeffs();
2329  m->howell(); // since m contains the identity, we'll have A->cols()
2330  // many cols.
2331  number den = n_Init(1, R);
2332 
2333  bigintmat * B = new bigintmat(A->rows(), 1, R);
2334  for(int i=1; i<= b->cols(); i++)
2335  {
2336  int A_col = A->cols();
2337  b->getcol(i, B);
2338  B->skalmult(den, R);
2339  for(int j = B->rows(); j>0; j--)
2340  {
2341  number Ai = m->view(m->rows()-B->rows() + j, A_col);
2342  if (n_IsZero(Ai, R) &&
2343  n_IsZero(B->view(j, 1), R))
2344  {
2345  continue; //all is fine: 0*x = 0
2346  }
2347  else if (n_IsZero(B->view(j, 1), R))
2348  {
2349  x->rawset(x->rows() - B->rows() + j, i, n_Init(0, R));
2350  A_col--;
2351  }
2352  else if (n_IsZero(Ai, R))
2353  {
2354  delete m;
2355  delete B;
2356  n_Delete(&den, R);
2357  return 0;
2358  }
2359  else
2360  {
2361  // solve ax=db, possibly enlarging d
2362  // so x = db/a
2363  number Bj = B->view(j, 1);
2364  number g = n_Gcd(Bj, Ai, R);
2365  number xi;
2366  if (n_Equal(Ai, g, R))
2367  { //good: den stable!
2368  xi = n_Div(Bj, Ai, R);
2369  }
2370  else
2371  { //den <- den * (a/g), so old sol. needs to be adjusted
2372  number inc_d = n_Div(Ai, g, R);
2373  n_InpMult(den, inc_d, R);
2374  x->skalmult(inc_d, R);
2375  B->skalmult(inc_d, R);
2376  xi = n_Div(Bj, g, R);
2377  n_Delete(&inc_d, R);
2378  } //now for the back-substitution:
2379  x->rawset(x->rows() - B->rows() + j, i, xi);
2380  for(int k=j; k>0; k--)
2381  {
2382  //B[k] = B[k] - x[k]A[k][j]
2383  number s = n_Mult(xi, m->view(m->rows()-B->rows() + k, A_col), R);
2384  B->rawset(k, 1, n_Sub(B->view(k, 1), s, R));
2385  n_Delete(&s, R);
2386  }
2387  n_Delete(&g, R);
2388  A_col--;
2389  }
2390  if (!A_col)
2391  {
2392  if (B->isZero()) break;
2393  else
2394  {
2395  delete m;
2396  delete B;
2397  n_Delete(&den, R);
2398  return 0;
2399  }
2400  }
2401  }
2402  }
2403  delete B;
2404  bigintmat *T = new bigintmat(A->cols(), A->cols(), R);
2405  T->copySubmatInto(m, 1, 1, A->cols(), A->cols(), 1, 1);
2406  if (kern)
2407  {
2408  int i, j;
2409  for(i=1; i<= A->cols(); i++)
2410  {
2411  for(j=m->rows(); j>A->cols(); j--)
2412  {
2413  if (!n_IsZero(m->view(j, i), R)) break;
2414  }
2415  if (j>A->cols()) break;
2416  }
2417  Print("Found nullity (kern dim) of %d\n", i-1);
2418  bigintmat * ker = new bigintmat(A->rows(), i-1, R);
2419  ker->copySubmatInto(T, 1, 1, A->rows(), i-1, 1, 1);
2420  kern->swapMatrix(ker);
2421  delete ker;
2422  }
2423  delete m;
2424  bigintmat * y = bimMult(T, x);
2425  x->swapMatrix(y);
2426  delete y;
2427  x->simplifyContentDen(&den);
2428 #if 0
2429  PrintS("sol = 1/");
2430  n_Print(den, R);
2431  PrintS(" *\n");
2432  x->Print();
2433  PrintLn();
2434 #endif
2435  return den;
2436 }
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
static FORCE_INLINE number n_Gcd(number a, number b, const coeffs r)
in Z: return the gcd of &#39;a&#39; and &#39;b&#39; in Z/nZ, Z/2^kZ: computed as in the case Z in Z/pZ...
Definition: coeffs.h:690
const CanonicalForm int s
Definition: facAbsFact.cc:55
const CanonicalForm int const CFList const Variable & y
Definition: facAbsFact.cc:57
void PrintLn()
Definition: reporter.cc:310
#define Print
Definition: emacs.cc:83
static bigintmat * prependIdentity(bigintmat *A)
Definition: bigintmat.cc:2044
static FORCE_INLINE void n_InpMult(number &a, number b, const coeffs r)
multiplication of &#39;a&#39; and &#39;b&#39;; replacement of &#39;a&#39; by the product a*b
Definition: coeffs.h:645
Matrices of numbers.
Definition: bigintmat.h:51
CF_NO_INLINE bool isZero() const
Definition: cf_inline.cc:372
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
g
Definition: cfModGcd.cc:4031
int k
Definition: cfEzgcd.cc:93
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
void copySubmatInto(bigintmat *, int sr, int sc, int nr, int nc, int tr, int tc)
copy the submatrix of b, staring at (a,b) having n rows, m cols into the given matrix at pos...
Definition: bigintmat.cc:1295
int j
Definition: myNF.cc:70
bigintmat * bimMult(bigintmat *a, bigintmat *b)
Definition: bigintmat.cc:256
void swapMatrix(bigintmat *a)
Definition: bigintmat.cc:1574
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
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
CanonicalForm den(const CanonicalForm &f)
static FORCE_INLINE number n_Div(number a, number b, const coeffs r)
return the quotient of &#39;a&#39; and &#39;b&#39;, i.e., a/b; raises an error if &#39;b&#39; is not invertible in r exceptio...
Definition: coeffs.h:619
b *CanonicalForm B
Definition: facBivar.cc:51
Variable x
Definition: cfModGcd.cc:4023
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
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:459
static jList * T
Definition: janet.cc:37
const poly b
Definition: syzextra.cc:213
void n_Print(number &a, const coeffs r)
print a number (BEWARE of string buffers!) mostly for debugging
Definition: numbers.cc:576