#include <FloatArray.hh>
Inheritance diagram for bit::FloatArray:
Public Member Functions | |
FloatArray () | |
Default constructor. | |
FloatArray (u64 num_elems, unsigned int bits_per_elem=0) | |
Construct an array with initial number of elements. | |
void | set_mode (const FloatArray &array) |
Copy the mode from another array. | |
void | linear_quantization (double step) |
Set linear quantization mode and quantize possible elements in the array. | |
void | linear_quantization_bits (unsigned int bits) |
Perform linear quantization to given number of bits so that maximum absolute value fits just in. | |
float | get (u64 elem) const |
Return value of an element. | |
void | set (u64 elem, float value) |
Set the value of an element. | |
void | set_grow (u64 elem, float value) |
Set the value of an element growing the array if necessary. | |
void | set_grow_widen (u64 elem, float value) |
Set the value of an element growing the array if necessary and widening bit_width if necessary. | |
u32 | to_uint (float value) const |
Convert float value to bit representation. | |
float | to_float (u32 i) const |
Convert an integer bit representation back to float. | |
void | write (FILE *file) const |
Write the array in file. | |
void | read (FILE *file) |
Read the array from file. | |
Private Types | |
enum | Mode { mode_default = 0, mode_linear, mode_kmeans } |
Quantization mode. More... | |
Private Attributes | |
enum bit::FloatArray::Mode | m_mode |
Quantization mode. | |
double | m_linear_step |
The quantization step for linear quantization (used only in mode_linear). |
The floats can be quantized either linearly or with k-means clustering.
|
Quantization mode.
|
|
Default constructor.
|
|
Construct an array with initial number of elements.
|
|
Return value of an element.
Reimplemented from bit::Array. |
|
Set linear quantization mode and quantize possible elements in the array.
|
|
Perform linear quantization to given number of bits so that maximum absolute value fits just in. Does nothing if the array has only zero-elements.
|
|
Read the array from file.
Reimplemented from bit::Array. |
|
Set the value of an element. Note that if the array is already quantized, and the value does not fit well to the existing quantization, the quantization error may be large.
|
|
Set the value of an element growing the array if necessary. Note that if the array is already quantized, and the value does not fit well to the existing quantization, the quantization error may be large.
|
|
Set the value of an element growing the array if necessary and widening bit_width if necessary. Note that if the array is already quantized, and the value does not fit well to the existing quantization, the quantization error may be large.
|
|
Copy the mode from another array.
|
|
Convert an integer bit representation back to float.
|
|
Convert float value to bit representation.
|
|
Write the array in file.
Reimplemented from bit::Array. |
|
The quantization step for linear quantization (used only in mode_linear).
|
|
Quantization mode.
|