3 * @author Florian Corzilius <corzilius@cs.rwth-aachen.de>
23 Value<T>::Value( const T& _num ):
29 Value<T>::Value( const T& _num1, const T& _num2 ):
35 Value<T>::Value( const Value<T>& _orig ):
36 mMainPart( _orig.mainPart() ),
37 mDeltaPart( _orig.deltaPart() )
44 Value<T>& Value<T>::operator=( const Value<T>& _value )
46 mMainPart = _value.mainPart();
47 mDeltaPart = _value.deltaPart();
52 Value<T> Value<T>::operator +( const Value<T>& _value ) const
54 T num1 = mMainPart + _value.mainPart();
55 T num2 = mDeltaPart + _value.deltaPart();
56 return Value( num1, num2 );
60 void Value<T>::operator +=( const Value<T>& _value )
62 mMainPart += _value.mainPart();
63 mDeltaPart += _value.deltaPart();
67 Value<T> Value<T>::operator -( const Value<T>& _value ) const
69 T num1 = mMainPart - _value.mainPart();
70 T num2 = mDeltaPart - _value.deltaPart();
71 return Value( num1, num2 );
75 void Value<T>::operator -=( const Value<T>& _value )
77 mMainPart -= _value.mainPart();
78 mDeltaPart -= _value.deltaPart();
82 Value<T> Value<T>::operator *( const T& a ) const
84 T num1 = a * mMainPart;
85 T num2 = a * mDeltaPart;
86 return Value( num1, num2 );
90 Value<T> Value<T>::operator *( const Value<T>& _value ) const
92 T num1 = _value.mainPart() * mMainPart;
93 T num2 = _value.deltaPart() * mDeltaPart;
94 return Value( num1, num2 );
98 void Value<T>::operator *=( const Value<T>& _value )
100 mMainPart *= _value.mainPart();
101 mDeltaPart *= _value.deltaPart();
105 void Value<T>::operator *=( const T& _a )
112 Value<T> Value<T>::operator /( const T& _a ) const
114 T num1 = T( mMainPart ) / _a;
115 T num2 = T( mDeltaPart ) / _a;
116 return Value( num1, num2 );
120 void Value<T>::operator /=( const T& _a )
127 bool Value<T>::operator <( const Value<T>& _value ) const
129 if( mMainPart < _value.mainPart() )
133 else if( mMainPart == _value.mainPart() )
135 if( mDeltaPart < _value.deltaPart() )
144 bool Value<T>::operator <=( const Value<T>& _value ) const
147 if( (mMainPart < _value.mainPart()) || (mMainPart == _value.mainPart() && mDeltaPart <= _value.deltaPart()) )
153 bool Value<T>::operator ==( const Value<T>& _value ) const
156 if( (mMainPart == _value.mainPart()) && (mDeltaPart == _value.deltaPart()) )
162 bool Value<T>::operator ==( const T& _a ) const
164 return (mMainPart == _a && mDeltaPart == 0 );
168 bool Value<T>::operator <( const T& _a ) const
170 return (mMainPart < _a || (mMainPart == _a && mDeltaPart < 0 ));
174 bool Value<T>::operator >( const T& _a ) const
176 return (mMainPart > _a || (mMainPart == _a && mDeltaPart > 0 ));
180 bool Value<T>::operator <=( const T& _a ) const
182 return (mMainPart < _a || (mMainPart == _a && mDeltaPart <= 0 ));
186 bool Value<T>::operator >=( const T& _a ) const
188 return (mMainPart > _a || (mMainPart == _a && mDeltaPart >= 0 ));
192 const std::string Value<T>::toString() const
194 std::stringstream out;
200 std::ostream& operator<<( std::ostream& _out, const Value<T1>& _value )
202 return _out << _value.mainPart() << "+d*" << _value.deltaPart();
206 void Value<T>::print( std::ostream& _out ) const
208 _out << "( " << mMainPart;
209 _out << " + d * " << mDeltaPart << " )";
213 * Computes the sign: 0 if main & delta part are unequal 0. Else +/- 1 determined by the sign of main part (if set) else delta part.
216 T Value<T>::sign() const{
227 } // end namspace lra
228 } // end namspace smtrat