6#include <initializer_list>
19 template <
class Tself,
typename Tdata>
25 static_assert(std::is_arithmetic<Tdata>::value,
"Tdata must be an arithmetic type");
32 static constexpr Tdata MIN_ELEMENT = std::numeric_limits<Tdata>::lowest();
38 static constexpr Tdata MAX_ELEMENT = std::numeric_limits<Tdata>::max();
69 Tdata result = ArithmeticBuffer::MAX_ELEMENT;
70 for (
size_t i = 0; i < this->size; ++i)
72 if (this->pData[i] < result)
74 result = this->pData[i];
86 Tdata result = ArithmeticBuffer::MIN_ELEMENT;
87 for (
size_t i = 0; i < this->size; ++i)
89 if (this->pData[i] > result)
91 result = this->pData[i];
105 double sumSquared = 0;
106 for (
size_t i = 0; i < this->size; ++i)
108 sumSquared += this->pData[i] * this->pData[i];
110 return std::sqrt(sumSquared / this->size);
116 static inline bool ADD_EVENT_HANDLERS =
false;
117 static void AddEventHandlers()
119 if (!ArithmeticBuffer::ADD_EVENT_HANDLERS)
123 ArithmeticBuffer::ADD_EVENT_HANDLERS =
true;
127 template<
typename Rhs>
128 static void ResultCreatedEventHandler(
const EventParams& params)
130 BufferOperatorResultCreatedEventArgs<Tself, Rhs>* pArgs = (BufferOperatorResultCreatedEventArgs<Tself, Rhs>*)params.pArgs;
132 pArgs->result.pData = ArithmeticBuffer::AllocateUninitialized(pArgs->lhs.SizeAsByte());
133 pArgs->result.size = pArgs->lhs.size;
143 template <
class Tself,
typename Tdata>
148 static_assert(std::is_signed<Tdata>::value,
"Tdata must be a signed type");
179 for (
size_t i = 0; i < this->size; ++i)
181 this->pData[i] = -this->pData[i];
192 for (
size_t i = 0; i < this->size; ++i)
194 const Tdata abs_current = std::abs(this->pData[i]);
195 if (abs_current > result)
197 result = abs_current;
BufferFlags
Definition BufferBase.h:13
#define HEPH_API
Definition HephShared.h:132
base class for buffers that store arithmetic types. Provides operations and methods for arithmetic da...
Definition ArithmeticBuffer.h:24
ArithmeticBuffer(ArithmeticBuffer &&rhs) noexcept
Definition ArithmeticBuffer.h:57
Tdata Max() const
Definition ArithmeticBuffer.h:84
ArithmeticBuffer(const std::initializer_list< Tdata > &rhs)
Definition ArithmeticBuffer.h:51
ArithmeticBuffer(size_t size)
Definition ArithmeticBuffer.h:45
double Rms() const
Definition ArithmeticBuffer.h:101
ArithmeticBuffer(size_t size, BufferFlags flags)
Definition ArithmeticBuffer.h:48
ArithmeticBuffer()
Definition ArithmeticBuffer.h:42
Tdata Min() const
Definition ArithmeticBuffer.h:67
ArithmeticBuffer(const ArithmeticBuffer &rhs)
Definition ArithmeticBuffer.h:54
virtual ~ArithmeticBuffer()=default
provides arithmetic operators to the buffer.
Definition BufferOperators.h:595
base class for buffers. Provides basic buffer operations and methods.
Definition BufferBase.h:31
provides unary minus operator to the buffer.
Definition BufferOperators.h:609
base class for buffers that store signed arithmetic types. Provides operations and methods for signed...
Definition ArithmeticBuffer.h:147
SignedArithmeticBuffer(size_t size, BufferFlags flags)
Definition ArithmeticBuffer.h:158
SignedArithmeticBuffer()
Definition ArithmeticBuffer.h:152
virtual ~SignedArithmeticBuffer()=default
SignedArithmeticBuffer(SignedArithmeticBuffer &&rhs) noexcept
Definition ArithmeticBuffer.h:167
Tdata AbsMax() const
Definition ArithmeticBuffer.h:189
SignedArithmeticBuffer(const SignedArithmeticBuffer &rhs)
Definition ArithmeticBuffer.h:164
SignedArithmeticBuffer(const std::initializer_list< Tdata > &rhs)
Definition ArithmeticBuffer.h:161
SignedArithmeticBuffer(size_t size)
Definition ArithmeticBuffer.h:155
void Invert()
Definition ArithmeticBuffer.h:177
Definition BufferOperators.h:28