[mathicgb] 299/393: merge

Doug Torrance dtorrance-guest at moszumanska.debian.org
Fri Apr 3 15:59:25 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 0ab694c3300302f60018d95cc5f6c9f09906e621
Merge: 12eb95e 2b0bdf1
Author: Bjarke Hammersholt Roune <bjarkehr.code at gmail.com>
Date:   Fri Apr 26 22:40:25 2013 +0200

    merge

 src/mathicgb/MonoMonoid.hpp |   1 +
 src/mathicgb/MonoOrder.hpp  | 338 ++++++++++++++++++++++----------------------
 2 files changed, 170 insertions(+), 169 deletions(-)

diff --cc src/mathicgb/MonoMonoid.hpp
index f984c27,3803f53..cfcd03f
--- a/src/mathicgb/MonoMonoid.hpp
+++ b/src/mathicgb/MonoMonoid.hpp
@@@ -1760,6 -1745,7 +1760,7 @@@ auto MonoMonoid<E, HC, SH, SO>::readMon
      in >> e;
      gradings[w] = static_cast<Exponent>(e);
    }
 -  typedef MonoOrder<Exponent> Order;
++
    Order order(
      varCount,
      std::move(gradings),
diff --cc src/mathicgb/MonoOrder.hpp
index 7a746b4,accd166..c46674d
--- a/src/mathicgb/MonoOrder.hpp
+++ b/src/mathicgb/MonoOrder.hpp
@@@ -1,169 -1,169 +1,169 @@@
--#ifndef MATHICGB_MONO_ORDER_GUARD
--#define MATHICGB_MONO_ORDER_GUARD
--
--#include <vector>
--
--/// Class used to describe an monomial order or a module monomial
--/// order. Use this class to construct a monoid. The monoid does the
--/// actual comparisons.
--///
--/// You can extend the functionality for ordering offered here for
--/// module mononials by pre- and post-processing of monomials. See
--/// MonoProcessor.
--template<class Weight>
--class MonoOrder;
--
--template<class W>
--class MonoOrder {
--public:
--  typedef W Weight;
--  typedef size_t VarIndex;
--
--  static const size_t ComponentAfterBaseOrder = static_cast<size_t>(-1);
--
--  enum BaseOrder {
--    /// Lexicographic order with x0 < x1 < ... < x_n.
--    LexBaseOrder = 0,
--
--    /// Reverse lexicographic order with x0 > x1 > ... > x_n.
--    RevLexBaseOrder = 1
--  };
--
--  /// Same as MonoOrder(varCount, varOrder, gradings, componentBefore)
--  /// where gradings has a single row of varCount 1's.
--  MonoOrder(
--    const VarIndex varCount,
--    const BaseOrder baseOrder = RevLexBaseOrder,
--    const size_t componentBefore = ComponentAfterBaseOrder
--  ):
--    mVarCount(varCount),
--    mGradings(varCount, 1),
--    mBaseOrder(baseOrder),
--    mComponentBefore(ComponentAfterBaseOrder)
--  {}
--
--  /// The specified base order is graded by the gradings matrix.
--  ///
--  /// The layout of the gradings matrix is row-major. For comparisons,
--  /// the degree with respect to the first row is considered first,
--  /// then the degree with respect to the second row and so on. The
--  /// base order is used as a tie-breaker. The gradings vector can be
--  /// empty. The order must be a monomial order - in particular, 1
--  /// must be strictly less than all other monomials.
--  ///
--  /// For module monomials, the component is considered too. When the
--  /// component is considered depens on componentBefore. If
--  /// componentBefore == 0 then the component is considered before
--  /// anything else. If componentBefore < gradingCount(), then the
--  /// component is considered before the grading with index
--  /// componentBefore and after the grading with index componentBefore
--  /// - 1. If componentBefore == gradingCount(), then the component is
--  /// considered after all gradings and before the base order. If
--  /// componentBefore = ComponentAfterBaseOrder then the component is
--  /// considered after everything else.
--  ///
--  /// The ordering represented by this object will be equivalent to
--  /// the specified order, but it may be encoded differently. For
--  /// example, if varCount == 0, then all orders are equivalent so all
--  /// the other parameters are ignored and the encoding will be chosen
--  /// to be the minimal-overhead one: ungraded lex with component
--  /// considered last (do not depend on this particular choice - it
--  /// may change). Therefore, you cannot count on any setting of this
--  /// order to match what you passed in as a parameter.
--  ///
--  /// If the ordering you hav specified is not a monomial order, then
--  /// the only guarantee in terms of encoding is that isMonomialOrder
--  /// will return false.
--  MonoOrder(
--    const VarIndex varCount,
--    std::vector<Weight>&& gradings,
--    const BaseOrder baseOrder = RevLexBaseOrder,
--    const size_t componentBefore = ComponentAfterBaseOrder
--  ):
--    mVarCount(varCount),
--    mGradings(std::move(gradings)),
--    mBaseOrder(baseOrder),
--    mComponentBefore(componentBefore)
--  {}
--
--  const VarIndex varCount() const {return mVarCount;}
--
--  /// Returns the number of rows in the grading vector.
--  size_t gradingCount() const {
--    return varCount() == 0 ? 0 : mGradings.size() / varCount();
--  }
--
--  /// Returns the grading matrix in row-major layout.
-   const std::vector<Weight>& gradings() const {return mGradings;}
 -  const std::vector<Weight>& gradings() {return mGradings;}
--
--  /// Returns true if the grading matrix is a single row of 1's.
--  bool isTotalDegree() const {
--    if (varCount() == 0 || mGradings.size() != varCount())
--      return false;
--    for (VarIndex var = 0; var < varCount(); ++var)
--      if (mGradings[var] != 1)
--        return false;
--    return true;
--  }
--
--  BaseOrder baseOrder() const {return mBaseOrder;}
--
--  /// Returns true if the order is a monomial order. A monomial order
--  /// is a total order on monomials where a>b => ac>bc for all
--  /// monomials a,b,c and where the order is a well order. Only the
--  /// well order property could currently fail. It is equivalent to
--  /// stating that x>1 for all variables x.
--  bool isMonomialOrder() const {
--    for (VarIndex var = 0; var < varCount(); ++var) {
--      // Check that x_var > 1.
--      for (size_t grading = 0; ; ++grading) {
--        if (grading == gradingCount) {
--          // The column was entirely zero, so x_var > 1 if and only if the
--          // base ordering is lex.
--          if (baseOrder() != LexBaseOrder)
--            return false;
--          break;
--        }
--        const auto index = grading * gradingCount() + var;
--        MATHICGB_ASSERT(index < mGradings.size());
--        const auto weight = mGradings[index];
--        if (weight != 0) {
--          // We have found the first non-zero weight in this column,
--          // so x_var > 1 if and only if this weight is positive.
--          if (weight < 0)
--            return false;
--          break;
--        }
--      }
--    }
--    return true;
--  }
--
--private:
--  bool debugAssertValid() {
--#ifdef MATHICGB_DEBUG
--    MATHICGB_ASSERT(mGradings.size() == gradingCount() * varCount());
--    MATHICGB_ASSERT(
--      mComponentBefore == ComponentAfterBaseOrder ||
--      mComponentBefore <= gradingCount()
--    );
--    MATHICGB_ASSERT(
--      mBaseOrder == LexBaseOrder ||
--      mBaseOrder == RevLexBaseOrder
--    );
--    if (varCount() == 0) {
--      MATHICGB_ASSERT(mGradings.empty());
--      MATHICGB_ASSERT(baseOrder() == RevLexBaseOrder());
--      MATHICGB_ASSERT(mComponentBefore == ComponentAfterBaseOrder);
--    }
--#endif
--    return true;
--  }
--
--  const VarIndex mVarCount;
--  const std::vector<Weight> mGradings;
--  const BaseOrder mBaseOrder;
--  const size_t mComponentBefore;
--};
--
--#endif
++#ifndef MATHICGB_MONO_ORDER_GUARD
++#define MATHICGB_MONO_ORDER_GUARD
++
++#include <vector>
++
++/// Class used to describe an monomial order or a module monomial
++/// order. Use this class to construct a monoid. The monoid does the
++/// actual comparisons.
++///
++/// You can extend the functionality for ordering offered here for
++/// module mononials by pre- and post-processing of monomials. See
++/// MonoProcessor.
++template<class Weight>
++class MonoOrder;
++
++template<class W>
++class MonoOrder {
++public:
++  typedef W Weight;
++  typedef size_t VarIndex;
++
++  static const size_t ComponentAfterBaseOrder = static_cast<size_t>(-1);
++
++  enum BaseOrder {
++    /// Lexicographic order with x0 < x1 < ... < x_n.
++    LexBaseOrder = 0,
++
++    /// Reverse lexicographic order with x0 > x1 > ... > x_n.
++    RevLexBaseOrder = 1
++  };
++
++  /// Same as MonoOrder(varCount, varOrder, gradings, componentBefore)
++  /// where gradings has a single row of varCount 1's.
++  MonoOrder(
++    const VarIndex varCount,
++    const BaseOrder baseOrder = RevLexBaseOrder,
++    const size_t componentBefore = ComponentAfterBaseOrder
++  ):
++    mVarCount(varCount),
++    mGradings(varCount, 1),
++    mBaseOrder(baseOrder),
++    mComponentBefore(ComponentAfterBaseOrder)
++  {}
++
++  /// The specified base order is graded by the gradings matrix.
++  ///
++  /// The layout of the gradings matrix is row-major. For comparisons,
++  /// the degree with respect to the first row is considered first,
++  /// then the degree with respect to the second row and so on. The
++  /// base order is used as a tie-breaker. The gradings vector can be
++  /// empty. The order must be a monomial order - in particular, 1
++  /// must be strictly less than all other monomials.
++  ///
++  /// For module monomials, the component is considered too. When the
++  /// component is considered depens on componentBefore. If
++  /// componentBefore == 0 then the component is considered before
++  /// anything else. If componentBefore < gradingCount(), then the
++  /// component is considered before the grading with index
++  /// componentBefore and after the grading with index componentBefore
++  /// - 1. If componentBefore == gradingCount(), then the component is
++  /// considered after all gradings and before the base order. If
++  /// componentBefore = ComponentAfterBaseOrder then the component is
++  /// considered after everything else.
++  ///
++  /// The ordering represented by this object will be equivalent to
++  /// the specified order, but it may be encoded differently. For
++  /// example, if varCount == 0, then all orders are equivalent so all
++  /// the other parameters are ignored and the encoding will be chosen
++  /// to be the minimal-overhead one: ungraded lex with component
++  /// considered last (do not depend on this particular choice - it
++  /// may change). Therefore, you cannot count on any setting of this
++  /// order to match what you passed in as a parameter.
++  ///
++  /// If the ordering you hav specified is not a monomial order, then
++  /// the only guarantee in terms of encoding is that isMonomialOrder
++  /// will return false.
++  MonoOrder(
++    const VarIndex varCount,
++    std::vector<Weight>&& gradings,
++    const BaseOrder baseOrder = RevLexBaseOrder,
++    const size_t componentBefore = ComponentAfterBaseOrder
++  ):
++    mVarCount(varCount),
++    mGradings(std::move(gradings)),
++    mBaseOrder(baseOrder),
++    mComponentBefore(componentBefore)
++  {}
++
++  const VarIndex varCount() const {return mVarCount;}
++
++  /// Returns the number of rows in the grading vector.
++  size_t gradingCount() const {
++    return varCount() == 0 ? 0 : mGradings.size() / varCount();
++  }
++
++  /// Returns the grading matrix in row-major layout.
++  const std::vector<Weight>& gradings() const {return mGradings;}
++
++  /// Returns true if the grading matrix is a single row of 1's.
++  bool isTotalDegree() const {
++    if (varCount() == 0 || mGradings.size() != varCount())
++      return false;
++    for (VarIndex var = 0; var < varCount(); ++var)
++      if (mGradings[var] != 1)
++        return false;
++    return true;
++  }
++
++  BaseOrder baseOrder() const {return mBaseOrder;}
++
++  /// Returns true if the order is a monomial order. A monomial order
++  /// is a total order on monomials where a>b => ac>bc for all
++  /// monomials a,b,c and where the order is a well order. Only the
++  /// well order property could currently fail. It is equivalent to
++  /// stating that x>1 for all variables x.
++  bool isMonomialOrder() const {
++    for (VarIndex var = 0; var < varCount(); ++var) {
++      // Check that x_var > 1.
++      for (size_t grading = 0; ; ++grading) {
++        if (grading == gradingCount) {
++          // The column was entirely zero, so x_var > 1 if and only if the
++          // base ordering is lex.
++          if (baseOrder() != LexBaseOrder)
++            return false;
++          break;
++        }
++        const auto index = grading * gradingCount() + var;
++        MATHICGB_ASSERT(index < mGradings.size());
++        const auto weight = mGradings[index];
++        if (weight != 0) {
++          // We have found the first non-zero weight in this column,
++          // so x_var > 1 if and only if this weight is positive.
++          if (weight < 0)
++            return false;
++          break;
++        }
++      }
++    }
++    return true;
++  }
++
++private:
++  bool debugAssertValid() {
++#ifdef MATHICGB_DEBUG
++    MATHICGB_ASSERT(mGradings.size() == gradingCount() * varCount());
++    MATHICGB_ASSERT(
++      mComponentBefore == ComponentAfterBaseOrder ||
++      mComponentBefore <= gradingCount()
++    );
++    MATHICGB_ASSERT(
++      mBaseOrder == LexBaseOrder ||
++      mBaseOrder == RevLexBaseOrder
++    );
++    if (varCount() == 0) {
++      MATHICGB_ASSERT(mGradings.empty());
++      MATHICGB_ASSERT(baseOrder() == RevLexBaseOrder());
++      MATHICGB_ASSERT(mComponentBefore == ComponentAfterBaseOrder);
++    }
++#endif
++    return true;
++  }
++
++  const VarIndex mVarCount;
++  const std::vector<Weight> mGradings;
++  const BaseOrder mBaseOrder;
++  const size_t mComponentBefore;
++};
++
++#endif

-- 
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