From e46563fafc28549c1bbada125bf02afda5762d40 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Mon, 31 Mar 2025 20:25:33 +0100 Subject: [PATCH] Work in progress --- include/etl/scaled_rounding.h | 11 +- test/test_scaled_rounding.cpp | 879 ++++++++++++++++++++++++---------- 2 files changed, 627 insertions(+), 263 deletions(-) diff --git a/include/etl/scaled_rounding.h b/include/etl/scaled_rounding.h index b1dbe18f..6f37de4f 100644 --- a/include/etl/scaled_rounding.h +++ b/include/etl/scaled_rounding.h @@ -154,7 +154,6 @@ namespace etl T round_half_up_unscaled(T value) ETL_NOEXCEPT { ETL_STATIC_ASSERT(etl::is_integral::value, "Type must be an integral"); - ETL_STATIC_ASSERT((Scaling == 1) || (((Scaling / 2U) * 2U) == Scaling), "Scaling must be divisible by 2"); typedef typename scaled_rounding_t::type scale_t; if (Scaling == 1) @@ -202,16 +201,20 @@ namespace etl T round_half_down_unscaled(T value) ETL_NOEXCEPT { ETL_STATIC_ASSERT(etl::is_integral::value, "Type must be an integral"); - ETL_STATIC_ASSERT((Scaling == 1) || (((Scaling / 2U) * 2U) == Scaling), "Scaling must be divisible by 2"); typedef typename scaled_rounding_t::type scale_t; + if (Scaling == 1) + { + return value; + } + if (value >= 0) { - return T((value + scale_t(((Scaling - 1) / 2U))) / scale_t(Scaling)); + return T((value + scale_t((Scaling - 1) / 2U)) / scale_t(Scaling)); } else { - return T((value - scale_t(((Scaling - 1) / 2U))) / scale_t(Scaling)); + return T((value - scale_t((Scaling - 1) / 2U)) / scale_t(Scaling)); } } diff --git a/test/test_scaled_rounding.cpp b/test/test_scaled_rounding.cpp index 998cda82..36974f1e 100644 --- a/test/test_scaled_rounding.cpp +++ b/test/test_scaled_rounding.cpp @@ -34,7 +34,9 @@ SOFTWARE. namespace { + // Index = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 14 16 17 18 19 std::array source = { 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, + // Index = 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 34 36 37 38 39 -50, -51, -52, -53, -54, -55, -56, -57, -58, -59, -60, -61, -62, -63, -64, -65, -66, -67, -68, -69 }; SUITE(test_scaled_rounding) @@ -45,6 +47,8 @@ namespace // Index = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 14 16 17 18 19 // Source = 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 std::array expected = { 50, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 70, 70, 70, 70, 70, 70, 70, 70, 70, + // Index = 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 34 36 37 38 39 + // Source = -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -60, -60, -60, -60, -60, -60, -60, -60, -60, -60 }; const size_t Scale = 10; @@ -98,6 +102,8 @@ namespace // Index = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 14 16 17 18 19 // Source = 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 std::array expected = { 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, + // Index = 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 34 36 37 38 39 + // Source = -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6 }; const size_t Scale = 10; @@ -150,7 +156,9 @@ namespace { // Index = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 14 16 17 18 19 // Source = 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 - std::array expected = { 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, + std::array expected = { 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, + // Index = 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 34 36 37 38 39 + // Source = -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -50, -51, -52, -53, -54, -55, -56, -57, -58, -59, -60, -61, -62, -63, -64, -65, -66, -67, -68, -69 }; const size_t Scale = 1; @@ -202,8 +210,10 @@ namespace TEST(round_ceiling_unscaled_with_scaling_of_1) { // Index = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 14 16 17 18 19 - // Source = 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 + // Source = 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 std::array expected = { 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, + // Index = 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 34 36 37 38 39 + // Source = -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -50, -51, -52, -53, -54, -55, -56, -57, -58, -59, -60, -61, -62, -63, -64, -65, -66, -67, -68, -69 }; const size_t Scale = 1; @@ -257,6 +267,8 @@ namespace // Index = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 14 16 17 18 19 // Source = 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 std::array expected = { 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, + // Index = 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 34 36 37 38 39 + // Source = -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -50, -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, -70, -70, -70, -70, -70, -70, -70, -70, -70 }; const size_t Scale = 10; @@ -310,6 +322,8 @@ namespace // Index = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 14 16 17 18 19 // Source = 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 std::array expected = { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + // Index = 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 34 36 37 38 39 + // Source = -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -5, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -7, -7, -7, -7, -7, -7, -7, -7, -7 }; const size_t Scale = 10; @@ -362,7 +376,9 @@ namespace { // Index = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 14 16 17 18 19 // Source = 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 - std::array expected = { 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, + std::array expected = { 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, + // Index = 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 34 36 37 38 39 + // Source = -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -50, -51, -52, -53, -54, -55, -56, -57, -58, -59, -60, -61, -62, -63, -64, -65, -66, -67, -68, -69 }; const size_t Scale = 1; @@ -416,6 +432,8 @@ namespace // Index = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 14 16 17 18 19 // Source = 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 std::array expected = { 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, + // Index = 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 34 36 37 38 39 + // Source = -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -50, -51, -52, -53, -54, -55, -56, -57, -58, -59, -60, -61, -62, -63, -64, -65, -66, -67, -68, -69 }; const size_t Scale = 1; @@ -469,6 +487,8 @@ namespace // Index = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 14 16 17 18 19 // Source = 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 std::array expected = { 50, 50, 50, 50, 50, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 70, 70, 70, 70, 70, + // Index = 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 34 36 37 38 39 + // Source = -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -50, -50, -50, -50, -50, -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, -70, -70, -70, -70, -70 }; const size_t Scale = 10; @@ -522,6 +542,8 @@ namespace // Index = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 14 16 17 18 19 // Source = 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 std::array expected = { 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, + // Index = 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 34 36 37 38 39 + // Source = -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -5, -5, -5, -5, -5, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -7, -7, -7, -7, -7 }; const size_t Scale = 10; @@ -575,6 +597,8 @@ namespace // Index = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 14 16 17 18 19 // Source = 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 std::array expected = { 50, 52, 52, 54, 54, 56, 56, 58, 58, 60, 60, 62, 62, 64, 64, 66, 66, 68, 68, 70, + // Index = 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 34 36 37 38 39 + // Source = -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -50, -52, -52, -54, -54, -56, -56, -58, -58, -60, -60, -62, -62, -64, -64, -66, -66, -68, -68, -70 }; const size_t Scale = 2; @@ -628,6 +652,8 @@ namespace // Index = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 14 16 17 18 19 // Source = 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 std::array expected = { 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, + // Index = 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 34 36 37 38 39 + // Source = -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -25, -26, -26, -27, -27, -28, -28, -29, -29, -30, -30, -31, -31, -32, -32, -33, -33, -34, -34, -35 }; const size_t Scale = 2; @@ -681,6 +707,8 @@ namespace // Index = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 14 16 17 18 19 // Source = 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 std::array expected = { 50, 50, 50, 50, 50, 50, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 70, 70, 70, 70, + // Index = 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 34 36 37 38 39 + // Source = -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -50, -50, -50, -50, -50, -50, -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, -70, -70, -70, -70 }; const size_t Scale = 10; @@ -734,6 +762,8 @@ namespace // Index = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 14 16 17 18 19 // Source = 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 std::array expected = { 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, + // Index = 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 34 36 37 38 39 + // Source = -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -5, -5, -5, -5, -5, -5, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -7, -7, -7, -7 }; const size_t Scale = 10; @@ -782,14 +812,16 @@ namespace } //************************************************************************* - TEST(round_half_down_scaled_with_scaling_of_2) + TEST(round_half_down_scaled_with_scaling_of_1) { // Index = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 14 16 17 18 19 // Source = 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 - std::array expected = { 50, 50, 52, 52, 54, 54, 56, 56, 58, 58, 60, 60, 62, 62, 64, 64, 66, 66, 68, 68, - -50, -50, -52, -52, -54, -54, -56, -56, -58, -58, -60, -60, -62, -62, -64, -64, -66, -66, -68, -68 }; + std::array expected = { 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, + // Index = 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 34 36 37 38 39 + // Source = -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 + -50, -51, -52, -53, -54, -55, -56, -57, -58, -59, -60, -61, -62, -63, -64, -65, -66, -67, -68, -69 }; - const size_t Scale = 2; + const size_t Scale = 1; CHECK_EQUAL(expected[0], etl::round_half_down_scaled(source[0])); CHECK_EQUAL(expected[1], etl::round_half_down_scaled(source[1])); @@ -834,284 +866,613 @@ namespace CHECK_EQUAL(expected[39], etl::round_half_down_scaled(source[39])); } - ////************************************************************************* - //TEST(round_half_down_unscaled_with_scaling_of_2) - //{ - // std::array expected = { 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, - // -25, -26, -26, -27, -27, -28, -28, -29, -29, -30, -30, -31, -31, -32, -32, -33, -33, -34, -34, -35 }; + //************************************************************************* + TEST(round_half_down_unscaled_with_scaling_of_1) + { + // Index = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 14 16 17 18 19 + // Source = 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 + std::array expected = { 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, + // Index = 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 34 36 37 38 39 + // Source = -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 + -50, -51, -52, -53, -54, -55, -56, -57, -58, -59, -60, -61, -62, -63, -64, -65, -66, -67, -68, -69 }; - // const size_t Scale = 2; + const size_t Scale = 1; - // CHECK_EQUAL(expected[0], etl::round_half_down_unscaled(source[0])); - // CHECK_EQUAL(expected[1], etl::round_half_down_unscaled(source[1])); - // CHECK_EQUAL(expected[2], etl::round_half_down_unscaled(source[2])); - // CHECK_EQUAL(expected[3], etl::round_half_down_unscaled(source[3])); - // CHECK_EQUAL(expected[4], etl::round_half_down_unscaled(source[4])); - // CHECK_EQUAL(expected[5], etl::round_half_down_unscaled(source[5])); - // CHECK_EQUAL(expected[6], etl::round_half_down_unscaled(source[6])); - // CHECK_EQUAL(expected[7], etl::round_half_down_unscaled(source[7])); - // CHECK_EQUAL(expected[8], etl::round_half_down_unscaled(source[8])); - // CHECK_EQUAL(expected[9], etl::round_half_down_unscaled(source[9])); - // CHECK_EQUAL(expected[10], etl::round_half_down_unscaled(source[10])); - // CHECK_EQUAL(expected[11], etl::round_half_down_unscaled(source[11])); - // CHECK_EQUAL(expected[12], etl::round_half_down_unscaled(source[12])); - // CHECK_EQUAL(expected[13], etl::round_half_down_unscaled(source[13])); - // CHECK_EQUAL(expected[14], etl::round_half_down_unscaled(source[14])); - // CHECK_EQUAL(expected[15], etl::round_half_down_unscaled(source[15])); - // CHECK_EQUAL(expected[16], etl::round_half_down_unscaled(source[16])); - // CHECK_EQUAL(expected[17], etl::round_half_down_unscaled(source[17])); - // CHECK_EQUAL(expected[18], etl::round_half_down_unscaled(source[18])); - // CHECK_EQUAL(expected[19], etl::round_half_down_unscaled(source[19])); + CHECK_EQUAL(expected[0], etl::round_half_down_unscaled(source[0])); + CHECK_EQUAL(expected[1], etl::round_half_down_unscaled(source[1])); + CHECK_EQUAL(expected[2], etl::round_half_down_unscaled(source[2])); + CHECK_EQUAL(expected[3], etl::round_half_down_unscaled(source[3])); + CHECK_EQUAL(expected[4], etl::round_half_down_unscaled(source[4])); + CHECK_EQUAL(expected[5], etl::round_half_down_unscaled(source[5])); + CHECK_EQUAL(expected[6], etl::round_half_down_unscaled(source[6])); + CHECK_EQUAL(expected[7], etl::round_half_down_unscaled(source[7])); + CHECK_EQUAL(expected[8], etl::round_half_down_unscaled(source[8])); + CHECK_EQUAL(expected[9], etl::round_half_down_unscaled(source[9])); + CHECK_EQUAL(expected[10], etl::round_half_down_unscaled(source[10])); + CHECK_EQUAL(expected[11], etl::round_half_down_unscaled(source[11])); + CHECK_EQUAL(expected[12], etl::round_half_down_unscaled(source[12])); + CHECK_EQUAL(expected[13], etl::round_half_down_unscaled(source[13])); + CHECK_EQUAL(expected[14], etl::round_half_down_unscaled(source[14])); + CHECK_EQUAL(expected[15], etl::round_half_down_unscaled(source[15])); + CHECK_EQUAL(expected[16], etl::round_half_down_unscaled(source[16])); + CHECK_EQUAL(expected[17], etl::round_half_down_unscaled(source[17])); + CHECK_EQUAL(expected[18], etl::round_half_down_unscaled(source[18])); + CHECK_EQUAL(expected[19], etl::round_half_down_unscaled(source[19])); - // CHECK_EQUAL(expected[20], etl::round_half_down_unscaled(source[20])); - // CHECK_EQUAL(expected[21], etl::round_half_down_unscaled(source[21])); - // CHECK_EQUAL(expected[22], etl::round_half_down_unscaled(source[22])); - // CHECK_EQUAL(expected[23], etl::round_half_down_unscaled(source[23])); - // CHECK_EQUAL(expected[24], etl::round_half_down_unscaled(source[24])); - // CHECK_EQUAL(expected[25], etl::round_half_down_unscaled(source[25])); - // CHECK_EQUAL(expected[26], etl::round_half_down_unscaled(source[26])); - // CHECK_EQUAL(expected[27], etl::round_half_down_unscaled(source[27])); - // CHECK_EQUAL(expected[28], etl::round_half_down_unscaled(source[28])); - // CHECK_EQUAL(expected[29], etl::round_half_down_unscaled(source[29])); - // CHECK_EQUAL(expected[30], etl::round_half_down_unscaled(source[30])); - // CHECK_EQUAL(expected[31], etl::round_half_down_unscaled(source[31])); - // CHECK_EQUAL(expected[32], etl::round_half_down_unscaled(source[32])); - // CHECK_EQUAL(expected[33], etl::round_half_down_unscaled(source[33])); - // CHECK_EQUAL(expected[34], etl::round_half_down_unscaled(source[34])); - // CHECK_EQUAL(expected[35], etl::round_half_down_unscaled(source[35])); - // CHECK_EQUAL(expected[36], etl::round_half_down_unscaled(source[36])); - // CHECK_EQUAL(expected[37], etl::round_half_down_unscaled(source[37])); - // CHECK_EQUAL(expected[38], etl::round_half_down_unscaled(source[38])); - // CHECK_EQUAL(expected[39], etl::round_half_down_unscaled(source[39])); - //} + CHECK_EQUAL(expected[20], etl::round_half_down_unscaled(source[20])); + CHECK_EQUAL(expected[21], etl::round_half_down_unscaled(source[21])); + CHECK_EQUAL(expected[22], etl::round_half_down_unscaled(source[22])); + CHECK_EQUAL(expected[23], etl::round_half_down_unscaled(source[23])); + CHECK_EQUAL(expected[24], etl::round_half_down_unscaled(source[24])); + CHECK_EQUAL(expected[25], etl::round_half_down_unscaled(source[25])); + CHECK_EQUAL(expected[26], etl::round_half_down_unscaled(source[26])); + CHECK_EQUAL(expected[27], etl::round_half_down_unscaled(source[27])); + CHECK_EQUAL(expected[28], etl::round_half_down_unscaled(source[28])); + CHECK_EQUAL(expected[29], etl::round_half_down_unscaled(source[29])); + CHECK_EQUAL(expected[30], etl::round_half_down_unscaled(source[30])); + CHECK_EQUAL(expected[31], etl::round_half_down_unscaled(source[31])); + CHECK_EQUAL(expected[32], etl::round_half_down_unscaled(source[32])); + CHECK_EQUAL(expected[33], etl::round_half_down_unscaled(source[33])); + CHECK_EQUAL(expected[34], etl::round_half_down_unscaled(source[34])); + CHECK_EQUAL(expected[35], etl::round_half_down_unscaled(source[35])); + CHECK_EQUAL(expected[36], etl::round_half_down_unscaled(source[36])); + CHECK_EQUAL(expected[37], etl::round_half_down_unscaled(source[37])); + CHECK_EQUAL(expected[38], etl::round_half_down_unscaled(source[38])); + CHECK_EQUAL(expected[39], etl::round_half_down_unscaled(source[39])); + } - ////************************************************************************* - //TEST(round_half_down_scaled) - //{ - // std::array expected = { 50, 50, 60, 60, 60, 70, -50, -50, -60, -60, -60, -70 }; + //************************************************************************* + TEST(round_zero_scaled) + { + // Index = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 14 16 17 18 19 + // Source = 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 + std::array expected = { 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, + // Index = 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 34 36 37 38 39 + // Source = -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 + -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -60, -60, -60, -60, -60, -60, -60, -60, -60, -60 }; - // CHECK_EQUAL(expected[0], etl::round_half_down_scaled(source[0])); - // CHECK_EQUAL(expected[1], etl::round_half_down_scaled(source[1])); - // CHECK_EQUAL(expected[2], etl::round_half_down_scaled(source[2])); - // CHECK_EQUAL(expected[3], etl::round_half_down_scaled(source[3])); - // CHECK_EQUAL(expected[4], etl::round_half_down_scaled(source[4])); - // CHECK_EQUAL(expected[5], etl::round_half_down_scaled(source[5])); - // CHECK_EQUAL(expected[6], etl::round_half_down_scaled(source[6])); - // CHECK_EQUAL(expected[7], etl::round_half_down_scaled(source[7])); - // CHECK_EQUAL(expected[8], etl::round_half_down_scaled(source[8])); - // CHECK_EQUAL(expected[9], etl::round_half_down_scaled(source[9])); - // CHECK_EQUAL(expected[10], etl::round_half_down_scaled(source[10])); - // CHECK_EQUAL(expected[11], etl::round_half_down_scaled(source[11])); - //} + const size_t Scale = 10; - ////************************************************************************* - //TEST(round_half_down_scaled_of_2) - //{ - // std::array expected = { 54, 55, 56, 64, 65, 66, -54, -55, -56, -64, -65, -66 }; + CHECK_EQUAL(expected[0], etl::round_zero_scaled(source[0])); + CHECK_EQUAL(expected[1], etl::round_zero_scaled(source[1])); + CHECK_EQUAL(expected[2], etl::round_zero_scaled(source[2])); + CHECK_EQUAL(expected[3], etl::round_zero_scaled(source[3])); + CHECK_EQUAL(expected[4], etl::round_zero_scaled(source[4])); + CHECK_EQUAL(expected[5], etl::round_zero_scaled(source[5])); + CHECK_EQUAL(expected[6], etl::round_zero_scaled(source[6])); + CHECK_EQUAL(expected[7], etl::round_zero_scaled(source[7])); + CHECK_EQUAL(expected[8], etl::round_zero_scaled(source[8])); + CHECK_EQUAL(expected[9], etl::round_zero_scaled(source[9])); + CHECK_EQUAL(expected[10], etl::round_zero_scaled(source[10])); + CHECK_EQUAL(expected[11], etl::round_zero_scaled(source[11])); + CHECK_EQUAL(expected[12], etl::round_zero_scaled(source[12])); + CHECK_EQUAL(expected[13], etl::round_zero_scaled(source[13])); + CHECK_EQUAL(expected[14], etl::round_zero_scaled(source[14])); + CHECK_EQUAL(expected[15], etl::round_zero_scaled(source[15])); + CHECK_EQUAL(expected[16], etl::round_zero_scaled(source[16])); + CHECK_EQUAL(expected[17], etl::round_zero_scaled(source[17])); + CHECK_EQUAL(expected[18], etl::round_zero_scaled(source[18])); + CHECK_EQUAL(expected[19], etl::round_zero_scaled(source[19])); - // CHECK_EQUAL(expected[0], etl::round_half_down_scaled<1>(source[0])); - // CHECK_EQUAL(expected[1], etl::round_half_down_scaled<1>(source[1])); - // CHECK_EQUAL(expected[2], etl::round_half_down_scaled<1>(source[2])); - // CHECK_EQUAL(expected[3], etl::round_half_down_scaled<1>(source[3])); - // CHECK_EQUAL(expected[4], etl::round_half_down_scaled<1>(source[4])); - // CHECK_EQUAL(expected[5], etl::round_half_down_scaled<1>(source[5])); - // CHECK_EQUAL(expected[6], etl::round_half_down_scaled<1>(source[6])); - // CHECK_EQUAL(expected[7], etl::round_half_down_scaled<1>(source[7])); - // CHECK_EQUAL(expected[8], etl::round_half_down_scaled<1>(source[8])); - // CHECK_EQUAL(expected[9], etl::round_half_down_scaled<1>(source[9])); - // CHECK_EQUAL(expected[10], etl::round_half_down_scaled<1>(source[10])); - // CHECK_EQUAL(expected[11], etl::round_half_down_scaled<1>(source[11])); - //} + CHECK_EQUAL(expected[20], etl::round_zero_scaled(source[20])); + CHECK_EQUAL(expected[21], etl::round_zero_scaled(source[21])); + CHECK_EQUAL(expected[22], etl::round_zero_scaled(source[22])); + CHECK_EQUAL(expected[23], etl::round_zero_scaled(source[23])); + CHECK_EQUAL(expected[24], etl::round_zero_scaled(source[24])); + CHECK_EQUAL(expected[25], etl::round_zero_scaled(source[25])); + CHECK_EQUAL(expected[26], etl::round_zero_scaled(source[26])); + CHECK_EQUAL(expected[27], etl::round_zero_scaled(source[27])); + CHECK_EQUAL(expected[28], etl::round_zero_scaled(source[28])); + CHECK_EQUAL(expected[29], etl::round_zero_scaled(source[29])); + CHECK_EQUAL(expected[30], etl::round_zero_scaled(source[30])); + CHECK_EQUAL(expected[31], etl::round_zero_scaled(source[31])); + CHECK_EQUAL(expected[32], etl::round_zero_scaled(source[32])); + CHECK_EQUAL(expected[33], etl::round_zero_scaled(source[33])); + CHECK_EQUAL(expected[34], etl::round_zero_scaled(source[34])); + CHECK_EQUAL(expected[35], etl::round_zero_scaled(source[35])); + CHECK_EQUAL(expected[36], etl::round_zero_scaled(source[36])); + CHECK_EQUAL(expected[37], etl::round_zero_scaled(source[37])); + CHECK_EQUAL(expected[38], etl::round_zero_scaled(source[38])); + CHECK_EQUAL(expected[39], etl::round_zero_scaled(source[39])); + } - ////************************************************************************* - //TEST(round_half_down_unscaled) - //{ - // std::array expected = { 5, 5, 6, 6, 6, 7, -5, -5, -6, -6, -6, -7 }; + //************************************************************************* + TEST(round_zero_unscaled) + { + // Index = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 14 16 17 18 19 + // Source = 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 + std::array expected = { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + // Index = 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 34 36 37 38 39 + // Source = -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 + -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6 }; - // CHECK_EQUAL(expected[0], etl::round_half_down_unscaled(source[0])); - // CHECK_EQUAL(expected[1], etl::round_half_down_unscaled(source[1])); - // CHECK_EQUAL(expected[2], etl::round_half_down_unscaled(source[2])); - // CHECK_EQUAL(expected[3], etl::round_half_down_unscaled(source[3])); - // CHECK_EQUAL(expected[4], etl::round_half_down_unscaled(source[4])); - // CHECK_EQUAL(expected[5], etl::round_half_down_unscaled(source[5])); - // CHECK_EQUAL(expected[6], etl::round_half_down_unscaled(source[6])); - // CHECK_EQUAL(expected[7], etl::round_half_down_unscaled(source[7])); - // CHECK_EQUAL(expected[8], etl::round_half_down_unscaled(source[8])); - // CHECK_EQUAL(expected[9], etl::round_half_down_unscaled(source[9])); - // CHECK_EQUAL(expected[10], etl::round_half_down_unscaled(source[10])); - // CHECK_EQUAL(expected[11], etl::round_half_down_unscaled(source[11])); - //} + const size_t Scale = 10; - ////************************************************************************* - //TEST(round_half_down_unscaled_of_2) - //{ - // std::array expected = { 54, 55, 56, 64, 65, 66, -54, -55, -56, -64, -65, -66 }; + CHECK_EQUAL(expected[0], etl::round_zero_unscaled(source[0])); + CHECK_EQUAL(expected[1], etl::round_zero_unscaled(source[1])); + CHECK_EQUAL(expected[2], etl::round_zero_unscaled(source[2])); + CHECK_EQUAL(expected[3], etl::round_zero_unscaled(source[3])); + CHECK_EQUAL(expected[4], etl::round_zero_unscaled(source[4])); + CHECK_EQUAL(expected[5], etl::round_zero_unscaled(source[5])); + CHECK_EQUAL(expected[6], etl::round_zero_unscaled(source[6])); + CHECK_EQUAL(expected[7], etl::round_zero_unscaled(source[7])); + CHECK_EQUAL(expected[8], etl::round_zero_unscaled(source[8])); + CHECK_EQUAL(expected[9], etl::round_zero_unscaled(source[9])); + CHECK_EQUAL(expected[10], etl::round_zero_unscaled(source[10])); + CHECK_EQUAL(expected[11], etl::round_zero_unscaled(source[11])); + CHECK_EQUAL(expected[12], etl::round_zero_unscaled(source[12])); + CHECK_EQUAL(expected[13], etl::round_zero_unscaled(source[13])); + CHECK_EQUAL(expected[14], etl::round_zero_unscaled(source[14])); + CHECK_EQUAL(expected[15], etl::round_zero_unscaled(source[15])); + CHECK_EQUAL(expected[16], etl::round_zero_unscaled(source[16])); + CHECK_EQUAL(expected[17], etl::round_zero_unscaled(source[17])); + CHECK_EQUAL(expected[18], etl::round_zero_unscaled(source[18])); + CHECK_EQUAL(expected[19], etl::round_zero_unscaled(source[19])); - // CHECK_EQUAL(expected[0], etl::round_half_down_unscaled<1>(source[0])); - // CHECK_EQUAL(expected[1], etl::round_half_down_unscaled<1>(source[1])); - // CHECK_EQUAL(expected[2], etl::round_half_down_unscaled<1>(source[2])); - // CHECK_EQUAL(expected[3], etl::round_half_down_unscaled<1>(source[3])); - // CHECK_EQUAL(expected[4], etl::round_half_down_unscaled<1>(source[4])); - // CHECK_EQUAL(expected[5], etl::round_half_down_unscaled<1>(source[5])); - // CHECK_EQUAL(expected[6], etl::round_half_down_unscaled<1>(source[6])); - // CHECK_EQUAL(expected[7], etl::round_half_down_unscaled<1>(source[7])); - // CHECK_EQUAL(expected[8], etl::round_half_down_unscaled<1>(source[8])); - // CHECK_EQUAL(expected[9], etl::round_half_down_unscaled<1>(source[9])); - // CHECK_EQUAL(expected[10], etl::round_half_down_unscaled<1>(source[10])); - // CHECK_EQUAL(expected[11], etl::round_half_down_unscaled<1>(source[11])); - //} + CHECK_EQUAL(expected[20], etl::round_zero_unscaled(source[20])); + CHECK_EQUAL(expected[21], etl::round_zero_unscaled(source[21])); + CHECK_EQUAL(expected[22], etl::round_zero_unscaled(source[22])); + CHECK_EQUAL(expected[23], etl::round_zero_unscaled(source[23])); + CHECK_EQUAL(expected[24], etl::round_zero_unscaled(source[24])); + CHECK_EQUAL(expected[25], etl::round_zero_unscaled(source[25])); + CHECK_EQUAL(expected[26], etl::round_zero_unscaled(source[26])); + CHECK_EQUAL(expected[27], etl::round_zero_unscaled(source[27])); + CHECK_EQUAL(expected[28], etl::round_zero_unscaled(source[28])); + CHECK_EQUAL(expected[29], etl::round_zero_unscaled(source[29])); + CHECK_EQUAL(expected[30], etl::round_zero_unscaled(source[30])); + CHECK_EQUAL(expected[31], etl::round_zero_unscaled(source[31])); + CHECK_EQUAL(expected[32], etl::round_zero_unscaled(source[32])); + CHECK_EQUAL(expected[33], etl::round_zero_unscaled(source[33])); + CHECK_EQUAL(expected[34], etl::round_zero_unscaled(source[34])); + CHECK_EQUAL(expected[35], etl::round_zero_unscaled(source[35])); + CHECK_EQUAL(expected[36], etl::round_zero_unscaled(source[36])); + CHECK_EQUAL(expected[37], etl::round_zero_unscaled(source[37])); + CHECK_EQUAL(expected[38], etl::round_zero_unscaled(source[38])); + CHECK_EQUAL(expected[39], etl::round_zero_unscaled(source[39])); + } - ////************************************************************************* - //TEST(round_zero_scaled) - //{ - // std::array expected = { 50, 50, 50, 60, 60, 60, -50, -50, -50, -60, -60, -60 }; + //************************************************************************* + TEST(round_zero_scaled_with_scaling_of_1) + { + // Index = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 14 16 17 18 19 + // Source = 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 + std::array expected = { 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, + // Index = 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 34 36 37 38 39 + // Source = -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 + -50, -51, -52, -53, -54, -55, -56, -57, -58, -59, -60, -61, -62, -63, -64, -65, -66, -67, -68, -69 }; - // CHECK_EQUAL(expected[0], etl::round_zero_scaled(source[0])); - // CHECK_EQUAL(expected[1], etl::round_zero_scaled(source[1])); - // CHECK_EQUAL(expected[2], etl::round_zero_scaled(source[2])); - // CHECK_EQUAL(expected[3], etl::round_zero_scaled(source[3])); - // CHECK_EQUAL(expected[4], etl::round_zero_scaled(source[4])); - // CHECK_EQUAL(expected[5], etl::round_zero_scaled(source[5])); - // CHECK_EQUAL(expected[6], etl::round_zero_scaled(source[6])); - // CHECK_EQUAL(expected[7], etl::round_zero_scaled(source[7])); - // CHECK_EQUAL(expected[8], etl::round_zero_scaled(source[8])); - // CHECK_EQUAL(expected[9], etl::round_zero_scaled(source[9])); - // CHECK_EQUAL(expected[10], etl::round_zero_scaled(source[10])); - // CHECK_EQUAL(expected[11], etl::round_zero_scaled(source[11])); - //} + const size_t Scale = 1; - ////************************************************************************* - //TEST(round_zero_scaled_of_1) - //{ - // std::array expected = { 54, 55, 56, 64, 65, 66, -54, -55, -56, -64, -65, -66 }; + CHECK_EQUAL(expected[0], etl::round_zero_scaled(source[0])); + CHECK_EQUAL(expected[1], etl::round_zero_scaled(source[1])); + CHECK_EQUAL(expected[2], etl::round_zero_scaled(source[2])); + CHECK_EQUAL(expected[3], etl::round_zero_scaled(source[3])); + CHECK_EQUAL(expected[4], etl::round_zero_scaled(source[4])); + CHECK_EQUAL(expected[5], etl::round_zero_scaled(source[5])); + CHECK_EQUAL(expected[6], etl::round_zero_scaled(source[6])); + CHECK_EQUAL(expected[7], etl::round_zero_scaled(source[7])); + CHECK_EQUAL(expected[8], etl::round_zero_scaled(source[8])); + CHECK_EQUAL(expected[9], etl::round_zero_scaled(source[9])); + CHECK_EQUAL(expected[10], etl::round_zero_scaled(source[10])); + CHECK_EQUAL(expected[11], etl::round_zero_scaled(source[11])); + CHECK_EQUAL(expected[12], etl::round_zero_scaled(source[12])); + CHECK_EQUAL(expected[13], etl::round_zero_scaled(source[13])); + CHECK_EQUAL(expected[14], etl::round_zero_scaled(source[14])); + CHECK_EQUAL(expected[15], etl::round_zero_scaled(source[15])); + CHECK_EQUAL(expected[16], etl::round_zero_scaled(source[16])); + CHECK_EQUAL(expected[17], etl::round_zero_scaled(source[17])); + CHECK_EQUAL(expected[18], etl::round_zero_scaled(source[18])); + CHECK_EQUAL(expected[19], etl::round_zero_scaled(source[19])); - // CHECK_EQUAL(expected[0], etl::round_zero_scaled<1>(source[0])); - // CHECK_EQUAL(expected[1], etl::round_zero_scaled<1>(source[1])); - // CHECK_EQUAL(expected[2], etl::round_zero_scaled<1>(source[2])); - // CHECK_EQUAL(expected[3], etl::round_zero_scaled<1>(source[3])); - // CHECK_EQUAL(expected[4], etl::round_zero_scaled<1>(source[4])); - // CHECK_EQUAL(expected[5], etl::round_zero_scaled<1>(source[5])); - // CHECK_EQUAL(expected[6], etl::round_zero_scaled<1>(source[6])); - // CHECK_EQUAL(expected[7], etl::round_zero_scaled<1>(source[7])); - // CHECK_EQUAL(expected[8], etl::round_zero_scaled<1>(source[8])); - // CHECK_EQUAL(expected[9], etl::round_zero_scaled<1>(source[9])); - // CHECK_EQUAL(expected[10], etl::round_zero_scaled<1>(source[10])); - // CHECK_EQUAL(expected[11], etl::round_zero_scaled<1>(source[11])); - //} + CHECK_EQUAL(expected[20], etl::round_zero_scaled(source[20])); + CHECK_EQUAL(expected[21], etl::round_zero_scaled(source[21])); + CHECK_EQUAL(expected[22], etl::round_zero_scaled(source[22])); + CHECK_EQUAL(expected[23], etl::round_zero_scaled(source[23])); + CHECK_EQUAL(expected[24], etl::round_zero_scaled(source[24])); + CHECK_EQUAL(expected[25], etl::round_zero_scaled(source[25])); + CHECK_EQUAL(expected[26], etl::round_zero_scaled(source[26])); + CHECK_EQUAL(expected[27], etl::round_zero_scaled(source[27])); + CHECK_EQUAL(expected[28], etl::round_zero_scaled(source[28])); + CHECK_EQUAL(expected[29], etl::round_zero_scaled(source[29])); + CHECK_EQUAL(expected[30], etl::round_zero_scaled(source[30])); + CHECK_EQUAL(expected[31], etl::round_zero_scaled(source[31])); + CHECK_EQUAL(expected[32], etl::round_zero_scaled(source[32])); + CHECK_EQUAL(expected[33], etl::round_zero_scaled(source[33])); + CHECK_EQUAL(expected[34], etl::round_zero_scaled(source[34])); + CHECK_EQUAL(expected[35], etl::round_zero_scaled(source[35])); + CHECK_EQUAL(expected[36], etl::round_zero_scaled(source[36])); + CHECK_EQUAL(expected[37], etl::round_zero_scaled(source[37])); + CHECK_EQUAL(expected[38], etl::round_zero_scaled(source[38])); + CHECK_EQUAL(expected[39], etl::round_zero_scaled(source[39])); + } - ////************************************************************************* - //TEST(round_zero_unscaled) - //{ - // std::array expected = { 5, 5, 5, 6, 6, 6, -5, -5, -5, -6, -6, -6 }; + //************************************************************************* + TEST(round_zero_unscaled_with_scaling_of_1) + { + // Index = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 14 16 17 18 19 + // Source = 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 + std::array expected = { 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, + // Index = 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 34 36 37 38 39 + // Source = -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 + -50, -51, -52, -53, -54, -55, -56, -57, -58, -59, -60, -61, -62, -63, -64, -65, -66, -67, -68, -69 }; - // CHECK_EQUAL(expected[0], etl::round_zero_unscaled(source[0])); - // CHECK_EQUAL(expected[1], etl::round_zero_unscaled(source[1])); - // CHECK_EQUAL(expected[2], etl::round_zero_unscaled(source[2])); - // CHECK_EQUAL(expected[3], etl::round_zero_unscaled(source[3])); - // CHECK_EQUAL(expected[4], etl::round_zero_unscaled(source[4])); - // CHECK_EQUAL(expected[5], etl::round_zero_unscaled(source[5])); - // CHECK_EQUAL(expected[6], etl::round_zero_unscaled(source[6])); - // CHECK_EQUAL(expected[7], etl::round_zero_unscaled(source[7])); - // CHECK_EQUAL(expected[8], etl::round_zero_unscaled(source[8])); - // CHECK_EQUAL(expected[9], etl::round_zero_unscaled(source[9])); - // CHECK_EQUAL(expected[10], etl::round_zero_unscaled(source[10])); - // CHECK_EQUAL(expected[11], etl::round_zero_unscaled(source[11])); - //} + const size_t Scale = 1; - ////************************************************************************* - //TEST(round_zero_unscaled_of_1) - //{ - // std::array expected = { 54, 55, 56, 64, 65, 66, -54, -55, -56, -64, -65, -66 }; + CHECK_EQUAL(expected[0], etl::round_zero_scaled(source[0])); + CHECK_EQUAL(expected[1], etl::round_zero_scaled(source[1])); + CHECK_EQUAL(expected[2], etl::round_zero_scaled(source[2])); + CHECK_EQUAL(expected[3], etl::round_zero_scaled(source[3])); + CHECK_EQUAL(expected[4], etl::round_zero_scaled(source[4])); + CHECK_EQUAL(expected[5], etl::round_zero_scaled(source[5])); + CHECK_EQUAL(expected[6], etl::round_zero_scaled(source[6])); + CHECK_EQUAL(expected[7], etl::round_zero_scaled(source[7])); + CHECK_EQUAL(expected[8], etl::round_zero_scaled(source[8])); + CHECK_EQUAL(expected[9], etl::round_zero_scaled(source[9])); + CHECK_EQUAL(expected[10], etl::round_zero_scaled(source[10])); + CHECK_EQUAL(expected[11], etl::round_zero_scaled(source[11])); + CHECK_EQUAL(expected[12], etl::round_zero_scaled(source[12])); + CHECK_EQUAL(expected[13], etl::round_zero_scaled(source[13])); + CHECK_EQUAL(expected[14], etl::round_zero_scaled(source[14])); + CHECK_EQUAL(expected[15], etl::round_zero_scaled(source[15])); + CHECK_EQUAL(expected[16], etl::round_zero_scaled(source[16])); + CHECK_EQUAL(expected[17], etl::round_zero_scaled(source[17])); + CHECK_EQUAL(expected[18], etl::round_zero_scaled(source[18])); + CHECK_EQUAL(expected[19], etl::round_zero_scaled(source[19])); - // CHECK_EQUAL(expected[0], etl::round_zero_unscaled<1>(source[0])); - // CHECK_EQUAL(expected[1], etl::round_zero_unscaled<1>(source[1])); - // CHECK_EQUAL(expected[2], etl::round_zero_unscaled<1>(source[2])); - // CHECK_EQUAL(expected[3], etl::round_zero_unscaled<1>(source[3])); - // CHECK_EQUAL(expected[4], etl::round_zero_unscaled<1>(source[4])); - // CHECK_EQUAL(expected[5], etl::round_zero_unscaled<1>(source[5])); - // CHECK_EQUAL(expected[6], etl::round_zero_unscaled<1>(source[6])); - // CHECK_EQUAL(expected[7], etl::round_zero_unscaled<1>(source[7])); - // CHECK_EQUAL(expected[8], etl::round_zero_unscaled<1>(source[8])); - // CHECK_EQUAL(expected[9], etl::round_zero_unscaled<1>(source[9])); - // CHECK_EQUAL(expected[10], etl::round_zero_unscaled<1>(source[10])); - // CHECK_EQUAL(expected[11], etl::round_zero_unscaled<1>(source[11])); - //} - // - ////************************************************************************* - //TEST(round_infinity_scaled) - //{ - // std::array expected = { 60, 60, 60, 70, 70, 70, -60, -60, -60, -70, -70, -70 }; + CHECK_EQUAL(expected[20], etl::round_zero_scaled(source[20])); + CHECK_EQUAL(expected[21], etl::round_zero_scaled(source[21])); + CHECK_EQUAL(expected[22], etl::round_zero_scaled(source[22])); + CHECK_EQUAL(expected[23], etl::round_zero_scaled(source[23])); + CHECK_EQUAL(expected[24], etl::round_zero_scaled(source[24])); + CHECK_EQUAL(expected[25], etl::round_zero_scaled(source[25])); + CHECK_EQUAL(expected[26], etl::round_zero_scaled(source[26])); + CHECK_EQUAL(expected[27], etl::round_zero_scaled(source[27])); + CHECK_EQUAL(expected[28], etl::round_zero_scaled(source[28])); + CHECK_EQUAL(expected[29], etl::round_zero_scaled(source[29])); + CHECK_EQUAL(expected[30], etl::round_zero_scaled(source[30])); + CHECK_EQUAL(expected[31], etl::round_zero_scaled(source[31])); + CHECK_EQUAL(expected[32], etl::round_zero_scaled(source[32])); + CHECK_EQUAL(expected[33], etl::round_zero_scaled(source[33])); + CHECK_EQUAL(expected[34], etl::round_zero_scaled(source[34])); + CHECK_EQUAL(expected[35], etl::round_zero_scaled(source[35])); + CHECK_EQUAL(expected[36], etl::round_zero_scaled(source[36])); + CHECK_EQUAL(expected[37], etl::round_zero_scaled(source[37])); + CHECK_EQUAL(expected[38], etl::round_zero_scaled(source[38])); + CHECK_EQUAL(expected[39], etl::round_zero_scaled(source[39])); + } - // CHECK_EQUAL(expected[0], etl::round_infinity_scaled(source[0])); - // CHECK_EQUAL(expected[1], etl::round_infinity_scaled(source[1])); - // CHECK_EQUAL(expected[2], etl::round_infinity_scaled(source[2])); - // CHECK_EQUAL(expected[3], etl::round_infinity_scaled(source[3])); - // CHECK_EQUAL(expected[4], etl::round_infinity_scaled(source[4])); - // CHECK_EQUAL(expected[5], etl::round_infinity_scaled(source[5])); - // CHECK_EQUAL(expected[6], etl::round_infinity_scaled(source[6])); - // CHECK_EQUAL(expected[7], etl::round_infinity_scaled(source[7])); - // CHECK_EQUAL(expected[8], etl::round_infinity_scaled(source[8])); - // CHECK_EQUAL(expected[9], etl::round_infinity_scaled(source[9])); - // CHECK_EQUAL(expected[10], etl::round_infinity_scaled(source[10])); - // CHECK_EQUAL(expected[11], etl::round_infinity_scaled(source[11])); - //} + //************************************************************************* + TEST(round_infinity_scaled) + { + // Index = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 14 16 17 18 19 + // Source = 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 + std::array expected = { 50, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 70, 70, 70, 70, 70, 70, 70, 70, 70, + // Index = 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 34 36 37 38 39 + // Source = -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 + -50, -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, -70, -70, -70, -70, -70, -70, -70, -70, -70 }; - ////************************************************************************* - //TEST(round_infinity_scaled_of_1) - //{ - // std::array expected = { 54, 55, 56, 64, 65, 66, -54, -55, -56, -64, -65, -66 }; + const size_t Scale = 10; - // CHECK_EQUAL(expected[0], etl::round_infinity_scaled<1>(source[0])); - // CHECK_EQUAL(expected[1], etl::round_infinity_scaled<1>(source[1])); - // CHECK_EQUAL(expected[2], etl::round_infinity_scaled<1>(source[2])); - // CHECK_EQUAL(expected[3], etl::round_infinity_scaled<1>(source[3])); - // CHECK_EQUAL(expected[4], etl::round_infinity_scaled<1>(source[4])); - // CHECK_EQUAL(expected[5], etl::round_infinity_scaled<1>(source[5])); - // CHECK_EQUAL(expected[6], etl::round_infinity_scaled<1>(source[6])); - // CHECK_EQUAL(expected[7], etl::round_infinity_scaled<1>(source[7])); - // CHECK_EQUAL(expected[8], etl::round_infinity_scaled<1>(source[8])); - // CHECK_EQUAL(expected[9], etl::round_infinity_scaled<1>(source[9])); - // CHECK_EQUAL(expected[10], etl::round_infinity_scaled<1>(source[10])); - // CHECK_EQUAL(expected[11], etl::round_infinity_scaled<1>(source[11])); - //} + CHECK_EQUAL(expected[0], etl::round_infinity_scaled(source[0])); + CHECK_EQUAL(expected[1], etl::round_infinity_scaled(source[1])); + CHECK_EQUAL(expected[2], etl::round_infinity_scaled(source[2])); + CHECK_EQUAL(expected[3], etl::round_infinity_scaled(source[3])); + CHECK_EQUAL(expected[4], etl::round_infinity_scaled(source[4])); + CHECK_EQUAL(expected[5], etl::round_infinity_scaled(source[5])); + CHECK_EQUAL(expected[6], etl::round_infinity_scaled(source[6])); + CHECK_EQUAL(expected[7], etl::round_infinity_scaled(source[7])); + CHECK_EQUAL(expected[8], etl::round_infinity_scaled(source[8])); + CHECK_EQUAL(expected[9], etl::round_infinity_scaled(source[9])); + CHECK_EQUAL(expected[10], etl::round_infinity_scaled(source[10])); + CHECK_EQUAL(expected[11], etl::round_infinity_scaled(source[11])); + CHECK_EQUAL(expected[12], etl::round_infinity_scaled(source[12])); + CHECK_EQUAL(expected[13], etl::round_infinity_scaled(source[13])); + CHECK_EQUAL(expected[14], etl::round_infinity_scaled(source[14])); + CHECK_EQUAL(expected[15], etl::round_infinity_scaled(source[15])); + CHECK_EQUAL(expected[16], etl::round_infinity_scaled(source[16])); + CHECK_EQUAL(expected[17], etl::round_infinity_scaled(source[17])); + CHECK_EQUAL(expected[18], etl::round_infinity_scaled(source[18])); + CHECK_EQUAL(expected[19], etl::round_infinity_scaled(source[19])); - ////************************************************************************* - //TEST(round_infinity_unscaled) - //{ - // std::array expected = { 6, 6, 6, 7, 7, 7, -6, -6, -6, -7, -7, -7 }; + CHECK_EQUAL(expected[20], etl::round_infinity_scaled(source[20])); + CHECK_EQUAL(expected[21], etl::round_infinity_scaled(source[21])); + CHECK_EQUAL(expected[22], etl::round_infinity_scaled(source[22])); + CHECK_EQUAL(expected[23], etl::round_infinity_scaled(source[23])); + CHECK_EQUAL(expected[24], etl::round_infinity_scaled(source[24])); + CHECK_EQUAL(expected[25], etl::round_infinity_scaled(source[25])); + CHECK_EQUAL(expected[26], etl::round_infinity_scaled(source[26])); + CHECK_EQUAL(expected[27], etl::round_infinity_scaled(source[27])); + CHECK_EQUAL(expected[28], etl::round_infinity_scaled(source[28])); + CHECK_EQUAL(expected[29], etl::round_infinity_scaled(source[29])); + CHECK_EQUAL(expected[30], etl::round_infinity_scaled(source[30])); + CHECK_EQUAL(expected[31], etl::round_infinity_scaled(source[31])); + CHECK_EQUAL(expected[32], etl::round_infinity_scaled(source[32])); + CHECK_EQUAL(expected[33], etl::round_infinity_scaled(source[33])); + CHECK_EQUAL(expected[34], etl::round_infinity_scaled(source[34])); + CHECK_EQUAL(expected[35], etl::round_infinity_scaled(source[35])); + CHECK_EQUAL(expected[36], etl::round_infinity_scaled(source[36])); + CHECK_EQUAL(expected[37], etl::round_infinity_scaled(source[37])); + CHECK_EQUAL(expected[38], etl::round_infinity_scaled(source[38])); + CHECK_EQUAL(expected[39], etl::round_infinity_scaled(source[39])); + } - // CHECK_EQUAL(expected[0], etl::round_infinity_unscaled(source[0])); - // CHECK_EQUAL(expected[1], etl::round_infinity_unscaled(source[1])); - // CHECK_EQUAL(expected[2], etl::round_infinity_unscaled(source[2])); - // CHECK_EQUAL(expected[3], etl::round_infinity_unscaled(source[3])); - // CHECK_EQUAL(expected[4], etl::round_infinity_unscaled(source[4])); - // CHECK_EQUAL(expected[5], etl::round_infinity_unscaled(source[5])); - // CHECK_EQUAL(expected[6], etl::round_infinity_unscaled(source[6])); - // CHECK_EQUAL(expected[7], etl::round_infinity_unscaled(source[7])); - // CHECK_EQUAL(expected[8], etl::round_infinity_unscaled(source[8])); - // CHECK_EQUAL(expected[9], etl::round_infinity_unscaled(source[9])); - // CHECK_EQUAL(expected[10], etl::round_infinity_unscaled(source[10])); - // CHECK_EQUAL(expected[11], etl::round_infinity_unscaled(source[11])); - //} + //************************************************************************* + TEST(round_infinity_unscaled) + { + // Index = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 14 16 17 18 19 + // Source = 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 + std::array expected = { 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, + // Index = 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 34 36 37 38 39 + // Source = -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 + -5, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -7, -7, -7, -7, -7, -7, -7, -7, -7 }; - ////************************************************************************* - //TEST(round_infinity_unscaled_of_1) - //{ - // std::array expected = { 54, 55, 56, 64, 65, 66, -54, -55, -56, -64, -65, -66 }; + const size_t Scale = 10; - // CHECK_EQUAL(expected[0], etl::round_infinity_unscaled<1>(source[0])); - // CHECK_EQUAL(expected[1], etl::round_infinity_unscaled<1>(source[1])); - // CHECK_EQUAL(expected[2], etl::round_infinity_unscaled<1>(source[2])); - // CHECK_EQUAL(expected[3], etl::round_infinity_unscaled<1>(source[3])); - // CHECK_EQUAL(expected[4], etl::round_infinity_unscaled<1>(source[4])); - // CHECK_EQUAL(expected[5], etl::round_infinity_unscaled<1>(source[5])); - // CHECK_EQUAL(expected[6], etl::round_infinity_unscaled<1>(source[6])); - // CHECK_EQUAL(expected[7], etl::round_infinity_unscaled<1>(source[7])); - // CHECK_EQUAL(expected[8], etl::round_infinity_unscaled<1>(source[8])); - // CHECK_EQUAL(expected[9], etl::round_infinity_unscaled<1>(source[9])); - // CHECK_EQUAL(expected[10], etl::round_infinity_unscaled<1>(source[10])); - // CHECK_EQUAL(expected[11], etl::round_infinity_unscaled<1>(source[11])); - //} + CHECK_EQUAL(expected[0], etl::round_infinity_unscaled(source[0])); + CHECK_EQUAL(expected[1], etl::round_infinity_unscaled(source[1])); + CHECK_EQUAL(expected[2], etl::round_infinity_unscaled(source[2])); + CHECK_EQUAL(expected[3], etl::round_infinity_unscaled(source[3])); + CHECK_EQUAL(expected[4], etl::round_infinity_unscaled(source[4])); + CHECK_EQUAL(expected[5], etl::round_infinity_unscaled(source[5])); + CHECK_EQUAL(expected[6], etl::round_infinity_unscaled(source[6])); + CHECK_EQUAL(expected[7], etl::round_infinity_unscaled(source[7])); + CHECK_EQUAL(expected[8], etl::round_infinity_unscaled(source[8])); + CHECK_EQUAL(expected[9], etl::round_infinity_unscaled(source[9])); + CHECK_EQUAL(expected[10], etl::round_infinity_unscaled(source[10])); + CHECK_EQUAL(expected[11], etl::round_infinity_unscaled(source[11])); + CHECK_EQUAL(expected[12], etl::round_infinity_unscaled(source[12])); + CHECK_EQUAL(expected[13], etl::round_infinity_unscaled(source[13])); + CHECK_EQUAL(expected[14], etl::round_infinity_unscaled(source[14])); + CHECK_EQUAL(expected[15], etl::round_infinity_unscaled(source[15])); + CHECK_EQUAL(expected[16], etl::round_infinity_unscaled(source[16])); + CHECK_EQUAL(expected[17], etl::round_infinity_unscaled(source[17])); + CHECK_EQUAL(expected[18], etl::round_infinity_unscaled(source[18])); + CHECK_EQUAL(expected[19], etl::round_infinity_unscaled(source[19])); + + CHECK_EQUAL(expected[20], etl::round_infinity_unscaled(source[20])); + CHECK_EQUAL(expected[21], etl::round_infinity_unscaled(source[21])); + CHECK_EQUAL(expected[22], etl::round_infinity_unscaled(source[22])); + CHECK_EQUAL(expected[23], etl::round_infinity_unscaled(source[23])); + CHECK_EQUAL(expected[24], etl::round_infinity_unscaled(source[24])); + CHECK_EQUAL(expected[25], etl::round_infinity_unscaled(source[25])); + CHECK_EQUAL(expected[26], etl::round_infinity_unscaled(source[26])); + CHECK_EQUAL(expected[27], etl::round_infinity_unscaled(source[27])); + CHECK_EQUAL(expected[28], etl::round_infinity_unscaled(source[28])); + CHECK_EQUAL(expected[29], etl::round_infinity_unscaled(source[29])); + CHECK_EQUAL(expected[30], etl::round_infinity_unscaled(source[30])); + CHECK_EQUAL(expected[31], etl::round_infinity_unscaled(source[31])); + CHECK_EQUAL(expected[32], etl::round_infinity_unscaled(source[32])); + CHECK_EQUAL(expected[33], etl::round_infinity_unscaled(source[33])); + CHECK_EQUAL(expected[34], etl::round_infinity_unscaled(source[34])); + CHECK_EQUAL(expected[35], etl::round_infinity_unscaled(source[35])); + CHECK_EQUAL(expected[36], etl::round_infinity_unscaled(source[36])); + CHECK_EQUAL(expected[37], etl::round_infinity_unscaled(source[37])); + CHECK_EQUAL(expected[38], etl::round_infinity_unscaled(source[38])); + CHECK_EQUAL(expected[39], etl::round_infinity_unscaled(source[39])); + } + + //************************************************************************* + TEST(round_infinity_scaled_with_scaling_of_1) + { + // Index = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 14 16 17 18 19 + // Source = 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 + std::array expected = { 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, + // Index = 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 34 36 37 38 39 + // Source = -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 + -50, -51, -52, -53, -54, -55, -56, -57, -58, -59, -60, -61, -62, -63, -64, -65, -66, -67, -68, -69 }; + + const size_t Scale = 1; + + CHECK_EQUAL(expected[0], etl::round_infinity_scaled(source[0])); + CHECK_EQUAL(expected[1], etl::round_infinity_scaled(source[1])); + CHECK_EQUAL(expected[2], etl::round_infinity_scaled(source[2])); + CHECK_EQUAL(expected[3], etl::round_infinity_scaled(source[3])); + CHECK_EQUAL(expected[4], etl::round_infinity_scaled(source[4])); + CHECK_EQUAL(expected[5], etl::round_infinity_scaled(source[5])); + CHECK_EQUAL(expected[6], etl::round_infinity_scaled(source[6])); + CHECK_EQUAL(expected[7], etl::round_infinity_scaled(source[7])); + CHECK_EQUAL(expected[8], etl::round_infinity_scaled(source[8])); + CHECK_EQUAL(expected[9], etl::round_infinity_scaled(source[9])); + CHECK_EQUAL(expected[10], etl::round_infinity_scaled(source[10])); + CHECK_EQUAL(expected[11], etl::round_infinity_scaled(source[11])); + CHECK_EQUAL(expected[12], etl::round_infinity_scaled(source[12])); + CHECK_EQUAL(expected[13], etl::round_infinity_scaled(source[13])); + CHECK_EQUAL(expected[14], etl::round_infinity_scaled(source[14])); + CHECK_EQUAL(expected[15], etl::round_infinity_scaled(source[15])); + CHECK_EQUAL(expected[16], etl::round_infinity_scaled(source[16])); + CHECK_EQUAL(expected[17], etl::round_infinity_scaled(source[17])); + CHECK_EQUAL(expected[18], etl::round_infinity_scaled(source[18])); + CHECK_EQUAL(expected[19], etl::round_infinity_scaled(source[19])); + + CHECK_EQUAL(expected[20], etl::round_infinity_scaled(source[20])); + CHECK_EQUAL(expected[21], etl::round_infinity_scaled(source[21])); + CHECK_EQUAL(expected[22], etl::round_infinity_scaled(source[22])); + CHECK_EQUAL(expected[23], etl::round_infinity_scaled(source[23])); + CHECK_EQUAL(expected[24], etl::round_infinity_scaled(source[24])); + CHECK_EQUAL(expected[25], etl::round_infinity_scaled(source[25])); + CHECK_EQUAL(expected[26], etl::round_infinity_scaled(source[26])); + CHECK_EQUAL(expected[27], etl::round_infinity_scaled(source[27])); + CHECK_EQUAL(expected[28], etl::round_infinity_scaled(source[28])); + CHECK_EQUAL(expected[29], etl::round_infinity_scaled(source[29])); + CHECK_EQUAL(expected[30], etl::round_infinity_scaled(source[30])); + CHECK_EQUAL(expected[31], etl::round_infinity_scaled(source[31])); + CHECK_EQUAL(expected[32], etl::round_infinity_scaled(source[32])); + CHECK_EQUAL(expected[33], etl::round_infinity_scaled(source[33])); + CHECK_EQUAL(expected[34], etl::round_infinity_scaled(source[34])); + CHECK_EQUAL(expected[35], etl::round_infinity_scaled(source[35])); + CHECK_EQUAL(expected[36], etl::round_infinity_scaled(source[36])); + CHECK_EQUAL(expected[37], etl::round_infinity_scaled(source[37])); + CHECK_EQUAL(expected[38], etl::round_infinity_scaled(source[38])); + CHECK_EQUAL(expected[39], etl::round_infinity_scaled(source[39])); + } + + //************************************************************************* + TEST(round_infinity_unscaled_with_scaling_of_1) + { + // Index = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 14 16 17 18 19 + // Source = 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 + std::array expected = { 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, + // Index = 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 34 36 37 38 39 + // Source = -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 + -50, -51, -52, -53, -54, -55, -56, -57, -58, -59, -60, -61, -62, -63, -64, -65, -66, -67, -68, -69 }; + + const size_t Scale = 1; + + CHECK_EQUAL(expected[0], etl::round_infinity_scaled(source[0])); + CHECK_EQUAL(expected[1], etl::round_infinity_scaled(source[1])); + CHECK_EQUAL(expected[2], etl::round_infinity_scaled(source[2])); + CHECK_EQUAL(expected[3], etl::round_infinity_scaled(source[3])); + CHECK_EQUAL(expected[4], etl::round_infinity_scaled(source[4])); + CHECK_EQUAL(expected[5], etl::round_infinity_scaled(source[5])); + CHECK_EQUAL(expected[6], etl::round_infinity_scaled(source[6])); + CHECK_EQUAL(expected[7], etl::round_infinity_scaled(source[7])); + CHECK_EQUAL(expected[8], etl::round_infinity_scaled(source[8])); + CHECK_EQUAL(expected[9], etl::round_infinity_scaled(source[9])); + CHECK_EQUAL(expected[10], etl::round_infinity_scaled(source[10])); + CHECK_EQUAL(expected[11], etl::round_infinity_scaled(source[11])); + CHECK_EQUAL(expected[12], etl::round_infinity_scaled(source[12])); + CHECK_EQUAL(expected[13], etl::round_infinity_scaled(source[13])); + CHECK_EQUAL(expected[14], etl::round_infinity_scaled(source[14])); + CHECK_EQUAL(expected[15], etl::round_infinity_scaled(source[15])); + CHECK_EQUAL(expected[16], etl::round_infinity_scaled(source[16])); + CHECK_EQUAL(expected[17], etl::round_infinity_scaled(source[17])); + CHECK_EQUAL(expected[18], etl::round_infinity_scaled(source[18])); + CHECK_EQUAL(expected[19], etl::round_infinity_scaled(source[19])); + + CHECK_EQUAL(expected[20], etl::round_infinity_scaled(source[20])); + CHECK_EQUAL(expected[21], etl::round_infinity_scaled(source[21])); + CHECK_EQUAL(expected[22], etl::round_infinity_scaled(source[22])); + CHECK_EQUAL(expected[23], etl::round_infinity_scaled(source[23])); + CHECK_EQUAL(expected[24], etl::round_infinity_scaled(source[24])); + CHECK_EQUAL(expected[25], etl::round_infinity_scaled(source[25])); + CHECK_EQUAL(expected[26], etl::round_infinity_scaled(source[26])); + CHECK_EQUAL(expected[27], etl::round_infinity_scaled(source[27])); + CHECK_EQUAL(expected[28], etl::round_infinity_scaled(source[28])); + CHECK_EQUAL(expected[29], etl::round_infinity_scaled(source[29])); + CHECK_EQUAL(expected[30], etl::round_infinity_scaled(source[30])); + CHECK_EQUAL(expected[31], etl::round_infinity_scaled(source[31])); + CHECK_EQUAL(expected[32], etl::round_infinity_scaled(source[32])); + CHECK_EQUAL(expected[33], etl::round_infinity_scaled(source[33])); + CHECK_EQUAL(expected[34], etl::round_infinity_scaled(source[34])); + CHECK_EQUAL(expected[35], etl::round_infinity_scaled(source[35])); + CHECK_EQUAL(expected[36], etl::round_infinity_scaled(source[36])); + CHECK_EQUAL(expected[37], etl::round_infinity_scaled(source[37])); + CHECK_EQUAL(expected[38], etl::round_infinity_scaled(source[38])); + CHECK_EQUAL(expected[39], etl::round_infinity_scaled(source[39])); + } + + + + + //************************************************************************* + TEST(round_half_even_scaled) + { + // Index = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 14 16 17 18 19 + // Source = 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 + std::array expected = { 50, 50, 50, 50, 50, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 70, 70, 70, 70, + // Index = 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 34 36 37 38 39 + // Source = -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 + -50, -50, -50, -50, -50, -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, -70, -70, -70, -70 }; + + const size_t Scale = 10; + + CHECK_EQUAL(expected[0], etl::round_half_even_scaled(source[0])); + CHECK_EQUAL(expected[1], etl::round_half_even_scaled(source[1])); + CHECK_EQUAL(expected[2], etl::round_half_even_scaled(source[2])); + CHECK_EQUAL(expected[3], etl::round_half_even_scaled(source[3])); + CHECK_EQUAL(expected[4], etl::round_half_even_scaled(source[4])); + CHECK_EQUAL(expected[5], etl::round_half_even_scaled(source[5])); + CHECK_EQUAL(expected[6], etl::round_half_even_scaled(source[6])); + CHECK_EQUAL(expected[7], etl::round_half_even_scaled(source[7])); + CHECK_EQUAL(expected[8], etl::round_half_even_scaled(source[8])); + CHECK_EQUAL(expected[9], etl::round_half_even_scaled(source[9])); + CHECK_EQUAL(expected[10], etl::round_half_even_scaled(source[10])); + CHECK_EQUAL(expected[11], etl::round_half_even_scaled(source[11])); + CHECK_EQUAL(expected[12], etl::round_half_even_scaled(source[12])); + CHECK_EQUAL(expected[13], etl::round_half_even_scaled(source[13])); + CHECK_EQUAL(expected[14], etl::round_half_even_scaled(source[14])); + CHECK_EQUAL(expected[15], etl::round_half_even_scaled(source[15])); + CHECK_EQUAL(expected[16], etl::round_half_even_scaled(source[16])); + CHECK_EQUAL(expected[17], etl::round_half_even_scaled(source[17])); + CHECK_EQUAL(expected[18], etl::round_half_even_scaled(source[18])); + CHECK_EQUAL(expected[19], etl::round_half_even_scaled(source[19])); + + CHECK_EQUAL(expected[20], etl::round_half_even_scaled(source[20])); + CHECK_EQUAL(expected[21], etl::round_half_even_scaled(source[21])); + CHECK_EQUAL(expected[22], etl::round_half_even_scaled(source[22])); + CHECK_EQUAL(expected[23], etl::round_half_even_scaled(source[23])); + CHECK_EQUAL(expected[24], etl::round_half_even_scaled(source[24])); + CHECK_EQUAL(expected[25], etl::round_half_even_scaled(source[25])); + CHECK_EQUAL(expected[26], etl::round_half_even_scaled(source[26])); + CHECK_EQUAL(expected[27], etl::round_half_even_scaled(source[27])); + CHECK_EQUAL(expected[28], etl::round_half_even_scaled(source[28])); + CHECK_EQUAL(expected[29], etl::round_half_even_scaled(source[29])); + CHECK_EQUAL(expected[30], etl::round_half_even_scaled(source[30])); + CHECK_EQUAL(expected[31], etl::round_half_even_scaled(source[31])); + CHECK_EQUAL(expected[32], etl::round_half_even_scaled(source[32])); + CHECK_EQUAL(expected[33], etl::round_half_even_scaled(source[33])); + CHECK_EQUAL(expected[34], etl::round_half_even_scaled(source[34])); + CHECK_EQUAL(expected[35], etl::round_half_even_scaled(source[35])); + CHECK_EQUAL(expected[36], etl::round_half_even_scaled(source[36])); + CHECK_EQUAL(expected[37], etl::round_half_even_scaled(source[37])); + CHECK_EQUAL(expected[38], etl::round_half_even_scaled(source[38])); + CHECK_EQUAL(expected[39], etl::round_half_even_scaled(source[39])); + } + + //************************************************************************* + TEST(round_half_even_unscaled) + { + // Index = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 14 16 17 18 19 + // Source = 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 + std::array expected = { 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, + // Index = 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 34 36 37 38 39 + // Source = -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 + -5, -5, -5, -5, -5, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -7, -7, -7, -7 }; + + const size_t Scale = 10; + + CHECK_EQUAL(expected[0], etl::round_half_even_unscaled(source[0])); + CHECK_EQUAL(expected[1], etl::round_half_even_unscaled(source[1])); + CHECK_EQUAL(expected[2], etl::round_half_even_unscaled(source[2])); + CHECK_EQUAL(expected[3], etl::round_half_even_unscaled(source[3])); + CHECK_EQUAL(expected[4], etl::round_half_even_unscaled(source[4])); + CHECK_EQUAL(expected[5], etl::round_half_even_unscaled(source[5])); + CHECK_EQUAL(expected[6], etl::round_half_even_unscaled(source[6])); + CHECK_EQUAL(expected[7], etl::round_half_even_unscaled(source[7])); + CHECK_EQUAL(expected[8], etl::round_half_even_unscaled(source[8])); + CHECK_EQUAL(expected[9], etl::round_half_even_unscaled(source[9])); + CHECK_EQUAL(expected[10], etl::round_half_even_unscaled(source[10])); + CHECK_EQUAL(expected[11], etl::round_half_even_unscaled(source[11])); + CHECK_EQUAL(expected[12], etl::round_half_even_unscaled(source[12])); + CHECK_EQUAL(expected[13], etl::round_half_even_unscaled(source[13])); + CHECK_EQUAL(expected[14], etl::round_half_even_unscaled(source[14])); + CHECK_EQUAL(expected[15], etl::round_half_even_unscaled(source[15])); + CHECK_EQUAL(expected[16], etl::round_half_even_unscaled(source[16])); + CHECK_EQUAL(expected[17], etl::round_half_even_unscaled(source[17])); + CHECK_EQUAL(expected[18], etl::round_half_even_unscaled(source[18])); + CHECK_EQUAL(expected[19], etl::round_half_even_unscaled(source[19])); + + CHECK_EQUAL(expected[20], etl::round_half_even_unscaled(source[20])); + CHECK_EQUAL(expected[21], etl::round_half_even_unscaled(source[21])); + CHECK_EQUAL(expected[22], etl::round_half_even_unscaled(source[22])); + CHECK_EQUAL(expected[23], etl::round_half_even_unscaled(source[23])); + CHECK_EQUAL(expected[24], etl::round_half_even_unscaled(source[24])); + CHECK_EQUAL(expected[25], etl::round_half_even_unscaled(source[25])); + CHECK_EQUAL(expected[26], etl::round_half_even_unscaled(source[26])); + CHECK_EQUAL(expected[27], etl::round_half_even_unscaled(source[27])); + CHECK_EQUAL(expected[28], etl::round_half_even_unscaled(source[28])); + CHECK_EQUAL(expected[29], etl::round_half_even_unscaled(source[29])); + CHECK_EQUAL(expected[30], etl::round_half_even_unscaled(source[30])); + CHECK_EQUAL(expected[31], etl::round_half_even_unscaled(source[31])); + CHECK_EQUAL(expected[32], etl::round_half_even_unscaled(source[32])); + CHECK_EQUAL(expected[33], etl::round_half_even_unscaled(source[33])); + CHECK_EQUAL(expected[34], etl::round_half_even_unscaled(source[34])); + CHECK_EQUAL(expected[35], etl::round_half_even_unscaled(source[35])); + CHECK_EQUAL(expected[36], etl::round_half_even_unscaled(source[36])); + CHECK_EQUAL(expected[37], etl::round_half_even_unscaled(source[37])); + CHECK_EQUAL(expected[38], etl::round_half_even_unscaled(source[38])); + CHECK_EQUAL(expected[39], etl::round_half_even_unscaled(source[39])); + } ////************************************************************************* //TEST(round_half_even_scaled)