eDSP  0.0.1
A cross-platform DSP library written in C++.
Functions
edsp::algorithm Namespace Reference

Functions

template<typename InputIt , typename OutputIt , typename Numeric >
constexpr void amplifier (InputIt first, InputIt last, OutputIt d_first, Numeric factor)
 Amplifies or attenuates the elements in the range [first, last) and stores the result in another range, beginning at d_first. More...
 
template<typename InputIt , typename OutputIt , typename Numeric >
constexpr void amplifier (InputIt first, InputIt last, OutputIt d_first, Numeric factor, Numeric min, Numeric max)
 Amplifies the signal in the range [first, last) and stores the result in another range, beginning at d_first. More...
 
template<typename ForwardIt >
constexpr ForwardIt binary_search (ForwardIt first, ForwardIt last, const meta::value_type_t< ForwardIt > &value)
 Checks if an element equivalent to value appears within the range [first, last). More...
 
template<typename InputIt , typename OutputIt >
constexpr void ceil (InputIt first, InputIt last, OutputIt d_first)
 For each element in the range [first, last) computes the smallest integer value not less than the element's value and stores the result in another range, beginning at d_first. More...
 
template<typename InputItr , typename OutputIt , typename Numeric >
constexpr void clipper (InputItr first, InputItr last, OutputIt d_first, Numeric min, Numeric max)
 Limits the values of the elements in the range [first, last) once it exceeds a threshold [min, max], and stores the result in another range, beginning at d_first. More...
 
template<typename InputIt , typename OutputIt >
constexpr void concatenate (InputIt first1, InputIt last1, InputIt first2, InputIt last2, OutputIt d_first)
 Concatenates the elements defined in the range [firs1, last1) and [first2, last2), and stores the result in another range, beginning at d_first. More...
 
template<typename InputItr , typename OutputIt , typename Numeric >
constexpr void derivative (InputItr first, InputItr last, OutputIt d_first)
 Computes the first order derivative of the elements in the range [first, last), and stores the result in another range, beginning at d_first. More...
 
template<typename ForwardIt1 , typename ForwardIt2 , typename BinaryPredicate >
constexpr bool equal (ForwardIt1 first1, ForwardIt2 last1, ForwardIt2 first2, ForwardIt2 last2, BinaryPredicate p)
 Returns true if the range [first1, last1) is equal to the range [first2, last2), and false otherwise. More...
 
template<typename ForwardIt1 , typename ForwardIt2 >
constexpr bool equal (ForwardIt1 first1, ForwardIt2 last1, ForwardIt2 first2, ForwardIt2 last2)
 Returns true if the range [first1, last1) is equal to the range [first2, last2), and false otherwise. More...
 
template<typename InputIt , typename OutputIt >
constexpr void fix (InputIt first, InputIt last, OutputIt d_first)
 For each element in the range [first, last) computes the nearest integer not greater in magnitude than the element's value and stores the result in another range, beginning at d_first. More...
 
template<typename InputIt , typename OutputIt >
constexpr void floor (InputIt first, InputIt last, OutputIt d_first)
 For each element in the range [first, last) computes the largest integer value not greater than the element's value and stores the result in another range, beginning at d_first. More...
 
template<typename ForwardIt >
constexpr std::int32_t indexof (ForwardIt first, ForwardIt last, const typename std::iterator_traits< ForwardIt >::value_type &value)
 Searches for an element equivalent to value in the range [first, last) and returns its position. More...
 
template<typename ForwardIt , class UnaryPredicate >
constexpr ForwardIt binary_search (ForwardIt first, ForwardIt last, UnaryPredicate p)
 Searches for an element for which predicate p returns true in the range [first, last). More...
 
template<typename OutputIt , typename Numeric >
constexpr void linspace (OutputIt d_first, Numeric N, meta::value_type_t< OutputIt > x1, meta::value_type_t< OutputIt > x2)
 Generate N linearly spaced values between the range [x1,x2] and stores the result in another range, beginning at d_first. More...
 
template<typename OutputIt , typename Numeric >
constexpr void logspace (OutputIt d_first, Numeric N, meta::value_type_t< OutputIt > x1, meta::value_type_t< OutputIt > x2)
 Generate N logarithmic spaced values between the range [x1,x2] and stores the result in another range, beginning at d_first. More...
 
template<typename InputIt , typename OutputIt >
constexpr void normalize (InputIt first, InputIt last, OutputIt d_first)
 Normalizes the elements in the range [first, last) and stores the result in another range, beginning at d_first. More...
 
template<typename InputIt , typename OutputIt >
constexpr void normalize_rms (InputIt first, InputIt last, OutputIt d_first)
 Normalizes the elements in the range [first, last) and stores the result in another range, beginning at d_first. More...
 
template<typename InputIt , typename OutputIt >
constexpr void padder (InputIt first, InputIt last, OutputIt d_first, OutputIt d_last)
 Extends the signal defined in the range [first, last) with zeros and stores the result in the range [d_first, d_last]. More...
 
template<typename InputIt , typename OutputIt >
constexpr void rectify (InputIt first, InputIt last, OutputIt d_first)
 For each element in the range [first, last) computes the absolute value not and stores the result in another range, beginning at d_first. More...
 
template<typename InputIt , typename OutputIt >
constexpr void round (InputIt first, InputIt last, OutputIt d_first)
 For each element in the range [first, last) computes the nearest integer value to the element's value rounding halfway cases away from zero, and stores the result in another range, beginning at d_first. More...
 
template<typename InputIt , typename OutputIt , typename Numeric >
constexpr bool silence (InputIt first, InputIt last, Numeric threshold)
 Checks if the elements in the range [first, last) are a silenced frame. More...
 

Function Documentation

◆ amplifier() [1/2]

template<typename InputIt , typename OutputIt , typename Numeric >
constexpr void edsp::algorithm::amplifier ( InputIt  first,
InputIt  last,
OutputIt  d_first,
Numeric  factor 
)

Amplifies or attenuates the elements in the range [first, last) and stores the result in another range, beginning at d_first.

This function increases the amplitude of the input signal defined in the range [first, last). The output signal is a proportionally amplitude signal dependent of the scale factor ( \( \alpha \)):

\[ y(n) = \alpha x(n) \]

Parameters
firstInput iterator defining the beginning of the input range.
lastInput iterator defining the ending of the input range.
d_firstOutput iterator defining the beginning of the destination range.
factorScale factor ( \( \alpha \)).

◆ amplifier() [2/2]

template<typename InputIt , typename OutputIt , typename Numeric >
constexpr void edsp::algorithm::amplifier ( InputIt  first,
InputIt  last,
OutputIt  d_first,
Numeric  factor,
Numeric  min,
Numeric  max 
)

Amplifies the signal in the range [first, last) and stores the result in another range, beginning at d_first.

This function increases the amplitude of the input signal defined in the range [first, last). The output signal is a proportionally amplitude signal dependent of the scale factor ( \( \alpha \)):

\[ y(n) = \alpha x(n) \]

The output signal is then clipped to avoid exceding the threshold defined in the range [min, max].

Parameters
firstInput iterator defining the beginning of the input range.
lastInput iterator defining the ending of the input range.
d_firstOutput iterator defining the beginning of the destination range.
factorScale factor ( \( \alpha \)).
minMinimum threshold value.
maxMaximum threshold value.

◆ binary_search() [1/2]

template<typename ForwardIt >
constexpr ForwardIt edsp::algorithm::binary_search ( ForwardIt  first,
ForwardIt  last,
const meta::value_type_t< ForwardIt > &  value 
)

Checks if an element equivalent to value appears within the range [first, last).

Searches for an element equivalent to value in the range [first, last).

For binary_search to succeed, the range [first, last) must be ordered.

Parameters
firstForward iterator defining the begin of the range to examine.
lastForward iterator defining the end of the range to examine.
valueValue to compare the elements to.
Returns
Iterator pointing to the first element that is equal than value, or last if no such element is found.
Parameters
firstForward iterator defining the begin of the range to examine.
lastForward iterator defining the end of the range to examine.
valueValue to UnaryPredicate the elements to.
Returns
Iterator pointing to the first element that is equal than value, or last if no such element is found.

◆ binary_search() [2/2]

template<typename ForwardIt , class UnaryPredicate >
constexpr ForwardIt edsp::algorithm::binary_search ( ForwardIt  first,
ForwardIt  last,
UnaryPredicate  p 
)

Searches for an element for which predicate p returns true in the range [first, last).

Parameters
firstForward iterator defining the begin of the range to examine.
lastForward iterator defining the end of the range to examine.
pBinary predicate which returns ​true for the required element. .
Returns
Iterator pointing to the first element that is equal than value, or last if no such element is found.

◆ ceil()

template<typename InputIt , typename OutputIt >
constexpr void edsp::algorithm::ceil ( InputIt  first,
InputIt  last,
OutputIt  d_first 
)

For each element in the range [first, last) computes the smallest integer value not less than the element's value and stores the result in another range, beginning at d_first.

Parameters
firstForward iterator defining the begin of the range to examine.
lastForward iterator defining the end of the range to examine.
d_firstOutput iterator defining the beginning of the destination range.

◆ clipper()

template<typename InputItr , typename OutputIt , typename Numeric >
constexpr void edsp::algorithm::clipper ( InputItr  first,
InputItr  last,
OutputIt  d_first,
Numeric  min,
Numeric  max 
)

Limits the values of the elements in the range [first, last) once it exceeds a threshold [min, max], and stores the result in another range, beginning at d_first.

Parameters
firstForward iterator defining the begin of the range to examine.
lastForward iterator defining the end of the range to examine.
d_firstOutput iterator defining the beginning of the destination range.
minMinimum threshold value.
maxMaximum threshold value.

◆ concatenate()

template<typename InputIt , typename OutputIt >
constexpr void edsp::algorithm::concatenate ( InputIt  first1,
InputIt  last1,
InputIt  first2,
InputIt  last2,
OutputIt  d_first 
)

Concatenates the elements defined in the range [firs1, last1) and [first2, last2), and stores the result in another range, beginning at d_first.

Parameters
first1Forward iterator defining the begin of the first range.
last1Forward iterator defining the end of the first range.
first2Forward iterator defining the begin of the second range.
last2Forward iterator defining the end of the second range.
d_firstOutput iterator defining the beginning of the destination range.

◆ derivative()

template<typename InputItr , typename OutputIt , typename Numeric >
constexpr void edsp::algorithm::derivative ( InputItr  first,
InputItr  last,
OutputIt  d_first 
)

Computes the first order derivative of the elements in the range [first, last), and stores the result in another range, beginning at d_first.

The definition of the first order derivative derivative is:

\[ y(n) = x(n) - x(n - 1) \]

Parameters
firstForward iterator defining the begin of the range to examine.
lastForward iterator defining the end of the range to examine.
d_firstOutput iterator defining the beginning of the destination range.

◆ equal() [1/2]

template<typename ForwardIt1 , typename ForwardIt2 , typename BinaryPredicate >
constexpr bool edsp::algorithm::equal ( ForwardIt1  first1,
ForwardIt2  last1,
ForwardIt2  first2,
ForwardIt2  last2,
BinaryPredicate  p 
)

Returns true if the range [first1, last1) is equal to the range [first2, last2), and false otherwise.

Parameters
first1Forward iterator defining the begin of the first range.
last1Forward iterator defining the end of the first range.
first2Forward iterator defining the begin of the second range.
last2Forward iterator defining the end of the second range.
pBinary predicate which returns ​true if the elements should be treated as equal.
Returns
If the elements in the two ranges are equal, returns true. Otherwise returns false.

◆ equal() [2/2]

template<typename ForwardIt1 , typename ForwardIt2 >
constexpr bool edsp::algorithm::equal ( ForwardIt1  first1,
ForwardIt2  last1,
ForwardIt2  first2,
ForwardIt2  last2 
)

Returns true if the range [first1, last1) is equal to the range [first2, last2), and false otherwise.

Parameters
first1Forward iterator defining the begin of the first range.
last1Forward iterator defining the end of the first range.
first2Forward iterator defining the begin of the second range.
last2Forward iterator defining the end of the second range.
Returns
If the elements in the two ranges are equal, returns true. Otherwise returns false.

◆ fix()

template<typename InputIt , typename OutputIt >
constexpr void edsp::algorithm::fix ( InputIt  first,
InputIt  last,
OutputIt  d_first 
)

For each element in the range [first, last) computes the nearest integer not greater in magnitude than the element's value and stores the result in another range, beginning at d_first.

Parameters
firstForward iterator defining the begin of the range to examine.
lastForward iterator defining the end of the range to examine.
d_firstOutput iterator defining the beginning of the destination range.

◆ floor()

template<typename InputIt , typename OutputIt >
constexpr void edsp::algorithm::floor ( InputIt  first,
InputIt  last,
OutputIt  d_first 
)

For each element in the range [first, last) computes the largest integer value not greater than the element's value and stores the result in another range, beginning at d_first.

Parameters
firstForward iterator defining the begin of the range to examine.
lastForward iterator defining the end of the range to examine.
d_firstOutput iterator defining the beginning of the destination range.

◆ indexof()

template<typename ForwardIt >
constexpr std::int32_t edsp::algorithm::indexof ( ForwardIt  first,
ForwardIt  last,
const typename std::iterator_traits< ForwardIt >::value_type &  value 
)

Searches for an element equivalent to value in the range [first, last) and returns its position.

Parameters
firstForward iterator defining the begin of the range to examine.
lastForward iterator defining the end of the range to examine.
valueElement to be found.
Returns
Iterator pointing to the first element that is equal than value, or last if no such element is found.

◆ linspace()

template<typename OutputIt , typename Numeric >
constexpr void edsp::algorithm::linspace ( OutputIt  d_first,
Numeric  N,
meta::value_type_t< OutputIt >  x1,
meta::value_type_t< OutputIt >  x2 
)

Generate N linearly spaced values between the range [x1,x2] and stores the result in another range, beginning at d_first.

Parameters
x1Defines the beginning of the interval over which linspace generates points.
x2Defines the ending of the interval over which linspace generates points.
NNumber of points to generate.
d_firstThe beginning of the destination range

◆ logspace()

template<typename OutputIt , typename Numeric >
constexpr void edsp::algorithm::logspace ( OutputIt  d_first,
Numeric  N,
meta::value_type_t< OutputIt >  x1,
meta::value_type_t< OutputIt >  x2 
)

Generate N logarithmic spaced values between the range [x1,x2] and stores the result in another range, beginning at d_first.

Parameters
x1Defines the beginning of the interval over which linspace generates points.
x2Defines the ending of the interval over which linspace generates points.
NNumber of points to generate.
d_firstThe beginning of the destination range

◆ normalize()

template<typename InputIt , typename OutputIt >
constexpr void edsp::algorithm::normalize ( InputIt  first,
InputIt  last,
OutputIt  d_first 
)

Normalizes the elements in the range [first, last) and stores the result in another range, beginning at d_first.

The denominator is the maximum absolute value of the signal.

\[ y = \frac{x}{\frac{\sum_{n=1}^{N}x(n)}{N}} \]

Parameters
firstInput iterator defining the beginning of the input range.
lastInput iterator defining the ending of the input range.
d_firstOutput iterator defining the beginning of the destination range.
See also
maxabs

◆ normalize_rms()

template<typename InputIt , typename OutputIt >
constexpr void edsp::algorithm::normalize_rms ( InputIt  first,
InputIt  last,
OutputIt  d_first 
)

Normalizes the elements in the range [first, last) and stores the result in another range, beginning at d_first.

The denominator is the RMS value of the signal.

\[ y = \frac{x}{\sqrt{\frac{\sum_{n=1}^{N}\left|x(n)^2\right|}{N}}} \]

Parameters
firstInput iterator defining the beginning of the input range.
lastInput iterator defining the ending of the input range.
d_firstOutput iterator defining the beginning of the destination range.
See also
rms

◆ padder()

template<typename InputIt , typename OutputIt >
constexpr void edsp::algorithm::padder ( InputIt  first,
InputIt  last,
OutputIt  d_first,
OutputIt  d_last 
)

Extends the signal defined in the range [first, last) with zeros and stores the result in the range [d_first, d_last].

\[ y(n) = \left\{\begin{matrix} x(n) & 0 <= n < N \\ 0 & N <= n < M \end{matrix}\right. \]

where N is the size of the input range and M the size of the output range.

Parameters
firstForward iterator defining the begin of the range to examine.
lastForward iterator defining the end of the range to examine.
d_firstForward iterator defining the begin of the output range.
d_lastForward iterator defining the end of the output range.

◆ rectify()

template<typename InputIt , typename OutputIt >
constexpr void edsp::algorithm::rectify ( InputIt  first,
InputIt  last,
OutputIt  d_first 
)

For each element in the range [first, last) computes the absolute value not and stores the result in another range, beginning at d_first.

Parameters
firstForward iterator defining the begin of the range to examine.
lastForward iterator defining the end of the range to examine.
d_firstOutput iterator defining the beginning of the destination range.

◆ round()

template<typename InputIt , typename OutputIt >
constexpr void edsp::algorithm::round ( InputIt  first,
InputIt  last,
OutputIt  d_first 
)

For each element in the range [first, last) computes the nearest integer value to the element's value rounding halfway cases away from zero, and stores the result in another range, beginning at d_first.

Parameters
firstForward iterator defining the begin of the range to examine.
lastForward iterator defining the end of the range to examine.
d_firstOutput iterator defining the beginning of the destination range.

◆ silence()

template<typename InputIt , typename OutputIt , typename Numeric >
constexpr bool edsp::algorithm::silence ( InputIt  first,
InputIt  last,
Numeric  threshold 
)

Checks if the elements in the range [first, last) are a silenced frame.

A silenced frame is a frame with an instant power up to a threshold.

Parameters
firstInput iterator defining the beginning of the input range.
lastInput iterator defining the ending of the input range.
thresholdThreshold .