Skip to content

Commit

Permalink
fix the probable negative issue size in the example
Browse files Browse the repository at this point in the history
  • Loading branch information
azimafroozeh committed Jul 18, 2024
1 parent aa7a00e commit b74fe72
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion example/simple_compress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,20 @@ using namespace alp;
int main() {
constexpr std::array<int, 3> n_tup_vec {1, 1025, 1024 * 100};
for (const auto n_tup : n_tup_vec) {
size_t buffer_sz = n_tup * sizeof(double) + 8096; // We leave some headroom in case of negative compression
size_t n_vec = ceil(n_tup / config::VECTOR_SIZE);
// extra size needed if all values are exceptions.
size_t if_all_exceptions_size =
n_vec * config::VECTOR_SIZE * sizeof(double) + sizeof(exp_p_t) + n_vec * sizeof(exp_c_t);

size_t buffer_sz =
n_tup * sizeof(double) + if_all_exceptions_size; // We leave some headroom in case of negative compression
size_t original_sz = n_tup * sizeof(double);

double in[n_tup];
uint8_t out[buffer_sz];
example::fill_random_data<double>(in, n_tup, 2);

if (n_tup == 1) { in[0] = 204.92; }
// compress
auto compressor = AlpCompressor<double>();
compressor.compress(in, n_tup, out);
Expand Down

0 comments on commit b74fe72

Please sign in to comment.