25 #define DEBUG_PRINTS 1 //remove this line to disable debugging
29 # define DEBUG_BLOCK(x) bool debug_block = x;
33 # define DEBUG_PRINT(x) do {if(debug_block) {Print x ;}} while(0)
34 # define DEBUG_CMD(x) do {if(debug_block) {x;}} while(0)
35 # define DEBUG_VAR(x) do {if(debug_block) {std::cout<<#x<<": "<<x<<std::endl;}} while(0)
36 # define DEBUG_N(x) do {if(debug_block) {Print(#x);Print(": ");n_Print(x,coef);Print("\n");}} while(0)
37 # define DEBUG_BIM(x) do {if(debug_block) {Print(#x);Print(": ");x->Print();Print("\n");}} while(0)
39 # define DEBUG_BLOCK(x) do {} while (0)
40 # define DEBUG_PRINT(x) do {} while (0)
41 # define DEBUG_CMD(x) do {} while (0)
42 # define DEBUG_VAR(x) do {} while (0)
43 # define DEBUG_N(x) do {} while (0)
44 # define DEBUG_BIM(x) do {} while (0)
55 n = basismatrix->
cols();
56 m = basismatrix->
rows();
66 for(
int i=1;
i<=
n;
i++) {
95 for(
int i=0;
i<=
n;
i++) {
102 for(
int i=0;
i<=
n;
i++) {
109 for(
int i=0;
i<=
n;
i++) {
137 number default_c =
n_Div(three,four,
coef);
149 for(
int j=1;
j<=
n;
j++) {
154 for(
int j=1;
j<=
n;
j++) {
162 for(
int j=0;
j<=
n;
j++) {
166 for(
int j=0;
j<=
n;
j++) {
175 for(
int j=0;
j<=
n;
j++) {
241 if(
n_Greater(
n_Mult(
n_Sub(c,
n_Mult(
my->
view(k,k-1),
my->
view(k,k-1),
coef),
coef),
B[k-1],
coef),
B[k],
coef)){
251 for(
int l=k-2;
l>0;
l--){
277 DEBUG_PRINT((
"Start RED with k=%d and l=%d\n",k,l));
283 number my_kl =
my->
get(k,l);
289 number my_klplus1div2;
291 my_klplus1div2 =
n_Add(my_kl, n_1div2,
coef);
293 my_klplus1div2 =
n_Add(my_kl, n_neg1div2,
coef);
308 for(
int i=1;
i<=l-1;
i++){
316 DEBUG_PRINT((
"Start SWAP with k=%d and k_max=%d\n",k,k_max));
326 for(
int j = 1;
j <= k-2;
j++){
327 number my_kj =
my->
get(k,
j);
332 number my_ =
my->
get(k,k-1);
349 for(
int i = k+1;
i <= k_max;
i++){
358 DEBUG_PRINT((
"Start SWAPG with k=%d and k_max=%d\n",k,k_max));
368 for(
int j = 1;
j <= k-2;
j++){
369 number my_kj =
my->
get(k,
j);
374 number my_ =
my->
get(k,k-1);
380 number tempnumber =
B[
k];
388 for(
int i = k+1;
i <= k_max;
i++){
389 number tempnumber =
my->
get(
i,k);
400 for(
int i = k+1;
i <= k_max;
i++){
421 for(
int i = k+1;
i <= k_max;
i++){
436 for(
int j=1;
j<
k;
j++) {
445 Werror(
"did not form a basis\n");
457 for(
int j=1;
j<
k;
j++) {
467 for(
int j=1;
j<
k;
j++) {
535 DEBUG_PRINT((
"Initialize vector and other variables\n"));
536 std::vector<std::pair<number,bigintmat*> > elementsvector;
554 for(
int i = 2;
i<
n+1;
i++){
570 for(
unsigned i=1;
i<elementsvector.size();
i++){
572 elementsvector.pop_back();
573 elementsvector.insert(elementsvector.begin()+
i,std::make_pair(
n_Copy(check,
coef),
bimCopy(
x)));
578 if(elementsvector.size() >= 1000000){
579 elementsvector.pop_back();
590 for(
unsigned i=1;
i<elementsvector.size();
i++){
594 for(
unsigned i=1;
i<elementsvector.size();
i++){
607 DEBUG_PRINT((
"Start enumerate_next number and bigintmat\n"));
648 for(
int j =
n;
j>1;
j--){
680 Werror(
"no bound for elements given\n");
695 Werror(
"not initialized\n");
720 DEBUG_PRINT((
"enumerate_get_next\t\t\t\t\taaaaaaaaaaaaa\n"));
748 }
else if(index == 1){
811 for(
int j = 1;
j<
i;
j++){
834 for(
int i=1;
i<=
n;
i++) {
835 for(
int j=1;
j<=
n;
j++) {
876 for(
int j=1;
j<=
n;
j++) {
884 for(
int j=1;
j<=
n;
j++) {
917 Werror(
"a->cols()!=1 in scalarproduct(a,b)\n");
921 Werror(
"b->cols()!=1 in scalarproduct(a,b)\n");
925 Werror(
"b->cols()!=1 in scalarproduct(a,b)\n");
929 Werror(
"a->basecoeffs()!=b->basecoeffs() in scalarproduct(a,b)\n");
935 for(
int i = 1;
i <= b->
rows();
i++){
952 if(elementarray ==
NULL || poly ==
NULL || coef != elementarray[0]->basecoeffs()){
957 for(
int i=1;
i<size_elementarray;
i++){
958 if(coef != elementarray[0]->basecoeffs()){
967 WerrorS(
"Ground field not implemented!\n");
972 WerrorS(
"degree of polynomial to small\n");
985 char*
n[] = {(
char*)
"i"};
986 ring newring =
rDefault(coef, 1, n);
991 rootcont->
solver( precision+12);
993 if(number_roots != deg){
994 WerrorS(
"something went wrong: \n\tnot all roots found\n");
1000 paramComp.
par_name=(
const char*)
"i";
1004 number* roots =
new number[deg+1];
1005 number* complexroots =
new number[deg+1];
1008 for(
int j=0;
j<deg;
j++){
1011 roots[r1] =
n_Copy(a,comp);
1014 complexroots[r2] =
n_Copy(a,comp);
1026 for(
int j=0;
j<r2;
j++){
1027 roots[r1+
j]=
n_Copy(complexroots[
j],comp);
1030 delete complexroots;
1033 for(
int i=0;
i<size_elementarray;
i++){
1039 for(
int i=1;
i<= r1;
i++){
1040 number pot =
n_Init(1,comp);
1041 for(
int l=0;
l< deg;
l++){
1042 for(
int j=0;
j<size_elementarray;
j++){
1052 number sqrt2 =
n_Init(1,comp);
1054 number two =
n_Init(2,comp);
1055 number sqrt2 =
squareroot(two,comp,precision+10);
1057 for(
int i=1;
i<= r2;
i++){
1058 number pot =
n_Init(1,comp);
1059 for(
int l=0;
l< deg;
l++){
1060 for(
int j=0;
j<size_elementarray;
j++){
1068 for(
int j=1;
j<=size_elementarray;
j++){
1076 for(
int i=0;
i<size_elementarray;
i++){
1080 for(
int i=0;
i<r1+r2;
i++){
1089 paramComp.
par_name=(
const char*)
"i";
1118 number two =
n_Init(2,coef);
1121 for(
int i=0;
i<prec;
i++){
1122 xn1 =
n_Div(a,xn,coef);
1123 xn2 =
n_Add(xn,xn1,coef);
1125 xn =
n_Div(xn2,two,coef);
static FORCE_INLINE number n_Sub(number a, number b, const coeffs r)
return the difference of 'a' and 'b', i.e., a-b
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
static FORCE_INLINE BOOLEAN n_Greater(number a, number b, const coeffs r)
ordered fields: TRUE iff 'a' is larger than 'b'; in Z/pZ: TRUE iff la > lb, where la and lb are the l...
complex root finder for univariate polynomials based on laguers algorithm
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) ...
bool quadratic_supplement()
static void view(const intvec *v)
bigintmat * bimSub(bigintmat *a, bigintmat *b)
bool addcol(int i, int j, number a, coeffs c)
addiert a-faches der j-ten Spalte zur i-ten dazu
void SWAPG(int k, int k_max)
bigintmat * enumerate_all(number a)
bigintmat * enumerate_next()
static int si_min(const int a, const int b)
number enumerate_get_next()
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
lattice(bigintmat *basis)
static FORCE_INLINE BOOLEAN nCoeff_is_long_R(const coeffs r)
void setcol(int j, bigintmat *m)
Setzt j-te Spalte gleich übergebenem Vektor (Matrix) m.
void appendCol(bigintmat *a)
horizontally join the matrices, m <- m|a
bool sub(bigintmat *b)
Subtrahiert ...
static FORCE_INLINE BOOLEAN nCoeff_is_Ring_Z(const coeffs r)
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
static FORCE_INLINE BOOLEAN nCoeff_is_R(const coeffs r)
const CanonicalForm CFMap CFMap int &both_non_zero int n
bigintmat * bimAdd(bigintmat *a, bigintmat *b)
Matrix-Add/-Sub/-Mult so oder mit operator+/-/* ? : NULL as a result means an error (non-compatible m...
void zero()
Setzt alle Einträge auf 0.
bigintmat * minkowksi(bigintmat **elementarray, int size_elementarray, number *poly, int deg, coeffs coef, int precision)
void gram_schmidt_MLLL(int k)
bool solver(const int polishmode=PM_NONE)
void WerrorS(const char *s)
static FORCE_INLINE BOOLEAN nCoeff_is_Q(const coeffs r)
static FORCE_INLINE BOOLEAN nCoeff_is_long_C(const coeffs r)
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
real floating point (GMP) numbers
void set(int i, int j, number n, const coeffs C=NULL)
replace an entry with a copy (delete old + copy new!). NOTE: starts at [1,1]
short float_len2
additional char-flags, rInit
int comp(const CanonicalForm &A, const CanonicalForm &B)
compare polynomials
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 FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of 'a' and 'b', i.e., a*b
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
void compute_gram_matrix()
short float_len
additional char-flags, rInit
Coefficient rings, fields and other domains suitable for Singular polynomials.
bigintmat * bimCopy(const bigintmat *b)
same as copy constructor - apart from it being able to accept NULL as input
bigintmat * bimMult(bigintmat *a, bigintmat *b)
The main handler for Singular numbers which are suitable for Singular polynomials.
static FORCE_INLINE number n_Add(number a, number b, const coeffs r)
return the sum of 'a' and 'b', i.e., a+b
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
bool skalmult(number b, coeffs c)
Multipliziert zur Matrix den Skalar b hinzu.
void swap(int i, int j)
swap columns i and j
complex floating point (GMP) numbers
ring rDefault(const coeffs cf, int N, char **n, int ord_size, int *ord, int *block0, int *block1, int **wvhdl)
void fillContainer(number *_coeffs, number *_ievpoint, const int _var, const int _tdg, const rootType _rt, const int _anz)
bool ImagGreaterZero(number a, coeffs coef)
gmp_complex * getRoot(const int i)
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
static FORCE_INLINE nMapFunc n_SetMap(const coeffs src, const coeffs dst)
set the mapping function pointers for translating numbers from src to dst
bigintmat * bimChangeCoeff(bigintmat *a, coeffs cnew)
Liefert Kopier von Matrix a zurück, mit coeffs cnew statt den ursprünglichen.
bigintmat * get_transformation_matrix()
void Print()
IO: simply prints the matrix to the current output (screen?)
static int index(p_Length length, p_Ord ord)
static FORCE_INLINE number n_ImPart(number i, const coeffs cf)
void rChangeCurrRing(ring r)
number scalarproduct(bigintmat *a, bigintmat *b)
void getcol(int j, bigintmat *a)
copies the j-th column into the matrix a - which needs to be pre-allocated with the correct size...
void SWAP(int k, int k_max)
void mult(unsigned long *result, unsigned long *a, unsigned long *b, unsigned long p, int dega, int degb)
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of 'n'
void rDelete(ring r)
unconditionally deletes fields in r
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...
coeffs basecoeffs() const
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) ...
static FORCE_INLINE number n_RePart(number i, const coeffs cf)
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 CFFList norm(const CanonicalForm &f, const CanonicalForm &PPalpha, CFGenerator &myrandom, CanonicalForm &s, CanonicalForm &g, CanonicalForm &R, bool proof)
compute the norm R of f over PPalpha, g= f (x-s*alpha) if proof==true, R is squarefree and if in addi...
const char * par_name
parameter name
void increase_x(int index)
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
static FORCE_INLINE BOOLEAN n_GreaterZero(number n, const coeffs r)
ordered fields: TRUE iff 'n' is positive; in Z/pZ: TRUE iff 0 < m <= roundedBelow(p/2), where m is the long representing n in C: TRUE iff (Im(n) != 0 and Im(n) >= 0) or (Im(n) == 0 and Re(n) >= 0) in K(a)/
: TRUE iff (n != 0 and (LC(n) > 0 or deg(n) > 0)) in K(t_1, ..., t_n): TRUE iff (LC(numerator(n) is a constant and > 0) or (LC(numerator(n) is not a constant) in Z/2^kZ: TRUE iff 0 < n <= 2^(k-1) in Z/mZ: TRUE iff the internal mpz is greater than zero in Z: TRUE iff n > 0
number squareroot(number a, coeffs coef, int prec)
number check_bound(int index)
void setGMPFloatDigits(size_t digits, size_t rest)
Set size of mantissa digits - the number of output digits (basis 10) the size of mantissa consists of...
void Werror(const char *fmt,...)
void one()
Macht Matrix (Falls quadratisch) zu Einheitsmatrix.
number get(int i, int j) const
get a copy of an entry. NOTE: starts at [1,1]
bigintmat * get_reduced_basis()
bool IsReal(number a, coeffs coef)
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL