keegan_csmith / watercomp
A compression algorithm targeting molecular dynamics simulations with large amounts of water.
Clone this repository (size: 15.1 MB): HTTPS / SSH
$ hg clone http://bitbucket.org/keegan_csmith/watercomp/
| commit 381: | ace6f671364f |
| parent 379: | 476437758982 |
| branch: | default |
Renamed best permutation encoder to optimal, as this is what it is called in the report.
Changed (Δ57 bytes):
raw changeset »
code/components/Permutation.cpp (11 lines added, 11 lines removed)
code/components/Permutation.h (5 lines added, 5 lines removed)
code/verifiers/testsuite.py (1 lines added, 1 lines removed)
Up to file-list code/components/Permutation.cpp:
| … | … | @@ -9,12 +9,12 @@ std::string get_permutation_env() |
9 |
9 |
{ |
10 |
10 |
char * perm = getenv("PERMUTATION"); |
11 |
11 |
if (!perm) |
12 |
return " |
|
12 |
return "optimal"; |
|
13 |
13 |
else return perm; |
14 |
14 |
} |
15 |
15 |
|
16 |
16 |
const char * perm_error_msg = "ERROR: PERMUTATION environment variable must " |
17 |
"be 'null', 'naive', 'delta', 'interframe' or ' |
|
17 |
"be 'null', 'naive', 'delta', 'interframe' or 'optimal' (default)\n"; |
|
18 |
18 |
|
19 |
19 |
PermutationWriter * PermutationWriter::get_writer(ArithmeticEncoder * enc, |
20 |
20 |
int size) |
| … | … | @@ -28,8 +28,8 @@ PermutationWriter * PermutationWriter::g |
28 |
28 |
return new DeltaPermutationWriter(enc); |
29 |
29 |
if (perm == "interframe") |
30 |
30 |
return new InterframePermutationWriter(enc, size); |
31 |
if (perm == "best") |
|
32 |
return new BestPermutationWriter(enc, size); |
|
31 |
if (perm == "optimal") |
|
32 |
return new OptimalPermutationWriter(enc, size); |
|
33 |
33 |
fprintf(stderr, "%s", perm_error_msg); |
34 |
34 |
exit(1); |
35 |
35 |
} |
| … | … | @@ -47,8 +47,8 @@ PermutationReader * PermutationReader::g |
47 |
47 |
return new DeltaPermutationReader(dec); |
48 |
48 |
if (perm == "interframe") |
49 |
49 |
return new InterframePermutationReader(dec, size); |
50 |
if (perm == "best") |
|
51 |
return new BestPermutationReader(dec, size); |
|
50 |
if (perm == "optimal") |
|
51 |
return new OptimalPermutationReader(dec, size); |
|
52 |
52 |
fprintf(stderr, "%s", perm_error_msg); |
53 |
53 |
exit(1); |
54 |
54 |
} |
| … | … | @@ -117,7 +117,7 @@ int DeltaPermutationReader::next_index() |
117 |
117 |
|
118 |
118 |
|
119 |
119 |
// |
120 |
// |
|
120 |
// OptimalPermutation |
|
121 |
121 |
// |
122 |
122 |
|
123 |
123 |
IndexToSymbol::IndexToSymbol(int size) |
| … | … | @@ -166,14 +166,14 @@ void IndexToSymbol::reset() |
166 |
166 |
} |
167 |
167 |
|
168 |
168 |
|
169 |
|
|
169 |
OptimalPermutationWriter::OptimalPermutationWriter(ArithmeticEncoder * enc, |
|
170 |
170 |
int size) |
171 |
171 |
: m_enc(enc), m_indicies(size) |
172 |
172 |
{ |
173 |
173 |
} |
174 |
174 |
|
175 |
175 |
|
176 |
void |
|
176 |
void OptimalPermutationWriter::next_index(int index) |
|
177 |
177 |
{ |
178 |
178 |
int size = m_indicies.size(); |
179 |
179 |
int val = m_indicies.pop_index(index); |
| … | … | @@ -181,14 +181,14 @@ void BestPermutationWriter::next_index(i |
181 |
181 |
} |
182 |
182 |
|
183 |
183 |
|
184 |
|
|
184 |
OptimalPermutationReader::OptimalPermutationReader(ArithmeticDecoder * dec, |
|
185 |
185 |
int size) |
186 |
186 |
: m_dec(dec), m_indicies(size) |
187 |
187 |
{ |
188 |
188 |
} |
189 |
189 |
|
190 |
190 |
|
191 |
int |
|
191 |
int OptimalPermutationReader::next_index() |
|
192 |
192 |
{ |
193 |
193 |
int val = m_dec->decode(m_indicies.size()); |
194 |
194 |
m_dec->decoder_update(val, val+1); |
Up to file-list code/components/Permutation.h:
| … | … | @@ -97,7 +97,7 @@ private: |
97 |
97 |
}; |
98 |
98 |
|
99 |
99 |
|
100 |
// |
|
100 |
// OptimalPermutation encodes values using an arithmetic coder where as each |
|
101 |
101 |
// value is encoded, it's symbol is removed from the arithmetic coder |
102 |
102 |
// frequency table |
103 |
103 |
class IndexToSymbol |
| … | … | @@ -114,10 +114,10 @@ private: |
114 |
114 |
std::vector<int> m_symbols; |
115 |
115 |
}; |
116 |
116 |
|
117 |
class |
|
117 |
class OptimalPermutationWriter : public PermutationWriter |
|
118 |
118 |
{ |
119 |
119 |
public: |
120 |
|
|
120 |
OptimalPermutationWriter(ArithmeticEncoder * enc, int size); |
|
121 |
121 |
void next_index(int index); |
122 |
122 |
void reset() { m_indicies.reset(); } |
123 |
123 |
private: |
| … | … | @@ -125,10 +125,10 @@ private: |
125 |
125 |
IndexToSymbol m_indicies; |
126 |
126 |
}; |
127 |
127 |
|
128 |
class |
|
128 |
class OptimalPermutationReader : public PermutationReader |
|
129 |
129 |
{ |
130 |
130 |
public: |
131 |
|
|
131 |
OptimalPermutationReader(ArithmeticDecoder * dec, int size); |
|
132 |
132 |
int next_index(); |
133 |
133 |
void reset() { m_indicies.reset(); } |
134 |
134 |
private: |
Up to file-list code/verifiers/testsuite.py:
| … | … | @@ -11,7 +11,7 @@ import time |
11 |
11 |
|
12 |
12 |
RESULTS = os.path.expanduser('~/dcd_results') |
13 |
13 |
QUANTISATION = ['8', '12']#, '16'] |
14 |
PERMUTATIONS = 'null |
|
14 |
PERMUTATIONS = 'null optimal naive interframe delta'.split() |
|
15 |
15 |
CMD_PATH = os.path.abspath(sys.argv[0]) |
16 |
16 |
WORKING_DIR = os.path.dirname(os.path.dirname(CMD_PATH)) |
17 |
17 |
INPUT_DIR = os.path.expanduser('~/dcd_input') |
