1#ifndef SXEVAL_OPERATIONS_AVERAGE_HPP
2#define SXEVAL_OPERATIONS_AVERAGE_HPP
15 static constexpr const char*
KEY =
"avg";
39 this->_result =
static_cast<T
>(0);
40 for (
const auto& arg : this->_args) {
41 this->_result += arg.get();
43 this->_result /=
static_cast<T
>(this->_args.size());
The AOperation class is an abstract base class for operations in the SXEval library.
Definition AOperation.hpp:22
The IInstruction class is an interface for any instructions.
Definition IInstruction.hpp:21
Definition Average.hpp:13
std::string toString() const override
String representation of the instruction.
Definition Average.hpp:24
void execute() override
Execute the operation.
Definition Average.hpp:38
static constexpr const char * KEY
Definition Average.hpp:15
Average(const std::vector< IInstruction< T > * > &args)
Definition Average.hpp:19
static constexpr const int ARITY_MIN
Definition Average.hpp:16
static constexpr const int ARITY_MAX
Definition Average.hpp:17
Definition AOperation.hpp:8
std::enable_if< std::is_unsigned< T >::value, T >::type Absolute(const T &a)
Perform an absolute value operation on types T.
Definition utils.hpp:262