|
TRIQS/nda 1.3.0
Multi-dimensional array library for C++
|
Various algorithms that can be applied to arrays and views.
We can group the different algorithms into
Functions | |
| template<Array A> | |
| bool | nda::all (A const &a) |
| Do all elements of the array evaluate to true? | |
| template<Array A> | |
| bool | nda::any (A const &a) |
| Does any of the elements of the array evaluate to true? | |
| template<Array A, typename F> | |
| auto | nda::fold (F f, A const &a) |
| The same as nda::fold, except that the initial value is a default constructed value type of the array. | |
| template<Array A, typename F, typename R> | |
| auto | nda::fold (F f, A const &a, R r) |
| Perform a fold operation on the given nda::Array object. | |
| template<Array A, Array B> | |
| constexpr auto | nda::hadamard (A &&a, B &&b) |
| Hadamard product of two nda::Array objects. | |
| constexpr auto | nda::hadamard (nda::Scalar auto a, nda::Scalar auto b) |
| Hadamard product of two arithmetic types. | |
| template<typename T, typename U, size_t R> | |
| constexpr auto | nda::hadamard (std::array< T, R > const &a, std::array< U, R > const &b) |
| Hadamard product of two std::array objects. | |
| template<typename T, typename U> | |
| constexpr auto | nda::hadamard (std::vector< T > const &a, std::vector< U > const &b) |
| Hadamard product of two std::vector objects. | |
| template<Array A> | |
| auto | nda::max_element (A const &a) |
| Find the maximum element of an array. | |
| template<Array A> | |
| auto | nda::min_element (A const &a) |
| Find the minimum element of an array. | |
| template<Array A, typename Value = get_value_t<A>> requires (nda::Scalar<Value> or nda::Array<Value>) | |
| auto | nda::product (A const &a) |
| Multiply all the elements of an nda::Array object. | |
| template<Array A, typename Value = get_value_t<A>> requires (nda::Scalar<Value> or nda::Array<Value>) | |
| auto | nda::sum (A const &a) |
| Sum all the elements of an nda::Array object. | |
| template<Array A> | |
| auto | nda::sum (A const &a, int axis) |
| Sum elements of an nda::Array along a specified axis. | |
| template<Array A, std::integral I, size_t N> | |
| auto | nda::sum (A const &a, std::array< I, N > axes) |
| Sum elements of an nda::Array along specified axes. | |
| bool nda::all | ( | A const & | a | ) |
#include <nda/algorithms.hpp>
Do all elements of the array evaluate to true?
The given nda::Array object can also be some lazy expression that evaluates to a boolean. For example:
| A | nda::Array type. |
| a | nda::Array object. |
Definition at line 110 of file algorithms.hpp.
| bool nda::any | ( | A const & | a | ) |
#include <nda/algorithms.hpp>
Does any of the elements of the array evaluate to true?
The given nda::Array object can also be some lazy expression that evaluates to a boolean. For example:
| A | nda::Array type. |
| a | nda::Array object. |
Definition at line 89 of file algorithms.hpp.
| auto nda::fold | ( | F | f, |
| A const & | a, | ||
| R | r ) |
#include <nda/algorithms.hpp>
Perform a fold operation on the given nda::Array object.
It calculates the following (where r is an initial value);
| A | nda::Array type. |
| F | Callable type. |
| R | Type of the initial value. |
| f | Callable object taking two arguments compatible with the initial value and the array value type. |
| a | nda::Array object. |
| r | Initial value. |
Definition at line 59 of file algorithms.hpp.
|
nodiscardconstexpr |
#include <nda/algorithms.hpp>
Hadamard product of two nda::Array objects.
| A | nda::Array type. |
| B | nda::Array type. |
| a | nda::Array object. |
| b | nda::Array object. |
Definition at line 293 of file algorithms.hpp.
|
constexpr |
#include <nda/algorithms.hpp>
Hadamard product of two arithmetic types.
| T | nda::Scalar type of the first input. |
| U | nda::Scalar type of the second input. |
| a | First input. |
| b | Second input. |
Definition at line 340 of file algorithms.hpp.
|
nodiscardconstexpr |
#include <nda/algorithms.hpp>
Hadamard product of two std::array objects.
| T | Value type of the first array. |
| U | Value type of the second array. |
| R | Size of the arrays. |
| a | std::array object. |
| b | std::array object. |
Definition at line 308 of file algorithms.hpp.
|
nodiscardconstexpr |
#include <nda/algorithms.hpp>
Hadamard product of two std::vector objects.
| T | Value type of the first input vector. |
| U | Value type of the second input vector. |
| a | std::vector object. |
| b | std::vector object. |
Definition at line 322 of file algorithms.hpp.
| auto nda::max_element | ( | A const & | a | ) |
#include <nda/algorithms.hpp>
Find the maximum element of an array.
It uses nda::fold and std::max.
| A | nda::Array type. |
| a | nda::Array object. |
Definition at line 125 of file algorithms.hpp.
| auto nda::min_element | ( | A const & | a | ) |
#include <nda/algorithms.hpp>
Find the minimum element of an array.
It uses nda::fold and std::min.
| A | nda::Array type. |
| a | nda::Array object. |
Definition at line 144 of file algorithms.hpp.
| auto nda::product | ( | A const & | a | ) |
#include <nda/algorithms.hpp>
Multiply all the elements of an nda::Array object.
| A | nda::Array type. |
| a | nda::Array object. |
Definition at line 272 of file algorithms.hpp.
| auto nda::sum | ( | A const & | a | ) |
#include <nda/algorithms.hpp>
Sum all the elements of an nda::Array object.
| A | nda::Array type. |
| a | nda::Array object. |
Definition at line 179 of file algorithms.hpp.
| auto nda::sum | ( | A const & | a, |
| int | axis ) |
#include <nda/algorithms.hpp>
Sum elements of an nda::Array along a specified axis.
It simply calls nda::sum(A const &, std::array<I, N>).
| A | nda::Array type. |
| a | nda::Array object. |
| axis | The axis along which to sum. |
Definition at line 260 of file algorithms.hpp.
| auto nda::sum | ( | A const & | a, |
| std::array< I, N > | axes ) |
#include <nda/algorithms.hpp>
Sum elements of an nda::Array along specified axes.
This function behaves similar to numpy.sum. The result is an array with rank reduced by the number of axes summed over, i.e. if the original array has rank \( R \) and we sum over \( N \) axes, the resulting array has rank \( R - N \).
If all axes are summed over, \( R = N \), the call is dispatched to nda::sum.
If no axes are specified, \( N = 0 \), a copy of the input array is returned.
The given axes are expected to be unique and in the range \( [0, R-1] \).
| A | nda::Array type. |
| N | Number of axes to sum over. |
| a | nda::Array object. |
| axes | Array of axis indices to sum over. |
Definition at line 210 of file algorithms.hpp.