The example beneath is designed to explain how squeeze works, and not how (un-)effective it is as a compression tool.
| Input parameter: | Input value(s): | Description etc.: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mode | 0 | Always set this to '0' on first call, leave untouched thereafter | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| algorithm | 4 |
Defines the compression algorithm no. to use, 4: try to compress defined values in 'idata()' in groups of 2 or 3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ldat | 29 |
No. of elements in the 'idata()' array prior to compression, including
'leading' and 'trailing'; will be reset if compression is successful (see information on output variables below) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| leading | 1 | No. of leading elements in 'idata()' that the users does not wish to compress | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| trailing | 1 | No. of trailing elements in 'idata()' that the users does not wish to compress | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| length | 29 | Total no. of elements in 'idata()'; left unchanged by squeeze | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| idata |
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| maxsize | 27 |
Dimension of the work array 'iwork()'; in the 2D case, this must be set >= nx*ny, etc. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| nfactors | 263 |
Dimension of 'factors()'; should be set >= 263 for the present case ('algorithm'=4) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| factors | ... |
Factors used in the construction of a compressed set of values; will be set on first call (when 'mode'=1), and reset on subsequent calls if the compression algorithm is changed (i.e., if the value of 'algorithm' is changed) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |#3 - #2|: | d1 = | |38 - 28| = | 10 |
| |#4 - #3|: | d2 = | |58 - 38| = | 20 |
| |#5 - #4|: | d3 = | |22 - 58| = | 36 |
| entries | difference | category | value | value (accumulative) |
| #3 - #2: | 10 | >= 0 | 0 * (2**0) | 0 |
| #4 - #3: | 20 | >= 0 | 0 * (2**1) | 0 |
| #5 - #4: | - 36 | < 0 | 1 * (2**2) | 4 |
| #6 - #5: | 6 | >= 0 | 0 * (2**3) | 4 |
| #7 - #6: | -2 | < 0 | 1 * (2**4) | 20 |
| #8 - #7: | - 18 | < 0 | 1 * (2**5) | 52 |
| #9 - #8: | 120 | >= 0 | 0 * (2**6) | 52 |
| #10 - #9: | 4000 | >= 0 | 0 * (2**7) | 52 |
| #11 - #10: | - 36985 | < 0 | 1 * (2**8) | 308 |
| #12 - #11: | 0 | >= 0 | 0 * (2**9) | 308 |
| #13 - #12: | 0 | >= 0 | 0 * (2**10) | 308 |
| #14 - #13: | 0 | >= 0 | 0 * (2**11) | 308 |
| #15 - #14: | 0 | >= 0 | 0 * (2**12) | 308 |
| #16 - #15: | 0 | >= 0 | 0 * (2**13) | 308 |
| #17 - #16: | 32849 | >= 0 | 0 * (2**14) | 308 |
| #18 - #17: | - 54 | < 0 | 1 * (2**15) | 33076 |
| |#5 - #4|: | d1 = | |22 - 58| = | 36 |
| |#6 - #5|: | d2 = | |28 - 22| = | 6 |
| |#7 - #6|: | d3 = | |26 - 28| = | 2 |
Compress the next values as differences; first, find the absolute value
of the differences of the next 3 entries:
| |#7 - #6|: | d1 = | |26 - 28| = | 2 |
| |#8 - #7|: | d2 = | |8 - 26| = | 18 |
| |#9 - #8|: | d3 = | |128 - 8| = | 120 |
Compress the next values as differences; first, find the absolute value
of the differences of the next 3 entries:
| |#9 - #8|: | d1 = | |128 - 8| = | 120 |
| |#10 - #9|: | d2 = | |218 - 128| = | 90 |
| |#11 - #10|: | Not considered, since #11 = 'undef' |
The next entry (#11) is the undefined value.
Special algorithm:
The first defined value after consequtive undefined values are stored
as a single value:
Compress the next values as differences; first, find the absolute value
of the differences of the next 3 entries:
| |#18 - #17|: | d1 = | |28 - 82| = | 54 |
| |#19 - #18|: | d2 = | |88 - 28| = | 60 |
| |#20 - #19|: | d3 = | |128 - 88| = | 40 |
We have not stored the sign of the difference 'd2' above.
So next, we find the bitwise representation of the final differences
| entries | difference | category | value | value (accumulative) |
| #19 - #18: | 60 | >= 0 | 0 * (2**0) | 0 |
| #20 - #19: | 40 | >= 0 | 0 * (2**1) | 0 |
| #21 - #20: | - 10 | < 0 | 1 * (2**2) | 4 |
| #22 - #21: | 100 | >= 0 | 0 * (2**3) | 4 |
| #23 - #22: | -30 | < 0 | 1 * (2**4) | 20 |
| #24 - #23: | 20 | >= 0 | 0 * (2**5) | 20 |
| #25 - #24: | 10 | >= 0 | 0 * (2**6) | 20 |
| #26 - #25: | - 20 | < 0 | 1 * (2**7) | 148 |
| #27 - #26: | - 10 | < 0 | 1 * (2**8) | 404 |
| #28 - #27: | - 10 | < 0 | 1 * (2**9) | 916 |
Compress the next values as differences; first, find the absolute value
of the differences of the next 3 entries:
| |#20 - #19|: | d1 = | |128 - 88| = | 40 |
| |#21 - #20|: | d2 = | |118 - 128| = | 10 |
| |#22 - #21|: | d3 = | |118 - 218| = | 100 |
Compress the next values as differences; first, find the absolute value
of the differences of the next 3 entries:
| |#22 - #21|: | d1 = | |118 - 218| = | 100 |
| |#23 - #22|: | d2 = | |188 - 218| = | 30 |
| |#24 - #23|: | d3 = | |208 - 188| = | 20 |
Compress the next values as differences; first, find the absolute value
of the differences of the next 3 entries:
| |#24 - #23|: | d1 = | |208 - 188| = | 20 |
| |#25 - #24|: | d2 = | |218 - 208| = | 10 |
| |#26 - #25|: | d3 = | |198 - 218| = | 20 |
Compress the next values as differences; first, find the absolute value
of the differences of the next 3 entries:
| |#27 - #26|: | d1 = | |188 - 198| = | 10 |
| |#28 - #27|: | d2 = | |178 - 188| = | 10 |
Is the compression successful?
| Output parameter: | Output value(s): | Description etc.: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mode | 1 | see explanation above (item 16) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ldat | 24 | reset to 'leading' + 5 + 'trailing' + no. of compressed values | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| idata |
2*: 'leading' - 32768 3*: 'trailing' - 32768 4*: int(# compressed entries/65536) - 32768 5*: mod(# compressed entries, 65536) - 32768 6*: compression algorithm no. 7 - 23: compressed array 24: trailing entry | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| factors |
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
Suggestion for output to file: