Molecular Dynamics  v0.4
Project for the Practical hosted by the Scientific Computing Chair
Namespaces | Classes | Functions
ArrayUtils Namespace Reference

Namespaces

 is_container_impl
 

Classes

struct  is_container
 

Functions

template<class Container >
std::string to_string (const Container &container, const std::string &delimiter=", ", const std::array< std::string, 2 > &surround={"[", "]"})
 
template<class Container , class F >
Container elementWisePairOp (const Container &lhs, const Container &rhs, F binaryFunction)
 
template<class Scalar , class Container , class F >
Container elementWiseScalarOp (const Scalar &lhs, const Container &rhs, F binaryFunction)
 
template<class Container >
auto L2Norm (const Container &c)
 

Detailed Description

Collection of utility functions and operators for iterable data containers like std::array, std::vector, etc.

Function Documentation

◆ elementWisePairOp()

template<class Container , class F >
Container ArrayUtils::elementWisePairOp ( const Container &  lhs,
const Container &  rhs,
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
ContainerType for both containers.
FType of binary function.
Parameters
lhs
rhs
binaryFunction
Returns
Element wise F(lhs, rhs).
Here is the caller graph for this function:

◆ elementWiseScalarOp()

template<class Scalar , class Container , class F >
Container ArrayUtils::elementWiseScalarOp ( const Scalar &  lhs,
const Container &  rhs,
binaryFunction 
)
inline

Applies a binary function F to with a scalar to every element in a container.

Template Parameters
ScalarType of scalar value.
ContainerType of the container.
F
Parameters
lhs
rhs
binaryFunction
Returns
Element wise F(lhs, rhs).
Here is the caller graph for this function:

◆ L2Norm()

template<class Container >
auto ArrayUtils::L2Norm ( const Container &  c)

Calculates the L2 norm for a given container.

Template Parameters
Container
Parameters
c
Returns
sqrt(sum_i(c[i]*c[i])).
Here is the caller graph for this function:

◆ 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
ContainerType of Container.
Parameters
container.
delimiterString that is put between items.
surroundStrings to be put before and after the listing (e.g. brackets).
Returns
String representation of container.
Here is the caller graph for this function: