Macaulay2 Engine
Loading...
Searching...
No Matches
launcher.cpp
Go to the documentation of this file.
1/*****************************************************************************
2 * Copyright (C) 2006-2011 by Mikhail V. Zinin *
3 * mzinin@gmail.com *
4 * *
5 * You may redistribute this file under the terms of the GNU General *
6 * Public License as published by the Free Software Foundation, either *
7 * version 2 of the License, or any later version. *
8 *****************************************************************************/
9
10#include "launcher.hpp"
11#include "involutive.hpp"
12#include "monom.hpp"
13#include "monomDL.hpp"
14#include "monomDRL.hpp"
15#include "monomLex.hpp"
16#include "settings-manager.hpp"
17#include "matrix.hpp"
18
19namespace BIBasis
20{
21 const Matrix* Launcher::GetBIBasisMatrix(const Matrix* matrix, int toGroebner) const
22 {
23 if (!CheckMatrix(matrix))
24 {
25 return nullptr;
26 }
27
28 switch(GetSettingsManager().GetMonomialOrder())
29 {
30 case Monom::Lex:
31 {
32 BooleanInvolutiveBasis<MonomLex> basis(matrix, toGroebner);
33 return basis.ToMatrix();
34 }
35 case Monom::DegLex:
36 {
37 BooleanInvolutiveBasis<MonomDL> basis(matrix, toGroebner);
38 return basis.ToMatrix();
39 }
41 {
42 BooleanInvolutiveBasis<MonomDRL> basis(matrix, toGroebner);
43 return basis.ToMatrix();
44 }
45 default:
46 return nullptr;
47 };
48 }
49
50 bool Launcher::CheckMatrix(const Matrix* matrix) const
51 {
52 if (!matrix)
53 {
54 ERROR("BIBasis::CheckMatrix(): no input matrix.");
55 return false;
56 }
57
58 const Ring* matrixRing = matrix->get_ring();
59 if (!matrixRing)
60 {
61 ERROR("BIBasis::CheckMatrix(): failed to get input matrix ring.");
62 return false;
63 }
64
65 if (matrixRing->characteristic() != 2)
66 {
67 ERROR("BIBasis::CheckMatrix(): input matrix ring is not ZZ/2.");
68 return false;
69 }
70
71 const PolynomialRing* polynomialRing = matrixRing->cast_to_PolynomialRing();
72 if (!polynomialRing)
73 {
74 ERROR("BIBasis::CheckMatrix(): failed to cast matrix ring to polynomial ring.");
75 return false;
76 }
77
78 const Ring* coefficientRing = polynomialRing->getCoefficientRing();
79 if (!coefficientRing)
80 {
81 ERROR("BIBasis::CheckMatrix(): failed to get coefficient ring.");
82 return false;
83 }
84
85 if (!coefficientRing->isFinitePrimeField())
86 {
87 ERROR("BIBasis::CheckMatrix(): coefficient ring is not ZZ/2.");
88 return false;
89 }
90
91 const Monoid* monoid = polynomialRing->getMonoid();
92 if (!monoid)
93 {
94 ERROR("BIBasis::CheckMatrix(): failed to get monoid.");
95 return false;
96 }
97
98 const MonomialOrdering* monomialOrdering = monoid->getMonomialOrdering();
99 if (!monomialOrdering)
100 {
101 ERROR("BIBasis::CheckMatrix(): failed to get monomial ordering.");
102 return false;
103 }
104
105 if (!monomialOrdering->array[0])
106 {
107 ERROR("BIBasis::CheckMatrix(): monomial ordering is unknown.");
108 return false;
109 }
110
111 switch(monomialOrdering->array[0]->type)
112 {
113 case MO_LEX:
115 break;
116 case MO_GREVLEX:
118 break;
119 case MO_WEIGHTS:
121 break;
122 default:
123 ERROR("BIBasis::CheckMatrix(): monomial ordering is unsupported: %d.", monomialOrdering->array[0]->type);
124 return false;
125 }
126
128
129 return true;
130 }
131}
const Matrix * ToMatrix() const
bool CheckMatrix(const Matrix *matrix) const
Definition launcher.cpp:50
const Matrix * GetBIBasisMatrix(const Matrix *matrix, int toGroebner) const
Definition launcher.cpp:21
short int Integer
Definition monom.hpp:72
void SetMonomialOrder(Monom::Order order)
void SetNumberOfVariables(Monom::Integer numberOfVariables)
const Ring * get_ring() const
Definition matrix.hpp:134
const MonomialOrdering * getMonomialOrdering() const
Definition monoid.hpp:173
Engine-side commutative monomial monoid: variable names, ordering, multidegree machinery,...
Definition monoid.hpp:89
const Ring * getCoefficientRing() const
Definition polyring.hpp:200
virtual const Monoid * getMonoid() const
Definition polyring.hpp:282
int n_vars() const
Definition polyring.hpp:196
Abstract base for the engine's polynomial-ring hierarchy.
Definition polyring.hpp:96
virtual const PolynomialRing * cast_to_PolynomialRing() const
Definition ring.hpp:243
long characteristic() const
Definition ring.hpp:159
virtual bool isFinitePrimeField() const
Definition ring.hpp:169
xxx xxx xxx
Definition ring.hpp:102
#define Matrix
Definition factory.cpp:14
BIBasis::BooleanInvolutiveBasis<MonomType> — Janet-involutive Gröbner driver for F_2[x]/(x_i^2-x_i).
BIBasis::Launcher — monomial-order dispatcher between the engine boundary and BooleanInvolutiveBasis.
const int ERROR
Definition m2-mem.cpp:55
Matrix — the engine's immutable homomorphism F -> G between free modules.
BIBasis::Monom — abstract squarefree-monomial base for the three Janet orderings.
BIBasis::MonomDL — degree-lex specialisation of the BIBasis monomial type.
BIBasis::MonomDRL — degree-reverse-lex specialisation of the BIBasis monomial type.
BIBasis::MonomLex — pure lexicographic specialisation of the BIBasis monomial type.
@ MO_LEX
@ MO_GREVLEX
@ MO_WEIGHTS
SettingsManager & GetSettingsManager()
BIBasis::SettingsManager — singleton holding the per-run monomial order and variable count.
Front-end-side description of a monomial ordering as a list of mon_part blocks.