Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
mahrud committed Dec 8, 2023
1 parent 74779e9 commit 901b70b
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 22 deletions.
51 changes: 29 additions & 22 deletions M2/Macaulay2/e/MonomialOrder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,36 +40,39 @@ using EncodedMonomial = int*;
/// MO = monomial order types, internal functions and types for monomial orders */
namespace MO {
enum order_type {
Packing, /**< # exponents per (currently 32 bit) word. Only affects Lex, GRevLex, GRevLexWeights
(but not the weight part). Does not affect the monomial order. */
Lex, /**< lexicographic order on a specified number of variables */
Packing, /**< # exponents per (currently 32 bit) word. Only affects Lex,
GRevLex, GRevLexWeights (but not the weight part). Does not
affect the monomial order. */
Lex, /**< lexicographic order on a specified number of variables */
GRevLex, /**< graded reverse lexicographic order
on a specified number of variables,
with weights 1 for each variable */
GRevLexWeights, /**< graded reverse lexicographic order
with specified positive weights, on a number of variables */
RevLex, /**< reverse lexicographic order
on a specified number of variables.
Not a global order! */
with specified positive weights, on a number of variables
*/
RevLex, /**< reverse lexicographic order
on a specified number of variables.
Not a global order! */
Weights,
GroupLex, // previously MO_LAURENT
GroupRevLex, // previously MO_LAURENT_REVLEX
GroupLex, // previously MO_LAURENT
GroupRevLex, // previously MO_LAURENT_REVLEX
PositionUp,
PositionDown
PositionDown,
};
//Previous names and values
// MO_LEX = 1,
// MO_GREVLEX = 4,
// MO_GREVLEX_WTS = 7,
// MO_REVLEX = 10,
// MO_WEIGHTS = 11,
// MO_LAURENT = 12, /* Lex order here */
// MO_LAURENT_REVLEX = 13, /* Rev lex order here */
// MO_POSITION_UP = 15,
// MO_POSITION_DOWN = 16
// Previous names and values
// MO_LEX = 1,
// MO_GREVLEX = 4,
// MO_GREVLEX_WTS = 7,
// MO_REVLEX = 10,
// MO_WEIGHTS = 11,
// MO_LAURENT = 12, /* Lex order here */
// MO_LAURENT_REVLEX = 13, /* Rev lex order here */
// MO_POSITION_UP = 15,
// MO_POSITION_DOWN = 16

std::string toString(MO::order_type t);

// Information about a piece of the monomial order
class MonomialBlock
{
private:
Expand All @@ -92,7 +95,10 @@ namespace MO {

/// index of the first variable for this block
int mStartVariable;
std::vector<int> mWeights; // Only used for MO::Weights, MO::GRevLex

// Only used for MO::Weights, MO::GRevLex
std::vector<int> mWeights;

public:
/** constructor */
MonomialBlock(enum order_type t,
Expand All @@ -110,6 +116,7 @@ namespace MO {
std::pair<enum MO::order_type, std::vector<int>> toMonomialType() const;
};

// Information for encoding and decoding monomials
class EncodingBlock
{
private:
Expand Down Expand Up @@ -205,7 +212,7 @@ std::ostream& operator<<(std::ostream& o, const NewAgeMonomialOrder::MOInput& a)
class MonomialEncoder
{
private:
std::vector<MO::EncodingBlock> mParts;
std::vector<MO::EncodingBlock> mParts;

/// Number of variables
int mNumVars;
Expand Down
30 changes: 30 additions & 0 deletions M2/Macaulay2/e/unit-tests/MonomialOrderTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,36 @@ TEST(MonomialOrder, createFromArray)
{MO::GRevLexWeights, {1, 1, 1, 1, 2}},
{MO::PositionUp, {}}
};

/*
//day 1: std::vector array1 coming from the top level;
//day 2: MonomialOrder {BLOCK{...}, BLOCK{...}, ..., list of beginning points, is it local order?, etc.};
//day 3: M->to_monomial(MO, exp, mon);
// hpp
template <MO::order_type mo>
int encode(m, int* vec, int* iter, ...);
// cpp
encoder(exp, monorder)
{
exp;
int *iter = monomial;
for (auto& mo : array1 + ...)
{
// e.g. mo = {MO::Weights, {0, 1, 2, 3, 4}}
switch mo.type:
...
//iter += encode<mo.type>(&exp, mo.content, iter)
}
}
inline int encode_Lex(exp, int* vec, int* iter, ...)
{
e++...
}
*/

NewAgeMonomialOrder mo1 {12, array1};
auto array2 = mo1.toMonomialType();
EXPECT_EQ(array1, array2);
Expand Down

0 comments on commit 901b70b

Please sign in to comment.