Mesh Oriented datABase  (version 5.6.0)
An array-based unstructured mesh library
moab::anonymous_namespace{IntegerReprosum.cpp} Namespace Reference

Functions

double frac_and_exp (double x, int &exp_out)
 Fortran-equivalent fraction(x) for radix-2 doubles: returns f in [0.5, 1) (or in (-1, -0.5] for negative x) and stores the exponent so that x = f * 2^e Same as std::frexp. More...
 
double scale2 (double x, int n)
 Fortran-equivalent scale(x, n) for radix-2 doubles: returns x * 2^n. Same as std::ldexp. More...
 
double set_exp (double x, int e)
 Fortran-equivalent set_exponent(x, e): returns a value with the same fraction as x but with exponent e. Same as ldexp(frexp(x, &dummy), e) More...
 
int64_t i2pow (int k)
 MPI_INT64_T equivalent for our int64 type. Use MPI_LONG_LONG_INT for portability across MPI implementations that don't yet expose MPI_INT64_T as a primary datatype. More...
 

Function Documentation

◆ frac_and_exp()

double moab::anonymous_namespace{IntegerReprosum.cpp}::frac_and_exp ( double  x,
int &  exp_out 
)
inline

Fortran-equivalent fraction(x) for radix-2 doubles: returns f in [0.5, 1) (or in (-1, -0.5] for negative x) and stores the exponent so that x = f * 2^e Same as std::frexp.

Definition at line 49 of file IntegerReprosum.cpp.

50 {
51  return std::frexp( x, &exp_out );
52 }

◆ i2pow()

int64_t moab::anonymous_namespace{IntegerReprosum.cpp}::i2pow ( int  k)
inline

MPI_INT64_T equivalent for our int64 type. Use MPI_LONG_LONG_INT for portability across MPI implementations that don't yet expose MPI_INT64_T as a primary datatype.

Integer power 2^k (for small k <= 62).

Definition at line 86 of file IntegerReprosum.cpp.

87 {
88  return ( static_cast< int64_t >( 1 ) << k );
89 }

Referenced by moab::IntegerReprosum::decode_global(), and moab::IntegerReprosum::encode_local().

◆ scale2()

double moab::anonymous_namespace{IntegerReprosum.cpp}::scale2 ( double  x,
int  n 
)
inline

Fortran-equivalent scale(x, n) for radix-2 doubles: returns x * 2^n. Same as std::ldexp.

Definition at line 56 of file IntegerReprosum.cpp.

57 {
58  return std::ldexp( x, n );
59 }

Referenced by moab::IntegerReprosum::decode_global(), and moab::IntegerReprosum::encode_local().

◆ set_exp()

double moab::anonymous_namespace{IntegerReprosum.cpp}::set_exp ( double  x,
int  e 
)
inline

Fortran-equivalent set_exponent(x, e): returns a value with the same fraction as x but with exponent e. Same as ldexp(frexp(x, &dummy), e)

Definition at line 64 of file IntegerReprosum.cpp.

65 {
66  int dummy;
67  double f = std::frexp( x, &dummy );
68  return std::ldexp( f, e );
69 }

Referenced by moab::IntegerReprosum::decode_global().