[mathicgb] 383/393: Poly now uses containers from Field and Monoid to store coefficients and monomials. Poly.cpp was removed since it is no longer needed.
Doug Torrance
dtorrance-guest at moszumanska.debian.org
Fri Apr 3 15:59:37 UTC 2015
This is an automated email from the git hooks/post-receive script.
dtorrance-guest pushed a commit to branch upstream
in repository mathicgb.
commit 71bcaa689c47d61832fd9ba275e282fcb9f1cbfc
Author: Bjarke Hammersholt Roune <bjarkehr.code at gmail.com>
Date: Mon Sep 23 14:12:48 2013 +0200
Poly now uses containers from Field and Monoid to store coefficients and monomials. Poly.cpp was removed since it is no longer needed.
---
Makefile.am | 33 +++--
build/vs12/mathicgb-lib/mathicgb-lib.vcxproj | 1 -
.../vs12/mathicgb-lib/mathicgb-lib.vcxproj.filters | 3 -
src/mathicgb/MonoMonoid.hpp | 92 ++++++++------
src/mathicgb/Poly.cpp | 68 -----------
src/mathicgb/Poly.hpp | 134 ++++++++++-----------
src/mathicgb/PolyRing.hpp | 10 ++
src/mathicgb/PrimeField.hpp | 14 +++
8 files changed, 161 insertions(+), 194 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 171d553..f19ccc5 100755
--- a/Makefile.am
+++ b/Makefile.am
@@ -22,23 +22,22 @@ libmathicgb_la_SOURCES = src/mathicgb/Range.hpp \
src/mathicgb/Basis.hpp src/mathicgb/io-util.cpp \
src/mathicgb/io-util.hpp src/mathicgb/KoszulQueue.hpp \
src/mathicgb/ModuleMonoSet.cpp src/mathicgb/ModuleMonoSet.hpp \
- src/mathicgb/Poly.cpp src/mathicgb/Poly.hpp \
- src/mathicgb/PolyBasis.cpp src/mathicgb/PolyBasis.hpp \
- src/mathicgb/PolyHashTable.cpp src/mathicgb/PolyHashTable.hpp \
- src/mathicgb/PolyRing.cpp src/mathicgb/PolyRing.hpp \
- src/mathicgb/Reducer.cpp src/mathicgb/Reducer.hpp \
- src/mathicgb/ReducerDedup.hpp src/mathicgb/ReducerDedup.cpp \
- src/mathicgb/ReducerHash.hpp src/mathicgb/ReducerHash.cpp \
- src/mathicgb/ReducerHashPack.hpp src/mathicgb/ReducerHashPack.cpp \
- src/mathicgb/ReducerHelper.hpp src/mathicgb/ReducerNoDedup.hpp \
- src/mathicgb/ReducerNoDedup.cpp src/mathicgb/ReducerPackDedup.hpp \
- src/mathicgb/ReducerPackDedup.cpp src/mathicgb/SignatureGB.cpp \
- src/mathicgb/SignatureGB.hpp src/mathicgb/SigSPairs.cpp \
- src/mathicgb/SigSPairs.hpp src/mathicgb/SPairs.cpp \
- src/mathicgb/SPairs.hpp src/mathicgb/stdinc.h \
- src/mathicgb/SigSPairQueue.hpp src/mathicgb/SigSPairQueue.cpp \
- src/mathicgb/SparseMatrix.hpp src/mathicgb/SparseMatrix.cpp \
- src/mathicgb/QuadMatrixBuilder.hpp \
+ src/mathicgb/Poly.hpp src/mathicgb/PolyBasis.cpp \
+ src/mathicgb/PolyBasis.hpp src/mathicgb/PolyHashTable.cpp \
+ src/mathicgb/PolyHashTable.hpp src/mathicgb/PolyRing.cpp \
+ src/mathicgb/PolyRing.hpp src/mathicgb/Reducer.cpp \
+ src/mathicgb/Reducer.hpp src/mathicgb/ReducerDedup.hpp \
+ src/mathicgb/ReducerDedup.cpp src/mathicgb/ReducerHash.hpp \
+ src/mathicgb/ReducerHash.cpp src/mathicgb/ReducerHashPack.hpp \
+ src/mathicgb/ReducerHashPack.cpp src/mathicgb/ReducerHelper.hpp \
+ src/mathicgb/ReducerNoDedup.hpp src/mathicgb/ReducerNoDedup.cpp \
+ src/mathicgb/ReducerPackDedup.hpp src/mathicgb/ReducerPackDedup.cpp \
+ src/mathicgb/SignatureGB.cpp src/mathicgb/SignatureGB.hpp \
+ src/mathicgb/SigSPairs.cpp src/mathicgb/SigSPairs.hpp \
+ src/mathicgb/SPairs.cpp src/mathicgb/SPairs.hpp \
+ src/mathicgb/stdinc.h src/mathicgb/SigSPairQueue.hpp \
+ src/mathicgb/SigSPairQueue.cpp src/mathicgb/SparseMatrix.hpp \
+ src/mathicgb/SparseMatrix.cpp src/mathicgb/QuadMatrixBuilder.hpp \
src/mathicgb/QuadMatrixBuilder.cpp src/mathicgb/TypicalReducer.cpp \
src/mathicgb/TypicalReducer.hpp src/mathicgb/F4Reducer.hpp \
src/mathicgb/F4Reducer.cpp src/mathicgb/F4MatrixBuilder.hpp \
diff --git a/build/vs12/mathicgb-lib/mathicgb-lib.vcxproj b/build/vs12/mathicgb-lib/mathicgb-lib.vcxproj
index 3e31c01..9dfdbb1 100755
--- a/build/vs12/mathicgb-lib/mathicgb-lib.vcxproj
+++ b/build/vs12/mathicgb-lib/mathicgb-lib.vcxproj
@@ -454,7 +454,6 @@
<ClCompile Include="..\..\..\src\mathicgb\LogDomainSet.cpp" />
<ClCompile Include="..\..\..\src\mathicgb\ModuleMonoSet.cpp" />
<ClCompile Include="..\..\..\src\mathicgb\MonoLookup.cpp" />
- <ClCompile Include="..\..\..\src\mathicgb\Poly.cpp" />
<ClCompile Include="..\..\..\src\mathicgb\PolyBasis.cpp" />
<ClCompile Include="..\..\..\src\mathicgb\PolyHashTable.cpp" />
<ClCompile Include="..\..\..\src\mathicgb\PolyRing.cpp" />
diff --git a/build/vs12/mathicgb-lib/mathicgb-lib.vcxproj.filters b/build/vs12/mathicgb-lib/mathicgb-lib.vcxproj.filters
index 82c3898..57b89b0 100755
--- a/build/vs12/mathicgb-lib/mathicgb-lib.vcxproj.filters
+++ b/build/vs12/mathicgb-lib/mathicgb-lib.vcxproj.filters
@@ -23,9 +23,6 @@
<ClCompile Include="..\..\..\src\mathicgb\io-util.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="..\..\..\src\mathicgb\Poly.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
<ClCompile Include="..\..\..\src\mathicgb\PolyBasis.cpp">
<Filter>Source Files</Filter>
</ClCompile>
diff --git a/src/mathicgb/MonoMonoid.hpp b/src/mathicgb/MonoMonoid.hpp
index fa57d1d..ecaf3c3 100755
--- a/src/mathicgb/MonoMonoid.hpp
+++ b/src/mathicgb/MonoMonoid.hpp
@@ -425,14 +425,6 @@ public:
);
}
- bool operator==(const MonoMonoid& monoid) const {
- return this == &monoid;
- }
-
- bool operator!=(const MonoMonoid& monoid) const {
- return !(*this == monoid);
- }
-
/// Returns true if higher component is considered greater when
/// comparing module monomials. Only relevant once actually
/// considering the component. This is only relevant for module
@@ -1450,6 +1442,9 @@ public:
public:
typedef std::forward_iterator_tag iterator_category;
typedef ConstMonoRef value_type;
+ typedef ptrdiff_t difference_type;
+ typedef ConstMonoPtr pointer;
+ typedef ConstMonoRef reference;
const_iterator(): mIt(), mEntriesPerMono(0) {}
const_iterator(const const_iterator& it):
@@ -1458,7 +1453,7 @@ public:
bool operator==(const const_iterator& it) const {return mIt == it.mIt;}
bool operator!=(const const_iterator& it) const {return mIt != it.mIt;}
- ConstMonoRef operator*() {
+ ConstMonoRef operator*() const {
MATHICGB_ASSERT(debugValid());
return *ConstMonoPtr(&*mIt);
}
@@ -1471,7 +1466,7 @@ public:
private:
friend class MonoVector;
- bool debugValid() {return mEntriesPerMono > 0;}
+ bool debugValid() const {return mEntriesPerMono > 0;}
const_iterator(
typename RawVector::const_iterator it,
@@ -1482,7 +1477,9 @@ public:
size_t mEntriesPerMono;
};
- // ** Constructors and assignment
+
+ // *** Constructors and assignment
+
MonoVector(const MonoMonoid& monoid): mMonoid(monoid) {}
MonoVector(const MonoVector& v): mMonos(v.mMonos), mMonoid(v.monoid()) {}
MonoVector(MonoVector&& v):
@@ -1500,7 +1497,9 @@ public:
return *this;
}
- // ** Iterators
+
+ // *** Iterators
+
const_iterator begin() const {
return const_iterator(mMonos.begin(), mMonoid.entryCount());
}
@@ -1512,11 +1511,32 @@ public:
const_iterator cbegin() const {return begin();}
const_iterator cend() const {return end();}
- // ** Capacity
+ // *** Operators
+
+ /// Returns true if *this and v contain the same monomials in the same
+ /// order. This ought to be a free-standing function, but it cannot be,
+ /// because template argument deduction cannot deduce a type T from
+ /// something of the form A<T>::MonoVector.
+ bool operator==(const MonoVector& v) const {
+ MATHICGB_ASSERT(monoid() == v.monoid());
+ return mMonos == v.mMonos;
+ }
+
+ /// As !(*this == v).
+ bool operator!=(const MonoVector& v) const {
+ MATHICGB_ASSERT(monoid() == v.monoid());
+ return !(*this == v);
+ }
+
+
+ // *** Size and capacity
+
size_t size() const {return mMonos.size() / monoid().entryCount();}
bool empty() const {return mMonos.empty();}
- // ** Element access
+
+ // *** Element access
+
ConstMonoRef front() const {
MATHICGB_ASSERT(!empty());
return *begin();
@@ -1534,7 +1554,8 @@ public:
return *ConstMonoPtr(mMonos.data() + offset);
}
- // ** Modifiers
+
+ // *** Modifiers
void reserve(size_t count) {
mMonos.reserve(count * monoid().entryCount());
@@ -1575,16 +1596,11 @@ public:
void clear() {mMonos.clear();}
- // ** Relational operators
- bool operator==(const MonoVector& v) const {
- MATHICGB_ASSERT(monoid() == v.monoid());
- return mMonos == v.mMonos;
- }
- bool operator!=(const MonoVector& v) const {return !(*this == v);}
- // ** Other
+ // *** Other
+
size_t memoryBytesUsed() const {
- return mMonos.capacity() * sizeof(mMonos[0]);
+ return mMonos.capacity() * sizeof(mMonos.front());
}
const MonoMonoid& monoid() const {return mMonoid;}
@@ -1889,20 +1905,22 @@ private:
mutable MonoPool mPool;
};
-namespace MonoMonoidHelper {
- /// ostream and istream handle characters differently from other
- /// integers. Use unchar to cast chars to a different type that get
- /// handled as other integers do.
- template<class T>
- struct unchar {typedef int type;};
-
- // Yes: char, signed char and unsigned char are 3 distinct types.
- template<>
- struct unchar<char> {typedef short type;};
- template<>
- struct unchar<signed char> {typedef short type;};
- template<>
- struct unchar<unsigned char> {typedef unsigned short type;};
+/// Returns true if a and b are the same object.
+template<class E, bool HC, bool SH, bool SO>
+bool operator==(
+ const MonoMonoid<E,HC,SH,SO>& a,
+ const MonoMonoid<E,HC,SH,SO>& b
+) {
+ return &a == &b;
+}
+
+/// As !(a == b).
+template<class E, bool HC, bool SH, bool SO>
+bool operator!=(
+ const MonoMonoid<E,HC,SH,SO>& a,
+ const MonoMonoid<E,HC,SH,SO>& b
+) {
+ return !(a == b);
}
MATHICGB_NAMESPACE_END
diff --git a/src/mathicgb/Poly.cpp b/src/mathicgb/Poly.cpp
index fe84c9a..adb5202 100755
--- a/src/mathicgb/Poly.cpp
+++ b/src/mathicgb/Poly.cpp
@@ -7,72 +7,4 @@
MATHICGB_NAMESPACE_BEGIN
-Poly Poly::polyWithTermsDescending() {
- // *** Sort terms in descending order of monomial.
- // It would be possible but cumbersome to implement a sort directly
- // on mMonos. That way no allocation would need to happen, however
- // it is not clear that that would be any faster, since swapping around
- // monomials in-place is slow. Swapping terms is faster, since terms
- // just refer to the monomials. This way is also easier to implement.
- //
- /// @todo: make a separate TermSorter object that allows the terms vector
- /// to be reused between sorts. This should matter for sorting input
- /// ideals where there might be a lot of polynomials to go through.
- /// That way terms would not need to be allocated anew for each polynomial.
- auto greaterOrEqual = [&](const NewConstTerm& a, const NewConstTerm& b) {
- return monoid().lessThan(*b.mono, *a.mono);
- };
- auto terms = rangeToVector(*this);
- std::sort(std::begin(terms), std::end(terms), greaterOrEqual);
-
- // *** Make a new polynomial with terms in that order
- Poly poly(ring());
- poly.reserve(termCount());
- poly.append(terms);
-
- MATHICGB_ASSERT(poly.termsAreInDescendingOrder());
- MATHICGB_ASSERT(poly.termCount() == termCount());
- return poly;
-}
-
-void Poly::makeMonic() {
- MATHICGB_ASSERT(!isZero());
- if (isMonic())
- return;
- auto multiplier = field().inverse(leadCoef());
- for (auto& coef : mCoefs)
- coef = field().product(coef, multiplier);
- MATHICGB_ASSERT(isMonic());
-}
-
-size_t Poly::getMemoryUse() const {
- return
- sizeof(mCoefs.front()) * mCoefs.capacity() +
- sizeof(mMonos.front()) * mMonos.capacity();
-}
-
-bool Poly::termsAreInDescendingOrder() const {
- auto greaterThanOrEqual = [&](ConstMonoRef a, ConstMonoRef b) {
- return !monoid().lessThan(a, b);
- };
- return std::is_sorted(monoBegin(), monoEnd(), greaterThanOrEqual);
-}
-
-bool operator==(const Poly& a, const Poly& b) {
- MATHICGB_ASSERT(&a.ring() == &b.ring());
- if (a.termCount() != b.termCount())
- return false;
-
- for (const auto& coef : zip(a.coefRange(), b.coefRange()))
- if (coef.first != coef.second)
- return false;
-
- const auto& monoid = a.ring().monoid();
- for (const auto& mono : zip(a.monoRange(), b.monoRange()))
- if (!monoid.equal(mono.first, mono.second))
- return false;
-
- return true;
-}
-
MATHICGB_NAMESPACE_END
diff --git a/src/mathicgb/Poly.hpp b/src/mathicgb/Poly.hpp
index 3320788..cc29e16 100755
--- a/src/mathicgb/Poly.hpp
+++ b/src/mathicgb/Poly.hpp
@@ -27,7 +27,7 @@ public:
typedef Monoid::ConstMonoPtr ConstMonoPtr;
/// Constructs the zero polynomial in the given ring.
- Poly(const PolyRing& ring): mRing(ring) {}
+ Poly(const PolyRing& ring): mRing(ring), mMonos(ring.monoid()) {}
Poly(const Poly& poly):
mRing(poly.ring()), mCoefs(poly.mCoefs), mMonos(poly.mMonos)
@@ -45,7 +45,10 @@ public:
bool isZero() const {return mCoefs.empty();}
size_t termCount() const {return mCoefs.size();}
- size_t getMemoryUse() const;
+ size_t getMemoryUse() const {
+ return sizeof(mCoefs.front()) * mCoefs.capacity() +
+ mMonos.memoryBytesUsed();
+ }
/// Returns a polynomial whose terms have been permuted to be in
/// descending order.
@@ -57,21 +60,46 @@ public:
/// p that is necessary to avoid an in-place operation:
///
/// p = p.polyWithTermsDescending()
- Poly polyWithTermsDescending();
+ Poly polyWithTermsDescending() {
+ // *** Sort terms in descending order of monomial.
+ // It would be possible but cumbersome to implement a sort directly
+ // on mMonos. That way no allocation would need to happen, however
+ // it is not clear that that would be any faster, since swapping around
+ // monomials in-place is slow. Swapping terms is faster, since terms
+ // just refer to the monomials. This way is also easier to implement.
+ //
+ /// @todo: make a separate TermSorter object that allows the temporary
+ /// vector to be reused between sorts. This should matter for sorting input
+ /// ideals where there might be a lot of polynomials to go through.
+ auto greaterOrEqual = [&](const NewConstTerm& a, const NewConstTerm& b) {
+ return monoid().lessThan(*b.mono, *a.mono);
+ };
+ auto terms = rangeToVector(*this);
+ std::sort(std::begin(terms), std::end(terms), greaterOrEqual);
+
+ // *** Make a new polynomial with terms in that order
+ Poly poly(ring());
+ poly.reserve(termCount());
+ poly.append(terms);
+
+ MATHICGB_ASSERT(poly.termsAreInDescendingOrder());
+ MATHICGB_ASSERT(poly.termCount() == termCount());
+ return poly;
+ }
+
+ /// Appends the given term as the last term in the polynomial.
+ void append(ConstCoefRef coef, ConstMonoRef mono) {
+ mCoefs.push_back(coef);
+ mMonos.push_back(mono);
+ }
/// Appends the given term as the last term in the polynomial.
void append(const NewConstTerm& term) {
MATHICGB_ASSERT(term.mono != nullptr);
- typedef Field::RawElement C;
- typedef Field::Element E;
- C c = term.coef;
- E e = c;
-
append(term.coef, *term.mono);
}
/// Appends each term in the range r to the end of the polynomial.
- ///
template<class Range>
void append(const Range& r) {
for (const auto& term : r)
@@ -87,8 +115,6 @@ public:
append(range(termsBegin, termsEnd));
}
- void append(ConstCoefRef coef, ConstMonoRef mono);
-
/// Hint that space for the give number of terms is going to be needed.
/// This serves the same purpose as std::vector<>::reserve.
void reserve(size_t spaceForThisManyTerms) {
@@ -97,7 +123,15 @@ public:
/// Makes the polynomial monic by multiplying by the multiplicative inverse
/// of leadCoef(). Calling this method is an error if isZero().
- void makeMonic();
+ void makeMonic() {
+ MATHICGB_ASSERT(!isZero());
+ if (isMonic())
+ return;
+ auto multiplier = field().inverse(leadCoef());
+ for (auto& coef : mCoefs)
+ coef = field().product(coef, multiplier);
+ MATHICGB_ASSERT(isMonic());
+ }
void setToZero() {
mCoefs.clear();
@@ -131,7 +165,8 @@ public:
return field().isOne(leadCoef());
}
- typedef std::vector<Coef>::const_iterator ConstCoefIterator;
+ typedef Field::ElementVector CoefVector;
+ typedef CoefVector::const_iterator ConstCoefIterator;
typedef Range<ConstCoefIterator> ConstCoefIteratorRange;
ConstCoefIterator coefBegin() const {return mCoefs.begin();}
@@ -146,62 +181,31 @@ public:
/// Returns the monomial of the leading term.
ConstMonoRef leadMono() const {
MATHICGB_ASSERT(!isZero());
- return Monoid::toRef(&mMonos.front());
+ return mMonos.front();
}
/// Returns the monomial of the last term.
ConstMonoRef backMono() const {
MATHICGB_ASSERT(!isZero());
- return Monoid::toRef(&mMonos[(termCount() - 1) * monoid().entryCount()]);
+ return mMonos.back();
}
/// Returns true if the terms are in descending order. The terms are in
/// descending order when mono(0) >= mono(1) >= ... >= backMono.
- bool termsAreInDescendingOrder() const;
-
- class ConstMonoIterator {
- public:
- typedef std::forward_iterator_tag iterator_category;
- typedef ConstMonoRef value_type;
- typedef ptrdiff_t difference_type;
- typedef value_type* pointer;
- typedef ConstMonoRef reference;
-
- ConstMonoIterator() {}
-
- ConstMonoIterator& operator++() {
- mIt += mEntryCount;
- return *this;
- }
-
- ConstMonoRef operator*() const {return Monoid::toRef(&*mIt);}
-
- bool operator==(const ConstMonoIterator& it) const {return mIt == it.mIt;}
- bool operator!=(const ConstMonoIterator& it) const {return mIt != it.mIt;}
-
- private:
- friend class Poly;
- typedef std::vector<exponent>::const_iterator Iterator;
-
- ConstMonoIterator(const Monoid& monoid, Iterator it):
- mEntryCount(monoid.entryCount()),
- mIt(it)
- {}
-
- size_t mEntryCount;
- Iterator mIt;
- };
-
- typedef Range<ConstMonoIterator> ConstMonoIteratorRange;
-
- ConstMonoIterator monoBegin() const {
- return ConstMonoIterator(monoid(), mMonos.begin());
+ /// The coefficient of the terms are not considered in this comparison.
+ bool termsAreInDescendingOrder() const {
+ auto greaterThanOrEqual = [&](ConstMonoRef a, ConstMonoRef b) {
+ return !monoid().lessThan(a, b);
+ };
+ return std::is_sorted(monoBegin(), monoEnd(), greaterThanOrEqual);
}
- ConstMonoIterator monoEnd() const {
- return ConstMonoIterator(monoid(), mMonos.end());
- }
+ typedef Monoid::MonoVector MonoVector;
+ typedef MonoVector::const_iterator ConstMonoIterator;
+ typedef Range<ConstMonoIterator> ConstMonoIteratorRange;
+ ConstMonoIterator monoBegin() const {return mMonos.begin();}
+ ConstMonoIterator monoEnd() const {return mMonos.end();}
ConstMonoIteratorRange monoRange() const {
return range(monoBegin(), monoEnd());
}
@@ -254,19 +258,13 @@ private:
friend bool operator==(const Poly &a, const Poly &b);
const PolyRing& mRing;
- std::vector<Coef> mCoefs;
- std::vector<exponent> mMonos;
+ CoefVector mCoefs;
+ MonoVector mMonos;
};
-bool operator==(const Poly& a, const Poly& b);
-
-// This is inline since it is performance-critical.
-inline void Poly::append(ConstCoefRef a, ConstMonoRef m) {
- mCoefs.push_back(a);
-
- const auto offset = mMonos.size();
- mMonos.resize(offset + monoid().entryCount());
- monoid().copy(m, *PolyRing::Monoid::MonoPtr(mMonos.data() + offset));
+inline bool operator==(const Poly& a, const Poly& b) {
+ MATHICGB_ASSERT(a.ring() == b.ring());
+ return a.mCoefs == b.mCoefs && a.mMonos == b.mMonos;
}
MATHICGB_NAMESPACE_END
diff --git a/src/mathicgb/PolyRing.hpp b/src/mathicgb/PolyRing.hpp
index 97140cc..23e9a20 100755
--- a/src/mathicgb/PolyRing.hpp
+++ b/src/mathicgb/PolyRing.hpp
@@ -726,5 +726,15 @@ inline bool PolyRing::monomialHasAmpleCapacity(ConstMonomial mono) const {
return monoid().hasAmpleCapacity(mono);
}
+/// Returns true if a and b are the same object.
+inline bool operator==(const PolyRing& a, const PolyRing& b) {
+ return &a == &b;
+}
+
+/// As !(a == b).
+inline bool operator!=(const PolyRing& a, const PolyRing& b) {
+ return !(a == b);
+}
+
MATHICGB_NAMESPACE_END
#endif
diff --git a/src/mathicgb/PrimeField.hpp b/src/mathicgb/PrimeField.hpp
index a486752..1401d10 100755
--- a/src/mathicgb/PrimeField.hpp
+++ b/src/mathicgb/PrimeField.hpp
@@ -3,6 +3,7 @@
#ifndef MATHICGB_PRIME_FIELD_GUARD
#define MATHICGB_PRIME_FIELD_GUARD
+#include <vector>
#include <limits>
#include <type_traits>
#include <ostream>
@@ -70,6 +71,8 @@ public:
typedef Element* ElementPtr;
typedef const Element* ConstElementPtr;
+ typedef std::vector<Element> ElementVector;
+
PrimeField(const T primeCharacteristic): mCharac(primeCharacteristic) {}
Element zero() const {return Element(0);}
@@ -270,6 +273,17 @@ auto PrimeField<T>::inverse(const Element elementA) const -> Element {
return inverseElement;
}
+/// Returns true if a and b are the same object.
+template<class E>
+bool operator==(const PrimeField<E>& a, const PrimeField<E>& b) {
+ return &a == &b;
+}
+
+/// As !(a == b).
+template<class E>
+bool operator!=(const PrimeField<E>& a, const PrimeField<E>& b) {
+ return !(a == b);
+}
template<class T>
std::ostream& operator<<(
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/mathicgb.git
More information about the debian-science-commits
mailing list