BooleExponent.h
Go to the documentation of this file.
// -*- c++ -*-
//*****************************************************************************
//*****************************************************************************
#ifndef polybori_BooleExponent_h_
#define polybori_BooleExponent_h_
// include basic definitions
#include <polybori/pbori_defs.h>
// get definition of BoolePolynomial, BooleMonomial, and BooleVariable
#include <polybori/BooleMonomial.h>
#include <polybori/BooleVariable.h>
BEGIN_NAMESPACE_PBORI
class BooleExponent:
public CAuxTypes {
public:
//-------------------------------------------------------------------------
// types definitions
//-------------------------------------------------------------------------
typedef std::vector<idx_type> data_type;
typedef data_type::value_type value_type;
typedef data_type::iterator iterator;
typedef data_type::const_iterator const_iterator;
typedef data_type::reverse_iterator reverse_iterator;
typedef data_type::const_reverse_iterator const_reverse_iterator;
typedef BooleExponent self;
typedef BoolePolynomial poly_type;
typedef poly_type::ring_type ring_type;
typedef poly_type::var_type var_type;
typedef poly_type::monom_type monom_type;
typedef poly_type::set_type set_type;
typedef generate_index_map<self>::type idx_map_type;
typedef invalid_tag easy_equality_property;
BooleExponent();
BooleExponent(const self&);
// explicit BooleExponent(bool);
self& get(const monom_type&);
explicit BooleExponent(const monom_type& rhs);
~BooleExponent();
const_iterator begin() const { return m_data.begin(); }
const_iterator end() const { return m_data.end(); }
const_reverse_iterator rbegin() const { return m_data.rbegin(); }
const_reverse_iterator rend() const { return m_data.rend(); }
size_type size() const { return m_data.size(); }
void reserve(size_type nsize) { m_data.reserve(nsize); }
void resize(size_type nsize) { m_data.resize(nsize); }
deg_type deg() const { return size(); }
set_type divisors(const ring_type&) const;
set_type multiples(const self&, const ring_type&) const;
set_type multiples(const monom_type&) const;
hash_type stableHash() const {
return stable_term_hash(begin(), end());
}
hash_type hash() const { return stableHash(); }
self& changeAssign(idx_type);
self change(idx_type) const;
self& insert(idx_type);
self& push_back(idx_type idx);
self& remove(idx_type);
self insertConst(idx_type) const;
self removeConst(idx_type) const;
self divide(const self&) const;
self divideByIndex(const idx_type& rhs) const {
return (reducibleBy(rhs)? removeConst(rhs) : self() ); }
self divide(const var_type& rhs) const { return divideByIndex(rhs.index()); }
self divide(const monom_type&) const;
self multiply(const self&) const;
self multiply(const idx_type& rhs) const { return insertConst(rhs); }
self multiply(const var_type& rhs) const { return multiply(rhs.index()); }
self multiply(const monom_type&) const;
self multiplyFirst(const set_type&) const;
// /// @name Arithmetical operations
// //@{
// self& operator*=(const self&);
// self& operator/=(const self&);
// self& operator*=(const var_type&);
// self& operator/=(const var_type&);
// //@}
bool_type operator==(const self& rhs) const { return m_data == rhs.m_data; }
bool_type operator!=(const self& rhs) const { return m_data != rhs.m_data; }
self& operator=(const self& rhs) { m_data = rhs.m_data; return *this; }
self& operator=(const monom_type& rhs) {
m_data.resize(rhs.size());
std::copy(rhs.begin(), rhs.end(), internalBegin());
return *this;
}
bool_type reducibleBy(const self& rhs) const;
bool_type reducibleBy(const monom_type& rhs) const;
bool_type reducibleBy(const idx_type& rhs) const;
bool_type reducibleBy(const var_type& rhs) const {
return reducibleBy(rhs.index()); }
// /// Test for reducibility wrt. to a given variable
// bool_type reducibleBy(const var_type& rhs) const;
deg_type LCMDeg(const self&) const;
self LCM(const self&) const;
//self& GCDAssign(const self&);
self GCD(const self&) const;
self& popFirst() {
if(!m_data.empty())
m_data.erase(m_data.begin());
return *this;
}
ostream_type& print(ostream_type&) const;
protected:
iterator internalBegin() { return m_data.begin(); }
iterator internalEnd() { return m_data.end(); }
reverse_iterator rInternalBegin() { return m_data.rbegin(); }
reverse_iterator rInternalEnd() { return m_data.rend(); }
data_type m_data;
};
template <class RHSType>
inline BooleExponent
operator+(const BooleExponent& lhs, const RHSType& rhs) {
return lhs.multiply(rhs);
}
template <class RHSType>
inline BooleExponent
operator-(const BooleExponent& lhs, const RHSType& rhs) {
return lhs.divide(rhs);
}
inline BooleExponent
GCD(const BooleExponent& lhs, const BooleExponent& rhs ){
return lhs.GCD(rhs);
}
inline BooleExponent
LCM(const BooleExponent& lhs, const BooleExponent& rhs ){
return lhs.LCM(rhs);
}
inline BooleExponent::ostream_type&
operator<<(BooleExponent::ostream_type& os, const BooleExponent& rhs) {
return rhs.print(os);
}
END_NAMESPACE_PBORI
#endif // of polybori_BooleExponent_h_