This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let html5QrcodeScanner = new Html5QrcodeScanner( | |
| "reader", | |
| { | |
| fps: 10, | |
| qrbox: {width: 250, height: 250}, | |
| rememberLastUsedCamera: true, | |
| aspectRatio: 1.7777778, | |
| showTorchButtonIfSupported: true | |
| }); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| float a = 100.151f + 0.151f; | |
| float b = 100.101f + 0.201f; | |
| std::cout << "a = " << a << "; b = " << b << "\n"; | |
| float diff = a - b; | |
| std::cout << "Diff = " << diff << "\n"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| inline bool isNearlyEqual(float val_a, float val_b, float max_relative_diff = FLT_EPSILON) { | |
| float abs_diff = abs(val_a - val_b); | |
| val_a = fabs(val_a); | |
| val_b = fabs(val_b); | |
| float scaled_epsilon = max_relative_diff * max(val_a, val_b); | |
| return abs_diff <= scaled_epsilon; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| float a = 100.151f + 0.151f; | |
| float b = 100.101f + 0.201f; | |
| bool d = isNearlyEqual(a, b); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <math.h> | |
| #include <float.h> | |
| using namespace std; | |
| inline bool isNearlyEqual(float val_a, float val_b) { | |
| return fabs(val_a - val_b) < FLT_EPSILON; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| constexpr int kIterations = 10000000; | |
| int counter = 0; | |
| for (int i = 0; i < kIterations; ++i) { | |
| float a = 0.151f + 0.151f; | |
| float b = 0.101f + 0.201f; | |
| bool d = (a == b); | |
| if (d) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Without Loop Unrolling | |
| for (int y = 0; y < height; ++y) { | |
| for (int x = 0; x < width; ++x) { | |
| for (int c = 0; c < 3; ++c) { | |
| output(x, y, c) = input(x, y, c) + b; | |
| } | |
| } | |
| } | |
| # With Loop Unrolling |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Algorithm | |
| Expr numerator = f32(u32(input_a_(x, y)) * u32(coeff_a_(x, y)) + | |
| u32(input_b_(x, y)) * u32(coeff_b_(x, y))); | |
| Expr denominator = u16(coeff_a_(x, y)) + u16(coeff_b_(x, y)); | |
| output_(x, y) = u8_sat(numerator / denominator + 0.5f); | |
| // Schedule | |
| Var xi("xi"), yi("yi"); | |
| output_.compute_root() | |
| .split(y, y, yi, 32, TailStrategy::ShiftInwards) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Approach 1 - division | |
| output_(x, y) = u8(f32(input(x, y)) / factor); | |
| # Approach 2 - multiplication | |
| Expr multiplier = 1.0f / factor; | |
| output_(x, y) = u8(f32(input(x, y) * multiplier); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Algorithm | |
| output_(x, y) = u8(u16(x + y) % 256); | |
| // Schedule 1 without vectorisation | |
| output_.compute_root().vectorise(x).reorder(x, y); | |
| // Schedule 2 with vectorisation | |
| output_.compute_root().reorder(x, y); |