#include <cstdint>
#include <cstring>
#include <cmath>
#include <limits>
Go to the source code of this file.
◆ POLYNOMIAL
| #define POLYNOMIAL 0xEDB88320 |
◆ init_crc32_table()
| void init_crc32_table |
( |
uint32_t * | crc32_table | ) |
|
Definition at line 34 of file simple_checksum.cpp.
34 {
35 for (uint32_t i = 0; i < 256; i++) {
36 uint32_t crc = i;
37 for (uint32_t j = 0; j < 8; j++) {
39 }
40 crc32_table[i] = crc;
41 }
42}
◆ simple_checksum()
| void simple_checksum |
( |
const double * | vector, |
|
|
const int * | length, |
|
|
double * | hash ) |
Definition at line 43 of file simple_checksum.cpp.
43 {
44 uint32_t crc32_table[256];
45 uint32_t crc = 0xFFFFFFFF;
46
48
49 for (size_t i = 0; i < *length; i++) {
50 uint64_t value = *(uint64_t*)&vector[i];
51
52 for (size_t j = 0; j < sizeof(value); j++) {
53 uint8_t byte = value & 0xFF;
54 crc = (crc >> 8) ^ crc32_table[(crc ^ byte) & 0xFF];
55 value >>= 8;
56 }
57 }
58 *hash = (double) (crc ^ 0xFFFFFFFF);
59 }
void init_crc32_table(uint32_t *crc32_table)