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

◆ k_basis()

Matrix * KBasis::k_basis ( const Matrix * bottom,
M2_arrayint lo_degree,
M2_arrayint hi_degree,
std::vector< int > heftvec,
std::vector< int > varlist,
bool do_truncation,
int limit )
static

Definition at line 491 of file matrix-kbasis.cpp.

498{
499 // There are essentially 3 situations:
500 // (a) basis(M) -- lo_degree and hi_degree are not given
501 // in this case, only need that for each variable in 'varlist',
502 // some power is an initial term of 'bottom' (for each row of 'bottom').
503 // heft is not used here, or considered.
504 // (b) basis(lo,hi,M) -- case when the ring is singly-graded
505 // one of lo and hi must be given. (otherwise we are in case (a) above)
506 // In this case, heft is a list with one element in it.
507 // Assume: heft * deg(x) > 0, for all x in 'varlist'.
508 // In this situation: we use kb_target_lo_heft, kb_target_hi_heft
509 // (c) basis(d, d, M) -- ring is multi-graded
510 // ASSUME: deg_d(x) . heft > 0 for all vars 'x' in 'varlist'
511 // where deg_d(x) consists of the first #d components of deg(x)
512 // ASSUME: 1 <= #d <= degreeRank of the ring
513 // use kb_target_multidegree, kb_target_lo_heft
514 // and kb_exp_multidegree (of length #d).
515 // if do_truncation, then any generator with heft > kb_target_lo_heft is
516 // placed in the resulting matrix
517 //
518 // Further assumptions:
519 // 1 <= #heft <= degreeRank P
520 // #heft = #lo_degree = #hi_degree, if these are not 0.
521 //
522 //
523 // Do some checks first, return 0 if not good.
524 const PolynomialRing *P = bottom->get_ring()->cast_to_PolynomialRing();
525 if (P == nullptr) return Matrix::identity(bottom->rows());
526
527 const PolynomialRing *D = P->get_degree_ring();
528 const int *lo = lo_degree->len > 0 ? lo_degree->array : nullptr;
529 const int *hi = hi_degree->len > 0 ? hi_degree->array : nullptr;
530
531 if (heftvec.size() > D->n_vars())
532 {
533 ERROR("expected heft vector of length <= %d", D->n_vars());
534 return nullptr;
535 }
536
537 if (lo && heftvec.size() != lo_degree->len)
538 {
539 ERROR("expected degrees of length %d", heftvec.size());
540 return nullptr;
541 }
542
543 if (hi && heftvec.size() != hi_degree->len)
544 {
545 ERROR("expected degrees of length %d", heftvec.size());
546 return nullptr;
547 }
548
549 // If heftvec.size() is > 1, and both lo and hi are non-null,
550 // they need to be the same
551 if (heftvec.size() > 1 && lo && hi)
552 for (int i = 0; i < heftvec.size(); i++)
553 if (lo_degree->array[i] != hi_degree->array[i])
554 {
555 ERROR("expected degree bounds to be equal");
556 return nullptr;
557 }
558
559 KBasis KB(bottom, lo, hi, heftvec, varlist, do_truncation, limit);
560
561 // If either a low degree, or high degree is given, then we require a
562 // non-negative heft vector:
563 if (lo || hi)
564 for (int i = 0; i < varlist.size(); i++)
565 if (KB.var_wts[i] < 0)
566 {
567 ERROR(
568 "basis: computation requires a heft form non-negative on the "
569 "degrees of the variables");
570 return nullptr;
571 }
572 // This next line will happen if both lo,hi degrees are given, and they are
573 // different. This can only be the singly generated case, and in that case
574 // the degrees are in the wrong order, so return with 0 basis.
575 if (lo != nullptr && hi != nullptr && lo[0] > hi[0]) return KB.value();
576
577 KB.compute();
578 if (system_interrupted()) return nullptr;
579 return KB.value();
580}
const Monoid * D
const int * lo_degree
bool do_truncation
const int * hi_degree
const PolynomialRing * P
KBasis(const Matrix *bottom, const int *lo_degree, const int *hi_degree, std::vector< int > heftvec, std::vector< int > varlist, bool do_truncation, int limit)
const Ring * get_ring() const
Definition matrix.hpp:134
static Matrix * identity(const FreeModule *F)
Definition matrix.cpp:380
const FreeModule * rows() const
Definition matrix.hpp:144
virtual const PolynomialRing * cast_to_PolynomialRing() const
Definition ring.hpp:243
bool system_interrupted()
const int ERROR
Definition m2-mem.cpp:55

References Ring::cast_to_PolynomialRing(), compute(), D, do_truncation, ERROR, Matrix::get_ring(), hi_degree, KBasis(), limit, lo_degree, Matrix, P, Matrix::rows(), system_interrupted(), value(), and var_wts.

Referenced by Matrix::basis().