Collection of utility functions and operators for iterable data containers like std::array, std::vector, etc.
More...
|
| namespace | is_container_impl |
| | Collection of structs that define what we consider a container. Remove / add whatever you need.
|
| |
|
| template<class Container > |
| std::string | to_string (const Container &container, const std::string &delimiter=", ", const std::array< std::string, 2 > &surround={"[", "]"}) |
| | Generates a string representation of a container which fulfills the Container requirement (provide cbegin and cend).
|
| |
| template<class Container , class F > |
| Container | elementWisePairOp (const Container &lhs, const Container &rhs, F binaryFunction) |
| | Applies an element wise binary function F to two containers.
|
| |
| template<class Scalar , class Container , class F > |
| Container | elementWiseScalarOp (const Scalar &lhs, const Container &rhs, F binaryFunction) |
| | Applies a binary function F to with a scalar to every element in a container.
|
| |
| template<class Container > |
| auto | L2NormSquared (const Container &c) |
| | Calculates the square of the L2 norm for a given container.
|
| |
| template<class Container > |
| auto | L2Norm (const Container &c) |
| | Calculates the L2 norm for a given container.
|
| |
Collection of utility functions and operators for iterable data containers like std::array, std::vector, etc.
◆ elementWisePairOp()
template<class Container , class F >
| Container ArrayUtils::elementWisePairOp |
( |
const Container & |
lhs, |
|
|
const Container & |
rhs, |
|
|
F |
binaryFunction |
|
) |
| |
|
inline |
Applies an element wise binary function F to two containers.
If the containers differ in size the F is only applied to as many elements as are in the smaller container.
- Template Parameters
-
| Container | Type for both containers. |
| F | Type of binary function. |
- Parameters
-
- Returns
- Element wise F(lhs, rhs).
◆ elementWiseScalarOp()
template<class Scalar , class Container , class F >
| Container ArrayUtils::elementWiseScalarOp |
( |
const Scalar & |
lhs, |
|
|
const Container & |
rhs, |
|
|
F |
binaryFunction |
|
) |
| |
|
inline |
Applies a binary function F to with a scalar to every element in a container.
- Template Parameters
-
| Scalar | Type of scalar value. |
| Container | Type of the container. |
| F | |
- Parameters
-
- Returns
- Element wise F(lhs, rhs).
◆ L2Norm()
template<class Container >
| auto ArrayUtils::L2Norm |
( |
const Container & |
c | ) |
|
Calculates the L2 norm for a given container.
- Template Parameters
-
- Parameters
-
- Returns
- sqrt(sum_i(c[i]*c[i])).
◆ L2NormSquared()
template<class Container >
| auto ArrayUtils::L2NormSquared |
( |
const Container & |
c | ) |
|
Calculates the square of the L2 norm for a given container.
- Template Parameters
-
- Parameters
-
- Returns
- sum_i(c[i]*c[i]).
◆ to_string()
template<class Container >
| std::string ArrayUtils::to_string |
( |
const Container & |
container, |
|
|
const std::string & |
delimiter = ", ", |
|
|
const std::array< std::string, 2 > & |
surround = {"[", "]"} |
|
) |
| |
Generates a string representation of a container which fulfills the Container requirement (provide cbegin and cend).
- Template Parameters
-
| Container | Type of Container. |
- Parameters
-
| container | The container to create the string representation from. |
| delimiter | String that is put between items. |
| surround | Strings to be put before and after the listing (e.g. brackets). |
- Returns
- String representation of container.