Macaulay2 Engine
Loading...
Searching...
No Matches

◆ initialize()

void res2_comp::initialize ( const Matrix * mat,
int LengthLimit,
bool UseDegreeLimit,
int SlantedDegreeLimit,
int SortStrategy )
private

Definition at line 420 of file res-a0.cpp.

425{
428 assert(P != NULL);
429 R = new res2_poly(const_cast<PolynomialRing *>(P));
430 M = P->getMonoid();
431 K = P->getCoefficientRing();
432 generator_matrix = mat;
433
434 exp_size = EXPONENT_BYTE_SIZE(P->n_vars());
435 monom_size = MONOMIAL_BYTE_SIZE(M->monomial_size());
436
437 res2_pair_stash = new stash("res2pair", sizeof(res2_pair));
438 mi_stash = new stash("res2 minodes", sizeof(Nmi_node));
439
440 length_limit = -3; // The resolution is always kept at least in range
441 // 0 .. length_limit + 2.
442 increase_level(LengthLimit);
443
444 projdim = 0;
445 max_mon_degree = M->max_degree();
446
447 if (mat->n_rows() > 0)
448 {
449 lodegree = mat->rows()->primary_degree(0);
450 for (auto i = 1; i < mat->n_rows(); i++)
451 if (lodegree > mat->rows()->primary_degree(i))
452 lodegree = mat->rows()->primary_degree(i);
453 }
454 else
455 lodegree = 0;
456
457 // This can't actually set lodegree, can it?
458 for (auto i = 0; i < mat->n_cols(); i++)
459 if (lodegree > mat->cols()->primary_degree(i) - 1)
460 lodegree = mat->cols()->primary_degree(i) - 1;
461
462 hidegree = 0; // hidegree is an offset from 'lodegree'.
463
464 have_degree_limit = UseDegreeLimit;
465 hard_degree_limit = SlantedDegreeLimit;
466
467 nleft = 0;
468 npairs = 0;
469 nminimal = 0;
471
472 n_ones = 0;
473 n_unique = 0;
474 n_others = 0;
475
476 // Do level 0
477 next_component = 0;
478 for (auto i = 0; i < mat->n_rows(); i++)
479 {
480 res2_pair *p = new_base_res2_pair(i);
481 base_components.push_back(p);
482 }
483 for (auto p = base_components.rbegin(); p != base_components.rend(); ++p)
484 insert_pair(*p);
485
486 // Do level 1
487 for (auto i = 0; i < generator_matrix->n_cols(); i++)
488 if ((*generator_matrix)[i] != nullptr)
489 {
490 res2_pair *p = new_res2_pair(i); // Makes a generator 'pair'
491 insert_pair(p);
492 }
493
494 // Set variables for compare_res2_pairs
499
500 skeleton_sort = SortStrategy & 63;
501 reduction_sort = (SortStrategy >> 6) & 63;
502 reduction_sort |= FLAGS_DEGREE; // ALWAYS do by increasing degree.
503 do_by_level = (unsigned char)(SortStrategy & FLAGS_LEVEL ? 1 : 0);
504 if (SortStrategy & FLAGS_LEVEL_STRIP) do_by_level = 2;
505 do_by_degree = (unsigned char)(SortStrategy & FLAGS_DEGREELEVEL ? 1 : 0);
506 auto_reduce = (SortStrategy & FLAGS_AUTO) >> SHIFT_AUTO;
507 use_respolyHeaps = (unsigned char)(SortStrategy & FLAGS_GEO ? 1 : 0);
508
509 if (do_by_degree) do_by_level = 0;
510 if (M2_gbTrace >= 3)
511 {
512 buffer o;
513 o << "auto-reduce level = " << auto_reduce << newline;
514 if (do_by_level)
515 {
516 o << "computing resolution level by level" << newline;
517 if (do_by_level == 2) o << "with strip optimization" << newline;
518 }
519 if (do_by_degree)
520 o << "computing resolution degree by slanted degree" << newline;
521 if (use_respolyHeaps) o << "using heap based reduction" << newline;
522 o << "skeleton order = ";
524 o << "reduction sort = ";
526 emit(o.str());
527 }
528}
enum ComputationStatusCode set_status(enum ComputationStatusCode)
Definition comp.cpp:66
int primary_degree(int i) const
Definition freemod.cpp:440
const Ring * get_ring() const
Definition matrix.hpp:134
int n_cols() const
Definition matrix.hpp:147
int n_rows() const
Definition matrix.hpp:146
const FreeModule * rows() const
Definition matrix.hpp:144
const FreeModule * cols() const
Definition matrix.hpp:145
virtual const PolynomialRing * cast_to_PolynomialRing() const
Definition ring.hpp:243
char * str()
Definition buffer.hpp:72
size_t exp_size
Definition res-a0.hpp:192
int total_reduce_count
Definition res-a0.hpp:184
int skeleton_sort
Definition res-a0.hpp:167
int compare_use_degree
Definition res-a0.hpp:197
int next_component
Definition res-a0.hpp:163
int max_mon_degree
Definition res-a0.hpp:159
unsigned char do_by_degree
Definition res-a0.hpp:175
int hidegree
Definition res-a0.hpp:138
int projdim
Definition res-a0.hpp:155
res2_pair * new_res2_pair(int i)
Definition res-a0.cpp:646
size_t monom_size
Definition res-a0.hpp:193
stash * mi_stash
Definition res-a0.hpp:130
res2_poly * R
Definition res-a0.hpp:123
const Monoid * M
Definition res-a0.hpp:124
int auto_reduce
Definition res-a0.hpp:178
int n_others
Definition res-a0.hpp:189
int compare_use_descending
Definition res-a0.hpp:198
const PolynomialRing * P
Definition res-a0.hpp:122
const Matrix * generator_matrix
Definition res-a0.hpp:127
int length_limit
Definition res-a0.hpp:147
res2_pair * new_base_res2_pair(int i)
Definition res-a0.cpp:627
void increase_level(int newmax)
Definition res-a0.cpp:75
void insert_pair(res2_pair *p)
Definition res-a0.cpp:663
int nminimal
Definition res-a0.hpp:183
int npairs
Definition res-a0.hpp:182
void display_order(buffer &o, int sortval) const
Definition res-a0.cpp:530
int reduction_sort
Definition res-a0.hpp:169
int compare_type
Definition res-a0.hpp:196
int n_unique
Definition res-a0.hpp:188
unsigned char use_respolyHeaps
Definition res-a0.hpp:177
int nleft
Definition res-a0.hpp:181
int lodegree
Definition res-a0.hpp:137
int compare_use_reverse
Definition res-a0.hpp:199
int hard_degree_limit
Definition res-a0.hpp:139
bool have_degree_limit
Definition res-a0.hpp:143
stash * res2_pair_stash
Definition res-a0.hpp:129
const Ring * K
Definition res-a0.hpp:125
unsigned char do_by_level
Definition res-a0.hpp:173
int n_ones
Definition res-a0.hpp:187
@ COMP_COMPUTING
Definition computation.h:71
int p
char newline[]
Definition m2-types.cpp:49
int M2_gbTrace
Definition m2-types.cpp:52
#define MONOMIAL_BYTE_SIZE(mon_size)
Definition monoid.hpp:66
#define EXPONENT_BYTE_SIZE(nvars)
Definition monoid.hpp:63
const int COMPARE_LEX
Definition res-a0.hpp:78
const int SHIFT_AUTO
Definition res-a0.hpp:68
const int FLAGS_DEGREE
Definition res-a0.hpp:65
const int FLAGS_GEO
Definition res-a0.hpp:69
const int FLAGS_DEGREELEVEL
Definition res-a0.hpp:70
const int FLAGS_LEVEL_STRIP
Definition res-a0.hpp:71
const int FLAGS_AUTO
Definition res-a0.hpp:67
const int FLAGS_LEVEL
Definition res-a0.hpp:66
void emit(const char *s)
Definition text-io.cpp:41

References auto_reduce, Ring::cast_to_PolynomialRing(), Matrix::cols(), COMP_COMPUTING, COMPARE_LEX, compare_type, compare_use_degree, compare_use_descending, compare_use_reverse, display_order(), do_by_degree, do_by_level, emit(), exp_size, EXPONENT_BYTE_SIZE, FLAGS_AUTO, FLAGS_DEGREE, FLAGS_DEGREELEVEL, FLAGS_GEO, FLAGS_LEVEL, FLAGS_LEVEL_STRIP, generator_matrix, Matrix::get_ring(), hard_degree_limit, have_degree_limit, hidegree, increase_level(), insert_pair(), K, length_limit, lodegree, M, M2_gbTrace, Matrix, max_mon_degree, mi_stash, monom_size, MONOMIAL_BYTE_SIZE, Matrix::n_cols(), n_ones, n_others, Matrix::n_rows(), n_unique, new_base_res2_pair(), new_res2_pair(), newline, next_component, nleft, nminimal, npairs, P, p, FreeModule::primary_degree(), projdim, R, reduction_sort, res2_pair_stash, Matrix::rows(), Computation::set_status(), SHIFT_AUTO, skeleton_sort, buffer::str(), total_reduce_count, and use_respolyHeaps.

Referenced by res2_comp().