From 61ec50dabe14c5d4582ac187706ea27645b3562b Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Wed, 29 Nov 2017 10:54:33 -0500 Subject: Change Doxygen comment style from //! to /// Also see https://groups.google.com/forum/#!topic/cryptopp-users/A7-Xt5Knlzw --- polynomi.h | 178 ++++++++++++++++++++++++++++++------------------------------- 1 file changed, 89 insertions(+), 89 deletions(-) (limited to 'polynomi.h') diff --git a/polynomi.h b/polynomi.h index 2b904204..96dd238a 100644 --- a/polynomi.h +++ b/polynomi.h @@ -1,8 +1,8 @@ // polynomi.h - originally written and placed in the public domain by Wei Dai -//! \file -//! \headerfile polynomi.h -//! \brief Classes for polynomial basis and operations +/// \file +/// \headerfile polynomi.h +/// \brief Classes for polynomial basis and operations #ifndef CRYPTOPP_POLYNOMI_H @@ -20,21 +20,21 @@ NAMESPACE_BEGIN(CryptoPP) -//! represents single-variable polynomials over arbitrary rings +/// represents single-variable polynomials over arbitrary rings /*! \nosubgrouping */ template class PolynomialOver { public: - //! \name ENUMS, EXCEPTIONS, and TYPEDEFS + /// \name ENUMS, EXCEPTIONS, and TYPEDEFS //@{ - //! division by zero exception + /// division by zero exception class DivideByZero : public Exception { public: DivideByZero() : Exception(OTHER_ERROR, "PolynomialOver: division by zero") {} }; - //! specify the distribution for randomization functions + /// specify the distribution for randomization functions class RandomizationParameter { public: @@ -51,74 +51,74 @@ public: typedef typename T::Element CoefficientType; //@} - //! \name CREATORS + /// \name CREATORS //@{ - //! creates the zero polynomial + /// creates the zero polynomial PolynomialOver() {} - //! + /// PolynomialOver(const Ring &ring, unsigned int count) : m_coefficients((size_t)count, ring.Identity()) {} - //! copy constructor + /// copy constructor PolynomialOver(const PolynomialOver &t) : m_coefficients(t.m_coefficients.size()) {*this = t;} - //! construct constant polynomial + /// construct constant polynomial PolynomialOver(const CoefficientType &element) : m_coefficients(1, element) {} - //! construct polynomial with specified coefficients, starting from coefficient of x^0 + /// construct polynomial with specified coefficients, starting from coefficient of x^0 template PolynomialOver(Iterator begin, Iterator end) : m_coefficients(begin, end) {} - //! convert from string + /// convert from string PolynomialOver(const char *str, const Ring &ring) {FromStr(str, ring);} - //! convert from big-endian byte array + /// convert from big-endian byte array PolynomialOver(const byte *encodedPolynomialOver, unsigned int byteCount); - //! convert from Basic Encoding Rules encoded byte array + /// convert from Basic Encoding Rules encoded byte array explicit PolynomialOver(const byte *BEREncodedPolynomialOver); - //! convert from BER encoded byte array stored in a BufferedTransformation object + /// convert from BER encoded byte array stored in a BufferedTransformation object explicit PolynomialOver(BufferedTransformation &bt); - //! create a random PolynomialOver + /// create a random PolynomialOver PolynomialOver(RandomNumberGenerator &rng, const RandomizationParameter ¶meter, const Ring &ring) {Randomize(rng, parameter, ring);} //@} - //! \name ACCESSORS + /// \name ACCESSORS //@{ - //! the zero polynomial will return a degree of -1 + /// the zero polynomial will return a degree of -1 int Degree(const Ring &ring) const {return int(CoefficientCount(ring))-1;} - //! + /// unsigned int CoefficientCount(const Ring &ring) const; - //! return coefficient for x^i + /// return coefficient for x^i CoefficientType GetCoefficient(unsigned int i, const Ring &ring) const; //@} - //! \name MANIPULATORS + /// \name MANIPULATORS //@{ - //! + /// PolynomialOver& operator=(const PolynomialOver& t); - //! + /// void Randomize(RandomNumberGenerator &rng, const RandomizationParameter ¶meter, const Ring &ring); - //! set the coefficient for x^i to value + /// set the coefficient for x^i to value void SetCoefficient(unsigned int i, const CoefficientType &value, const Ring &ring); - //! + /// void Negate(const Ring &ring); - //! + /// void swap(PolynomialOver &t); //@} - //! \name BASIC ARITHMETIC ON POLYNOMIALS + /// \name BASIC ARITHMETIC ON POLYNOMIALS //@{ bool Equals(const PolynomialOver &t, const Ring &ring) const; bool IsZero(const Ring &ring) const {return CoefficientCount(ring)==0;} @@ -136,9 +136,9 @@ public: PolynomialOver& Accumulate(const PolynomialOver& t, const Ring &ring); PolynomialOver& Reduce(const PolynomialOver& t, const Ring &ring); - //! + /// PolynomialOver Doubled(const Ring &ring) const {return Plus(*this, ring);} - //! + /// PolynomialOver Squared(const Ring &ring) const {return Times(*this, ring);} CoefficientType EvaluateAt(const CoefficientType &x, const Ring &ring) const; @@ -146,11 +146,11 @@ public: PolynomialOver& ShiftLeft(unsigned int n, const Ring &ring); PolynomialOver& ShiftRight(unsigned int n, const Ring &ring); - //! calculate r and q such that (a == d*q + r) && (0 <= degree of r < degree of d) + /// calculate r and q such that (a == d*q + r) && (0 <= degree of r < degree of d) static void Divide(PolynomialOver &r, PolynomialOver &q, const PolynomialOver &a, const PolynomialOver &d, const Ring &ring); //@} - //! \name INPUT/OUTPUT + /// \name INPUT/OUTPUT //@{ std::istream& Input(std::istream &in, const Ring &ring); std::ostream& Output(std::ostream &out, const Ring &ring) const; @@ -162,7 +162,7 @@ private: std::vector m_coefficients; }; -//! Polynomials over a fixed ring +/// Polynomials over a fixed ring /*! Having a fixed ring allows overloaded operators */ template class PolynomialOverFixedRing : private PolynomialOver { @@ -175,129 +175,129 @@ public: typedef typename B::DivideByZero DivideByZero; typedef typename B::RandomizationParameter RandomizationParameter; - //! \name CREATORS + /// \name CREATORS //@{ - //! creates the zero polynomial + /// creates the zero polynomial PolynomialOverFixedRing(unsigned int count = 0) : B(ms_fixedRing, count) {} - //! copy constructor + /// copy constructor PolynomialOverFixedRing(const ThisType &t) : B(t) {} explicit PolynomialOverFixedRing(const B &t) : B(t) {} - //! construct constant polynomial + /// construct constant polynomial PolynomialOverFixedRing(const CoefficientType &element) : B(element) {} - //! construct polynomial with specified coefficients, starting from coefficient of x^0 + /// construct polynomial with specified coefficients, starting from coefficient of x^0 template PolynomialOverFixedRing(Iterator first, Iterator last) : B(first, last) {} - //! convert from string + /// convert from string explicit PolynomialOverFixedRing(const char *str) : B(str, ms_fixedRing) {} - //! convert from big-endian byte array + /// convert from big-endian byte array PolynomialOverFixedRing(const byte *encodedPoly, unsigned int byteCount) : B(encodedPoly, byteCount) {} - //! convert from Basic Encoding Rules encoded byte array + /// convert from Basic Encoding Rules encoded byte array explicit PolynomialOverFixedRing(const byte *BEREncodedPoly) : B(BEREncodedPoly) {} - //! convert from BER encoded byte array stored in a BufferedTransformation object + /// convert from BER encoded byte array stored in a BufferedTransformation object explicit PolynomialOverFixedRing(BufferedTransformation &bt) : B(bt) {} - //! create a random PolynomialOverFixedRing + /// create a random PolynomialOverFixedRing PolynomialOverFixedRing(RandomNumberGenerator &rng, const RandomizationParameter ¶meter) : B(rng, parameter, ms_fixedRing) {} static const ThisType &Zero(); static const ThisType &One(); //@} - //! \name ACCESSORS + /// \name ACCESSORS //@{ - //! the zero polynomial will return a degree of -1 + /// the zero polynomial will return a degree of -1 int Degree() const {return B::Degree(ms_fixedRing);} - //! degree + 1 + /// degree + 1 unsigned int CoefficientCount() const {return B::CoefficientCount(ms_fixedRing);} - //! return coefficient for x^i + /// return coefficient for x^i CoefficientType GetCoefficient(unsigned int i) const {return B::GetCoefficient(i, ms_fixedRing);} - //! return coefficient for x^i + /// return coefficient for x^i CoefficientType operator[](unsigned int i) const {return B::GetCoefficient(i, ms_fixedRing);} //@} - //! \name MANIPULATORS + /// \name MANIPULATORS //@{ - //! + /// ThisType& operator=(const ThisType& t) {B::operator=(t); return *this;} - //! + /// ThisType& operator+=(const ThisType& t) {Accumulate(t, ms_fixedRing); return *this;} - //! + /// ThisType& operator-=(const ThisType& t) {Reduce(t, ms_fixedRing); return *this;} - //! + /// ThisType& operator*=(const ThisType& t) {return *this = *this*t;} - //! + /// ThisType& operator/=(const ThisType& t) {return *this = *this/t;} - //! + /// ThisType& operator%=(const ThisType& t) {return *this = *this%t;} - //! + /// ThisType& operator<<=(unsigned int n) {ShiftLeft(n, ms_fixedRing); return *this;} - //! + /// ThisType& operator>>=(unsigned int n) {ShiftRight(n, ms_fixedRing); return *this;} - //! set the coefficient for x^i to value + /// set the coefficient for x^i to value void SetCoefficient(unsigned int i, const CoefficientType &value) {B::SetCoefficient(i, value, ms_fixedRing);} - //! + /// void Randomize(RandomNumberGenerator &rng, const RandomizationParameter ¶meter) {B::Randomize(rng, parameter, ms_fixedRing);} - //! + /// void Negate() {B::Negate(ms_fixedRing);} void swap(ThisType &t) {B::swap(t);} //@} - //! \name UNARY OPERATORS + /// \name UNARY OPERATORS //@{ - //! + /// bool operator!() const {return CoefficientCount()==0;} - //! + /// ThisType operator+() const {return *this;} - //! + /// ThisType operator-() const {return ThisType(Inverse(ms_fixedRing));} //@} - //! \name BINARY OPERATORS + /// \name BINARY OPERATORS //@{ - //! + /// friend ThisType operator>>(ThisType a, unsigned int n) {return ThisType(a>>=n);} - //! + /// friend ThisType operator<<(ThisType a, unsigned int n) {return ThisType(a<<=n);} //@} - //! \name OTHER ARITHMETIC FUNCTIONS + /// \name OTHER ARITHMETIC FUNCTIONS //@{ - //! + /// ThisType MultiplicativeInverse() const {return ThisType(B::MultiplicativeInverse(ms_fixedRing));} - //! + /// bool IsUnit() const {return B::IsUnit(ms_fixedRing);} - //! + /// ThisType Doubled() const {return ThisType(B::Doubled(ms_fixedRing));} - //! + /// ThisType Squared() const {return ThisType(B::Squared(ms_fixedRing));} CoefficientType EvaluateAt(const CoefficientType &x) const {return B::EvaluateAt(x, ms_fixedRing);} - //! calculate r and q such that (a == d*q + r) && (0 <= r < abs(d)) + /// calculate r and q such that (a == d*q + r) && (0 <= r < abs(d)) static void Divide(ThisType &r, ThisType &q, const ThisType &a, const ThisType &d) {B::Divide(r, q, a, d, ms_fixedRing);} //@} - //! \name INPUT/OUTPUT + /// \name INPUT/OUTPUT //@{ - //! + /// friend std::istream& operator>>(std::istream& in, ThisType &a) {return a.Input(in, ms_fixedRing);} - //! + /// friend std::ostream& operator<<(std::ostream& out, const ThisType &a) {return a.Output(out, ms_fixedRing);} //@} @@ -314,7 +314,7 @@ private: static const Ring ms_fixedRing; }; -//! Ring of polynomials over another ring +/// Ring of polynomials over another ring template class RingOfPolynomialsOver : public AbstractEuclideanDomain > { public: @@ -404,49 +404,49 @@ void PrepareBulkPolynomialInterpolationAt(const Ring &ring, Element *v, const El template Element BulkPolynomialInterpolateAt(const Ring &ring, const Element y[], const Element v[], unsigned int n); -//! +/// template inline bool operator==(const CryptoPP::PolynomialOverFixedRing &a, const CryptoPP::PolynomialOverFixedRing &b) {return a.Equals(b, a.ms_fixedRing);} -//! +/// template inline bool operator!=(const CryptoPP::PolynomialOverFixedRing &a, const CryptoPP::PolynomialOverFixedRing &b) {return !(a==b);} -//! +/// template inline bool operator> (const CryptoPP::PolynomialOverFixedRing &a, const CryptoPP::PolynomialOverFixedRing &b) {return a.Degree() > b.Degree();} -//! +/// template inline bool operator>=(const CryptoPP::PolynomialOverFixedRing &a, const CryptoPP::PolynomialOverFixedRing &b) {return a.Degree() >= b.Degree();} -//! +/// template inline bool operator< (const CryptoPP::PolynomialOverFixedRing &a, const CryptoPP::PolynomialOverFixedRing &b) {return a.Degree() < b.Degree();} -//! +/// template inline bool operator<=(const CryptoPP::PolynomialOverFixedRing &a, const CryptoPP::PolynomialOverFixedRing &b) {return a.Degree() <= b.Degree();} -//! +/// template inline CryptoPP::PolynomialOverFixedRing operator+(const CryptoPP::PolynomialOverFixedRing &a, const CryptoPP::PolynomialOverFixedRing &b) {return CryptoPP::PolynomialOverFixedRing(a.Plus(b, a.ms_fixedRing));} -//! +/// template inline CryptoPP::PolynomialOverFixedRing operator-(const CryptoPP::PolynomialOverFixedRing &a, const CryptoPP::PolynomialOverFixedRing &b) {return CryptoPP::PolynomialOverFixedRing(a.Minus(b, a.ms_fixedRing));} -//! +/// template inline CryptoPP::PolynomialOverFixedRing operator*(const CryptoPP::PolynomialOverFixedRing &a, const CryptoPP::PolynomialOverFixedRing &b) {return CryptoPP::PolynomialOverFixedRing(a.Times(b, a.ms_fixedRing));} -//! +/// template inline CryptoPP::PolynomialOverFixedRing operator/(const CryptoPP::PolynomialOverFixedRing &a, const CryptoPP::PolynomialOverFixedRing &b) {return CryptoPP::PolynomialOverFixedRing(a.DividedBy(b, a.ms_fixedRing));} -//! +/// template inline CryptoPP::PolynomialOverFixedRing operator%(const CryptoPP::PolynomialOverFixedRing &a, const CryptoPP::PolynomialOverFixedRing &b) {return CryptoPP::PolynomialOverFixedRing(a.Modulo(b, a.ms_fixedRing));} -- cgit v1.2.1