8 #include "../Ring/BPASRing.hpp"     9 #include "../ExpressionTree/ExpressionTree.hpp"    10 #include "../Utils/TemplateHelpers.hpp"    30     Factor(
const Ring& r, 
int e) : 
std::pair<Ring,int>(r,e) {}
    37     Factor(Ring&& r, 
int e) : 
std::pair<Ring,int>(r,e) {}
    43     Factor(
const std::pair<Ring, int>& p) : 
std::pair<Ring, int>(p) {}
    51         return (this->first == f.first && this->second == f.second);
    60         return (this->first != f.first || this->second != f.second);
    68     friend std::ostream& operator<<(std::ostream& out, const Factor<Ring>& f) {
    69         out << 
"[" << f.first << 
", " << f.second << 
"]";
    79         std::vector<ExpressionTree> trees;
    80         trees.push_back(this->first.convertToExpressionTree());
    99     std::vector<Factor<Ring>> facts;
   119     Factors(
const std::vector<Ring>& v);
   127     Factors(
const std::vector<Ring>& v, 
const std::vector<int>& e);
   137     Factors(
const std::vector<Ring>& v, 
const std::vector<int>& e, 
const Ring& u);
   197     inline std::vector<Factor<Ring>> 
factors()
 const {
   207         if (i < facts.size())
   210             std::cerr << 
"BPAS: error, i exceeds array bounds of list of factors" << std::endl;
   228         if (f.first.isOne()) {
   231         for (
int i = 0; i < facts.size(); ++i) {
   232             if (f.first == facts[i].first) {
   233                 facts[i].second += f.second;
   249         for (
int i = 0; i < facts.size(); ++i) {
   250             if (r == facts[i].first) {
   251                 facts[i].second += e;
   255         facts.emplace_back(r, e);
   268         for (
int i = 0; i < facts.size(); ++i) {
   269             if (r == facts[i].first) {
   270                 facts[i].second += e;
   274         facts.emplace_back(r, e);
   283         for (
int i = 0; i < f.facts.size(); ++i) {
   284             this->addFactor(f.facts[i]);
   323         return !(*
this == f);
   340     friend std::ostream& operator<<(std::ostream& out, const Factors<Ring>& f) {
   341         out << 
"[" << f.u << 
", [";
   344         for (
int i = 0; i < f.facts.size(); ++i) {
   346             if (i + 1 < f.facts.size()) {
   360         std::vector<ExpressionTree> trees;
   364         trees.push_back(u.convertToExpressionTree());
   374 #include "Factors_impl.hxx" size_t size() const
Get the number of Factor elements in this Factors object. 
Definition: Factors.hpp:292
std::vector< Factor< Ring > > factors() const
Get the list of Factor elements. 
Definition: Factors.hpp:197
Factor< Ring > factor(int i) const
Get the i'th Factor. 
Definition: Factors.hpp:206
void setFactors(const std::vector< Factor< Ring >> &v)
Set the list of Factor elements. 
Definition: Factors.hpp:219
void addFactor(const Factor< Ring > &f)
A Factor to the list of Factor elements. 
Definition: Factors.hpp:227
Factor(const std::pair< Ring, int > &p)
Construct a Factor from a std::pair of a Ring element and integer exponent. 
Definition: Factors.hpp:43
Factor()
Construct an empty factor. 
Definition: Factors.hpp:23
An ExpressionTree encompasses various forms of data that can be expressed generically as a binary tre...
Definition: ExpressionTree.hpp:17
void addFactors(const Factors< Ring > f)
Combine another Factors' list of Factor elements with this Factors. 
Definition: Factors.hpp:282
bool operator!=(const Factor< Ring > &f)
Inequality comparison operator. 
Definition: Factors.hpp:59
A Factor is a pair of a BPASRing element and an integer exponent. 
Definition: Factors.hpp:17
A simple data structure for encapsulating a collection of Factor elements. 
Definition: Factors.hpp:95
ExpressionTree convertToExpressionTree() const
Convert the Factors object to an ExpressionTree. 
Definition: Factors.hpp:359
Factor(const Ring &r, int e)
Construct a factor from a Ring element and an exponent. 
Definition: Factors.hpp:30
void setRingElement(const Ring &r)
Set the invertible Ring element. 
Definition: Factors.hpp:173
void fromVector(const std::vector< ExpTreeConvert > &ringVec)
Fill this expression tree with the vector of BPASRing elements specified. 
Definition: ExpressionTree.hpp:180
ExpressionTree convertToExpressionTree() const
Convert the Factor to an ExpressionTree. 
Definition: Factors.hpp:78
void addFactor(Ring &&r, int e)
Add a Ring element and its corresponding exponent as a Factor. 
Definition: Factors.hpp:264
void multiplyRingElement(const Ring &r)
Multiply this Factors invertible Ring element by another Ring element. 
Definition: Factors.hpp:189
bool operator!=(const Factors< Ring > &f) const
Inequality testing for Factors. 
Definition: Factors.hpp:322
Factor(Ring &&r, int e)
Move-construct a factor from a Ring element and an exponent. 
Definition: Factors.hpp:37
ExprTreeNode is a single node in the bianry tree of an ExpressionTree. 
Definition: ExprTreeNode.hpp:76
Factor< Ring > & operator[](size_t idx)
Indexing operator. 
Definition: Factors.hpp:331
An interface defining conversion of a class to an ExpressionTree. 
Definition: ExpressionTree.hpp:195
bool operator==(const Factor< Ring > &f)
Equality comparison operator. 
Definition: Factors.hpp:50
Ring ringElement() const
Get the invertible Ring element. 
Definition: Factors.hpp:181
void addFactor(const Ring &r, int e)
Add a Ring element and its corresponding exponent as a Factor. 
Definition: Factors.hpp:245