SphinxBase
5prealpha
|
An implementation bit array - memory efficient storage for digit int and float data. More...
#include <assert.h>
#include <string.h>
#include <stdint.h>
#include <sphinxbase/prim_type.h>
#include <sphinxbase/sphinxbase_export.h>
Go to the source code of this file.
Data Structures | |
struct | bitarr_mask_s |
Structure that specifies bits required to efficiently store certain data. More... | |
struct | bitarr_address_s |
Structure that stores address of certain value in bit array. More... | |
Typedefs | |
typedef struct bitarr_mask_s | bitarr_mask_t |
Structure that specifies bits required to efficiently store certain data. | |
typedef struct bitarr_address_s | bitarr_address_t |
Structure that stores address of certain value in bit array. | |
Functions | |
SPHINXBASE_EXPORT uint64 | bitarr_read_int57 (bitarr_address_t address, uint8 length, uint64 mask) |
Read uint64 value from bit array. More... | |
SPHINXBASE_EXPORT void | bitarr_write_int57 (bitarr_address_t address, uint8 length, uint64 value) |
Write specified value into bit array. More... | |
SPHINXBASE_EXPORT uint32 | bitarr_read_int25 (bitarr_address_t address, uint8 length, uint32 mask) |
Read uint32 value from bit array. More... | |
SPHINXBASE_EXPORT void | bitarr_write_int25 (bitarr_address_t address, uint8 length, uint32 value) |
Write specified value into bit array. More... | |
SPHINXBASE_EXPORT float | bitarr_read_negfloat (bitarr_address_t address) |
Read non positive float32 from bit array. More... | |
SPHINXBASE_EXPORT void | bitarr_write_negfloat (bitarr_address_t address, float value) |
Writes non positive float32 to bit array. More... | |
SPHINXBASE_EXPORT float | bitarr_read_float (bitarr_address_t address) |
Reads float32 from bit array. More... | |
SPHINXBASE_EXPORT void | bitarr_write_float (bitarr_address_t address, float value) |
Writes float32 to bit array. More... | |
SPHINXBASE_EXPORT void | bitarr_mask_from_max (bitarr_mask_t *bit_mask, uint32 max_value) |
Fills mask for certain int range according to provided max value. More... | |
SPHINXBASE_EXPORT uint8 | bitarr_required_bits (uint32 max_value) |
Computes amount of bits required ti store integers upto value provided. More... | |
An implementation bit array - memory efficient storage for digit int and float data.
Implementation of basic operations of read/write digits consuming as little space as possible.
Definition in file bitarr.h.
SPHINXBASE_EXPORT void bitarr_mask_from_max | ( | bitarr_mask_t * | bit_mask, |
uint32 | max_value | ||
) |
Fills mask for certain int range according to provided max value.
bit_mask | mask that is filled |
max_value | bigest integer that is going to be stored using this mask |
Definition at line 172 of file bitarr.c.
References bitarr_required_bits().
SPHINXBASE_EXPORT float bitarr_read_float | ( | bitarr_address_t | address | ) |
SPHINXBASE_EXPORT uint32 bitarr_read_int25 | ( | bitarr_address_t | address, |
uint8 | length, | ||
uint32 | mask | ||
) |
SPHINXBASE_EXPORT uint64 bitarr_read_int57 | ( | bitarr_address_t | address, |
uint8 | length, | ||
uint64 | mask | ||
) |
SPHINXBASE_EXPORT float bitarr_read_negfloat | ( | bitarr_address_t | address | ) |
SPHINXBASE_EXPORT uint8 bitarr_required_bits | ( | uint32 | max_value | ) |
Computes amount of bits required ti store integers upto value provided.
max_value | bigest integer that going to be stored using this amount of bits |
Definition at line 178 of file bitarr.c.
Referenced by bitarr_mask_from_max().
SPHINXBASE_EXPORT void bitarr_write_float | ( | bitarr_address_t | address, |
float | value | ||
) |
Writes float32 to bit array.
address | in bit array where to write |
value | float32 to write |
Definition at line 165 of file bitarr.c.
References bitarr_write_int57().
SPHINXBASE_EXPORT void bitarr_write_int25 | ( | bitarr_address_t | address, |
uint8 | length, | ||
uint32 | value | ||
) |
SPHINXBASE_EXPORT void bitarr_write_int57 | ( | bitarr_address_t | address, |
uint8 | length, | ||
uint64 | value | ||
) |
Write specified value into bit array.
Assumes value < (1 << length) and length <= 57. Assumes the memory is zero initially.
address | to write to |
length | amount of active bytes in value to write |
value | integer to write |
Definition at line 103 of file bitarr.c.
Referenced by bitarr_write_float(), and bitarr_write_negfloat().
SPHINXBASE_EXPORT void bitarr_write_negfloat | ( | bitarr_address_t | address, |
float | value | ||
) |
Writes non positive float32 to bit array.
Probability [0, 1) in log domain can be stored like this
address | where to write |
value | what to write |
Definition at line 150 of file bitarr.c.
References bitarr_write_int57().