mirror of
https://github.com/ETLCPP/etl.git
synced 2026-04-30 19:09:10 +08:00
Renamed cumulative_moving _average to pseudo_moving_average
Modified etl::debounce internal enumeration names to avoid clashes with Arduino
This commit is contained in:
parent
b522608b94
commit
829d9fa220
@ -55,13 +55,13 @@ namespace etl
|
||||
void add_sample(bool sample)
|
||||
{
|
||||
// Changed from last time?
|
||||
if (sample != bool((flags & SAMPLE) != 0))
|
||||
if (sample != bool((flags & Sample) != 0))
|
||||
{
|
||||
count = 0;
|
||||
flags = (flags & ~SAMPLE) | (sample ? SAMPLE : 0);
|
||||
flags = (flags & ~Sample) | (sample ? Sample : 0);
|
||||
}
|
||||
|
||||
flags &= ~CHANGE;
|
||||
flags &= ~Change;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -70,7 +70,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
bool has_changed() const
|
||||
{
|
||||
return (flags & CHANGE) != 0;
|
||||
return (flags & Change) != 0;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -79,7 +79,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
bool is_set() const
|
||||
{
|
||||
return ((flags & STATE) > OFF);
|
||||
return ((flags & State) > Off);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -88,7 +88,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
bool is_held() const
|
||||
{
|
||||
return (flags & STATE) > ON;
|
||||
return (flags & State) > On;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -97,27 +97,27 @@ namespace etl
|
||||
//*************************************************************************
|
||||
bool is_repeating() const
|
||||
{
|
||||
return ((flags & STATE) == REPEATING);
|
||||
return ((flags & State) == Repeating);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
enum states
|
||||
{
|
||||
OFF = 0,
|
||||
ON = 1,
|
||||
HELD = 2,
|
||||
REPEATING = 3,
|
||||
STATE = 0x03U,
|
||||
SAMPLE = 4,
|
||||
CHANGE = 8
|
||||
Off = 0,
|
||||
On = 1,
|
||||
Held = 2,
|
||||
Repeating = 3,
|
||||
State = 0x03U,
|
||||
Sample = 4,
|
||||
Change = 8
|
||||
};
|
||||
|
||||
protected:
|
||||
|
||||
//*************************************************************************
|
||||
/// Constructor.
|
||||
//*************************************************************************
|
||||
debounce_base(bool initial_state)
|
||||
: flags(initial_state ? ON : OFF),
|
||||
: flags(initial_state ? On : Off),
|
||||
count(0)
|
||||
{
|
||||
}
|
||||
@ -134,21 +134,21 @@ namespace etl
|
||||
//*************************************************************************
|
||||
void get_next(bool sample, bool condition_set, bool condition_clear, const uint_least8_t state_table[][2])
|
||||
{
|
||||
int index1 = ((flags & STATE) * 2) + (sample ? 1 : 0);
|
||||
int index1 = ((flags & State) * 2) + (sample ? 1 : 0);
|
||||
int index2 = (sample ? (condition_set ? 0 : 1) : (condition_clear ? 0 : 1));
|
||||
|
||||
flags_t next = flags;
|
||||
|
||||
next &= ~STATE;
|
||||
next &= ~State;
|
||||
next |= state_table[index1][index2];
|
||||
|
||||
if (next != flags)
|
||||
{
|
||||
next |= CHANGE;
|
||||
next |= Change;
|
||||
}
|
||||
else
|
||||
{
|
||||
next &= ~CHANGE;
|
||||
next &= ~Change;
|
||||
}
|
||||
|
||||
flags = next;
|
||||
@ -184,10 +184,10 @@ namespace etl
|
||||
{
|
||||
static ETL_CONSTANT uint_least8_t state_table[4][2] =
|
||||
{
|
||||
/* OFF 0 */{ debounce_base::OFF, debounce_base::OFF },
|
||||
/* OFF 1 */{ debounce_base::ON, debounce_base::OFF },
|
||||
/* ON 0 */{ debounce_base::OFF, debounce_base::ON },
|
||||
/* ON 1 */{ debounce_base::ON, debounce_base::ON },
|
||||
/* Off 0 */{ debounce_base::Off, debounce_base::Off },
|
||||
/* Off 1 */{ debounce_base::On, debounce_base::Off },
|
||||
/* On 0 */{ debounce_base::Off, debounce_base::On },
|
||||
/* On 1 */{ debounce_base::On, debounce_base::On },
|
||||
};
|
||||
|
||||
get_next(sample, condition_set, condition_clear, state_table);
|
||||
@ -206,15 +206,15 @@ namespace etl
|
||||
|
||||
bool valid = (count == valid_count);
|
||||
|
||||
switch (flags & STATE)
|
||||
switch (flags & State)
|
||||
{
|
||||
case OFF:
|
||||
case Off:
|
||||
{
|
||||
set_state(sample, valid, valid);
|
||||
break;
|
||||
}
|
||||
|
||||
case ON:
|
||||
case On:
|
||||
{
|
||||
set_state(sample, valid, valid);
|
||||
break;
|
||||
@ -227,12 +227,12 @@ namespace etl
|
||||
}
|
||||
}
|
||||
|
||||
if (flags & CHANGE)
|
||||
if (flags & Change)
|
||||
{
|
||||
count = 0;
|
||||
}
|
||||
|
||||
return (flags & CHANGE);
|
||||
return (flags & Change);
|
||||
}
|
||||
};
|
||||
|
||||
@ -262,12 +262,12 @@ namespace etl
|
||||
{
|
||||
static ETL_CONSTANT uint_least8_t state_table[6][2] =
|
||||
{
|
||||
/* OFF 0 */{ debounce_base::OFF, debounce_base::OFF },
|
||||
/* OFF 1 */{ debounce_base::ON, debounce_base::OFF },
|
||||
/* ON 0 */{ debounce_base::OFF, debounce_base::ON },
|
||||
/* ON 1 */{ debounce_base::HELD, debounce_base::ON },
|
||||
/* HELD 0 */{ debounce_base::OFF, debounce_base::HELD },
|
||||
/* HELD 1 */{ debounce_base::HELD, debounce_base::HELD }
|
||||
/* Off 0 */{ debounce_base::Off, debounce_base::Off },
|
||||
/* Off 1 */{ debounce_base::On, debounce_base::Off },
|
||||
/* On 0 */{ debounce_base::Off, debounce_base::On },
|
||||
/* On 1 */{ debounce_base::Held, debounce_base::On },
|
||||
/* Held 0 */{ debounce_base::Off, debounce_base::Held },
|
||||
/* Held 1 */{ debounce_base::Held, debounce_base::Held }
|
||||
};
|
||||
|
||||
get_next(sample, condition_set, condition_clear, state_table);
|
||||
@ -287,21 +287,21 @@ namespace etl
|
||||
bool valid = (count == valid_count);
|
||||
bool hold = (count == hold_count);
|
||||
|
||||
switch (flags & STATE)
|
||||
switch (flags & State)
|
||||
{
|
||||
case OFF:
|
||||
case Off:
|
||||
{
|
||||
set_state(sample, valid, valid);
|
||||
break;
|
||||
}
|
||||
|
||||
case ON:
|
||||
case On:
|
||||
{
|
||||
set_state(sample, hold, valid);
|
||||
break;
|
||||
}
|
||||
|
||||
case HELD:
|
||||
case Held:
|
||||
{
|
||||
set_state(sample, hold, valid);
|
||||
break;
|
||||
@ -314,12 +314,12 @@ namespace etl
|
||||
}
|
||||
}
|
||||
|
||||
if (flags & CHANGE)
|
||||
if (flags & Change)
|
||||
{
|
||||
count = 0;
|
||||
}
|
||||
|
||||
return (flags & CHANGE);
|
||||
return (flags & Change);
|
||||
}
|
||||
};
|
||||
|
||||
@ -349,14 +349,14 @@ namespace etl
|
||||
{
|
||||
static ETL_CONSTANT uint_least8_t state_table[8][2] =
|
||||
{
|
||||
/* OFF 0 */{ debounce_base::OFF, debounce_base::OFF },
|
||||
/* OFF 1 */{ debounce_base::ON, debounce_base::OFF },
|
||||
/* ON 0 */{ debounce_base::OFF, debounce_base::ON },
|
||||
/* ON 1 */{ debounce_base::HELD, debounce_base::ON },
|
||||
/* HELD 0 */{ debounce_base::OFF, debounce_base::HELD },
|
||||
/* HELD 1 */{ debounce_base::REPEATING, debounce_base::HELD },
|
||||
/* REPEATING 0 */{ debounce_base::OFF, debounce_base::REPEATING },
|
||||
/* REPEATING 1 */{ debounce_base::REPEATING, debounce_base::REPEATING }
|
||||
/* Off 0 */{ debounce_base::Off, debounce_base::Off },
|
||||
/* Off 1 */{ debounce_base::On, debounce_base::Off },
|
||||
/* On 0 */{ debounce_base::Off, debounce_base::On },
|
||||
/* On 1 */{ debounce_base::Held, debounce_base::On },
|
||||
/* Held 0 */{ debounce_base::Off, debounce_base::Held },
|
||||
/* Held 1 */{ debounce_base::Repeating, debounce_base::Held },
|
||||
/* Repeating 0 */{ debounce_base::Off, debounce_base::Repeating },
|
||||
/* Repeating 1 */{ debounce_base::Repeating, debounce_base::Repeating }
|
||||
};
|
||||
|
||||
get_next(sample, condition_set, condition_clear, state_table);
|
||||
@ -377,34 +377,34 @@ namespace etl
|
||||
bool hold = (count == hold_count);
|
||||
bool repeat = (count == repeat_count);
|
||||
|
||||
switch (flags & STATE)
|
||||
switch (flags & State)
|
||||
{
|
||||
case OFF:
|
||||
case Off:
|
||||
{
|
||||
set_state(sample, valid, valid);
|
||||
break;
|
||||
}
|
||||
|
||||
case ON:
|
||||
case On:
|
||||
{
|
||||
set_state(sample, hold, valid);
|
||||
break;
|
||||
}
|
||||
|
||||
case HELD:
|
||||
case Held:
|
||||
{
|
||||
set_state(sample, repeat, valid);
|
||||
break;
|
||||
}
|
||||
|
||||
case REPEATING:
|
||||
case Repeating:
|
||||
{
|
||||
set_state(sample, repeat, valid);
|
||||
|
||||
if (sample && repeat)
|
||||
{
|
||||
count = 0;
|
||||
flags |= CHANGE;
|
||||
flags |= Change;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -416,12 +416,12 @@ namespace etl
|
||||
}
|
||||
}
|
||||
|
||||
if (flags & CHANGE)
|
||||
if (flags & Change)
|
||||
{
|
||||
count = 0;
|
||||
}
|
||||
|
||||
return (flags & CHANGE);
|
||||
return (flags & Change);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -36,7 +36,7 @@ SOFTWARE.
|
||||
|
||||
namespace etl
|
||||
{
|
||||
namespace private_cumulative_moving_average
|
||||
namespace private_pseudo_moving_average
|
||||
{
|
||||
//***************************************************
|
||||
/// add_insert_iterator
|
||||
@ -95,7 +95,7 @@ namespace etl
|
||||
const size_t SCALING = 1U,
|
||||
const bool IsIntegral = etl::is_integral<T>::value,
|
||||
const bool IsFloat = etl::is_floating_point<T>::value>
|
||||
class cumulative_moving_average;
|
||||
class pseudo_moving_average;
|
||||
|
||||
//***************************************************************************
|
||||
/// Cumulative Moving Average
|
||||
@ -105,11 +105,11 @@ namespace etl
|
||||
/// \tparam SCALING The scaling factor applied to samples. Default = 1.
|
||||
//***************************************************************************
|
||||
template <typename T, const size_t SAMPLE_SIZE_, const size_t SCALING_>
|
||||
class cumulative_moving_average<T, SAMPLE_SIZE_, SCALING_, true, false>
|
||||
class pseudo_moving_average<T, SAMPLE_SIZE_, SCALING_, true, false>
|
||||
{
|
||||
private:
|
||||
|
||||
typedef cumulative_moving_average<T, SAMPLE_SIZE_, SCALING_, true, false> this_t;
|
||||
typedef pseudo_moving_average<T, SAMPLE_SIZE_, SCALING_, true, false> this_t;
|
||||
|
||||
typedef typename etl::conditional<etl::is_signed<T>::value, int32_t, uint32_t>::type scale_t;
|
||||
typedef typename etl::conditional<etl::is_signed<T>::value, int32_t, uint32_t>::type sample_t;
|
||||
@ -120,7 +120,7 @@ namespace etl
|
||||
public:
|
||||
|
||||
typedef T value_type;
|
||||
typedef private_cumulative_moving_average::add_insert_iterator<this_t> add_insert_iterator;
|
||||
typedef private_pseudo_moving_average::add_insert_iterator<this_t> add_insert_iterator;
|
||||
|
||||
static ETL_CONSTANT size_t SAMPLE_SIZE = SAMPLE_SIZE_; ///< The number of samples averaged over.
|
||||
static ETL_CONSTANT size_t SCALING = SCALING_; ///< The sample scaling factor.
|
||||
@ -129,7 +129,7 @@ namespace etl
|
||||
/// Constructor
|
||||
/// \param initial_value The initial value for the average.
|
||||
//*************************************************************************
|
||||
cumulative_moving_average(const T initial_value)
|
||||
pseudo_moving_average(const T initial_value)
|
||||
: average(initial_value * SCALE)
|
||||
{
|
||||
}
|
||||
@ -155,7 +155,7 @@ namespace etl
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Gets the current cumulative average.
|
||||
/// Gets the current pseudo moving average.
|
||||
/// \return The current average.
|
||||
//*************************************************************************
|
||||
T value() const
|
||||
@ -174,7 +174,7 @@ namespace etl
|
||||
|
||||
private:
|
||||
|
||||
T average; ///< The current cumulative average.
|
||||
T average; ///< The current pseudo moving average.
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
@ -184,9 +184,9 @@ namespace etl
|
||||
/// \tparam SCALING The scaling factor applied to samples. Default = 1.
|
||||
//***************************************************************************
|
||||
template <typename T, const size_t SCALING_>
|
||||
class cumulative_moving_average<T, 0, SCALING_, true, false>
|
||||
class pseudo_moving_average<T, 0, SCALING_, true, false>
|
||||
{
|
||||
typedef cumulative_moving_average<T, 0, SCALING_, true, false> this_t;
|
||||
typedef pseudo_moving_average<T, 0, SCALING_, true, false> this_t;
|
||||
|
||||
typedef typename etl::conditional<etl::is_signed<T>::value, int32_t, uint32_t>::type scale_t;
|
||||
typedef typename etl::conditional<etl::is_signed<T>::value, int32_t, uint32_t>::type sample_t;
|
||||
@ -196,7 +196,7 @@ namespace etl
|
||||
public:
|
||||
|
||||
typedef T value_type;
|
||||
typedef private_cumulative_moving_average::add_insert_iterator<this_t> add_insert_iterator;
|
||||
typedef private_pseudo_moving_average::add_insert_iterator<this_t> add_insert_iterator;
|
||||
|
||||
static ETL_CONSTANT size_t SCALING = SCALING_; ///< The sample scaling factor.
|
||||
|
||||
@ -204,7 +204,7 @@ namespace etl
|
||||
/// Constructor
|
||||
/// \param initial_value The initial value for the average.
|
||||
//*************************************************************************
|
||||
cumulative_moving_average(const T initial_value, const size_t sample_size)
|
||||
pseudo_moving_average(const T initial_value, const size_t sample_size)
|
||||
: average(initial_value * SCALE)
|
||||
, samples(sample_t(sample_size))
|
||||
{
|
||||
@ -240,7 +240,7 @@ namespace etl
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Gets the current cumulative average.
|
||||
/// Gets the current pseudo moving average.
|
||||
/// \return The current average.
|
||||
//*************************************************************************
|
||||
T value() const
|
||||
@ -259,7 +259,7 @@ namespace etl
|
||||
|
||||
private:
|
||||
|
||||
T average; ///< The current cumulative average.
|
||||
T average; ///< The current pseudo moving average.
|
||||
sample_t samples; ///< The number of samples to average over.
|
||||
};
|
||||
|
||||
@ -270,14 +270,14 @@ namespace etl
|
||||
/// \tparam SAMPLE_SIZE The number of samples to average over.
|
||||
//***************************************************************************
|
||||
template <typename T, const size_t SAMPLE_SIZE_>
|
||||
class cumulative_moving_average<T, SAMPLE_SIZE_, 1U, false, true>
|
||||
class pseudo_moving_average<T, SAMPLE_SIZE_, 1U, false, true>
|
||||
{
|
||||
typedef cumulative_moving_average<T, SAMPLE_SIZE_, 1U, false, true> this_t;
|
||||
typedef pseudo_moving_average<T, SAMPLE_SIZE_, 1U, false, true> this_t;
|
||||
|
||||
public:
|
||||
|
||||
typedef T value_type;
|
||||
typedef private_cumulative_moving_average::add_insert_iterator<this_t> add_insert_iterator;
|
||||
typedef private_pseudo_moving_average::add_insert_iterator<this_t> add_insert_iterator;
|
||||
|
||||
static ETL_CONSTANT size_t SAMPLE_SIZE = SAMPLE_SIZE_;
|
||||
|
||||
@ -285,7 +285,7 @@ namespace etl
|
||||
/// Constructor
|
||||
/// \param initial_value The initial value for the average.
|
||||
//*************************************************************************
|
||||
cumulative_moving_average(const T initial_value)
|
||||
pseudo_moving_average(const T initial_value)
|
||||
: reciprocal_samples_plus_1(T(1.0) / T(SAMPLE_SIZE_ + 1U))
|
||||
, average(initial_value)
|
||||
{
|
||||
@ -310,7 +310,7 @@ namespace etl
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Gets the current cumulative average.
|
||||
/// Gets the current pseudo moving average.
|
||||
/// \return The current average.
|
||||
//*************************************************************************
|
||||
T value() const
|
||||
@ -330,7 +330,7 @@ namespace etl
|
||||
private:
|
||||
|
||||
const T reciprocal_samples_plus_1; ///< Reciprocal of one greater than the sample size.
|
||||
T average; ///< The current cumulative average.
|
||||
T average; ///< The current pseudo moving average.
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
@ -340,20 +340,20 @@ namespace etl
|
||||
/// \tparam SAMPLE_SIZE The number of samples to average over.
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
class cumulative_moving_average<T, 0U, 1U, false, true>
|
||||
class pseudo_moving_average<T, 0U, 1U, false, true>
|
||||
{
|
||||
typedef cumulative_moving_average<T, 0U, 1U, false, true> this_t;
|
||||
typedef pseudo_moving_average<T, 0U, 1U, false, true> this_t;
|
||||
|
||||
public:
|
||||
|
||||
typedef T value_type;
|
||||
typedef private_cumulative_moving_average::add_insert_iterator<this_t> add_insert_iterator;
|
||||
typedef private_pseudo_moving_average::add_insert_iterator<this_t> add_insert_iterator;
|
||||
|
||||
//*************************************************************************
|
||||
/// Constructor
|
||||
/// \param initial_value The initial value for the average.
|
||||
//*************************************************************************
|
||||
cumulative_moving_average(const T initial_value, const size_t sample_size)
|
||||
pseudo_moving_average(const T initial_value, const size_t sample_size)
|
||||
: reciprocal_samples_plus_1(T(1.0) / T(sample_size + 1U))
|
||||
, average(initial_value)
|
||||
{
|
||||
@ -387,7 +387,7 @@ namespace etl
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Gets the current cumulative average.
|
||||
/// Gets the current pseudo moving average.
|
||||
/// \return The current average.
|
||||
//*************************************************************************
|
||||
T value() const
|
||||
@ -407,7 +407,7 @@ namespace etl
|
||||
private:
|
||||
|
||||
T reciprocal_samples_plus_1; ///< Reciprocal of one greater than the sample size.
|
||||
T average; ///< The current cumulative average.
|
||||
T average; ///< The current pseudo moving average.
|
||||
};
|
||||
}
|
||||
|
||||
@ -13,6 +13,8 @@ Refactors etl::vector and etl::deque resize() to take const reference parameter
|
||||
Renamed ETL_ALWAYS_ASSERT to ETL_ASSERT_FAIL
|
||||
Removed duplicate void_t definition
|
||||
Removed duplicate etl::declvar definition
|
||||
Renamed cumulative_moving_average to pseudo_windowed_moving_average to more accurately reflect its algorithm.
|
||||
Changed etl::debounce internal state names to avoid clashes with Arduino macros.
|
||||
|
||||
===============================================================================
|
||||
20.28.0
|
||||
|
||||
@ -118,7 +118,6 @@ set(TEST_SOURCE_FILES
|
||||
test_crc8_maxim.cpp
|
||||
test_crc8_rohc.cpp
|
||||
test_crc8_wcdma.cpp
|
||||
test_cumulative_moving_average.cpp
|
||||
test_cyclic_value.cpp
|
||||
test_debounce.cpp
|
||||
test_delegate.cpp
|
||||
@ -200,6 +199,7 @@ set(TEST_SOURCE_FILES
|
||||
test_pool.cpp
|
||||
test_pool_external_buffer.cpp
|
||||
test_priority_queue.cpp
|
||||
test_pseudo_moving_average.cpp
|
||||
test_quantize.cpp
|
||||
test_queue.cpp
|
||||
test_queue_lockable.cpp
|
||||
|
||||
@ -26,4 +26,4 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
******************************************************************************/
|
||||
|
||||
#include <etl/cumulative_moving_average.h>
|
||||
#include <etl/pseudo_moving_average.h>
|
||||
|
||||
@ -31,7 +31,7 @@ SOFTWARE.
|
||||
#include <array>
|
||||
#include <algorithm>
|
||||
|
||||
#include "etl/cumulative_moving_average.h"
|
||||
#include "etl/pseudo_moving_average.h"
|
||||
#include "etl/scaled_rounding.h"
|
||||
|
||||
namespace
|
||||
@ -39,12 +39,12 @@ namespace
|
||||
const size_t SAMPLE_SIZE = 10UL;
|
||||
const size_t SCALING = 100UL;
|
||||
|
||||
SUITE(test_cumulative_moving_average)
|
||||
SUITE(test_pseudo_moving_average)
|
||||
{
|
||||
//*************************************************************************
|
||||
TEST(integral_signed_average_positive)
|
||||
{
|
||||
using CMA = etl::cumulative_moving_average<int, SAMPLE_SIZE, SCALING>;
|
||||
using CMA = etl::pseudo_moving_average<int, SAMPLE_SIZE, SCALING>;
|
||||
CMA cma(0);
|
||||
|
||||
CHECK_EQUAL(0, cma.value());
|
||||
@ -67,7 +67,7 @@ namespace
|
||||
{
|
||||
std::array data{ 9, 1, 8, 2, 7, 3, 6, 4, 5 };
|
||||
|
||||
using CMA = etl::cumulative_moving_average<int, SAMPLE_SIZE, SCALING>;
|
||||
using CMA = etl::pseudo_moving_average<int, SAMPLE_SIZE, SCALING>;
|
||||
CMA cma(0);
|
||||
|
||||
CHECK_EQUAL(0, cma.value());
|
||||
@ -80,7 +80,7 @@ namespace
|
||||
//*************************************************************************
|
||||
TEST(integral_signed_average_negative)
|
||||
{
|
||||
using CMA = etl::cumulative_moving_average<int, SAMPLE_SIZE, SCALING>;
|
||||
using CMA = etl::pseudo_moving_average<int, SAMPLE_SIZE, SCALING>;
|
||||
CMA cma(0);
|
||||
|
||||
CHECK_EQUAL(0, cma.value());
|
||||
@ -103,7 +103,7 @@ namespace
|
||||
{
|
||||
std::array data{ -9, -1, -8, -2, -7, -3, -6, -4, -5 };
|
||||
|
||||
using CMA = etl::cumulative_moving_average<int, SAMPLE_SIZE, SCALING>;
|
||||
using CMA = etl::pseudo_moving_average<int, SAMPLE_SIZE, SCALING>;
|
||||
CMA cma(0);
|
||||
|
||||
CHECK_EQUAL(0, cma.value());
|
||||
@ -116,7 +116,7 @@ namespace
|
||||
//*************************************************************************
|
||||
TEST(integral_unsigned_average_positive)
|
||||
{
|
||||
using CMA = etl::cumulative_moving_average<unsigned int, SAMPLE_SIZE, SCALING>;
|
||||
using CMA = etl::pseudo_moving_average<unsigned int, SAMPLE_SIZE, SCALING>;
|
||||
CMA cma(0U);
|
||||
|
||||
CHECK_EQUAL(0U, cma.value());
|
||||
@ -139,7 +139,7 @@ namespace
|
||||
{
|
||||
std::array data{ 9U, 1U, 8U, 2U, 7U, 3U, 6U, 4U, 5U };
|
||||
|
||||
using CMA = etl::cumulative_moving_average<unsigned int, SAMPLE_SIZE, SCALING>;
|
||||
using CMA = etl::pseudo_moving_average<unsigned int, SAMPLE_SIZE, SCALING>;
|
||||
CMA cma(0U);
|
||||
|
||||
CHECK_EQUAL(0U, cma.value());
|
||||
@ -152,7 +152,7 @@ namespace
|
||||
//*************************************************************************
|
||||
TEST(integral_signed_average_positive_runtime_sample_size)
|
||||
{
|
||||
using CMA = etl::cumulative_moving_average<int, 0U, SCALING>;
|
||||
using CMA = etl::pseudo_moving_average<int, 0U, SCALING>;
|
||||
CMA cma(0, SAMPLE_SIZE * 2U);
|
||||
|
||||
CHECK_EQUAL(0, cma.value());
|
||||
@ -177,7 +177,7 @@ namespace
|
||||
{
|
||||
std::array data{ 9, 1, 8, 2, 7, 3, 6, 4, 5 };
|
||||
|
||||
using CMA = etl::cumulative_moving_average<int, 0U, SCALING>;
|
||||
using CMA = etl::pseudo_moving_average<int, 0U, SCALING>;
|
||||
CMA cma(0, SAMPLE_SIZE * 2U);
|
||||
|
||||
CHECK_EQUAL(0, cma.value());
|
||||
@ -192,7 +192,7 @@ namespace
|
||||
//*************************************************************************
|
||||
TEST(integral_signed_average_negative_runtime_sample_size)
|
||||
{
|
||||
using CMA = etl::cumulative_moving_average<int, 0U, SCALING>;
|
||||
using CMA = etl::pseudo_moving_average<int, 0U, SCALING>;
|
||||
CMA cma(0, SAMPLE_SIZE * 2U);
|
||||
|
||||
CHECK_EQUAL(0, cma.value());
|
||||
@ -217,7 +217,7 @@ namespace
|
||||
{
|
||||
std::array data{ -9, -1, -8, -2, -7, -3, -6, -4, -5 };
|
||||
|
||||
using CMA = etl::cumulative_moving_average<int, 0U, SCALING>;
|
||||
using CMA = etl::pseudo_moving_average<int, 0U, SCALING>;
|
||||
CMA cma(0, SAMPLE_SIZE * 2U);
|
||||
|
||||
CHECK_EQUAL(0, cma.value());
|
||||
@ -232,7 +232,7 @@ namespace
|
||||
//*************************************************************************
|
||||
TEST(integral_unsigned_average_positive_runtime_sample_size)
|
||||
{
|
||||
using CMA = etl::cumulative_moving_average<unsigned int, 0U, SCALING>;
|
||||
using CMA = etl::pseudo_moving_average<unsigned int, 0U, SCALING>;
|
||||
CMA cma(0U, SAMPLE_SIZE * 2U);
|
||||
|
||||
CHECK_EQUAL(0U, cma.value());
|
||||
@ -257,7 +257,7 @@ namespace
|
||||
{
|
||||
std::array data{ 9U, 1U, 8U, 2U, 7U, 3U, 6U, 4U, 5U };
|
||||
|
||||
using CMA = etl::cumulative_moving_average<int, 0U, SCALING>;
|
||||
using CMA = etl::pseudo_moving_average<int, 0U, SCALING>;
|
||||
CMA cma(0U, SAMPLE_SIZE * 2U);
|
||||
|
||||
CHECK_EQUAL(0U, cma.value());
|
||||
@ -272,7 +272,7 @@ namespace
|
||||
//*************************************************************************
|
||||
TEST(floating_point_average)
|
||||
{
|
||||
using CMA = etl::cumulative_moving_average<double, SAMPLE_SIZE>;
|
||||
using CMA = etl::pseudo_moving_average<double, SAMPLE_SIZE>;
|
||||
CMA cma(0);
|
||||
|
||||
CHECK_EQUAL(0.0, cma.value());
|
||||
@ -295,7 +295,7 @@ namespace
|
||||
{
|
||||
std::array data{ 9.0, 1.0, 8.0, 2.0, 7.0, 3.0, 6.0, 4.0, 5.0 };
|
||||
|
||||
using CMA = etl::cumulative_moving_average<double, SAMPLE_SIZE>;
|
||||
using CMA = etl::pseudo_moving_average<double, SAMPLE_SIZE>;
|
||||
CMA cma(0);
|
||||
|
||||
CHECK_EQUAL(0.0, cma.value());
|
||||
@ -308,7 +308,7 @@ namespace
|
||||
//*************************************************************************
|
||||
TEST(floating_point_average_runtime_sample_size)
|
||||
{
|
||||
using CMA = etl::cumulative_moving_average<double, 0U>;
|
||||
using CMA = etl::pseudo_moving_average<double, 0U>;
|
||||
CMA cma(0, SAMPLE_SIZE * 2);
|
||||
|
||||
CHECK_EQUAL(0.0, cma.value());
|
||||
@ -333,7 +333,7 @@ namespace
|
||||
{
|
||||
std::array data{ 9.0, 1.0, 8.0, 2.0, 7.0, 3.0, 6.0, 4.0, 5.0 };
|
||||
|
||||
using CMA = etl::cumulative_moving_average<double, 0U>;
|
||||
using CMA = etl::pseudo_moving_average<double, 0U>;
|
||||
CMA cma(0, SAMPLE_SIZE * 2);
|
||||
|
||||
CHECK_EQUAL(0.0, cma.value());
|
||||
@ -2411,7 +2411,7 @@
|
||||
<ClInclude Include="..\..\include\etl\crc8_maxim.h" />
|
||||
<ClInclude Include="..\..\include\etl\crc8_rohc.h" />
|
||||
<ClInclude Include="..\..\include\etl\crc8_wcdma.h" />
|
||||
<ClInclude Include="..\..\include\etl\cumulative_moving_average.h" />
|
||||
<ClInclude Include="..\..\include\etl\pseudo_moving_average.h" />
|
||||
<ClInclude Include="..\..\include\etl\delegate.h" />
|
||||
<ClInclude Include="..\..\include\etl\delegate_service.h" />
|
||||
<ClInclude Include="..\..\include\etl\file_error_numbers.h" />
|
||||
@ -10973,7 +10973,7 @@
|
||||
<ClCompile Include="..\test_crc8_maxim.cpp" />
|
||||
<ClCompile Include="..\test_crc8_rohc.cpp" />
|
||||
<ClCompile Include="..\test_crc8_wcdma.cpp" />
|
||||
<ClCompile Include="..\test_cumulative_moving_average.cpp" />
|
||||
<ClCompile Include="..\test_pseudo_moving_average.cpp" />
|
||||
<ClCompile Include="..\test_delegate.cpp" />
|
||||
<ClCompile Include="..\test_delegate_cpp03.cpp" />
|
||||
<ClCompile Include="..\test_delegate_service.cpp" />
|
||||
|
||||
@ -588,7 +588,7 @@
|
||||
<ClInclude Include="..\..\include\etl\state_chart.h">
|
||||
<Filter>ETL\Frameworks</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\etl\cumulative_moving_average.h">
|
||||
<ClInclude Include="..\..\include\etl\pseudo_moving_average.h">
|
||||
<Filter>ETL\Maths</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\etl\scaled_rounding.h">
|
||||
@ -1790,7 +1790,7 @@
|
||||
<ClCompile Include="..\test_covariance.cpp">
|
||||
<Filter>Tests\Algorithms</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\test_cumulative_moving_average.cpp">
|
||||
<ClCompile Include="..\test_pseudo_moving_average.cpp">
|
||||
<Filter>Tests\Algorithms</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\test_cyclic_value.cpp">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user