 |
My Project
debian-1:4.1.1-p2+ds-4build3
|
#include "misc/auxiliary.h"
#include "coeffs/bigintmat.h"
#include "misc/intvec.h"
#include "coeffs/rmodulon.h"
#include <cmath>
Go to the source code of this file.
|
#define | swap(_i, _j) |
|
#define | MIN(a, b) (a < b ? a : b) |
|
|
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) |
|
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?) More...
|
|
bigintmat * | bimAdd (bigintmat *a, int b) |
|
bigintmat * | bimSub (bigintmat *a, bigintmat *b) |
|
bigintmat * | bimSub (bigintmat *a, int b) |
|
bigintmat * | bimMult (bigintmat *a, bigintmat *b) |
|
bigintmat * | bimMult (bigintmat *a, int b) |
|
bigintmat * | bimMult (bigintmat *a, number b, const coeffs cf) |
|
intvec * | bim2iv (bigintmat *b) |
|
bigintmat * | iv2bim (intvec *b, const coeffs C) |
|
bigintmat * | bimCopy (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) |
|
bigintmat * | bimChangeCoeff (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 bigintmat * | prependIdentity (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) |
|
◆ MIN
#define MIN |
( |
|
a, |
|
|
|
b |
|
) |
| (a < b ? a : b) |
◆ swap
Value: int __i = (_i), __j=(_j); \
v[__j] = c \
◆ bim2iv()
◆ bimAdd() [1/2]
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.
◆ bimAdd() [2/2]
◆ bimChangeCoeff()
Liefert Kopier von Matrix a zurück, mit coeffs cnew statt den ursprünglichen.
Definition at line 1805 of file bigintmat.cc.
1814 for (
int i=1;
i<=a->
rows();
i++)
1816 for (
int j=1;
j<=a->
cols();
j++)
1819 t2 =
f(t1, cold, cnew);
◆ bimCopy()
same as copy constructor - apart from it being able to accept NULL as input
Definition at line 405 of file bigintmat.cc.
◆ bimFarey()
Definition at line 2049 of file bigintmat.cc.
2056 for(
int i=1;
i<=
A->rows();
i++)
2058 for(
int j=1;
j<=
A->cols();
j++)
2077 number dz =
f(d,
Q, Z),
2087 PrintS(
"den increasing to ");
2098 PrintS(
"bimFarey worked\n");
◆ bimMult() [1/4]
Definition at line 255 of file bigintmat.cc.
257 const int ca = a->
cols();
258 const int cb =
b->cols();
260 const int ra = a->
rows();
261 const int rb =
b->rows();
266 Werror(
"wrong bigintmat sizes at multiplication a * b: acols: %d != brows: %d\n", ca, rb);
283 for (
i=1;
i<=ra;
i++)
284 for (
j=1;
j<=cb;
j++)
286 sum =
n_Init(0, basecoeffs);
288 for (
k=1;
k<=ca;
k++)
◆ bimMult() [2/4]
Multipliziert Matrix a und b und speichert Ergebnis in c.
Definition at line 1933 of file bigintmat.cc.
1937 WerrorS(
"Error in bimMult. Coeffs do not agree!");
1940 if ((a->
rows() != c->
rows()) || (
b->cols() != c->
cols()) || (a->
cols() !=
b->rows()))
1942 WerrorS(
"Error in bimMult. Dimensions do not agree!");
◆ bimMult() [3/4]
◆ bimMult() [4/4]
◆ bimSub() [1/2]
◆ bimSub() [2/2]
◆ diagonalForm()
Definition at line 2476 of file bigintmat.cc.
2522 for(
int i=0;
i<a->
cols();
i++)
2527 for (
int i=0;
i<a->
rows();
i++)
2533 for(
int i=0;
i<a->
cols();
i++)
2538 for(
int i=0;
i<a->
rows();
i++)
2547 Print(
"X: %ld\n", X);
2554 Print(
"\n2:X: %ld %ld %ld\n", X, *S, *
T);
2556 Print(
"\n2:x: %ld\n",
x);
2567 for(
int i=a->
rows(); diag &&
i>0;
i--)
2569 for(
int j=a->
cols();
j>0;
j--)
2579 PrintS(
"Diag ? %d\n", diag);
◆ findLongest()
static int findLongest |
( |
int * |
a, |
|
|
int |
length |
|
) |
| |
|
static |
◆ getShorter()
static int getShorter |
( |
int * |
a, |
|
|
int |
l, |
|
|
int |
j, |
|
|
int |
cols, |
|
|
int |
rows |
|
) |
| |
|
static |
◆ intArrSum()
static int intArrSum |
( |
int * |
a, |
|
|
int |
length |
|
) |
| |
|
static |
◆ iv2bim()
Definition at line 349 of file bigintmat.cc.
351 const int l = (
b->rows())*(
b->cols());
354 for (
int i=0;
i <
l;
i++)
◆ kernbase()
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.
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++);
2630 for(
int i=0;
i<rg;
i++)
2632 number
A =
n_Ann(
m->view(
m->rows()-
i,
m->cols()-
i), coe);
2633 k->set(
m->cols()-
i,
i+1,
A);
2636 for(
int i=rg;
i<
m->cols();
i++)
◆ nCoeffs_are_equal()
◆ numbercoeffs()
◆ operator!=()
◆ operator==()
Definition at line 159 of file bigintmat.cc.
161 if (&lhr == &rhr) {
return true; }
162 if (lhr.
cols() != rhr.
cols()) {
return false; }
163 if (lhr.
rows() != rhr.
rows()) {
return false; }
168 for (
int i=0;
i <
l;
i++)
◆ prependIdentity()
Definition at line 2037 of file bigintmat.cc.
2041 m->copySubmatInto(
A, 1, 1,
A->rows(),
A->cols(),
A->cols()+1, 1);
2043 for(
int i=1;
i<=
A->cols();
i++)
◆ reduce_mod_howell()
Definition at line 1951 of file bigintmat.cc.
1958 PrintS(
"reduce_mod_howell: A:\n");
1978 PrintS(
"\n****************************************\n");
1984 for(
int i=1;
i<=
b->cols();
i++)
1986 int A_col =
A->cols();
1988 for(
int j =
B->rows();
j>0;
j--)
1990 number Ai =
A->view(
A->rows() -
B->rows() +
j, A_col);
2008 number Bj =
B->view(
j, 1);
2009 number q =
n_Div(Bj, Ai,
R);
2010 x->rawset(
x->rows() -
B->rows() +
j,
i, q);
2011 for(
int k=
j;
k>
B->rows() -
A->rows();
k--)
2014 number
s =
n_Mult(q,
A->view(
A->rows() -
B->rows() +
k, A_col),
R);
2033 PrintS(
"\n****************************************\n");
◆ solveAx()
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.
2434 PrintS(
"Solve Ax=b for A=\n");
2446 assume ((
x->cols() ==
b->cols()) && (
x->rows() ==
A->cols()) && (
A->rows() ==
b->rows()));
2463 WarnS(
"have field, should use Gauss or better");
2466 if (
R->cfXExtGcd &&
R->cfAnn)
2470 WerrorS(
"have no solve algorithm");
◆ solveAx_dixon()
Definition at line 2109 of file bigintmat.cc.
2123 Hp->copySubmatInto(
m,
A->cols()+1, 1,
A->rows(),
A->cols(), 1, 1);
2125 Tp->copySubmatInto(
m, 1, 1,
A->cols(),
A->cols(), 1, 1);
2129 for(
i=1;
i<=
A->cols();
i++)
2131 for(
j=
m->rows();
j>
A->cols();
j--)
2135 if (
j>
A->cols())
break;
2155 x->skalmult(zero,
R);
2169 PrintS(
"no solution, since no modular solution\n");
2212 fps_p->extendCols(kp->
cols());
◆ solveAx_howell()
Definition at line 2299 of file bigintmat.cc.
2327 for(
int i=1;
i<=
b->cols();
i++)
2329 int A_col =
A->cols();
2331 B->skalmult(
den,
R);
2332 for(
int j =
B->rows();
j>0;
j--)
2334 number Ai =
m->view(
m->rows()-
B->rows() +
j, A_col);
2356 number Bj =
B->view(
j, 1);
2365 number inc_d =
n_Div(Ai,
g,
R);
2367 x->skalmult(inc_d,
R);
2368 B->skalmult(inc_d,
R);
2372 x->rawset(
x->rows() -
B->rows() +
j,
i, xi);
2373 for(
int k=
j;
k>0;
k--)
2376 number
s =
n_Mult(xi,
m->view(
m->rows()-
B->rows() +
k, A_col),
R);
2398 T->copySubmatInto(
m, 1, 1,
A->cols(),
A->cols(), 1, 1);
2402 for(
i=1;
i<=
A->cols();
i++)
2404 for(
j=
m->rows();
j>
A->cols();
j--)
2408 if (
j>
A->cols())
break;
2410 Print(
"Found nullity (kern dim) of %d\n",
i-1);
2420 x->simplifyContentDen(&
den);
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
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,...
@ n_Zn
only used if HAVE_RINGS is defined
void setrow(int i, bigintmat *m)
Setzt i-te Zeile gleich übergebenem Vektor (Matrix) m.
static bigintmat * prependIdentity(bigintmat *A)
const CanonicalForm int const CFList const Variable & y
void extendCols(int i)
append i zero-columns to the matrix
static FORCE_INLINE void n_InpMult(number &a, number b, const coeffs r)
multiplication of 'a' and 'b'; replacement of 'a' by the product a*b
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)
void getrow(int i, bigintmat *a)
Schreibt i-te Zeile in Vektor (Matrix) a.
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
@ n_Z2m
only used if HAVE_RINGS is defined
static BOOLEAN length(leftv result, leftv arg)
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
coeffs basecoeffs() const
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
@ n_Q
rational (GMP) numbers
bool nCoeffs_are_equal(coeffs r, coeffs s)
const signed long floor(const ampf< Precision > &x)
@ n_Znm
only used if HAVE_RINGS is defined
const CanonicalForm CFMap CFMap & N
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff 'n' represents the one element.
void one()
Macht Matrix (Falls quadratisch) zu Einheitsmatrix.
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)
bigintmat * bimMult(bigintmat *a, bigintmat *b)
bigintmat * bimSub(bigintmat *a, bigintmat *b)
void hnf()
transforms INPLACE to HNF
void skaldiv(number b)
Macht Ganzzahldivision aller Matrixeinträge mit b.
static FORCE_INLINE number n_Add(number a, number b, const coeffs r)
return the sum of 'a' and 'b', i.e., a+b
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
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
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
void PrintS(const char *s)
bool copy(bigintmat *b)
Kopiert Einträge von b auf Bigintmat.
static void reduce_mod_howell(bigintmat *A, bigintmat *b, bigintmat *eps, bigintmat *x)
bigintmat * bimAdd(bigintmat *a, bigintmat *b)
Matrix-Add/-Sub/-Mult so oder mit operator+/-/* ? @Note: NULL as a result means an error (non-compati...
@ n_Z
only used if HAVE_RINGS is defined
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of 'a' and 'b', i.e., a*b
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
void Print()
IO: simply prints the matrix to the current output (screen?)
static coeffs numbercoeffs(number n, coeffs c)
create Z/nA of type n_Zn
@ n_transExt
used for all transcendental extensions, i.e., the top-most extension in an extension tower is transce...
static FORCE_INLINE void number2mpz(number n, coeffs c, mpz_t m)
void n_Print(number &a, const coeffs r)
print a number (BEWARE of string buffers!) mostly for debugging
static FORCE_INLINE number n_Farey(number a, number b, const coeffs r)
void setcol(int j, bigintmat *m)
Setzt j-te Spalte gleich übergebenem Vektor (Matrix) m.
static FORCE_INLINE number n_Sub(number a, number b, const coeffs r)
return the difference of 'a' and 'b', i.e., a-b
static number bimFarey(bigintmat *A, number N, bigintmat *L)
number get(int i, int j) const
get a copy of an entry. NOTE: starts at [1,1]
void diagonalForm(bigintmat *A, bigintmat **S, bigintmat **T)
static int min(int a, int b)
void howell()
dito, but Howell form (only different for zero-divsors)
void Werror(const char *fmt,...)
const ampf< Precision > log10(const ampf< Precision > &x)
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_...
static number solveAx_howell(bigintmat *A, bigintmat *b, bigintmat *x, bigintmat *kern)
static FORCE_INLINE number n_Gcd(number a, number b, const coeffs r)
in Z: return the gcd of 'a' and 'b' in Z/nZ, Z/2^kZ: computed as in the case Z in Z/pZ,...
void WerrorS(const char *s)
#define BIMATELEM(M, I, J)
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....
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 ....
const Variable & v
< [in] a sqrfree bivariate poly
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.
static number solveAx_dixon(bigintmat *A, bigintmat *B, bigintmat *x, bigintmat *kern)
const CanonicalForm int s
static FORCE_INLINE number n_Div(number a, number b, const coeffs r)
return the quotient of 'a' and 'b', i.e., a/b; raises an error if 'b' is not invertible in r exceptio...
bigintmat * bimChangeCoeff(bigintmat *a, coeffs cnew)
Liefert Kopier von Matrix a zurück, mit coeffs cnew statt den ursprünglichen.
static FORCE_INLINE nMapFunc n_SetMap(const coeffs src, const coeffs dst)
set the mapping function pointers for translating numbers from src to dst
static int index(p_Length length, p_Ord ord)
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)
void nKillChar(coeffs r)
undo all initialisations
@ n_algExt
used for all algebraic extensions, i.e., the top-most extension in an extension tower is algebraic
void swapMatrix(bigintmat *a)
bool skalmult(number b, coeffs c)
Multipliziert zur Matrix den Skalar b hinzu.