Namespace to handle mathematical operations of std::array. More...
Functions | |
| template<class T , std::size_t SIZE> | |
| constexpr std::array< T, SIZE > | 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 > | 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 > | 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 | 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 > | 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 > | 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 > | 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 > | 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 > | 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 > | 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 > | 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 > | 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 | 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 > | 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 | L2Norm (const std::array< T, SIZE > &a) |
| Computes the L2Norm / Euclidean norm. | |
| template<class T > | |
| constexpr T::value_type | prod (const T &a) |
| Computes the product of all elements in a. | |
| template<class T , std::size_t SIZE> | |
| constexpr std::array< T, SIZE > | 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 > | 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 > | ceil (const std::array< T, SIZE > &a) |
| For each element in a, computes the smallest integer value not less than the element. | |
| template<typename target_T = int, typename float_T , std::size_t SIZE> | |
| constexpr std::array< target_T, SIZE > | floorAndCast (const std::array< float_T, SIZE > &a) |
| Floors all array elements and converts them to a different type. | |
| template<class target_T = int, class float_T , std::size_t SIZE> | |
| constexpr std::array< target_T, SIZE > | ceilAndCast (const std::array< float_T, SIZE > &a) |
| Ceils all array elements and converts them to a different type. | |
| template<class T , std::size_t SIZE> | |
| bool | 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 | 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 | isEqual (const std::vector< T > &a, const std::vector< T > &b) |
| Returns true if vectors are elementwise equal to each other. | |
| template<typename new_T , typename old_T , std::size_t SIZE> | |
| constexpr std::array< new_T, SIZE > | staticCastArray (const std::array< old_T, SIZE > &a) |
| static_casts all elements of an array to a new type. | |
| template<class T , std::size_t SIZE> | |
| constexpr std::array< T, SIZE > | 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 > & | 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 > | 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 > & | 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 > | 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 > & | 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 > | 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 > | 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 > | 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 > & | 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 > | 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 > & | 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 > | 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 > & | 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 > | 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 > & | 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 | 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. | |
Namespace to handle mathematical operations of std::array.
|
constexpr |
Computes the absolute value for all elements in a.
| T | floating point type |
| SIZE | size of the array |
| a | input array |
|
constexpr |
Adds two arrays, returns the result.
| T | floating point type |
| SIZE | size of the arrays |
| a | first summand |
| b | second summand |
|
constexpr |
Adds a scalar s to each element of array a and returns the result.
| T | floating point type |
| SIZE | size of the array a |
| a | the array |
| s | the scalar to be added to each element of a |
| 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.
The boxes are given by their lower and upper corners.
| aMin | |
| aMax | |
| bMin | |
| bMax |
|
constexpr |
For each element in a, computes the smallest integer value not less than the element.
| T | floating point type |
| SIZE | size of the array |
| a | input array |
|
constexpr |
Ceils all array elements and converts them to a different type.
Useful to ceil array elements and cast them to some integer type.
| target_T | target type. By default int. |
| float_T | floating point type |
| SIZE | size of the array |
| a | input array |
|
constexpr |
Generates the cross product of two arrays of 3 floats.
| T | floating point type |
| a | 3D vector (denoted by array of 3 floats) |
| b | 3D vector (denoted by array of 3 floats) |
|
constexpr |
Divides two array's element-wise and returns the result.
| T | floating point type |
| SIZE | size of the arrays |
| a | dividend. |
| b | divisor. |
result[i] = a[i]/b[i]
|
constexpr |
Divides an array element-wise by a given scalar and returns the result.
| T | floating point type |
| SIZE | size of the arrays |
| a | dividend. |
| s | divisor. |
result[i] = a[i]/s
|
constexpr |
Divides a scalar with by every element of an array to create an array of fractions.
| T | floating point type |
| SIZE | size of the arrays |
| a | dividend. |
| s | divisor. |
result[i] = s/a[i]
|
constexpr |
Generates the dot product of two arrays.
Returns the sum of a[i]*b[i] summed over all i, where i is in [0, SIZE)
| T | floating point type |
| SIZE | size of the arrays |
| a | first array |
| b | second array |
|
constexpr |
Floors all array elements and converts them to a different type.
Useful to floor array elements and cast them to some integer type.
| target_T | target type. By default int. |
| float_T | floating point type |
| SIZE | size of the array |
| a | input array |
| 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.
Also returns false if vectors are of different sizes. Should only be used with an integer type.
| T | integer type |
| a | input vector |
| b | input vector |
| 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.
| T | floating point type |
| SIZE | size of the array |
| a | input array |
| b | input array |
| maxRelativeDifference |
| 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.
Also returns false if vectors are of different sizes.
| T | floating point type |
| SIZE | size of the array |
| a | input vector of arrays |
| b | input vector of arrays |
| maxRelativeDifference |
|
constexpr |
Computes the L2Norm / Euclidean norm.
| T | floating point type |
| SIZE | size of the array |
| a | input array |
|
constexpr |
True iff for all d the following holds: a[d] < b[d].
| T | floating point type |
| SIZE | size of the arrays |
| a | first parameter |
| b | second parameter |
|
constexpr |
Takes elementwise maximum and returns the result.
| T | floating point type |
| SIZE | size of the arrays |
| a | |
| b |
|
constexpr |
Takes elementwise minimum, returns the result.
| T | floating point type |
| SIZE | size of the arrays |
| a | first parameter |
| b | second parameter |
|
constexpr |
Multiplies two array's element wise and returns the result.
| T | floating point type |
| SIZE | size of the arrays |
| a | |
| b |
|
constexpr |
Multiplies a scalar s to each element of array a and returns the result.
| T | floating point type |
| SIZE | size of the array a |
| a | the array |
| s | the scalar to be multiplied to each element of a |
|
constexpr |
Generates a normalized array (|a| = 1).
| T | floating point type |
| SIZE | size of the array |
| a | input array |
|
constexpr |
Multiplies two array's element wise and returns the result.
| T | floating point type |
| SIZE | size of the arrays |
| a | |
| b |
|
constexpr |
Multiplies a scalar s to each element of array a and returns the result.
| T | floating point type |
| SIZE | size of the array a |
| a | the array |
| s | the scalar to be multiplied to each element of a |
|
constexpr |
Assignment operator to multiply two arrays.
| T | floating point type |
| SIZE | size of the arrays |
| a | |
| b |
|
constexpr |
Assignment operator to multiply a scalar s to each element of array.
| T | floating point type |
| SIZE | size of the array a |
| a | the array |
| s | the scalar to be multiplied to each element of a |
|
constexpr |
Adds two arrays, returns the result.
| T | floating point type |
| SIZE | size of the arrays |
| a | first summand |
| b | second summand |
|
constexpr |
Adds a scalar s to each element of array a and returns the result.
| T | floating point type |
| SIZE | size of the array a |
| a | the array |
| s | the scalar to be added to each element of a |
|
constexpr |
Assignment operator to add two arrays.
| T | floating point type |
| SIZE | size of the arrays |
| a | first summand |
| b | second summand |
|
constexpr |
Assignment operator to add a scalar s to each element of array.
| T | floating point type |
| SIZE | size of the array a |
| a | the array |
| s | the scalar to be added to each element of a |
|
constexpr |
Subtracts array b from array a and returns the result.
| T | floating point type |
| SIZE | size of the arrays |
| a | |
| b |
|
constexpr |
Subtracts a scalar s from each element of array a and returns the result.
| T | floating point type |
| SIZE | size of the array a |
| a | the array |
| s | the scalar to be subtracted from each element of a |
|
constexpr |
Assignment operator to subtract two arrays.
| T | floating point type |
| SIZE | size of the arrays |
| a | |
| b |
|
constexpr |
Assignment operator to subtract a scalar s to each element of array.
| T | floating point type |
| SIZE | size of the array a |
| a | the array |
| s | the scalar to be subtracted from each element of a |
|
constexpr |
Divides two array's element-wise and returns the result.
| T | floating point type |
| SIZE | size of the arrays |
| a | dividend. |
| b | divisor. |
result[i] = a[i]/b[i]
|
constexpr |
Divides an array element-wise by a given scalar and returns the result.
| T | floating point type |
| SIZE | size of the arrays |
| a | dividend. |
| b | divisor. |
result[i] = a[i]/b
|
constexpr |
Divides a scalar by every element of an array to create an array of fractions.
| T | floating point type |
| SIZE | size of the arrays |
| a | dividend. |
| b | divisor. |
result[i] = a/b[i]
|
constexpr |
Assignment operator to divide two arrays.
| T | floating point type |
| SIZE | size of the arrays |
| a | dividend. |
| b | divisor. |
result[i] = a[i]/b[i]
|
constexpr |
Computes the product of all elements in a.
| T | input array type, which fulfills the C++ container requirement |
| a | input array |
|
constexpr |
static_casts all elements of an array to a new type.
| new_T | |
| old_T | |
| SIZE |
| a | Old Array |
|
constexpr |
Subtracts array b from array a and returns the result.
| T | floating point type |
| SIZE | size of the arrays |
| a | |
| b |
|
constexpr |
Subtracts a scalar s from each element of array a and returns the result.
| T | floating point type |
| SIZE | size of the array a |
| a | the array |
| s | the scalar to be subtracted from each element of a |