From c291144b7f08c21d08cdaf79cc64dc420ca70070 Mon Sep 17 00:00:00 2001 From: Richard Burton Date: Fri, 22 Apr 2022 09:08:21 +0100 Subject: MLECO-3077: Add ASR use case API * Minor adjustments to doc strings in KWS * Remove unused score threshold in KWS Signed-off-by: Richard Burton Change-Id: Ie1c5bf6f7bdbebb853b6a10cb7ba1c4a1d9a76c9 --- tests/common/PlatformMathTests.cpp | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'tests/common') diff --git a/tests/common/PlatformMathTests.cpp b/tests/common/PlatformMathTests.cpp index ab1153f..c07cbf1 100644 --- a/tests/common/PlatformMathTests.cpp +++ b/tests/common/PlatformMathTests.cpp @@ -150,13 +150,28 @@ TEST_CASE("Test SqrtF32") TEST_CASE("Test MeanF32") { - /*Test Constants: */ + /* Test Constants: */ std::vector input {0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 1.000}; /* Manually calculated mean of above vector */ float expectedResult = 0.100; CHECK (expectedResult == Approx(arm::app::math::MathUtils::MeanF32(input.data(), input.size()))); + + /* Mean of 0 */ + std::vector input2{1, 2, -1, -2}; + float expectedResult2 = 0.0f; + CHECK (expectedResult2 == Approx(arm::app::math::MathUtils::MeanF32(input2.data(), input2.size()))); + + /* All 0s */ + std::vector input3 = std::vector(9, 0); + float expectedResult3 = 0.0f; + CHECK (expectedResult3 == Approx(arm::app::math::MathUtils::MeanF32(input3.data(), input3.size()))); + + /* All 1s */ + std::vector input4 = std::vector(9, 1); + float expectedResult4 = 1.0f; + CHECK (expectedResult4 == Approx(arm::app::math::MathUtils::MeanF32(input4.data(), input4.size()))); } TEST_CASE("Test StdDevF32") @@ -184,6 +199,22 @@ TEST_CASE("Test StdDevF32") float expectedResult = 0.969589282958136; CHECK (expectedResult == Approx(output)); + + /* All 0s should have 0 std dev. */ + std::vector input2 = std::vector(4, 0); + float expectedResult2 = 0.0f; + CHECK (expectedResult2 == Approx(arm::app::math::MathUtils::StdDevF32(input2.data(), input2.size(), 0.0f))); + + /* All 1s should have 0 std dev. */ + std::vector input3 = std::vector(4, 1); + float expectedResult3 = 0.0f; + CHECK (expectedResult3 == Approx(arm::app::math::MathUtils::StdDevF32(input3.data(), input3.size(), 1.0f))); + + /* Manually calclualted std value */ + std::vector input4 {1, 2, 3, 4, 5, 6, 7, 8, 9, 0}; + float mean2 = (std::accumulate(input4.begin(), input4.end(), 0.0f))/float(input4.size()); + float expectedResult4 = 2.872281323; + CHECK (expectedResult4 == Approx(arm::app::math::MathUtils::StdDevF32(input4.data(), input4.size(), mean2))); } TEST_CASE("Test FFT32") -- cgit v1.2.1