void print(std::vector<bool> &vec);
void print(std::vector<std::vector<bool>> &symbol);
+void print_bytes(std::vector<bool> &vec);
void vec_xor(std::vector<bool> &v1, const std::vector<bool> v2);
unsigned int distance(std::vector<bool> &v1, const std::vector<bool> &v2);
void read_words_from_file(char const *filename, std::vector<std::vector<bool>> &symbol);
print(symbol);
std::vector<bool> codewords = get_codewords_from_symbol(symbol);
- print(codewords);
+ //print(codewords);
+ print_bytes(codewords);
+ //std::cout << "Number of codewords: " << codewords.size() / 8.0 << std::endl;
+ std::vector<bool> data_codewords(codewords.begin(), codewords.begin() + 16 * 8), error_correction_codewords(codewords.begin() + 16 * 8, codewords.end());
+
+ std::cout << "Number of data codewords: " << data_codewords.size() / 8.0 << std::endl;
+ std::cout << "Number of error correction codewords: " << error_correction_codewords.size() / 8.0 << std::endl;
+ //print_bytes(data_codewords);
+
+
return 0;
}
std::cout << std::endl;
}
+void print_bytes(std::vector<bool> &vec){
+ for (std::size_t i{0}; i < vec.size(); ++i){
+ if (i != 0 && i % 8 == 0){std::cout << ' ';}
+ std::cout << vec[i];
+ }
+ std::cout << std::endl;
+}
+
void vec_xor(std::vector<bool> &v1, const std::vector<bool> v2){
for (std::size_t i{0}; i < v1.size(); ++i){
v1[i] = v1[i] ^ v2[i];
P1
21 21
-1 1 1 1 1 1 1 0 0 1 1 0 0 0 1 1 1 1 1 1 1
-1 0 0 0 0 0 1 0 1 0 1 0 0 0 1 0 0 0 0 0 1
-1 0 1 1 1 0 1 0 0 1 1 0 0 0 1 0 1 1 1 0 1
-1 0 1 1 1 0 1 0 0 0 0 0 0 0 1 0 1 1 1 0 1
-1 0 1 1 1 0 1 0 1 0 0 1 0 0 1 0 1 1 1 0 1
-1 0 0 0 0 0 1 0 0 1 0 0 1 0 1 0 0 0 0 0 1
+1 1 1 1 1 1 1 0 0 1 0 0 1 0 1 1 1 1 1 1 1
+1 0 0 0 0 0 1 0 1 1 1 1 0 0 1 0 0 0 0 0 1
+1 0 1 1 1 0 1 0 0 1 0 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 1 0 1 1 1 0 1 0 0 0 1 0 1
+0 0 0 0 0 0 0 0 1 1 0 1 1 1 0 1 0 1 0 0 1
+1 1 1 1 1 1 1 0 0 1 1 0 1 1 1 1 0 1 0 1 0
+1 0 0 0 0 0 1 0 0 1 0 0 1 1 0 1 0 1 1 0 1
+1 0 1 1 1 0 1 0 1 1 1 1 0 0 1 0 0 0 1 0 1
+1 0 1 1 1 0 1 0 0 0 1 1 0 1 0 1 0 1 0 1 0
+1 0 1 1 1 0 1 0 1 0 0 0 0 0 0 1 1 0 0 1 1
+1 0 0 0 0 0 1 0 0 0 1 0 1 1 1 1 0 0 0 1 0
+1 1 1 1 1 1 1 0 1 0 1 0 0 0 0 1 0 1 0 1 0
//std::cout << "x=" << x << ",y=" << y << std::endl;
grid = symbol_placement_down(grid, x, y, character_symbol_horiz4);
- //print_grid(grid);
+ print_grid(grid);
std::vector<std::vector<std::vector<bool>>> mask_patterns(8, std::vector<std::vector<bool>>(21, std::vector<bool> (21, 0)));
for (std::size_t ind{}; ind < 8; ++ind){
for (std::size_t i{}; i < 21; ++i){
for (std::size_t j{}; j < 21; ++j){
- mask_pattern_results[ind][i][j] = (mask_pattern_results[ind][i][j] && grid[i][j]); // CHANGE test_grid BACK TO grid for REAL USE
- if (mask_patterns[ind][i][j]){
- mask_pattern_results[ind][i][j] = !mask_pattern_results[ind][i][j];
- }
+ mask_pattern_results[ind][i][j] = grid[i][j] ^ mask_patterns[ind][i][j];
+ //mask_pattern_results[ind][i][j] = (mask_pattern_results[ind][i][j] && grid[i][j]); // CHANGE test_grid BACK TO grid for REAL USE
+ //if (mask_patterns[ind][i][j]){
+ // mask_pattern_results[ind][i][j] = !mask_pattern_results[ind][i][j];
+ //}
}
}
}
//mask_pattern_bits = {1,0,1}; // REMOVE TESTinG PurposES ONLy
print_grid(mask_pattern_results[mask_pattern]);
+ grid = mask_pattern_results[mask_pattern];
std::cout << "best mask pattern: " << mask_pattern << std::endl;
for (auto i : mask_pattern_bits){std::cout << i;} std::cout << std::endl;