36 void test_compression(
void)
39 = { 1.0, 2.0, 3.0, 4.0, 3.0, 2.0, 1.0, 2.0, 6.0, 7.0, 9.0 };
40 size_t input_size =
sizeof(input) /
sizeof(input[0]);
51 assert(num_of_chunks == 3);
54 assert(decompr_size == input_size);
56 decompr = malloc(decompr_size *
sizeof(
double));
59 for (idx = 0; idx < decompr_size; ++idx) {
60 assert(fabs(input[idx] - decompr[idx]) <= MAX_ERROR);
67 void test_encoding(
void)
70 = { 1.0, 2.0, 3.0, 4.0, 3.0, 2.0, 1.0, 2.0, 6.0, 7.0, 9.0 };
71 size_t input_size =
sizeof(input) /
sizeof(input[0]);
87 == PCOMP_STAT_SUCCESS);
91 == PCOMP_STAT_SUCCESS);
95 assert(decompr_size == input_size);
97 decompr = malloc(decompr_size *
sizeof(
double));
100 for (idx = 0; idx < decompr_size; ++idx) {
101 assert(fabs(input[idx] - decompr[idx]) <= MAX_ERROR);
int pcomp_encode_chunks(void *buf, size_t *buf_size, pcomp_polycomp_chunk_t *const chunk_array[], size_t num_of_chunks)
Encode a list of chunks into a sequence of raw bytes.
int pcomp_decode_chunks(pcomp_polycomp_chunk_t **chunk_array[], size_t *num_of_chunks, const void *buf)
Decode a byte sequence created by pcomp_encode_chunks into an array of chunks.
void pcomp_free_polycomp(pcomp_polycomp_t *params)
Free the memory allocated by pcomp_init_polycomp for a pcomp_polycomp_t structure.
When needed, apply the Chebyshev transform to the residuals of the polynomial fit.
size_t pcomp_total_num_of_samples(pcomp_polycomp_chunk_t *const chunk_array[], size_t num_of_chunks)
Compute the sum of the number of samples encoded in chunk_array.
pcomp_polycomp_t * pcomp_init_polycomp(pcomp_chunk_size_t samples_per_chunk, pcomp_poly_size_t num_of_coeffs, double max_allowable_error, pcomp_polycomp_algorithm_t algorithm)
Allocate space for a pcomp_polycomp_t structure.
int pcomp_decompress_polycomp(double *output_buf, pcomp_polycomp_chunk_t *const chunk_array[], size_t num_of_chunks)
Decompress a sequence of chunks.
int pcomp_compress_polycomp(pcomp_polycomp_chunk_t **chunk_array[], size_t *num_of_chunks, const double *input_buf, size_t input_size, const pcomp_polycomp_t *params)
Compress the array input_buf using polynomial compression.
size_t pcomp_chunks_num_of_bytes(pcomp_polycomp_chunk_t *const chunks[], size_t num_of_chunks)
Number of bytes required by pcomp_encode_chunks.
void pcomp_free_chunks(pcomp_polycomp_chunk_t *chunk_array[], size_t num_of_chunks)
Free an array of chunks.
Header file for Libpolycomp.