LocARNA-1.9.2
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | Static Protected Attributes | Friends
LocARNA::TaintedInftyInt Class Reference

#include <infty_int.hh>

Inheritance diagram for LocARNA::TaintedInftyInt:
LocARNA::InftyInt LocARNA::FiniteInt

List of all members.

Public Types

typedef long int base_type
 the base type

Public Member Functions

 TaintedInftyInt ()
 Construct empty.
 TaintedInftyInt (const base_type &x)
 Construct from base type.
bool is_neg_infty () const
bool is_pos_infty () const
bool is_finite () const
bool is_normal () const
base_type finite_value () const
 Convert finite value to base type.
TaintedInftyIntoperator= (const FiniteInt &x)
 Assignment.

Static Public Member Functions

static base_type min_finite ()
 minimum finite value
static base_type max_finite ()
 maximum finite value

Protected Attributes

base_type val
 value

Static Protected Attributes

static const base_type min_finity
 minimum finite value
static const base_type max_finity
 maximum finite value
static const base_type min_normal_neg_infty
 minimum normal infinite value
static const base_type max_normal_pos_infty
 maximum normal infinite value

Friends

class InftyInt
bool operator== (const TaintedInftyInt &x, const TaintedInftyInt &y)
 Equality test.
TaintedInftyInt operator+ (const TaintedInftyInt &x, const FiniteInt &y)
 Add.
TaintedInftyInt operator- (const TaintedInftyInt &x, const FiniteInt &y)
 Subtract.
TaintedInftyInt operator+ (const InftyInt &x, const InftyInt &y)
 Add.
TaintedInftyInt operator- (const InftyInt &x, const InftyInt &y)
 Subtract.
TaintedInftyInt min (const TaintedInftyInt &x, const TaintedInftyInt &y)
 Minimum.
TaintedInftyInt max (const TaintedInftyInt &x, const TaintedInftyInt &y)
 Maximum.
bool operator> (const TaintedInftyInt &x, const TaintedInftyInt &y)
bool operator< (const TaintedInftyInt &x, const TaintedInftyInt &y)
bool operator>= (const TaintedInftyInt &x, const TaintedInftyInt &y)
bool operator<= (const TaintedInftyInt &x, const TaintedInftyInt &y)
std::ostream & operator<< (std::ostream &out, const TaintedInftyInt &x)

Detailed Description

Potentially infinite value where finite values are integer. In contrast to class NormInfyInt, the representation of infinity can be denormalized, this means that it is not safe (and therefore not supported) to subtract or add a second potentially infinite value. In general, such non-normalized potentially infinite integers are produced as results of adding/subtracting normal potentially infinite integers.

The infinity integer classes TaintedInftyInt, InftyInt and FiniteInt support efficient addition and minimization/maximization of potentially infinite integer values. For this purpose, the range of the base type (long int) is restricted. With this encoding, two normal infinite values (InftyInt) of the same sign can be added without resulting in overflow. This yields a non-normal TaintedInftyInt, which still allows to add finite integers (FiniteInt) without overflow (at least as long as the added finite integers do not exceed the remaining range of [-m..m-1]), where m=2^(s-1) and s is the width of the base type, e.g. 64.

The range of the base type is split into subranges, where s is the number of bits in the base type:

negative infinity [ -m..-m/5 [ normal negative infinity [ -3m/5..-m/5 [ normalized negative infinity -2m/5 finite range [ -m/5 .. m/5 [ normal positive infinity [ m/5 .. 3m/5 [ normalized positive infinity 2m/5 positive infinity [ m/5 .. m [

Normalizing resets negative infinite values to -2m/5 and positive infinite values to 2m/5. In this way, adding two normalized infinite values of the same sign and some finite value using fast standard integer addition always works without overflow and results in a defined value in the infinite range.


Constructor & Destructor Documentation

LocARNA::TaintedInftyInt::TaintedInftyInt ( const base_type x) [inline, explicit]

Construct from base type.

Parameters:
xbase type value

Member Function Documentation

Convert finite value to base type.

Returns:
value
Precondition:
is finite

Reimplemented in LocARNA::FiniteInt.

bool LocARNA::TaintedInftyInt::is_finite ( ) const [inline]

Test for finite

Returns:
whether object has a finite value
bool LocARNA::TaintedInftyInt::is_neg_infty ( ) const [inline]

Test for negative infinity

Returns:
whether object represents negative infinity
bool LocARNA::TaintedInftyInt::is_normal ( ) const [inline]

Test for finite or normal infinity

Returns:
whether object is in the range of normal infinity (or finite)
bool LocARNA::TaintedInftyInt::is_pos_infty ( ) const [inline]

Test for positive infinity

Returns:
whether object represents positive infinity
static base_type LocARNA::TaintedInftyInt::max_finite ( ) [inline, static]

maximum finite value

Returns:
maximum finite value
static base_type LocARNA::TaintedInftyInt::min_finite ( ) [inline, static]

minimum finite value

Returns:
minimum finite value
TaintedInftyInt & LocARNA::TaintedInftyInt::operator= ( const FiniteInt x) [inline]

Assignment.

Parameters:
xfinite int to be assigned
Returns:
*this

Friends And Related Function Documentation

TaintedInftyInt max ( const TaintedInftyInt x,
const TaintedInftyInt y 
) [friend]

Maximum.

Parameters:
xoperand 1
yoperand 2
Returns:
max of x and y
TaintedInftyInt min ( const TaintedInftyInt x,
const TaintedInftyInt y 
) [friend]

Minimum.

Parameters:
xoperand 1
yoperand 2
Returns:
min of x and y
TaintedInftyInt operator+ ( const TaintedInftyInt x,
const FiniteInt y 
) [friend]

Add.

Parameters:
xoperand 1
yoperand 2
Returns:
x plus y
TaintedInftyInt operator+ ( const InftyInt x,
const InftyInt y 
) [friend]

Add.

Parameters:
xoperand 1
yoperand 2
Returns:
x plus y
TaintedInftyInt operator- ( const TaintedInftyInt x,
const FiniteInt y 
) [friend]

Subtract.

Parameters:
xoperand 1
yoperand 2
Returns:
x minus y
TaintedInftyInt operator- ( const InftyInt x,
const InftyInt y 
) [friend]

Subtract.

Parameters:
xoperand 1
yoperand 2
Returns:
x minus y
bool operator< ( const TaintedInftyInt x,
const TaintedInftyInt y 
) [friend]

Less than operator

Parameters:
xoperand 1
yoperand 2
Returns:
whether x is less than y
Note:
The result is undefined when comparing infinte values of the same sign.
std::ostream& operator<< ( std::ostream &  out,
const TaintedInftyInt x 
) [friend]

Write TaintedInftyInt object to stream

Parameters:
outoutput stream
xobject
Returns:
output stream after writing

Output operator for writing object of TaintedInftyInt to output stream

Parameters:
outthe output stream
xthe object to be written
Returns:
output stream after writing x
bool operator<= ( const TaintedInftyInt x,
const TaintedInftyInt y 
) [friend]

Less or equal than operator

Parameters:
xoperand 1
yoperand 2
Returns:
whether x is less or equal than y
Note:
The result is undefined when comparing infinte values of the same sign.
bool operator== ( const TaintedInftyInt x,
const TaintedInftyInt y 
) [friend]

Equality test.

Parameters:
xoperand 1 (tainted)
yoperand 2 (tainted)
Returns:
whether x equals y
bool operator> ( const TaintedInftyInt x,
const TaintedInftyInt y 
) [friend]

Greater than operator

Parameters:
xoperand 1
yoperand 2
Returns:
whether x is greater than y
Note:
The result is undefined when comparing infinte values of the same sign.
bool operator>= ( const TaintedInftyInt x,
const TaintedInftyInt y 
) [friend]

Greater or equal than operator

Parameters:
xoperand 1
yoperand 2
Returns:
whether x is greater or equal than y
Note:
The result is undefined when comparing infinte values of the same sign.

Member Data Documentation

Initial value:

maximum finite value

Initial value:

maximum normal infinite value

Initial value:

minimum finite value

Initial value:

minimum normal infinite value


The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends