MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / require_allclose

Function require_allclose

tests/unittests/test_encoder_modules.cpp:26–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24}
25
26void require_allclose(
27 const std::vector<float> & actual,
28 const std::vector<float> & expected,
29 float atol,
30 const std::string & label) {
31 if (actual.size() != expected.size()) {
32 throw std::runtime_error(label + " size mismatch");
33 }
34 for (size_t i = 0; i < actual.size(); ++i) {
35 const float diff = std::fabs(actual[i] - expected[i]);
36 if (diff > atol) {
37 std::ostringstream oss;
38 oss << label << " mismatch at " << i << ": expected " << expected[i] << ", got " << actual[i]
39 << ", diff=" << diff;
40 throw std::runtime_error(oss.str());
41 }
42 }
43}
44
45void require_max_abs_diff_below(
46 const std::vector<float> & actual,

Calls 2

strMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected