PolyBoRi
PseudoLongProduct.h
Go to the documentation of this file.
1 // -*- c++ -*-
2 //*****************************************************************************
14 //*****************************************************************************
15 
16 #ifndef polybori_groebner_PseudoLongProduct_h_
17 #define polybori_groebner_PseudoLongProduct_h_
18 
19 // include basic definitions
20 #include "groebner_defs.h"
21 #include "PseudoLongLong.h"
22 #include "BitMask.h"
23 
25 
33  protected BitMask<sizeof(unsigned long)*4> {
34 
35 public:
36  typedef unsigned long long_type;
37 
38  PseudoLongProduct(const long_type& first, const long_type& second):
39  most(high(first)*high(second)), least(low(first)*low(second)) {
40 
41  long_type mixed = high(least) + high(first)*low(second);
42  most += high(mixed);
43 
44  mixed = low(mixed) + low(first)*high(second);
45  most += high(mixed);
46 
47  least = shift(mixed) + low(least);
48  }
49 
51  bool greater(long_type rhs) const {
52  return (most > 0) || (least > rhs);
53  }
54 
56  template <long_type MaxLow>
57  bool greater(const PseudoLongLong<0, MaxLow>&) const {
58  return greater(MaxLow);
59  }
60 
62  template <long_type MaxHigh, long_type MaxLow>
64  return (most > MaxHigh) || ( (most == MaxHigh) && (least > MaxLow) );
65  }
66 
67 private:
68  long_type most, least;
69 };
70 
71 template <class RhsType>
72 inline bool
73 operator> (PseudoLongProduct lhs, const RhsType& rhs) {
74  return lhs.greater(rhs);
75 }
76 
77 
78 
80 
81 #endif /* polybori_groebner_PseudoLongProduct_h_ */
bool operator>(PseudoLongProduct lhs, const RhsType &rhs)
Definition: PseudoLongProduct.h:73
#define END_NAMESPACE_PBORIGB
Definition: groebner_defs.h:16
bool greater(const PseudoLongLong< MaxHigh, MaxLow > &) const
compare carry-over savely with represented by two unsigned longs
Definition: PseudoLongProduct.h:63
bool greater(long_type rhs) const
compare carry-over savely
Definition: PseudoLongProduct.h:51
#define BEGIN_NAMESPACE_PBORIGB
Definition: groebner_defs.h:15
bool greater(const PseudoLongLong< 0, MaxLow > &) const
compare carry-over savely with represented by two unsigned longs
Definition: PseudoLongProduct.h:57
unsigned long long_type
Definition: PseudoLongProduct.h:36
PseudoLongProduct(const long_type &first, const long_type &second)
Definition: PseudoLongProduct.h:38
This class defines a delayed product of longs and comparison with LongLong Constant.
Definition: PseudoLongProduct.h:32
This class defines PseudoLongLong.
Definition: PseudoLongLong.h:31
This class defines a bit mask and related operations.
Definition: BitMask.h:30