Reputation: 727
I am working on the LTC algorithm to compress the data
int SIZE =256;
int data[SIZE ]={700,...}; // input dataset (original data)
After executed the LTC I get on output (compressed data) like this:
//format: "number:count" --> e.g., 511:4
700:1
812:15
511:4
117:25
905:25
117:25
905:25
117:25
How can I compute the compression ratio for this output (the compressed data)?
// CR = Original/ compressed
float CR = ((int)(SIZE*(sizeof(int)))/?);
Upvotes: 0
Views: 62
Reputation: 154173
How can I compute the compression ratio
// Size of one "number:count" pair.
size_t size_of_number_count = sizeof size_t + sizeof data[0];
// Number of "number:count" pairs.
size_t compressed_count = 8;
// CR = Original/ compressed
double CR = 1.0 * sizeof data / (compressed_count * size_of_number_count);
Upvotes: 2