Download mosesdecoder/cmph-2.0.2/src/bitbool.h from suricodes/hindi-sindhi-docker: direct link, hf CLI and curl.
- Browser
- Download file 6.89 kB
-
https://huggingface.co/spaces/suricodes/hindi-sindhi-docker/resolve/main/mosesdecoder/cmph-2.0.2/src/bitbool.h
- Command line
-
hf download hf://spaces/suricodes/hindi-sindhi-docker/mosesdecoder/cmph-2.0.2/src/bitbool.h
-
curl -L -o bitbool.h https://huggingface.co/spaces/suricodes/hindi-sindhi-docker/resolve/main/mosesdecoder/cmph-2.0.2/src/bitbool.h
6.89 kB
| static const cmph_uint8 bitmask[] = { 1, 1 << 1, 1 << 2, 1 << 3, 1 << 4, 1 << 5, 1 << 6, 1 << 7 }; | |
| static const cmph_uint32 bitmask32[] = { 1, 1 << 1, 1 << 2, 1 << 3, 1 << 4, 1 << 5, 1 << 6, 1 << 7, | |
| 1 << 8, 1 << 9, 1 << 10, 1 << 11, 1 << 12, 1 << 13, 1 << 14, 1 << 15, | |
| 1 << 16, 1 << 17, 1 << 18, 1 << 19, 1 << 20, 1 << 21, 1 << 22, 1 << 23, | |
| 1 << 24, 1 << 25, 1 << 26, 1 << 27, 1 << 28, 1 << 29, 1 << 30, 1U << 31 | |
| }; | |
| static const cmph_uint8 valuemask[] = { 0xfc, 0xf3, 0xcf, 0x3f}; | |
| /** \def GETBIT(array, i) | |
| * \brief get the value of an 1-bit integer stored in an array. | |
| * \param array to get 1-bit integer values from | |
| * \param i is the index in array to get the 1-bit integer value from | |
| * | |
| * GETBIT(array, i) is a macro that gets the value of an 1-bit integer stored in array. | |
| */ | |
| /** \def SETBIT(array, i) | |
| * \brief set 1 to an 1-bit integer stored in an array. | |
| * \param array to store 1-bit integer values | |
| * \param i is the index in array to set the the bit to 1 | |
| * | |
| * SETBIT(array, i) is a macro that sets 1 to an 1-bit integer stored in an array. | |
| */ | |
| //#define GETBIT(array, i) (array[(i) / 8] & bitmask[(i) % 8]) | |
| //#define SETBIT(array, i) (array[(i) / 8] |= bitmask[(i) % 8]) | |
| //#define UNSETBIT(array, i) (array[(i) / 8] ^= ((bitmask[(i) % 8]))) | |
| /** \def SETVALUE1(array, i, v) | |
| * \brief set a value for a 2-bit integer stored in an array initialized with 1s. | |
| * \param array to store 2-bit integer values | |
| * \param i is the index in array to set the value v | |
| * \param v is the value to be set | |
| * | |
| * SETVALUE1(array, i, v) is a macro that set a value for a 2-bit integer stored in an array. | |
| * The array should be initialized with all bits set to 1. For example: | |
| * memset(array, 0xff, arraySize); | |
| */ | |
| /** \def SETVALUE0(array, i, v) | |
| * \brief set a value for a 2-bit integer stored in an array initialized with 0s. | |
| * \param array to store 2-bit integer values | |
| * \param i is the index in array to set the value v | |
| * \param v is the value to be set | |
| * | |
| * SETVALUE0(array, i, v) is a macro that set a value for a 2-bit integer stored in an array. | |
| * The array should be initialized with all bits set to 0. For example: | |
| * memset(array, 0, arraySize); | |
| */ | |
| /** \def GETVALUE(array, i) | |
| * \brief get a value for a 2-bit integer stored in an array. | |
| * \param array to get 2-bit integer values from | |
| * \param i is the index in array to get the value from | |
| * | |
| * GETVALUE(array, i) is a macro that get a value for a 2-bit integer stored in an array. | |
| */ | |
| /** \def SETBIT32(array, i) | |
| * \brief set 1 to an 1-bit integer stored in an array of 32-bit words. | |
| * \param array to store 1-bit integer values. The entries are 32-bit words. | |
| * \param i is the index in array to set the the bit to 1 | |
| * | |
| * SETBIT32(array, i) is a macro that sets 1 to an 1-bit integer stored in an array of 32-bit words. | |
| */ | |
| /** \def GETBIT32(array, i) | |
| * \brief get the value of an 1-bit integer stored in an array of 32-bit words. | |
| * \param array to get 1-bit integer values from. The entries are 32-bit words. | |
| * \param i is the index in array to get the 1-bit integer value from | |
| * | |
| * GETBIT32(array, i) is a macro that gets the value of an 1-bit integer stored in an array of 32-bit words. | |
| */ | |
| /** \def UNSETBIT32(array, i) | |
| * \brief set 0 to an 1-bit integer stored in an array of 32-bit words. | |
| * \param array to store 1-bit integer values. The entries ar 32-bit words | |
| * \param i is the index in array to set the the bit to 0 | |
| * | |
| * UNSETBIT32(array, i) is a macro that sets 0 to an 1-bit integer stored in an array of 32-bit words. | |
| */ | |
| static inline void set_bits_value(cmph_uint32 * bits_table, cmph_uint32 index, cmph_uint32 bits_string, | |
| cmph_uint32 string_length, cmph_uint32 string_mask) | |
| { | |
| register cmph_uint32 bit_idx = index * string_length; | |
| register cmph_uint32 word_idx = bit_idx >> 5; | |
| register cmph_uint32 shift1 = bit_idx & 0x0000001f; | |
| register cmph_uint32 shift2 = 32 - shift1; | |
| bits_table[word_idx] &= ~((string_mask) << shift1); | |
| bits_table[word_idx] |= bits_string << shift1; | |
| if(shift2 < string_length) | |
| { | |
| bits_table[word_idx+1] &= ~((string_mask) >> shift2); | |
| bits_table[word_idx+1] |= bits_string >> shift2; | |
| }; | |
| }; | |
| static inline cmph_uint32 get_bits_value(cmph_uint32 * bits_table,cmph_uint32 index, cmph_uint32 string_length, cmph_uint32 string_mask) | |
| { | |
| register cmph_uint32 bit_idx = index * string_length; | |
| register cmph_uint32 word_idx = bit_idx >> 5; | |
| register cmph_uint32 shift1 = bit_idx & 0x0000001f; | |
| register cmph_uint32 shift2 = 32-shift1; | |
| register cmph_uint32 bits_string; | |
| bits_string = (bits_table[word_idx] >> shift1) & string_mask; | |
| if(shift2 < string_length) | |
| bits_string |= (bits_table[word_idx+1] << shift2) & string_mask; | |
| return bits_string; | |
| }; | |
| static inline void set_bits_at_pos(cmph_uint32 * bits_table, cmph_uint32 pos, cmph_uint32 bits_string, cmph_uint32 string_length) | |
| { | |
| register cmph_uint32 word_idx = pos >> 5; | |
| register cmph_uint32 shift1 = pos & 0x0000001f; | |
| register cmph_uint32 shift2 = 32-shift1; | |
| register cmph_uint32 string_mask = (1U << string_length) - 1; | |
| bits_table[word_idx] &= ~((string_mask) << shift1); | |
| bits_table[word_idx] |= bits_string << shift1; | |
| if(shift2 < string_length) | |
| { | |
| bits_table[word_idx+1] &= ~((string_mask) >> shift2); | |
| bits_table[word_idx+1] |= bits_string >> shift2; | |
| } | |
| }; | |
| static inline cmph_uint32 get_bits_at_pos(cmph_uint32 * bits_table,cmph_uint32 pos,cmph_uint32 string_length) | |
| { | |
| register cmph_uint32 word_idx = pos >> 5; | |
| register cmph_uint32 shift1 = pos & 0x0000001f; | |
| register cmph_uint32 shift2 = 32 - shift1; | |
| register cmph_uint32 string_mask = (1U << string_length) - 1; | |
| register cmph_uint32 bits_string; | |
| bits_string = (bits_table[word_idx] >> shift1) & string_mask; | |
| if(shift2 < string_length) | |
| bits_string |= (bits_table[word_idx+1] << shift2) & string_mask; | |
| return bits_string; | |
| } | |