Macaulay2 Engine
Loading...
Searching...
No Matches
franzi-brp.hpp
Go to the documentation of this file.
1/* This code written by Franziska Hinkelmann is in the public domain */
2
36
37#include <set>
38#include <vector>
39#include <iostream>
40#include <list>
41#include <map>
42#include <string>
43
45// addition is not const! It changes this
47
48typedef unsigned long brMonomial;
49
50struct lex
51{
52 bool operator()(const brMonomial &lhs, const brMonomial &rhs) const
53 {
54 return lhs > rhs;
55 }
56};
57
58typedef std::list<brMonomial> monomials;
59typedef std::set<brMonomial, lex> monomials_set;
60
74class BRP
75{
76 friend std::ostream &operator<<(std::ostream &out, const BRP &self)
77 {
78 for (monomials::const_iterator i = self.m.begin(); i != self.m.end(); ++i)
79 {
80 out << *i;
81 out << " ";
82 }
83 return out;
84 }
85
86 public:
87 monomials m; // this is the ordered list of monomials represented as integers
88
89 static bool isDivisibleBy(const brMonomial &a, const brMonomial &b)
90 {
91 // check if a is divisible by b
92 brMonomial lcm = a | b;
93 return lcm == a;
94 }
95
96 static bool isRelativelyPrime(const brMonomial &a, const brMonomial &b)
97 {
98 // check if a and b are relatively prime
99 return (((a | b) ^ a) == b);
100 }
101
102 BRP(){};
103 BRP(const monomials &other) { m = other; }
104 BRP(const monomials_set &other);
105 BRP(const brMonomial &val) { m.push_back(val); }
106 bool isZero() const;
107 bool operator==(const brMonomial &val) const;
108 bool operator!=(const brMonomial &val) const { return !((*this) == val); }
109 bool operator==(const BRP &other) const { return m == other.m; }
110 bool operator!=(const BRP &other) const { return !((*this) == other); }
111 BRP &operator+(const BRP &other);
112 void addition(const BRP &other, monomials::iterator pos);
113
114 BRP operator*(const BRP &other) const;
115 BRP operator*(const brMonomial &other) const;
116
117 unsigned int size() const { return static_cast<unsigned int>(m.size()); }
118 bool isLeadingReducibleBy(const BRP &other) const;
119 bool isLeadingReducibleBy(const brMonomial &other) const;
120
121 BRP remainder(const BRP &x)
122 const; // this = ax + b, return remainder b of division by x
123
125 {
126 // if ( (*this) == 0 ) {
127 // cerr << "ERROR, calling LT on 0" << endl;
128 // throw "calling LT on 0 polynomial";
129 // }
130 return *(m.begin());
131 } // Leading Term
132
133 bool reduceTail(const BRP &g);
134 // reduce tail of f with leading term of g
135 // return true if a change happened, otherwise false
136 // f is being changed to its reduction
137};
138
139typedef std::map<int, BRP> IntermediateBasisMap;
140typedef std::map<int, BRP> IntermediateBasis;
141// typedef std::vector<BRP*> IntermediateBasis;
142
143// Local Variables:
144// compile-command: "make -C $M2BUILDDIR/Macaulay2/e "
145// indent-tabs-mode: nil
146// End:
static bool isDivisibleBy(const brMonomial &a, const brMonomial &b)
BRP operator*(const BRP &other) const
bool reduceTail(const BRP &g)
void addition(const BRP &other, monomials::iterator pos)
bool operator!=(const brMonomial &val) const
bool isLeadingReducibleBy(const BRP &other) const
bool operator==(const BRP &other) const
bool operator!=(const BRP &other) const
brMonomial LT() const
friend std::ostream & operator<<(std::ostream &out, const BRP &self)
BRP remainder(const BRP &x) const
monomials m
bool isZero() const
BRP(const brMonomial &val)
BRP & operator+(const BRP &other)
bool operator==(const brMonomial &val) const
static bool isRelativelyPrime(const brMonomial &a, const brMonomial &b)
unsigned int size() const
BRP(const monomials &other)
Boolean (F_2-coefficient) polynomial stored as an ordered list of square-free monomials.
std::map< int, BRP > IntermediateBasisMap
unsigned long brMonomial
std::set< brMonomial, lex > monomials_set
std::list< brMonomial > monomials
std::map< int, BRP > IntermediateBasis
volatile int x
bool operator()(const brMonomial &lhs, const brMonomial &rhs) const