JPL Spatial
Sound spatialization and propagation library
Loading...
Searching...
No Matches
JPL::Algo Namespace Reference

Namespaces

namespace  Internal
 

Classes

struct  AccAbs
 functor for std::accumulate (and similar) to accumulate absolute values More...
 
struct  AccPow2
 functor for std::accumulate (and similar) to accumulate sum of value squares More...
 
class  Multiply
 functor for for_each (and similar) to multiply elements by a multiplier More...
 

Functions

template<class RangeType , class T , class Fn = std::plus<T>>
JPL_INLINE constexpr T Accumulate (RangeType &&range, T initialValue, Fn reduceOp={})
 Just a wrapper for a range, to not have to type begin and end iterators.
 
template<class ContainerType >
JPL_INLINE constexpr void NormalizeL1 (ContainerType &&data)
 Normalize so that the sum = 1.
 
template<class ContainerType >
JPL_INLINE constexpr void NormalizeL2 (ContainerType &&data)
 Apply unit vector scaling, so that the magnitude of the vector = 1.
 
template<class ContainerType >
JPL_INLINE constexpr bool IsNormalizedL1 (const ContainerType &data, float tolerance=JPL_FLOAT_EPS)
 
template<class ContainerType >
JPL_INLINE constexpr bool IsNormalizedL2 (const ContainerType &data, float tolerance=JPL_FLOAT_EPS)
 
template<std::random_access_iterator I, std::sentinel_for< I > S, class Gen >
requires std::permutable<I> && std::uniform_random_bit_generator<std::remove_reference_t<Gen>>
constexpr I PartialShuffle (I first, S last, std::size_t count, Gen &&gen)
 
template<std::ranges::random_access_range R, class Gen >
requires std::permutable<std::ranges::iterator_t<R>> and std::uniform_random_bit_generator<std::remove_reference_t<Gen>>
JPL_INLINE constexpr std::ranges::borrowed_iterator_t< R > PartialShuffle (R &&r, std::size_t count, Gen &&gen)
 

Function Documentation

◆ Accumulate()

template<class RangeType , class T , class Fn = std::plus<T>>
JPL_INLINE constexpr T JPL::Algo::Accumulate ( RangeType && range,
T initialValue,
Fn reduceOp = {} )
nodiscardconstexpr

Just a wrapper for a range, to not have to type begin and end iterators.

◆ IsNormalizedL1()

template<class ContainerType >
JPL_INLINE constexpr bool JPL::Algo::IsNormalizedL1 ( const ContainerType & data,
float tolerance = JPL_FLOAT_EPS )
nodiscardconstexpr

◆ IsNormalizedL2()

template<class ContainerType >
JPL_INLINE constexpr bool JPL::Algo::IsNormalizedL2 ( const ContainerType & data,
float tolerance = JPL_FLOAT_EPS )
nodiscardconstexpr

◆ NormalizeL1()

template<class ContainerType >
JPL_INLINE constexpr void JPL::Algo::NormalizeL1 ( ContainerType && data)
constexpr

Normalize so that the sum = 1.

◆ NormalizeL2()

template<class ContainerType >
JPL_INLINE constexpr void JPL::Algo::NormalizeL2 ( ContainerType && data)
constexpr

Apply unit vector scaling, so that the magnitude of the vector = 1.

◆ PartialShuffle() [1/2]

template<std::random_access_iterator I, std::sentinel_for< I > S, class Gen >
requires std::permutable<I> && std::uniform_random_bit_generator<std::remove_reference_t<Gen>>
I JPL::Algo::PartialShuffle ( I first,
S last,
std::size_t count,
Gen && gen )
constexpr

Shuffle 'count' number of elements in a given range. This is useful when you need to select X first elements from a range as if the entire range was shuffled, but much faster if X is < range size.

Returns
iterator to the end of the shuffled range

◆ PartialShuffle() [2/2]

template<std::ranges::random_access_range R, class Gen >
requires std::permutable<std::ranges::iterator_t<R>> and std::uniform_random_bit_generator<std::remove_reference_t<Gen>>
JPL_INLINE constexpr std::ranges::borrowed_iterator_t< R > JPL::Algo::PartialShuffle ( R && r,
std::size_t count,
Gen && gen )
constexpr

Shuffle 'count' number of elements in a given range. This is useful when you need to select X first elements from a range as if the entire range was shuffled, but much faster if X is < range size.

Returns
iterator to the end of the shuffled range