PseudoLongProduct.h
Go to the documentation of this file.
// -*- c++ -*-
//*****************************************************************************
//*****************************************************************************
#ifndef polybori_groebner_PseudoLongProduct_h_
#define polybori_groebner_PseudoLongProduct_h_
// include basic definitions
#include "groebner_defs.h"
#include "PseudoLongLong.h"
#include "BitMask.h"
BEGIN_NAMESPACE_PBORIGB
class PseudoLongProduct:
protected BitMask<sizeof(unsigned long)*4> {
public:
typedef unsigned long long_type;
PseudoLongProduct(const long_type& first, const long_type& second):
most(high(first)*high(second)), least(low(first)*low(second)) {
long_type mixed = high(least) + high(first)*low(second);
most += high(mixed);
mixed = low(mixed) + low(first)*high(second);
most += high(mixed);
least = shift(mixed) + low(least);
}
bool greater(long_type rhs) const {
return (most > 0) || (least > rhs);
}
template <long_type MaxLow>
bool greater(const PseudoLongLong<0, MaxLow>&) const {
return greater(MaxLow);
}
template <long_type MaxHigh, long_type MaxLow>
bool greater(const PseudoLongLong<MaxHigh, MaxLow>&) const {
return (most > MaxHigh) || ( (most == MaxHigh) && (least > MaxLow) );
}
private:
long_type most, least;
};
template <class RhsType>
inline bool
operator> (PseudoLongProduct lhs, const RhsType& rhs) {
return lhs.greater(rhs);
}
END_NAMESPACE_PBORIGB
#endif /* polybori_groebner_PseudoLongProduct_h_ */
polybori::groebner::operator>
bool operator>(PseudoLongProduct lhs, const RhsType &rhs)
Definition: PseudoLongProduct.h:73
END_NAMESPACE_PBORIGB
#define END_NAMESPACE_PBORIGB
Definition: groebner_defs.h:16
BitMask.h
polybori::groebner::PseudoLongProduct::greater
bool greater(const PseudoLongLong< MaxHigh, MaxLow > &) const
compare carry-over savely with represented by two unsigned longs
Definition: PseudoLongProduct.h:63
polybori::groebner::PseudoLongProduct::greater
bool greater(long_type rhs) const
compare carry-over savely
Definition: PseudoLongProduct.h:51
BEGIN_NAMESPACE_PBORIGB
#define BEGIN_NAMESPACE_PBORIGB
Definition: groebner_defs.h:15
PseudoLongLong.h
groebner_defs.h
polybori::groebner::PseudoLongProduct::greater
bool greater(const PseudoLongLong< 0, MaxLow > &) const
compare carry-over savely with represented by two unsigned longs
Definition: PseudoLongProduct.h:57
polybori::groebner::PseudoLongProduct::long_type
unsigned long long_type
Definition: PseudoLongProduct.h:36
polybori::groebner::PseudoLongProduct::PseudoLongProduct
PseudoLongProduct(const long_type &first, const long_type &second)
Definition: PseudoLongProduct.h:38
polybori::groebner::PseudoLongProduct
This class defines a delayed product of longs and comparison with LongLong Constant.
Definition: PseudoLongProduct.h:32
polybori::groebner::PseudoLongLong
This class defines PseudoLongLong.
Definition: PseudoLongLong.h:31
polybori::groebner::BitMask
This class defines a bit mask and related operations.
Definition: BitMask.h:30