ChimeraTK-DeviceAccess
03.18.00
|
The fixed point converter provides conversion functions between a user type and up to 32 bit fixed point (signed or unsigned). More...
#include <FixedPointConverter.h>
Classes | |
struct | vectorToCooked_impl |
struct | vectorToCooked_impl< std::string, RAW_ITERATOR, COOKED_ITERATOR > |
Public Member Functions | |
FixedPointConverter (std::string variableName, unsigned int nBits=32, int fractionalBits=0, bool isSignedFlag=true) | |
The constructor defines the conversion factor. More... | |
template<typename UserType > | |
uint32_t | toRaw (UserType cookedValue) const |
Conversion function from type T to fixed point. More... | |
template<typename UserType , typename RAW_ITERATOR , typename COOKED_ITERATOR > | |
void | vectorToCooked (const RAW_ITERATOR &raw_begin, const RAW_ITERATOR &raw_end, const COOKED_ITERATOR &cooked_begin) const |
Conversion function from fixed-point values to type T. More... | |
template<typename UserType > | |
UserType | scalarToCooked (int32_t const &raw) const |
Inefficient convenience function for converting a single value to cooked. More... | |
unsigned int | getNBits () const |
Read back the number of bits the converter is using. More... | |
int | getFractionalBits () const |
Read back the fractional bits the converter is using. More... | |
bool | isSigned () const |
Read back wether the conversion is using signed values. More... | |
void | reconfigure (unsigned int nBits=32, int fractionalBits=0, bool isSignedFlag=true) |
Reconfigure the fixed point converter with new type information. More... | |
bool | operator== (const FixedPointConverter &other) const |
Compare two fixed point converters. More... | |
bool | operator!= (const FixedPointConverter &other) const |
template<> | |
uint32_t | toRaw (Boolean cookedValue) const |
template<> | |
uint32_t | toRaw (__attribute__((unused)) Void cookedValue) const |
template<> | |
uint32_t | toRaw (std::string cookedValue) const |
template<> | |
uint32_t | toRaw (Boolean cookedValue) const |
template<> | |
uint32_t | toRaw (__attribute__((unused)) Void cookedValue) const |
The fixed point converter provides conversion functions between a user type and up to 32 bit fixed point (signed or unsigned).
Definition at line 28 of file FixedPointConverter.h.
|
explicit |
The constructor defines the conversion factor.
variableName | The name of the variable. It is used in case an exception is thrown which significantly simplifies the debugging. |
nBits | The number of total bits must not exceed 32. |
fractionalBits | The number of fractional bits can range from -1024+nBits to 1021-nBits (in case of a double user type). For integer user types, no fractional bits are allowed. |
isSignedFlag | Flag whether the most significant bit is interpreted as sign bit. Negative numbers are interpreted as two's complement number of the respective number of bits (i.e. in signed 6 bit, 0 fractional bits 0x3F is -1) |
Definition at line 14 of file FixedPointConverter.cc.
|
inline |
Read back the fractional bits the converter is using.
Definition at line 96 of file FixedPointConverter.h.
|
inline |
Read back the number of bits the converter is using.
Definition at line 93 of file FixedPointConverter.h.
|
inline |
Read back wether the conversion is using signed values.
Definition at line 99 of file FixedPointConverter.h.
|
inline |
|
inline |
Compare two fixed point converters.
The variable name is ignored in this comparison.
Definition at line 106 of file FixedPointConverter.h.
void ChimeraTK::FixedPointConverter::reconfigure | ( | unsigned int | nBits = 32 , |
int | fractionalBits = 0 , |
||
bool | isSignedFlag = true |
||
) |
Reconfigure the fixed point converter with new type information.
Definition at line 23 of file FixedPointConverter.cc.
|
inline |
Inefficient convenience function for converting a single value to cooked.
Definition at line 86 of file FixedPointConverter.h.
uint32_t ChimeraTK::FixedPointConverter::toRaw | ( | __attribute__((unused)) Void | cookedValue | ) | const |
Definition at line 110 of file FixedPointConverter.cc.
uint32_t ChimeraTK::FixedPointConverter::toRaw | ( | __attribute__((unused)) Void | cookedValue | ) | const |
uint32_t ChimeraTK::FixedPointConverter::toRaw | ( | Boolean | cookedValue | ) | const |
Definition at line 102 of file FixedPointConverter.cc.
uint32_t ChimeraTK::FixedPointConverter::toRaw | ( | Boolean | cookedValue | ) | const |
uint32_t ChimeraTK::FixedPointConverter::toRaw | ( | std::string | cookedValue | ) | const |
Definition at line 90 of file FixedPointConverter.cc.
uint32_t ChimeraTK::FixedPointConverter::toRaw | ( | UserType | cookedValue | ) | const |
Conversion function from type T to fixed point.
This conversion usually will introduce rounding errors due to this limited resolution of the fixed point number compared to the double. In case of a high number of fractional bits this can mean that the most significant digits are cut and only the 'noise' in the less significant bits is represented.
Definition at line 336 of file FixedPointConverter.h.
|
inline |
Conversion function from fixed-point values to type T.
The two vectors passed must be of equal size (i.e. cookedValues must already be properly allocated).
Definition at line 61 of file FixedPointConverter.h.