lattice.cc
Go to the documentation of this file.
1 #include <coeffs/bigintmat.h>
2 #include "lattice.h"
3 //#include "kernel/febase.h" // for Print, WerrorS
4 #include <coeffs/numbers.h>
5 #include <coeffs/coeffs.h>
6 #include "Singular/ipid.h"
7 #include <iostream>
8 #include <vector>
9 #include <utility>
10 //for minkowski
12 
13 
14 //NOTE: Todo: Combine scalarproduct and gram_matrix
15 
16 
17 
18 
19 
20 
21 ///////////////////////////////////////
22 // Debugging Stuff ///
23 ///////////////////////////////////////
24 
25 #define DEBUG_PRINTS 1 //remove this line to disable debugging
26 #ifdef DEBUG_PRINTS
27 
28  //DEBUG_BLOCK(true / false); to enable/disable debugging in this block
29 # define DEBUG_BLOCK(x) bool debug_block = x;
30  //standard if DEBUG_BLOCK( ); not used
31  static bool debug_block = false;
32  //use like: DEBUG_PRINT(("Status %d",i))
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)
38 #else
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)
45 #endif
46 
47 
48 ///////////////////////////////////////
49 // constructors/destructor ///
50 ///////////////////////////////////////
51 
53  DEBUG_BLOCK(true);
54  DEBUG_PRINT(("Creating new lattice..."));
55  n = basismatrix->cols();
56  m = basismatrix->rows();
57  out_coef = basismatrix->basecoeffs();
58  DEBUG_PRINT(("always set coef =out_coef"));
59  coef =out_coef;
60 
61  //NOTE: Add transformation from rings to fields here
62  // exact <-> rounded
63 
64  basis = new bigintmat*[n+1]; //basis[0] is not used
65  basis[0] = NULL;
66  for(int i=1; i<=n; i++) {
67  basis[i] = new bigintmat(m,1,coef);
68  basismatrix->getcol(i,basis[i]);
69  }
70  gram_matrix = bimCopy(basismatrix);
71  c = NULL;
72  B = NULL;
73  b = NULL;
74  b_star = NULL;
75  H = NULL;
76  my = NULL;
77  Q = NULL;
78  rank = 0;
79  independentVectors = true;
80  integral = true;
81  trans_matrix = true;
82 
83  //for enumeration
84  x = NULL;
85  bound = NULL;
86 
87  DEBUG_PRINT(("Done\n"));
88 }
89 
91  DEBUG_BLOCK(true);
92  DEBUG_PRINT(("Deleting lattice..."));
93 
94  if(basis != NULL) {
95  for(int i=0; i<=n; i++) {
96  delete basis[i];
97  }
98  delete[] basis;
99  }
100 
101  if(b != NULL) {
102  for(int i=0; i<=n; i++) {
103  delete b[i];
104  }
105  delete[] b;
106  }
107 
108  if(b_star != NULL) {
109  for(int i=0; i<=n; i++) {
110  delete b_star[i];
111  }
112  delete[] b_star;
113  }
114 
115  delete H;
116 
117  delete my;
118 
119  delete[] B;
120 
121  n_Delete(&c,coef);
122 
123  delete Q;
124 
125  DEBUG_PRINT(("Done\n"));
126 }
127 
128 
129 ///////////////////////////////////////
130 // LLL ///
131 ///////////////////////////////////////
132 
134  // c = 3/4
135  number three = n_Init(3, coef);
136  number four = n_Init(4, coef);
137  number default_c = n_Div(three,four,coef);
138  n_Delete(&three,coef);
139  n_Delete(&four,coef);
140  return lattice::LLL(default_c);
141 }
142 
143 bool lattice::LLL(number& c){
144  DEBUG_PRINT(("Start LLL\n"));
145 
146  if(b == NULL) {
147  b = new bigintmat*[n+1]; //b[0] is not used
148  b[0] = NULL;
149  for(int j=1; j<=n; j++) {
150  b[j] = bimCopy(basis[j]);
151  }
152  } else {
153  b[0] = NULL;
154  for(int j=1; j<=n; j++) {
155  delete b[j];
156  b[j] = bimCopy(basis[j]);
157  }
158  }
159 
160  if(b_star == NULL) {
161  b_star = new bigintmat*[n+1]; //b_star[0] is not used
162  for(int j=0; j<=n; j++) {
163  b_star[j] = NULL;
164  }
165  } else {
166  for(int j=0; j<=n; j++) {
167  delete b_star[j];
168  b_star[j] = NULL;
169  }
170  }
171 
172  if(B == NULL) {
173  B = new number[n+1]; //B[0] is not used
174  }
175  for(int j=0; j<=n; j++) {
176  B[j] = n_Init(0,coef);
177  }
178 
179  delete H;
180  if(trans_matrix) {
181  H = new bigintmat(n,n,coef);
182  } else {
183  H = NULL;
184  }
185 
186  delete my;
187  my = new bigintmat(m,n,coef);
188 
189  delete[] d;
190  if(integral) {
191  d = new number[n+1];
192  } else {
193  d = NULL;
194  }
195 
196  this->c = c;
197 
198  if (n == 0) {
199  return true;
200  }
201  if (n == 1) {
202  return false;
203  }
204 
205  DEBUG_BIM(b[1]);
206  DEBUG_BIM(b[2]);
207  DEBUG_BIM(b[3]);
208 
209  DEBUG_PRINT(("Initialize\n"));
210  int k = 2;
211  int k_max = 1;
212 
213 
214  b_star[1] = bimCopy(b[1]);
215 
216  B[1] = scalarproduct(b[1],b[1]);
217 
218  if(trans_matrix) {
219  H->one();
220  }
221 
222  do{
223  DEBUG_PRINT(("Incremental Gram-Schmidt\n"));
224  DEBUG_VAR(k);
225  DEBUG_VAR(k_max);
226  if(k > k_max){
227  k_max = k;
228  if(independentVectors) {
229  if(gram_schmidt(k)){
230  return true;
231  }
232  } else {
234  }
235  }
236  DEBUG_PRINT(("Test LLL condition\n"));
237  while(true){
238  RED(k,k-1);
239 
240  // if((B[k] < (c- my*my)*B[k-1]))
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)){
242  if(independentVectors) {
243  SWAP(k,k_max);
244  } else {
245  SWAPG(k,k_max);
246  }
247  if(k>2){
248  k--;
249  }
250  } else {
251  for(int l=k-2; l>0; l--){
252  RED(k,l);
253  }
254  k++;
255  break;
256  }
257  }
258  } while(k <= n);
259 
260  rank = n;
261  for(int i=1; b[i]->isZero() && i<=n; i++) {
262  rank--;
263  }
264 
265 
266 
267 
268  DEBUG_BIM(b[1]);
269  DEBUG_BIM(b[2]);
270  DEBUG_BIM(b[3]);
271 
272  DEBUG_PRINT(("End of LLL\n"));
273  return false;
274 }
275 
276 void lattice::RED(int k, int l){
277  DEBUG_PRINT(("Start RED with k=%d and l=%d\n",k,l));
278  DEBUG_BIM(b[1]);
279  DEBUG_BIM(b[2]);
280  DEBUG_BIM(b[3]);
281  number n_1div2 = n_Div(n_Init( 1,coef),n_Init(2,coef),coef);
282  number n_neg1div2 = n_Div(n_Init(-1,coef),n_Init(2,coef),coef);
283  number my_kl = my->get(k,l);
284  DEBUG_N(my_kl);
285 
286  // if(|my_kl| > 1/2)
287  if (n_Greater (my_kl,n_1div2,coef) || n_Greater (n_neg1div2,my_kl,coef)) {
288 
289  number my_klplus1div2;
290  if(n_Greater (my_kl,n_Init(0,coef),coef)) {
291  my_klplus1div2 = n_Add(my_kl, n_1div2, coef);
292  } else {
293  my_klplus1div2 = n_Add(my_kl, n_neg1div2, coef);
294  }
295 
296  number q = n_Div(n_GetNumerator(my_klplus1div2,coef),n_GetDenom(my_klplus1div2,coef),coef);
297 
298  DEBUG_N(q);
299 
300  b[k]->sub(bimMult(b[l],q,coef));
301 
302  if(trans_matrix) {
303  H->addcol(k,l,n_Mult(q,n_Init(-1,coef),coef),coef);
304  }
305 
306  my->set(k,l,n_Sub(my->view(k,l),q,coef),coef);
307 
308  for(int i=1;i<=l-1;i++){
309  my->set(k,i,n_Sub(my->view(k,i), n_Mult(q, my->view(l,i),coef), coef), coef);
310  }
311  }
312  DEBUG_PRINT(("End of RED\n"));
313 }
314 
315 void lattice::SWAP(int k, int k_max){
316  DEBUG_PRINT(("Start SWAP with k=%d and k_max=%d\n",k,k_max));
317 
318  bigintmat * temp = b[k];
319  b[k] = b[k-1];
320  b[k-1] = temp;
321 
322  if(trans_matrix) {
323  H->swap(k,k-1);
324  }
325 
326  for(int j = 1; j <= k-2; j++){
327  number my_kj = my->get(k,j);
328  my->set(k,j,my->view(k-1,j),coef);
329  my->set(k-1,j,my_kj,coef);
330  }
331 
332  number my_ = my->get(k,k-1);
333 
334  number B_ = n_Add(B[k], n_Mult(n_Mult(my_,my_,coef), B[k-1], coef), coef);
335 
336  my->set(k,k-1,n_Div(n_Mult(my_, B[k-1], coef), B_, coef), coef);
337 
338  bigintmat * b_ = bimCopy(b_star[k-1]);
339 
340  b_star[k-1] = bimAdd(b_star[k], bimMult(b_, my_, coef));
341 
342  b_star[k] = bimSub(bimMult(b_, n_Div(B[k], B_, coef),coef), bimMult( b_star[k], my->view(k,k-1), coef));
343 
344  delete b_;
345 
346  B[k] = n_Div(n_Mult(B[k], B[k-1], coef), B_, coef);
347 
348  B[k-1] = n_Copy(B_, coef);
349  for(int i = k+1; i <= k_max; i++){
350  number t = my->get(i,k);
351  my->set(i,k,n_Sub(my->get(i,k-1), n_Mult(my_, t, coef), coef), coef);
352  my->set(i,k-1, n_Add(t, n_Mult(my->view(k,k-1), my->view(i,k), coef), coef), coef);
353  }
354  DEBUG_PRINT(("End of SWAP\n"));
355 }
356 
357 void lattice::SWAPG(int k, int k_max){
358  DEBUG_PRINT(("Start SWAPG with k=%d and k_max=%d\n",k,k_max));
359 
360  bigintmat * temp = b[k];
361  b[k] = b[k-1];
362  b[k-1] = temp;
363 
364  if(trans_matrix) {
365  H->swap(k,k-1);
366  }
367 
368  for(int j = 1; j <= k-2; j++){
369  number my_kj = my->get(k,j);
370  my->set(k,j,my->get(k-1,j),coef);
371  my->set(k-1,j,my_kj,coef);
372  }
373 
374  number my_ = my->get(k,k-1);
375 
376  number B_ = n_Add(B[k], n_Mult(n_Mult(my_,my_,coef), B[k-1], coef), coef);
377 
378  if(n_IsZero(B[k],coef)) {
379  if(n_IsZero(my_,coef)) {
380  number tempnumber = B[k];
381  B[k] = B[k-1];
382  B[k-1] = tempnumber;
383 
384  bigintmat * temp = b_star[k];
385  b_star[k] = b_star[k-1];
386  b_star[k-1] = temp;
387 
388  for(int i = k+1; i <= k_max; i++){
389  number tempnumber = my->get(i,k);
390  my->set(i,k,my->get(i,k-1), coef);
391  my->set(i,k-1,tempnumber, coef);
392  }
393  } else {
394  B[k-1] = n_Copy(B_, coef); //delete B[k-1] ?
395 
396  b_star[k-1]->skalmult(my_, coef);
397 
398  my->set(k,k-1, n_Div(n_Init(1,coef),my_, coef), coef);
399 
400  for(int i = k+1; i <= k_max; i++){
401  my->set(i,k-1,n_Div(my->view(i,k-1), my_, coef), coef);
402  }
403  }
404  } else {
405  number t = n_Div(B[k-1], B_, coef);
406 
407  my->set(k,k-1,n_Mult(my_,t,coef),coef);
408 
409  bigintmat * b_ = b_star[k-1];
410 
411  b_star[k-1] = bimAdd(b_star[k], bimMult(b_, my_, coef));
412 
413  b_star[k] = bimSub(bimMult(b_, n_Div(B[k], B_, coef),coef), bimMult( b_star[k], my->view(k,k-1), coef));
414 
415  delete b_;
416 
417  B[k] = n_Mult(B[k],t,coef); // n_InpMult
418 
419  B[k-1] = n_Copy(B_, coef);
420 
421  for(int i = k+1; i <= k_max; i++){
422  t = my->get(i,k);
423  my->set(i,k,n_Sub(my->view(i,k-1),n_Mult(my_,t,coef), coef), coef);
424  my->set(i,k-1,n_Add(t,n_Mult(my->view(k,k-1),my->view(i,k),coef),coef),coef);
425  }
426  }
427  DEBUG_PRINT(("End of SWAPG\n"));
428 }
429 
431  DEBUG_PRINT(("Start gram_schmidt(%d)\n",k));
432 
433  delete b_star[k];
434  b_star[k] = bimCopy(b[k]);
435 
436  for(int j=1; j<k; j++) {
437  my->set(k,j,n_Div(scalarproduct(b[k],b_star[j]),B[j],coef),coef);
438 
439  b_star[k]->sub(bimMult(b_star[j],my->view(k,j),coef));
440  }
441 
442  B[k] = scalarproduct(b_star[k],b_star[k]);
443 
444  if(n_IsZero(B[k],coef)){
445  Werror("did not form a basis\n");
446  DEBUG_PRINT(("End of gram_schmidt(%d)\n",k));
447  return true;
448  } else {
449  DEBUG_PRINT(("End of gram_schmidt(%d)\n",k));
450  return false;
451  }
452 }
453 
455  DEBUG_PRINT(("Start gram_schmidt_MLLL(%d)\n",k));
456 
457  for(int j=1; j<k; j++) {
458  if(n_IsZero(B[j],coef)) {
459  my->set(k,j,n_Init(0,coef));
460  } else {
461  my->set(k,j,n_Div(scalarproduct(b[k],b_star[j]),B[j],coef),coef);
462  }
463  }
464 
465  delete b_star[k];
466  b_star[k] = bimCopy(b[k]);
467  for(int j=1; j<k; j++) {
468  b_star[k]->sub(bimMult(b_star[j],my->view(k,j),coef));
469  }
470 
471  B[k] = scalarproduct(b_star[k],b_star[k]);
472 
473  DEBUG_PRINT(("End of gram_schmidt_MLLL(%d)\n",k));
474 }
475 
476 
477 // bool lattice::gram_matrix(int k){ Page 89 Remark 2
478 // number* a = new number[k];
479 // for(int j = 1; j<k;j++){
480 // a[j] = n_Init(0,coef);
481 // for(int i =1; i<=b->rows(); i++){
482 // a[j] = n_Add(a[j],n_Mult(b->view(i,k),b->view(i,j),coef),coef);//a[j] += b->view(i,k) * b->view(i,j);
483 // }
484 // for(int i =1; i<=j-1; i++){
485 // a[j] = n_Add(a[j],n_Mult(b->view(i,j),a[i],coef),coef);//a[j] += my->view(j,i) * a[i];
486 // }
487 // my->set(k,j,n_Div(a[j],B[j],coef),coef);
488 // }
489 // B[k]=n_Init(0,coef);
490 // for(int i =1; i<=b->rows(); i++){
491 // B[k]=n_Add(B[k],n_Mult(b->view(i,k),b->view(i,k),coef),coef);//B[k] += b->view(i,k) * b->view(i,k);
492 // }
493 // for(int i =1; i<=k-1; i++){
494 // B[k] = n_Add(B[k],n_Mult(my->view(k,i),a[i],coef),coef);//B[k] += my->view(k,i) * a[i];
495 // }
496 // if(B[k] == 0){
497 // Werror("did not form a basis\n");
498 // return false;
499 // }
500 // return true;
501 // }
502 
503 ///////////////////////////////////////
504 // Enumerate ///
505 ///////////////////////////////////////
506 //Public
508  //Quadratic Supplement
509  DEBUG_BLOCK(true);
510  DEBUG_PRINT(("Start enumerate_all\n"));
511  DEBUG_PRINT(("check input\n"));
512  if(!n_GreaterZero(a,out_coef)){
513  if(n_IsZero(a,out_coef) && n==m){
514  return new bigintmat(m,1,out_coef);
515  } else {
516  DEBUG_PRINT(("negative input\n"));
517  return NULL;
518  }
519  }
520  if( Q == NULL){
521  if(quadratic_supplement()){
522  return NULL;
523  }
524  }
525  DEBUG_PRINT(("Q defined\n"));
526  //Q->Print();PrintS("\n");
527 
528  //usefull numbers
529  number zero = n_Init(0,coef);
530  number minusOne = n_Init(-1,coef);
531 
532  //backtracking for elements
533  //DEBUG_BLOCK(true);
534  DEBUG_PRINT(("Start backtracking\n"));
535  DEBUG_PRINT(("Initialize vector and other variables\n"));
536  std::vector<std::pair<number,bigintmat*> > elementsvector;
537  elementsvector.push_back( std::make_pair(zero, new bigintmat(m,1,out_coef)));
538  if( x != NULL){
539  delete x;
540  x=NULL;
541  }
542  x = new bigintmat(m,1,coef);
543  //x->Print();PrintS("\n");
544  DEBUG_PRINT(("map a\n"));
545  if(bound != NULL){
546  delete bound;
547  bound = NULL;
548  }
549  bound = new number[n+1];
551  bound[1] = f(a, out_coef, coef);//map a to coef
552  //n_Print(bound[1],coef);PrintS("\n");
553  DEBUG_PRINT(("set bound\n"));
554  for(int i = 2; i<n+1; i++){
555  bound[i] = n_Copy(bound[1],coef);
556  //n_Print(bound[i],coef);PrintS("\n");
557  }
558  DEBUG_PRINT(("find element\n"));
559  //bigintmat* elements = enumerate_next(a);
560  increase_x(1);
561  number check = enumerate_get_next();
562  while(!n_Equal(minusOne,check,coef)){
563  //append x to elements
564  DEBUG_PRINT(("new element to list\n"));
565  //elements->appendCol(bimChangeout_coeff(x,out_coef));
566  check = n_Sub(bound[1],check,coef);
567  check = n_Sub(bound[n],check,coef);
568  elementsvector.push_back(std::make_pair(n_Copy(check,coef),bimCopy(x)));
569  //n_Print(elementsvector[elementsvector.size()-1].first,coef);PrintS("\n");
570  for(unsigned i=1; i<elementsvector.size();i++){
571  if(n_Greater(elementsvector[i].first,check,coef)){
572  elementsvector.pop_back();
573  elementsvector.insert(elementsvector.begin()+i,std::make_pair(n_Copy(check,coef),bimCopy(x)));
574  DEBUG_VAR(elementsvector.size());
575  break;
576  }
577  }
578  if(elementsvector.size() >= 1000000){
579  elementsvector.pop_back();
580  }
581  increase_x(1);
582  DEBUG_PRINT(("increased x:\n"));x->Print();
583  n_Delete(&check,coef);
584  check = enumerate_get_next();
585  DEBUG_PRINT(("got it\n"));
586  }
587  DEBUG_PRINT(("generate bigintmat for return\n"));
588  bigintmat* elements = new bigintmat(m,1,out_coef);
589  if(b!=NULL){
590  for(unsigned i=1; i<elementsvector.size();i++){
591  elements->appendCol(bimChangeCoeff(elementsvector[i].second,out_coef));
592  }
593  } else {
594  for(unsigned i=1; i<elementsvector.size();i++){
595  elements->appendCol(bimChangeCoeff(elementsvector[i].second,out_coef));
596  }
597  }
598  delete bound;
599  bound = NULL;
600  delete x;
601  x = NULL;
602  return elements;
603 }
604 
605 bigintmat * lattice::enumerate_next(number a, bigintmat * in){//next element x with norm(x)<a and x=in possible
606  DEBUG_BLOCK(true);
607  DEBUG_PRINT(("Start enumerate_next number and bigintmat\n"));
608  if (in == NULL || in->rows()!=n || in->cols()!=1){
609  DEBUG_PRINT(("Dimension error of input\n"));
610  return NULL;
611  }
612 
613  if(!n_GreaterZero(a,out_coef) || n_IsZero(a,out_coef) ){
614  DEBUG_PRINT(("negative input\n"));
615  return NULL;
616  }
617 
618  DEBUG_PRINT(("check quadratic\n"));
619 
620  if( Q == NULL){
621  if(!quadratic_supplement()){
622  return NULL;
623  }
624  }
625  DEBUG_PRINT(("Q defined\n"));
626  //Q->Print();PrintS("\n");
627 
628  //usefull numbers
629  number check;
630 
631  //backtracking for elements
632  //DEBUG_BLOCK(true);
633  DEBUG_PRINT(("Start backtracking\n"));
634  DEBUG_PRINT(("Initialize variables\n"));
635  if( x != NULL){
636  delete x;
637  x=NULL;
638  }
639  x = bimChangeCoeff(in,coef);
640  if( bound != NULL){
641  delete bound;
642  bound=NULL;
643  }
644  bound = new number[n+1];
645  DEBUG_PRINT(("set bound\n"));
647  bound[n] = f(a, out_coef, coef);//map a to coef
648  for(int j = n; j>1; j--){
649  check = check_bound(j);
650  bound[j-1] = n_Sub(bound[j],check,coef);
651  //n_Delete(&check, coef);
652  }
653  number minusOne = n_Init(-1,coef);
654  DEBUG_PRINT(("find element\n"));
655  number norm = enumerate_get_next();
656  DEBUG_PRINT(("generate bigintmat for return\n"));
657  if(n_Equal(minusOne,norm,coef)){
658  return NULL;
659  }
661  return out;
662 }
663 
665  DEBUG_BLOCK(true);
666  DEBUG_PRINT(("Start enumerate_next number\n"));
667  bigintmat * in =new bigintmat(m,1,out_coef);
668  if(x == NULL){
669  in->set(1,1,n_Init(1,out_coef),out_coef);
670  } else {
671  in = bimChangeCoeff(x,out_coef);
672  }
673  return enumerate_next(a,in);
674 }
675 
677  DEBUG_BLOCK(true);
678  DEBUG_PRINT(("Start enumerate_next bigintmat\n"));
679  if(bound == NULL){
680  Werror("no bound for elements given\n");
681  return NULL;
682  }
683  if (in == NULL || in->rows()!=n || in->cols()!=1){
684  DEBUG_PRINT(("Dimension error of input\n"));
685  return NULL;
686  }
687  number a = bound[n];
688  return enumerate_next(a,in);
689 }
690 
692  DEBUG_BLOCK(true);
693  DEBUG_PRINT(("enumerate_next\n"));
694  if(Q == NULL){
695  Werror("not initialized\n");
696  return NULL;
697  }
698  if(bound == NULL || x == NULL){
699  return NULL;
700  }
701  increase_x(1);
702  number minusOne = n_Init(-1,coef);
703  number one = n_Init(1,coef);
704  DEBUG_PRINT(("find element\n"));
705  number norm = enumerate_get_next();
706  DEBUG_PRINT(("generate bigintmat for return\n"));
707  if(n_Equal(minusOne,norm,coef)){
708  if(!n_Equal(minusOne, x->view(1,1),coef)){
709  x->rawset(1,1, n_Add(one,x->view(1,1),coef),coef);
710  }
711  return NULL;
712  }
714  return out;
715 }
716 
717 //Private
719  DEBUG_BLOCK(true);
720  DEBUG_PRINT(("enumerate_get_next\t\t\t\t\taaaaaaaaaaaaa\n"));
721  number one = n_Init(1,coef);
722  number zero = n_Init(0,coef);
723  number minusOne = n_Init(-1,coef);
724  int index =1;
725  //x->Print();PrintS("\n");
726  //DEBUG_PRINT(("first time changing x\n"));
727  //increase_x(1);
728  DEBUG_PRINT(("actual backtracking\n"));
729  while (index <= m) {
730  DEBUG_PRINT(("update check\n"));
731  number check = check_bound(index);
732  DEBUG_PRINT(("check check\n"));
733  if (n_Greater(check,bound[index],coef)){
734  DEBUG_PRINT(("element to great\n"));
735  if(!(n_GreaterZero(x->view(index,1),coef) || n_IsZero(x->view(index,1),coef))){
736  bound[index] = zero;
737  x->set(index,1,zero,coef);
738  index++;
739  if(index<= m){
740  increase_x(index);
741  }
742  } else {
743  if(index == n){
744  return minusOne;
745  }
746  x->set(index,1,minusOne,coef);
747  }
748  } else if(index == 1){
749  DEBUG_PRINT(("possible new element\n"));
750  if(n_IsZero(x->view(n,1),coef)){
751  int j=n-1;
752  while(n_IsZero(x->view(j,1),coef)){
753  j--;
754  }DEBUG_VAR(j);
755  if(n_GreaterZero(x->view(j,1),coef)){
756  return check;
757  } else {
758  index = j+1;
759  x->zero();
760  x->set(index,1,one,coef);
761  }
762  } else {
763  DEBUG_PRINT(("return\n"));
764  return check;
765  }
766  } else {
767  DEBUG_PRINT(("reduce index\n"));
768  index--;
769  bound[index] = n_Sub(bound[index+1],check,coef);
770  }
771  }
772  return minusOne;
773 }
774 
776  //DEBUG_BLOCK(true);
777  delete Q;
778  Q = NULL;
779  if(n != m) { //NOTE: rank?
780  return true;
781  }
783  Q = gram_matrix;
784 
785  number zero = n_Init(0,coef);
786  number mult;
787 
788  DEBUG_PRINT(("Begin Quadratic Suplement\n"));
789  for(int i = 1; i<Q->cols();i++){
790  if(n_IsZero( Q->view(i,i), coef)){
791  DEBUG_PRINT(("matrix not positive definite\n"));
792  delete Q;
793  Q = NULL;
794  return true;
795  }
796  for( int j=i+1; j<=Q->cols();j++){
797  Q->rawset(j,i,Q->get(i,j),coef);
798  Q->rawset(i,j,n_Div(Q->get(i,j),Q->view(i,i),coef),coef);
799  }
800  for(int m=i+1; m<=Q->rows();m++){
801  for(int n=i+1; n<=Q->cols();n++){
802  mult = n_Mult(Q->view(m,i),Q->view(i,n),coef);
803  Q->rawset(m,n,n_Sub(Q->get(m,n),mult,coef),coef);
804  n_Delete(&mult,coef);
805  }
806  }
807  }
808 
809  DEBUG_PRINT(("Set Zeros\n"));
810  for(int i = 2; i<=Q->cols();i++){
811  for(int j = 1; j<i;j++){
812  Q->set(i,j,zero,coef);
813  }
814  }
815  n_Delete(&zero,coef);
816  DEBUG_PRINT(("Test: matrix positive definite\n"));
817  for(int i=1; i<=Q->cols();i++){
818  if(!n_GreaterZero( Q->view(i,i), coef)){
819  DEBUG_PRINT(("matrix not positive definite\n"));
820  delete Q;
821  Q = NULL;
822  return true;
823  }
824  }
825  return false;
826 }
827 
829  if(gram_matrix != NULL) {
830  delete gram_matrix;
831  gram_matrix = NULL;
832  }
833  gram_matrix = new bigintmat(n,n,coef);
834  for(int i=1; i<=n; i++) {
835  for(int j=1; j<=n; j++) {
837  }
838  }
839 }
840 
842  number one = n_Init(1,coef);x->Print();
843  number newNumber;
844  if (n_GreaterZero(x->view(index,1),coef) || n_IsZero(x->view(index,1),coef)){
845  newNumber = n_Add(one,x->view(index,1),coef); //x_i=x_i+1
846  } else {
847  newNumber = n_Sub(x->view(index,1),one,coef);//x_i=x_i-1
848  }
849  x->set(index,1,newNumber,coef);
850  x->Print();
851  n_Delete(&one,coef);
852  n_Delete(&newNumber,coef);
853 }
854 
856  DEBUG_BLOCK(true);DEBUG_PRINT(("check bound\n"));DEBUG_VAR(index);
857  number check = n_Init(0,coef);DEBUG_PRINT(("x:\n"));x->Print();
858  for(int i=index + 1;i<=Q->cols();i++){DEBUG_VAR(i);
859  number mult = n_Mult(x->view(i,1),Q->view(index,i),coef);
860  n_InpAdd(check,mult,coef);
861  n_Delete(&mult,coef);
862  }
863  n_InpAdd(check, x->view(index,1), coef);
864  n_InpMult(check, check, coef);
865  n_InpMult(check, Q->get(index,index), coef);
866  return check;
867 }
868 
869 
870 ///////////////////////////////////////
871 // Getter ///
872 ///////////////////////////////////////
873 
875  bigintmat * r = new bigintmat(m,n,coef);
876  for(int j=1; j<=n; j++) {
877  r->setcol(j,basis[j]);
878  }
879  return r;
880 }
881 
883  bigintmat * r = new bigintmat(m,n,coef);
884  for(int j=1; j<=n; j++) {
885  r->setcol(j,b[j]);
886  }
887  return r;
888 }
889 
891  return bimCopy(H);
892 }
893 
894 
895 ///////////////////////////////////////
896 // Setter ///
897 ///////////////////////////////////////
898 
899 // void lattice::set_c(number a){
900 // if (n_Greater (n_Mult(a,n_Init(4,coef),coef),n_Init(1,coef),coef) && n_Greater (n_Init(1,coef),a,coef)) {//(1<4*a && a<1){
901 // c = n_Copy(a, coef);
902 // } else if(n_IsOne(a, coef)){
903 // c = n_Copy(a, coef);
904 // Werror("probably not in polynomial time\n");
905 // } else {
906 // Werror("not a possible value\n");
907 // }
908 // }
909 
910 
911 ///////////////////////////////////////
912 // Other ///
913 ///////////////////////////////////////
914 
916  if(a->cols()!=1) {
917  Werror("a->cols()!=1 in scalarproduct(a,b)\n");
918  return NULL;
919  }
920  if(b->cols()!=1) {
921  Werror("b->cols()!=1 in scalarproduct(a,b)\n");
922  return NULL;
923  }
924  if(a->rows()!=b->rows()) {
925  Werror("b->cols()!=1 in scalarproduct(a,b)\n");
926  return NULL;
927  }
928  if(a->basecoeffs()!=b->basecoeffs()) {
929  Werror("a->basecoeffs()!=b->basecoeffs() in scalarproduct(a,b)\n");
930  return NULL;
931  }
932 
933  coeffs coef = a->basecoeffs();
934  number p = n_Init(0,coef);
935  for(int i = 1; i <= b->rows(); i++){
936  number prod = n_Mult(a->view(i,1), b->view(i,1), coef);
937  n_InpAdd(p, prod, coef);
938  n_Delete(&prod,coef);
939  }
940  return p;
941 }
942 
943 
944 ///////////////////////////////////////
945 // Minkowski map ///
946 ///////////////////////////////////////
947 
948 bigintmat * minkowksi(bigintmat ** elementarray,int size_elementarray, number * poly,int deg, coeffs coef, int precision){
949  DEBUG_BLOCK(true);
950  DEBUG_PRINT(("Begin Minkowski map\n"));
951  DEBUG_PRINT(("Input check\n"));
952  if(elementarray == NULL || poly == NULL || coef != elementarray[0]->basecoeffs()){
953  WerrorS("wrong input!\n");
954  return NULL;
955  }
956 
957  for(int i=1;i<size_elementarray;i++){
958  if(coef != elementarray[0]->basecoeffs()){
959  WerrorS("wrong input!\n");
960  return NULL;
961  }
962  }
963 
964  //char = 0
965  if ( !(nCoeff_is_Ring_Z(coef) || nCoeff_is_R(coef) || nCoeff_is_Q(coef) ||
966  nCoeff_is_long_R(coef) || nCoeff_is_long_C(coef)) ){
967  WerrorS("Ground field not implemented!\n");
968  return NULL;
969  }
970 
971  if(deg<2){
972  WerrorS("degree of polynomial to small\n");
973  return NULL;
974  }
975  //check and define precision for Q
976  if(precision<6){
977  precision = 6;
978  }
979  if ( !(nCoeff_is_R(coef) || nCoeff_is_long_R(coef) || nCoeff_is_long_C(coef)) ){
980  setGMPFloatDigits( precision+6,precision+6);
981  }
982 
983  DEBUG_PRINT(("find roots\n"));
984  ring CurrOldRing = rCopy(currRing);//need to change currRing, because rootContainer uses the coef of it
985  char* n[] = {(char*)"i"};
986  ring newring = rDefault(coef, 1, n);
987  rChangeCurrRing(newring);
988  DEBUG_PRINT(("initialize rootContainer\n"));
989  rootContainer * rootcont= new rootContainer();
990  rootcont->fillContainer( poly, NULL, 1, deg, rootContainer::onepoly, 1 );///
991  rootcont->solver( precision+12);
992  int number_roots = rootcont ->getAnzRoots();
993  if(number_roots != deg){
994  WerrorS("something went wrong: \n\tnot all roots found\n");
995  return NULL;
996  }
997  LongComplexInfo paramComp;
998  paramComp.float_len = si_min (precision+6, 32767);
999  paramComp.float_len2 = si_min (precision+8, 32767);
1000  paramComp.par_name=(const char*)"i";
1001 
1002  coeffs comp = nInitChar(n_long_C, &paramComp);
1003 
1004  number* roots = new number[deg+1];
1005  number* complexroots = new number[deg+1];
1006  int r1 = 0;
1007  int r2 = 0;
1008  for(int j=0; j<deg; j++){
1009  number a = n_Copy((number)(rootcont->getRoot(j)),comp);
1010  if( IsReal(a,comp)){
1011  roots[r1] = n_Copy(a,comp);
1012  r1++;
1013  }else if(ImagGreaterZero(a, comp)){
1014  complexroots[r2] = n_Copy(a,comp);
1015  r2++;
1016  }
1017  n_Delete(&a,comp);
1018  }
1019  rChangeCurrRing(CurrOldRing);
1020  DEBUG_PRINT(("delete some variables\n"));
1021  rDelete(newring);
1022  delete &n;
1023  //delete rootcont;DEBUG_PRINT(("can't delete rootcontainer rootcont\n"));
1024  DEBUG_VAR(r1);
1025  DEBUG_VAR(r2);
1026  for(int j=0;j<r2;j++){
1027  roots[r1+j]= n_Copy(complexroots[j],comp);
1028  n_Delete(&complexroots[j],comp);
1029  }
1030  delete complexroots;
1031  DEBUG_PRINT(("map elementarray to complex\n"));
1032  bigintmat ** elements = new bigintmat*[size_elementarray];
1033  for(int i=0;i<size_elementarray;i++){
1034  elements[i] = bimChangeCoeff(elementarray[i],comp);
1035  }
1036  DEBUG_PRINT(("generate output matrix\n"));
1037  DEBUG_PRINT(("real part\n"));
1038  bigintmat * complexmat = new bigintmat(r1+2*r2,size_elementarray,comp);
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++){
1043  number mult = n_Mult(pot,elements[j]->view(l),comp);
1044  complexmat->rawset(i,j+1,n_Add(complexmat->view(i,j+1),mult,comp),comp);
1045  n_Delete(&mult,comp);
1046  }
1047  n_InpMult(pot, roots[i-1],comp);
1048  }
1049  n_Delete(&pot,comp);
1050  }
1051  DEBUG_PRINT(("imaginary part\n"));
1052  number sqrt2 = n_Init(1,comp);
1053  if(r2>0){
1054  number two = n_Init(2,comp);
1055  number sqrt2 = squareroot(two,comp,precision+10);
1056  n_Delete(&two,comp);
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++){
1061  number mult = n_Mult(pot,elements[j]->view(l),comp);
1062  complexmat->rawset(r1+2*i,j+1,n_Add(complexmat->view(r1+2*i,j+1),mult,comp),comp);
1063  n_Delete(&mult,comp);
1064  }
1065  n_InpMult(pot, roots[i-1],comp);
1066  }
1067  n_Delete(&pot,comp);
1068  for(int j=1;j<=size_elementarray;j++){
1069  complexmat->set(r1+2*i,j,n_Mult(complexmat->view(r1+2*i,j),sqrt2,comp),comp);
1070  complexmat->set(r1+2*i-1,j,n_RePart(complexmat->view(r1+2*i,j),comp),comp);
1071  complexmat->set(r1+2*i,j,n_ImPart(complexmat->view(r1+2*i,j),comp),comp);
1072  }
1073  }
1074  }
1075  DEBUG_PRINT(("delete Variables\n"));
1076  for(int i=0;i<size_elementarray;i++){
1077  delete elements[i];
1078  }
1079  delete elements;
1080  for(int i=0;i<r1+r2;i++){
1081  n_Delete(&roots[i],comp);
1082  }
1083  delete roots;
1084 
1085  DEBUG_PRINT(("to real\n"));
1086  LongComplexInfo paramReal;
1087  paramReal.float_len = si_min (precision, 32767);
1088  paramReal.float_len2 = si_min (precision, 32767);
1089  paramComp.par_name=(const char*)"i";
1090  coeffs real = nInitChar(n_long_R, &paramReal);
1091  //setGMPFloatDigits( precision, precision);
1092  bigintmat * realmat = bimChangeCoeff(complexmat,real);
1093  delete complexmat;
1094  return realmat;
1095 }
1096 
1097 bool IsReal(number a, coeffs coef){ //Im(a)==0
1098  number imag = n_ImPart(a, coef);
1099  bool out = n_IsZero(imag,coef);
1100  n_Delete(&imag,coef);
1101  return out;
1102 }
1103 
1104 bool ImagGreaterZero(number a, coeffs coef){ //Im(a)>0
1105  number imag = n_ImPart(a, coef);
1106  bool out = n_GreaterZero(imag,coef);
1107  n_Delete(&imag,coef);
1108  return out;
1109 }
1110 
1111 number squareroot(number a, coeffs coef, int prec){
1112  if(n_IsZero(a,coef)){
1113  return a;
1114  }
1115  if(!n_GreaterZero(a,coef)){
1116  return n_Init(0,coef);
1117  }
1118  number two = n_Init(2,coef);
1119  number xn = n_Copy(a,coef);
1120  number xn1,xn2;
1121  for(int i=0;i<prec;i++){
1122  xn1 = n_Div(a,xn,coef);
1123  xn2 = n_Add(xn,xn1,coef);
1124  n_Delete(&xn,coef);
1125  xn = n_Div(xn2,two,coef);
1126  n_Delete(&xn1,coef);
1127  n_Delete(&xn2,coef);
1128  }
1129  return xn;
1130 }
1131 
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:668
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:125
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...
Definition: coeffs.h:512
complex root finder for univariate polynomials based on laguers algorithm
Definition: mpr_numeric.h:65
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:609
bool quadratic_supplement()
Definition: lattice.cc:775
static void view(const intvec *v)
Definition: mod_main.cc:252
int rank
Definition: lattice.h:46
bigintmat * Q
Definition: lattice.h:58
bigintmat * gram_matrix
Definition: lattice.h:14
~lattice()
Definition: lattice.cc:90
bool trans_matrix
Definition: lattice.h:49
const poly a
Definition: syzextra.cc:212
bigintmat * bimSub(bigintmat *a, bigintmat *b)
Definition: bigintmat.cc:216
int n
Definition: lattice.h:17
bool addcol(int i, int j, number a, coeffs c)
addiert a-faches der j-ten Spalte zur i-ten dazu
Definition: bigintmat.cc:927
void SWAPG(int k, int k_max)
Definition: lattice.cc:357
bigintmat * enumerate_all(number a)
Definition: lattice.cc:507
number * d
Definition: lattice.h:43
int check
Definition: libparse.cc:1104
bigintmat * enumerate_next()
Definition: lattice.cc:691
static int si_min(const int a, const int b)
Definition: auxiliary.h:167
number enumerate_get_next()
Definition: lattice.cc:718
bigintmat ** b
Definition: lattice.h:28
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
Definition: coeffs.h:640
return P p
Definition: myNF.cc:203
lattice(bigintmat *basis)
Definition: lattice.cc:52
Matrices of numbers.
Definition: bigintmat.h:32
static FORCE_INLINE BOOLEAN nCoeff_is_long_R(const coeffs r)
Definition: coeffs.h:892
bigintmat * my
Definition: lattice.h:40
void setcol(int j, bigintmat *m)
Setzt j-te Spalte gleich übergebenem Vektor (Matrix) m.
Definition: bigintmat.cc:812
void appendCol(bigintmat *a)
horizontally join the matrices, m <- m|a
Definition: bigintmat.cc:1034
bool sub(bigintmat *b)
Subtrahiert ...
Definition: bigintmat.cc:888
#define DEBUG_VAR(x)
Definition: lattice.cc:35
static FORCE_INLINE BOOLEAN nCoeff_is_Ring_Z(const coeffs r)
Definition: coeffs.h:750
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
static FORCE_INLINE BOOLEAN nCoeff_is_R(const coeffs r)
Definition: coeffs.h:834
const CanonicalForm CFMap CFMap int &both_non_zero int n
Definition: cfEzgcd.cc:52
number * bound
Definition: lattice.h:64
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:180
void zero()
Setzt alle Einträge auf 0.
Definition: bigintmat.cc:1256
coeffs out_coef
Definition: lattice.h:67
bigintmat * minkowksi(bigintmat **elementarray, int size_elementarray, number *poly, int deg, coeffs coef, int precision)
Definition: lattice.cc:948
void gram_schmidt_MLLL(int k)
Definition: lattice.cc:454
bool gram_schmidt(int k)
Definition: lattice.cc:430
bigintmat ** b_star
Definition: lattice.h:31
bool solver(const int polishmode=PM_NONE)
Definition: mpr_numeric.cc:450
bigintmat * x
Definition: lattice.h:61
void RED(int k, int l)
Definition: lattice.cc:276
void WerrorS(const char *s)
Definition: feFopen.cc:23
int k
Definition: cfEzgcd.cc:93
bool independentVectors
Definition: lattice.h:52
static FORCE_INLINE BOOLEAN nCoeff_is_Q(const coeffs r)
Definition: coeffs.h:824
static FORCE_INLINE BOOLEAN nCoeff_is_long_C(const coeffs r)
Definition: coeffs.h:895
int xn
Definition: walk.cc:4285
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:645
real floating point (GMP) numbers
Definition: coeffs.h:34
void set(int i, int j, number n, const coeffs C=NULL)
replace an entry with a copy (delete old + copy new!). NOTE: starts at [1,1]
Definition: bigintmat.cc:93
short float_len2
additional char-flags, rInit
Definition: coeffs.h:101
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_...
Definition: bigintmat.h:180
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of 'a' and 'b', i.e., a*b
Definition: coeffs.h:635
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
void compute_gram_matrix()
Definition: lattice.cc:828
short float_len
additional char-flags, rInit
Definition: coeffs.h:100
const ring r
Definition: syzextra.cc:208
Coefficient rings, fields and other domains suitable for Singular polynomials.
int j
Definition: myNF.cc:70
bigintmat * bimCopy(const bigintmat *b)
same as copy constructor - apart from it being able to accept NULL as input
Definition: bigintmat.cc:405
bigintmat * bimMult(bigintmat *a, bigintmat *b)
Definition: bigintmat.cc:253
static bool debug_block
Definition: lattice.cc:31
The main handler for Singular numbers which are suitable for Singular polynomials.
static FORCE_INLINE number n_Add(number a, number b, const coeffs r)
return the sum of 'a' and 'b', i.e., a+b
Definition: coeffs.h:655
bigintmat ** basis
Definition: lattice.h:11
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:72
bool skalmult(number b, coeffs c)
Multipliziert zur Matrix den Skalar b hinzu.
Definition: bigintmat.cc:906
void swap(int i, int j)
swap columns i and j
Definition: bigintmat.cc:690
complex floating point (GMP) numbers
Definition: coeffs.h:41
#define DEBUG_BIM(x)
Definition: lattice.cc:37
ring rDefault(const coeffs cf, int N, char **n, int ord_size, int *ord, int *block0, int *block1, int **wvhdl)
Definition: ring.cc:113
void fillContainer(number *_coeffs, number *_ievpoint, const int _var, const int _tdg, const rootType _rt, const int _anz)
Definition: mpr_numeric.cc:313
FILE * f
Definition: checklibs.c:7
int i
Definition: cfEzgcd.cc:123
bool ImagGreaterZero(number a, coeffs coef)
Definition: lattice.cc:1104
gmp_complex * getRoot(const int i)
Definition: mpr_numeric.h:88
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
Definition: coeffs.h:465
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:720
bigintmat * get_basis()
Definition: lattice.cc:874
bigintmat * bimChangeCoeff(bigintmat *a, coeffs cnew)
Liefert Kopier von Matrix a zurück, mit coeffs cnew statt den ursprünglichen.
Definition: bigintmat.cc:1706
bigintmat * get_transformation_matrix()
Definition: lattice.cc:890
int cols() const
Definition: bigintmat.h:128
void Print()
IO: simply prints the matrix to the current output (screen?)
Definition: bigintmat.cc:440
static int index(p_Length length, p_Ord ord)
Definition: p_Procs_Impl.h:597
static FORCE_INLINE number n_ImPart(number i, const coeffs cf)
Definition: coeffs.h:811
void rChangeCurrRing(ring r)
Definition: polys.cc:14
number scalarproduct(bigintmat *a, bigintmat *b)
Definition: lattice.cc:915
#define DEBUG_N(x)
Definition: lattice.cc:36
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...
Definition: bigintmat.cc:743
ring rCopy(ring r)
Definition: ring.cc:1618
void SWAP(int k, int k_max)
Definition: lattice.cc:315
int rows() const
Definition: bigintmat.h:129
bigintmat * H
Definition: lattice.h:37
bool LLL()
Definition: lattice.cc:133
void mult(unsigned long *result, unsigned long *a, unsigned long *b, unsigned long p, int dega, int degb)
Definition: minpoly.cc:649
#define NULL
Definition: omList.c:10
number c
Definition: lattice.h:25
int getAnzRoots()
Definition: mpr_numeric.h:97
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of 'n'
Definition: coeffs.h:452
void rDelete(ring r)
unconditionally deletes fields in r
Definition: ring.cc:448
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...
Definition: coeffs.h:615
int m
Definition: lattice.h:20
fq_nmod_poly_t prod
Definition: facHensel.cc:95
coeffs basecoeffs() const
Definition: bigintmat.h:130
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:604
static FORCE_INLINE number n_RePart(number i, const coeffs cf)
Definition: coeffs.h:808
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
coeffs coef
Definition: lattice.h:22
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...
Definition: facAlgFunc.cc:206
const char * par_name
parameter name
Definition: coeffs.h:102
#define DEBUG_PRINT(x)
Definition: lattice.cc:33
void increase_x(int index)
Definition: lattice.cc:841
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:456
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
Definition: coeffs.h:495
number squareroot(number a, coeffs coef, int prec)
Definition: lattice.cc:1111
number check_bound(int index)
Definition: lattice.cc:855
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...
Definition: mpr_complex.cc:62
int isZero()
Definition: bigintmat.cc:1266
polyrec * poly
Definition: hilb.h:10
const poly b
Definition: syzextra.cc:213
bool integral
Definition: lattice.h:55
void Werror(const char *fmt,...)
Definition: reporter.cc:199
#define DEBUG_BLOCK(x)
Definition: lattice.cc:29
void one()
Macht Matrix (Falls quadratisch) zu Einheitsmatrix.
Definition: bigintmat.cc:1238
number * B
Definition: lattice.h:34
int l
Definition: cfEzgcd.cc:94
number get(int i, int j) const
get a copy of an entry. NOTE: starts at [1,1]
Definition: bigintmat.cc:117
bigintmat * get_reduced_basis()
Definition: lattice.cc:882
bool IsReal(number a, coeffs coef)
Definition: lattice.cc:1097
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
Definition: numbers.cc:327