Changes

Jump to: navigation, search

Kernal Blas

1,194 bytes added, 17:54, 24 February 2018
Assignment 1
The compress dictionary copies the file into a new file with a .LZW filetype which uses ASCII
'''The function that compresses the file initializing with ASCII
<syntaxhighlight lang="cpp">
 
void compress(string input, int size, string filename) {
unordered_map<string, int> compress_dictionary(MAX_DEF);
//Dictionary initializing with ASCII
for (int unsigned i = 0; i < 256; i++) {
compress_dictionary[string(1, i)] = i;
}
string current_string;
unsigned int code;
unsigned int next_code = 256;
//Output file for compressed data
ofstream outputFile;
outputFile.open(filename + ".lzw");
 
for (char& c : input) {
current_string = current_string + c;
if (compress_dictionary.find(current_string) == compress_dictionary.end()) {
if (next_code <= MAX_DEF)
compress_dictionary.insert(make_pair(current_string, next_code++));
current_string.erase(current_string.size() - 1);
outputFile << convert_int_to_bin(compress_dictionary[current_string]);
current_string = c;
}
}
if (current_string.size())
outputFile << convert_int_to_bin(compress_dictionary[current_string]);
outputFile.close();
}
 
</syntaxhighlight>
[[File:Compression_test.png|thumb|Compression Test In Matrix]]   [[File:Compression_test_chart.png]]  '''Parallelizing From one of the suggested improvements in the algorithm post link. A potential improvement is changing from char& c to a const char in the for loop <syntaxhighlight lang="cpp">
for (char& c : input) {
</syntaxhighlight >
[[File:Compression_test_chartsince char& c is not being modified.png|thumb|Compression Test Results With Chart]]
=== Assignment 2 ===
=== Assignment 3 ===
25
edits

Navigation menu