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

◆ initialize_weyl()

bool WeylAlgebra::initialize_weyl ( M2_arrayint derivs,
M2_arrayint comms,
int homog_var )
private

Definition at line 10 of file weylalg.cpp.

13{
14 if (homog_var >= nvars_)
15 {
16 ERROR("Weyl algebra homogenizing variable out of range");
17 return false;
18 }
19 if (homog_var < 0) _homog_var = -1;
20 if (derivs->len != comms->len)
21 {
22 ERROR("Weyl algebra: expected arrays of the same length");
23 return false;
24 }
25 for (unsigned int i = 0; i < derivs->len; i++)
26 {
27 if (derivs->array[i] < 0 || derivs->array[i] >= nvars_)
28 {
29 ERROR("Weyl algebra: variable out of range");
30 return false;
31 }
32 if (comms->array[i] < 0 || comms->array[i] >= nvars_)
33 {
34 ERROR("Weyl algebra: variable out of range");
35 return false;
36 }
37 }
38
39 this->_nderivatives = derivs->len;
40 this->_homogeneous_weyl_algebra = (homog_var >= 0);
41 this->_homog_var = homog_var;
42
45 for (int i = 0; i < _nderivatives; i++)
46 {
47 this->_derivative[i] = derivs->array[i];
48 this->_commutative[i] = comms->array[i];
49 }
50
51 // Now set whether this ring is graded. This will be the case iff
52 // deg(x_i) + deg(D_i) = 2 deg(h), for every i.
53
54 if (_homog_var < 0)
55 {
56 bool isgraded = true;
57 auto D = degree_monoid();
58 monomial degxD = D->make_one();
59 for (int j = 0; j < _nderivatives; j++)
60 {
61 const_monomial degx = M_->degree_of_var(_commutative[j]);
62 const_monomial degD = M_->degree_of_var(_derivative[j]);
63 D->mult(degx, degD, degxD);
64 if (not D->is_one(degxD))
65 {
66 isgraded = false;
67 break;
68 }
69 }
70 this->setIsGraded(isgraded);
71 }
72 else
73 {
74 this->setIsGraded(true);
75 auto D = degree_monoid();
76 const_monomial degh = M_->degree_of_var(_homog_var);
77 monomial deg2h = D->make_one();
78 monomial degxD = D->make_one();
79 D->mult(degh, degh, deg2h);
80
81 for (int j = 0; j < _nderivatives; j++)
82 {
83 const_monomial degx = M_->degree_of_var(_commutative[j]);
84 const_monomial degD = M_->degree_of_var(_derivative[j]);
85 D->mult(degx, degD, degxD);
86 if (D->compare(deg2h, degxD) != EQ)
87 {
88 ERROR("Weyl algebra: failed to create homogeneous Weyl algebra");
89 return false;
90 }
91 }
92 }
93
94 // Now initialize the tables
96 return true;
97}
void setIsGraded(bool new_val)
Definition polyring.hpp:142
const Monoid * M_
Definition polyring.hpp:124
const Monoid * degree_monoid() const
Definition ring.cpp:13
int * _derivative
Definition weylalg.hpp:65
int _homog_var
Definition weylalg.hpp:64
int _nderivatives
Definition weylalg.hpp:62
bool _homogeneous_weyl_algebra
Definition weylalg.hpp:63
int * _commutative
Definition weylalg.hpp:67
void initialize1()
Definition weylalg.cpp:175
#define monomial
Definition gb-toric.cpp:11
const int * const_monomial
Definition imonorder.hpp:45
const int ERROR
Definition m2-mem.cpp:55
#define newarray_atomic(T, len)
Definition newdelete.hpp:91
const int EQ
Definition style.hpp:40

References _commutative, _derivative, _homog_var, _homogeneous_weyl_algebra, _nderivatives, Ring::degree_monoid(), EQ, ERROR, initialize1(), PolynomialRing::M_, monomial, newarray_atomic, PolynomialRing::nvars_, and PolynomialRing::setIsGraded().