#include <FabConv.H>
Public Member Functions | |
RealDescriptor () | |
The default constructor. | |
RealDescriptor (const long *format, const int *order, int order_length) | |
Construct a specific RealDescriptor, passing in the format of the Real, the order of the Real, and the length of the array detailing the ordering. | |
RealDescriptor (const RealDescriptor &rhs) | |
The copy constructor. | |
RealDescriptor & | operator= (const RealDescriptor &rhs) |
The assignment operator. | |
virtual | ~RealDescriptor () |
Destructor is virtual incase a derived class has a non-trivial. | |
const long * | format () const |
Returns the format array as a `const long*'. | |
const Array< long > & | formatarray () const |
Returns const Array<long> reference to the format array. | |
const int * | order () const |
Returns the order array as a `const int*'. | |
const Array< int > & | orderarray () const |
Returns const Array<int> reference to the order array. | |
int | numBytes () const |
Returns the number of bytes in the Real. | |
bool | operator== (const RealDescriptor &rd) const |
The equality operator. | |
bool | operator!= (const RealDescriptor &rd) const |
The inequality operator. | |
virtual RealDescriptor * | clone () const |
Returns a copy of this RealDescriptor on the heap. | |
Static Public Member Functions | |
static void | SetFixDenormals () |
Set to always fix denormals when converting to native format. | |
static RealDescriptor * | newRealDescriptor (int format, int precision, const char *systype, int ordering) |
Returns a RealDescriptor on the heap detailing requested floating-point type. | |
static void | convertToNativeFormat (Real *out, long nitems, void *in, const RealDescriptor &id) |
Convert nitems in RealDescriptor format to native Real format. | |
static void | convertToNativeFormat (Real *out, long nitems, std::istream &is, const RealDescriptor &id) |
Read nitems from istream in ReadDescriptor format and convert them to the native Real format. | |
static void | convertFromNativeFormat (std::ostream &os, long nitems, const Real *in, const RealDescriptor &od) |
Convert nitems Reals in native format to RealDescriptor format and write them to the ostream. | |
static void | convertFromNativeFormat (void *out, long nitems, Real *in, const RealDescriptor &od) |
Convert nitems Reals in native format to RealDescriptor format. | |
Protected Attributes | |
Array< long > | fr |
Array< int > | ord |
Static Protected Attributes | |
static bool | bAlwaysFixDenormals |
This class is meant to hold all information needed to completely describe the "Real" floating-point type on a machine. By "Real" here we mean either the "float" or "double" type that this version of BoxLib was built with, which corresponds to whether BL or BL was used to build the version of the library.
To describe a "Real" type two arrays are needed: one detailing the ordering of the bytes in the Real, relative to the canonical ordering 1 .. sizeof(Real) and the other detailing the format of the floating-point number.
The array detailing the format of a floating-point number is an eight-element array of longs containing the following information:
format[0] = number of bits per number format[1] = number of bits in exponent format[2] = number of bits in mantissa format[3] = start bit of sign format[4] = start bit of exponent format[5] = start bit of mantissa format[6] = high order mantissa bit (CRAY needs this) format[7] = bias of exponent
This allows us to write out "Real"s in the native format on a machine, and then by also saving the IntDescriptor, we can read them back in on another machine and have enough information to construct the exact same "Real" values, provided the Reals have the same size on the two machines.
RealDescriptor::RealDescriptor | ( | ) |
The default constructor.
Does not build a proper RealDescriptor. This should only be used when you need to build a generic RealDescriptor in order to be able to read in a specific one from an istream.
Referenced by clone(), newRealDescriptor(), and operator>>().
RealDescriptor::RealDescriptor | ( | const long * | format, | |
const int * | order, | |||
int | order_length | |||
) |
Construct a specific RealDescriptor, passing in the format of the Real, the order of the Real, and the length of the array detailing the ordering.
RealDescriptor::RealDescriptor | ( | const RealDescriptor & | rhs | ) |
The copy constructor.
RealDescriptor::~RealDescriptor | ( | ) | [virtual] |
Destructor is virtual incase a derived class has a non-trivial.
RealDescriptor & RealDescriptor::operator= | ( | const RealDescriptor & | rhs | ) |
const long * RealDescriptor::format | ( | ) | const |
Returns the format array as a `const long*'.
References BL_ASSERT, Array< T >::dataPtr(), fr, and Array< T >::size().
Referenced by convertToNativeFormat(), and PD_convert().
const Array< long > & RealDescriptor::formatarray | ( | ) | const |
Returns const Array<long> reference to the format array.
References BL_ASSERT, fr, and Array< T >::size().
Referenced by operator<<(), and PD_convert().
const int * RealDescriptor::order | ( | ) | const |
Returns the order array as a `const int*'.
References BL_ASSERT, Array< T >::dataPtr(), ord, and Array< T >::size().
Referenced by convertToNativeFormat(), and PD_convert().
const Array< int > & RealDescriptor::orderarray | ( | ) | const |
Returns const Array<int> reference to the order array.
References BL_ASSERT, ord, and Array< T >::size().
Referenced by operator<<().
int RealDescriptor::numBytes | ( | ) | const |
Returns the number of bytes in the Real.
References BL_ASSERT, fr, and Array< T >::size().
Referenced by convertFromNativeFormat(), convertToNativeFormat(), and PD_convert().
bool RealDescriptor::operator== | ( | const RealDescriptor & | rd | ) | const |
bool RealDescriptor::operator!= | ( | const RealDescriptor & | rd | ) | const |
void RealDescriptor::SetFixDenormals | ( | ) | [static] |
RealDescriptor * RealDescriptor::clone | ( | ) | const [virtual] |
Returns a copy of this RealDescriptor on the heap.
The user is responsible for deletion.
References RealDescriptor().
Referenced by FArrayBox::Initialize(), and FArrayBox::setFormat().
RealDescriptor * RealDescriptor::newRealDescriptor | ( | int | format, | |
int | precision, | |||
const char * | systype, | |||
int | ordering | |||
) | [static] |
Returns a RealDescriptor on the heap detailing requested floating-point type.
Here format, precision, and ordering correspond to the enumerations in FABio. This is here to support reading "old" FABs. Do NOT use it in new code.
References FPC::cray_float, FPC::cray_float_order, BoxLib::Error(), FABio::FAB_DOUBLE, FABio::FAB_FLOAT, FABio::FAB_IEEE, FABio::FAB_NATIVE, FPC::ieee_double, FPC::ieee_float, ord, RealDescriptor(), and selectOrdering().
Referenced by FABio::read_header().
void RealDescriptor::convertToNativeFormat | ( | Real * | out, | |
long | nitems, | |||
void * | in, | |||
const RealDescriptor & | id | |||
) | [static] |
Convert nitems in RealDescriptor format to native Real format.
The out array is assumed to be large enough to hold the resulting output.
References bAlwaysFixDenormals, format(), FPC::NativeLongDescriptor(), FPC::NativeRealDescriptor(), order(), PD_convert(), and PD_fixdenormals().
void RealDescriptor::convertToNativeFormat | ( | Real * | out, | |
long | nitems, | |||
std::istream & | is, | |||
const RealDescriptor & | id | |||
) | [static] |
Read nitems from istream in ReadDescriptor format and convert them to the native Real format.
The out array is assumed to be large enough to hold the resulting output.
References bAlwaysFixDenormals, BoxLib::Error(), format(), FPC::NativeLongDescriptor(), FPC::NativeRealDescriptor(), numBytes(), order(), PD_convert(), and PD_fixdenormals().
void RealDescriptor::convertFromNativeFormat | ( | std::ostream & | os, | |
long | nitems, | |||
const Real * | in, | |||
const RealDescriptor & | od | |||
) | [static] |
Convert nitems Reals in native format to RealDescriptor format and write them to the ostream.
References BoxLib::Error(), FPC::NativeLongDescriptor(), FPC::NativeRealDescriptor(), numBytes(), and PD_convert().
void RealDescriptor::convertFromNativeFormat | ( | void * | out, | |
long | nitems, | |||
Real * | in, | |||
const RealDescriptor & | od | |||
) | [static] |
Convert nitems Reals in native format to RealDescriptor format.
The out array is assumed to be large enough to hold the resulting output.
References FPC::NativeLongDescriptor(), FPC::NativeRealDescriptor(), and PD_convert().
Array<long> RealDescriptor::fr [protected] |
Referenced by format(), formatarray(), numBytes(), operator=(), and operator==().
Array<int> RealDescriptor::ord [protected] |
Referenced by newRealDescriptor(), operator=(), operator==(), operator>>(), order(), and orderarray().
bool RealDescriptor::bAlwaysFixDenormals [static, protected] |
Referenced by convertToNativeFormat(), and SetFixDenormals().