AutoPas  3.0.0
Loading...
Searching...
No Matches
Namespaces | Functions
ArrayMath.h File Reference
#include <array>
#include <cmath>
#include <numeric>
#include <sstream>
#include "Math.h"
Include dependency graph for ArrayMath.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  autopas
 This is the main namespace of AutoPas.
 
namespace  autopas::utils
 In this namespace some helper classes and functions can be found used inside of AutoPas.
 
namespace  autopas::utils::ArrayMath
 Namespace to handle mathematical operations of std::array.
 

Functions

template<class T , std::size_t SIZE>
constexpr std::array< T, SIZE > autopas::utils::ArrayMath::add (const std::array< T, SIZE > &a, const std::array< T, SIZE > &b)
 Adds two arrays, returns the result.
 
template<class T , std::size_t SIZE>
constexpr std::array< T, SIZE > autopas::utils::ArrayMath::sub (const std::array< T, SIZE > &a, const std::array< T, SIZE > &b)
 Subtracts array b from array a and returns the result.
 
template<class T , std::size_t SIZE>
constexpr std::array< T, SIZE > autopas::utils::ArrayMath::min (const std::array< T, SIZE > &a, const std::array< T, SIZE > &b)
 Takes elementwise minimum, returns the result.
 
template<class T , std::size_t SIZE>
constexpr bool autopas::utils::ArrayMath::less (const std::array< T, SIZE > &a, const std::array< T, SIZE > &b)
 True iff for all d the following holds: a[d] < b[d].
 
template<class T , std::size_t SIZE>
constexpr std::array< T, SIZE > autopas::utils::ArrayMath::max (const std::array< T, SIZE > &a, const std::array< T, SIZE > &b)
 Takes elementwise maximum and returns the result.
 
template<class T , std::size_t SIZE>
constexpr std::array< T, SIZE > autopas::utils::ArrayMath::mul (const std::array< T, SIZE > &a, const std::array< T, SIZE > &b)
 Multiplies two array's element wise and returns the result.
 
template<class T , std::size_t SIZE>
constexpr std::array< T, SIZE > autopas::utils::ArrayMath::div (const std::array< T, SIZE > &a, const std::array< T, SIZE > &b)
 Divides two array's element-wise and returns the result.
 
template<class T , std::size_t SIZE>
constexpr std::array< T, SIZE > autopas::utils::ArrayMath::addScalar (const std::array< T, SIZE > &a, T s)
 Adds a scalar s to each element of array a and returns the result.
 
template<class T , std::size_t SIZE>
constexpr std::array< T, SIZE > autopas::utils::ArrayMath::subScalar (const std::array< T, SIZE > &a, T s)
 Subtracts a scalar s from each element of array a and returns the result.
 
template<class T , std::size_t SIZE>
constexpr std::array< T, SIZE > autopas::utils::ArrayMath::mulScalar (const std::array< T, SIZE > &a, T s)
 Multiplies a scalar s to each element of array a and returns the result.
 
template<class T , std::size_t SIZE>
constexpr std::array< T, SIZE > autopas::utils::ArrayMath::divScalar (const std::array< T, SIZE > &a, T s)
 Divides an array element-wise by a given scalar and returns the result.
 
template<class T , std::size_t SIZE>
constexpr std::array< T, SIZE > autopas::utils::ArrayMath::divScalar (T s, const std::array< T, SIZE > &a)
 Divides a scalar with by every element of an array to create an array of fractions.
 
template<class T , std::size_t SIZE>
constexpr T autopas::utils::ArrayMath::dot (const std::array< T, SIZE > &a, const std::array< T, SIZE > &b)
 Generates the dot product of two arrays.
 
template<class T >
constexpr std::array< T, 3 > autopas::utils::ArrayMath::cross (const std::array< T, 3 > &a, const std::array< T, 3 > &b)
 Generates the cross product of two arrays of 3 floats.
 
template<class T , std::size_t SIZE>
constexpr T autopas::utils::ArrayMath::L2Norm (const std::array< T, SIZE > &a)
 Computes the L2Norm / Euclidean norm.
 
template<class T >
constexpr T::value_type autopas::utils::ArrayMath::prod (const T &a)
 Computes the product of all elements in a.
 
template<class T , std::size_t SIZE>
constexpr std::array< T, SIZE > autopas::utils::ArrayMath::abs (const std::array< T, SIZE > &a)
 Computes the absolute value for all elements in a.
 
template<class T , std::size_t SIZE>
constexpr std::array< T, SIZE > autopas::utils::ArrayMath::normalize (const std::array< T, SIZE > &a)
 Generates a normalized array (|a| = 1).
 
template<class T , std::size_t SIZE>
constexpr std::array< T, SIZE > autopas::utils::ArrayMath::ceil (const std::array< T, SIZE > &a)
 For each element in a, computes the smallest integer value not less than the element.
 
template<class T , std::size_t SIZE>
constexpr std::array< int, SIZE > autopas::utils::ArrayMath::floorToInt (const std::array< T, SIZE > &a)
 Floors all array elements and converts them to integers.
 
template<class T , std::size_t SIZE>
constexpr std::array< int, SIZE > autopas::utils::ArrayMath::ceilToInt (const std::array< T, SIZE > &a)
 Ceils all array elements and converts them to integers.
 
template<class T , std::size_t SIZE>
bool autopas::utils::ArrayMath::isNearRel (const std::array< T, SIZE > &a, const std::array< T, SIZE > &b, double maxRelativeDifference=1e-9)
 Returns true if arrays are elementwise relatively near each other.
 
template<class T , std::size_t SIZE>
bool autopas::utils::ArrayMath::isNearRel (const std::vector< std::array< T, SIZE > > &a, const std::vector< std::array< T, SIZE > > &b, double maxRelativeDifference=1e-9)
 Returns true if vectors of arrays are elementwise relatively near each other.
 
template<class T >
bool autopas::utils::ArrayMath::isEqual (const std::vector< T > &a, const std::vector< T > &b)
 Returns true if vectors are elementwise equal to each other.
 
template<class T , std::size_t SIZE>
constexpr std::array< T, SIZE > autopas::utils::ArrayMath::operator+ (const std::array< T, SIZE > &a, const std::array< T, SIZE > &b)
 Adds two arrays, returns the result.
 
template<class T , std::size_t SIZE>
constexpr std::array< T, SIZE > & autopas::utils::ArrayMath::operator+= (std::array< T, SIZE > &a, const std::array< T, SIZE > &b)
 Assignment operator to add two arrays.
 
template<class T , std::size_t SIZE>
constexpr std::array< T, SIZE > autopas::utils::ArrayMath::operator- (const std::array< T, SIZE > &a, const std::array< T, SIZE > &b)
 Subtracts array b from array a and returns the result.
 
template<class T , std::size_t SIZE>
constexpr std::array< T, SIZE > & autopas::utils::ArrayMath::operator-= (std::array< T, SIZE > &a, const std::array< T, SIZE > &b)
 Assignment operator to subtract two arrays.
 
template<class T , std::size_t SIZE>
constexpr std::array< T, SIZE > autopas::utils::ArrayMath::operator* (const std::array< T, SIZE > &a, const std::array< T, SIZE > &b)
 Multiplies two array's element wise and returns the result.
 
template<class T , std::size_t SIZE>
constexpr std::array< T, SIZE > & autopas::utils::ArrayMath::operator*= (std::array< T, SIZE > &a, const std::array< T, SIZE > &b)
 Assignment operator to multiply two arrays.
 
template<class T , std::size_t SIZE>
constexpr std::array< T, SIZE > autopas::utils::ArrayMath::operator/ (const std::array< T, SIZE > &a, const std::array< T, SIZE > &b)
 Divides two array's element-wise and returns the result.
 
template<class T , std::size_t SIZE>
constexpr std::array< T, SIZE > autopas::utils::ArrayMath::operator/ (const std::array< T, SIZE > &a, T b)
 Divides an array element-wise by a given scalar and returns the result.
 
template<class T , std::size_t SIZE>
constexpr std::array< T, SIZE > autopas::utils::ArrayMath::operator/ (T a, const std::array< T, SIZE > &b)
 Divides a scalar by every element of an array to create an array of fractions.
 
template<class T , std::size_t SIZE>
constexpr std::array< T, SIZE > & autopas::utils::ArrayMath::operator/= (std::array< T, SIZE > &a, const std::array< T, SIZE > &b)
 Assignment operator to divide two arrays.
 
template<class T , std::size_t SIZE>
constexpr std::array< T, SIZE > autopas::utils::ArrayMath::operator+ (const std::array< T, SIZE > &a, T s)
 Adds a scalar s to each element of array a and returns the result.
 
template<class T , std::size_t SIZE>
constexpr std::array< T, SIZE > & autopas::utils::ArrayMath::operator+= (std::array< T, SIZE > &a, T s)
 Assignment operator to add a scalar s to each element of array.
 
template<class T , std::size_t SIZE>
constexpr std::array< T, SIZE > autopas::utils::ArrayMath::operator- (const std::array< T, SIZE > &a, T s)
 Subtracts a scalar s from each element of array a and returns the result.
 
template<class T , std::size_t SIZE>
constexpr std::array< T, SIZE > & autopas::utils::ArrayMath::operator-= (std::array< T, SIZE > &a, T s)
 Assignment operator to subtract a scalar s to each element of array.
 
template<class T , std::size_t SIZE>
constexpr std::array< T, SIZE > autopas::utils::ArrayMath::operator* (const std::array< T, SIZE > &a, T s)
 Multiplies a scalar s to each element of array a and returns the result.
 
template<class T , std::size_t SIZE>
constexpr std::array< T, SIZE > & autopas::utils::ArrayMath::operator*= (std::array< T, SIZE > &a, T s)
 Assignment operator to multiply a scalar s to each element of array.
 
template<class T , std::size_t SIZE>
double autopas::utils::ArrayMath::boxDistanceSquared (const std::array< T, SIZE > &aMin, const std::array< T, SIZE > &aMax, const std::array< T, SIZE > &bMin, const std::array< T, SIZE > &bMax)
 Calculate the squared minimum distance between two boxes, which are aligned to the Cartesian grid.
 

Detailed Description

Date
18 Jan 2018
Author
tchipevn