|
TRIQS/nda 2.0.0
Multi-dimensional array library for C++
|
Various mathematical functions that can be applied to arrays and views.
Mathematical functions are (mostly) implemented as lazy expressions. That means they do not return the result right away but the following proxy object instead:
This lazy function call expression satisfies the nda::Array concept and can therefore be used to assign to or construct nda::basic_array and nda::basic_array_view objects. Another way to evaluate lazy expressions is with nda::make_regular:
Output:
All functions also accept scalars. For the <cmath> functions, the scalar overloads are the std ones, while nda::conj, nda::real, nda::imag, nda::abs2, nda::reciprocal, nda::max and nda::min provide their own. The exception is nda::isnan for complex scalars, which is not covered by std::isnan and is true if either component is NaN.
Classes | |
| struct | nda::expr_call< F, As > |
| A lazy function call expression on arrays/views. More... | |
| struct | nda::mapped< F > |
| Functor that is returned by the nda::map function. More... | |
Functions | |
| template<Array A> | |
| auto | nda::abs (A &&a) |
| Function abs for nda::Array types (lazy and coefficient-wise). | |
| template<Scalar S> | |
| auto | nda::abs (S s) |
| Function abs for nda::Scalar types (uses std::abs). | |
| template<ArrayOrScalar A> | |
| auto | nda::abs2 (A &&a) |
| Function abs2 for nda::ArrayOrScalar types (lazy and coefficient-wise for nda::Array types). | |
| template<Array A> requires (get_algebra<A> != 'M') | |
| auto | nda::acos (A &&a) |
| Function acos for non-matrix nda::Array types (lazy and coefficient-wise). | |
| template<Scalar S> | |
| auto | nda::acos (S s) |
| Function acos for nda::Scalar types (uses std::acos). | |
| template<Array A> requires (get_algebra<A> != 'M') | |
| auto | nda::asin (A &&a) |
| Function asin for non-matrix nda::Array types (lazy and coefficient-wise). | |
| template<Scalar S> | |
| auto | nda::asin (S s) |
| Function asin for nda::Scalar types (uses std::asin). | |
| template<Array A> requires (get_algebra<A> != 'M') | |
| auto | nda::atan (A &&a) |
| Function atan for non-matrix nda::Array types (lazy and coefficient-wise). | |
| template<Scalar S> | |
| auto | nda::atan (S s) |
| Function atan for nda::Scalar types (uses std::atan). | |
| template<ArrayOrScalar A> | |
| decltype(auto) | nda::conj (A &&a) |
| Function conj for nda::ArrayOrScalar types (lazy and coefficient-wise for nda::Array types with a complex value type). | |
| template<Array A> requires (get_algebra<A> != 'M') | |
| auto | nda::cos (A &&a) |
| Function cos for non-matrix nda::Array types (lazy and coefficient-wise). | |
| template<Scalar S> | |
| auto | nda::cos (S s) |
| Function cos for nda::Scalar types (uses std::cos). | |
| template<Array A> requires (get_algebra<A> != 'M') | |
| auto | nda::cosh (A &&a) |
| Function cosh for non-matrix nda::Array types (lazy and coefficient-wise). | |
| template<Scalar S> | |
| auto | nda::cosh (S s) |
| Function cosh for nda::Scalar types (uses std::cosh). | |
| template<ArrayOfRank< 2 > M> | |
| ArrayOfRank< 2 > auto | nda::dagger (M const &m) |
| Get the conjugate transpose of 2-dimensional array/view. | |
| template<Array A> requires (get_algebra<A> != 'M') | |
| auto | nda::exp (A &&a) |
| Function exp for non-matrix nda::Array types (lazy and coefficient-wise). | |
| template<Scalar S> | |
| auto | nda::exp (S s) |
| Function exp for nda::Scalar types (uses std::exp). | |
| template<Array A> | |
| auto | nda::floor (A &&a) |
| Function floor for nda::Array types (lazy and coefficient-wise). | |
| template<Scalar S> | |
| auto | nda::floor (S s) |
| Function floor for nda::Scalar types (uses std::floor). | |
| template<ArrayOfRank< 2 > A> | |
| auto | nda::frobenius_norm (A const &a) |
| Calculate the Frobenius norm of a 2-dimensional array. | |
| template<ArrayOrScalar A> | |
| auto | nda::imag (A &&a) |
| Function imag for nda::ArrayOrScalar types (lazy and coefficient-wise for nda::Array types). | |
| template<typename A> requires (Array<A> || is_complex_v<A>) | |
| auto | nda::isnan (A &&a) |
| Function isnan for nda::Array types and complex nda::Scalar types (lazy and coefficient-wise for nda::Array types). | |
|
template<Scalar S> requires (not is_complex_v<S>) | |
| auto | nda::isnan (S s) |
| Function isnan for real nda::Scalar types (uses std::isnan). | |
| template<Array A> requires (get_algebra<A> != 'M') | |
| auto | nda::log (A &&a) |
| Function log for non-matrix nda::Array types (lazy and coefficient-wise). | |
| template<Scalar S> | |
| auto | nda::log (S s) |
| Function log for nda::Scalar types (uses std::log). | |
| template<class F> | |
| mapped< F > | nda::map (F f) |
| Create a lazy function call expression on arrays/views. | |
| template<ArrayOrScalar A, ArrayOrScalar B> requires (((Scalar<A> && Scalar<B>) || (Array<A> && Array<B> && get_rank<A> == get_rank<B>)) && !is_complex_v<get_value_t<A>> && !is_complex_v<get_value_t<B>>) | |
| auto | nda::max (A &&a, B &&b) |
| Function max for nda::ArrayOrScalar types (lazy and coefficient-wise for nda::Array types). | |
| template<ArrayOrScalar A, ArrayOrScalar B> requires (((Scalar<A> && Scalar<B>) || (Array<A> && Array<B> && get_rank<A> == get_rank<B>)) && !is_complex_v<get_value_t<A>> && !is_complex_v<get_value_t<B>>) | |
| auto | nda::min (A &&a, B &&b) |
| Function min for nda::ArrayOrScalar types (lazy and coefficient-wise for nda::Array types). | |
| template<Array A, Scalar S> | |
| auto | nda::pow (A &&a, S p) |
| Function pow for nda::Array types (lazy and coefficient-wise). | |
| template<Scalar S, Scalar P> | |
| auto | nda::pow (S s, P p) |
| Function pow for nda::Scalar types (uses std::pow). | |
| template<ArrayOrScalar A> | |
| auto | nda::real (A &&a) |
| Function real for nda::ArrayOrScalar types (lazy and coefficient-wise for nda::Array types). | |
| template<ArrayOrScalar A> | |
| auto | nda::reciprocal (A &&a) |
| Reciprocal function for nda::ArrayOrScalar types (lazy and coefficient-wise for nda::Array types). | |
| template<Array A> requires (get_algebra<A> != 'M') | |
| auto | nda::sin (A &&a) |
| Function sin for non-matrix nda::Array types (lazy and coefficient-wise). | |
| template<Scalar S> | |
| auto | nda::sin (S s) |
| Function sin for nda::Scalar types (uses std::sin). | |
| template<Array A> requires (get_algebra<A> != 'M') | |
| auto | nda::sinh (A &&a) |
| Function sinh for non-matrix nda::Array types (lazy and coefficient-wise). | |
| template<Scalar S> | |
| auto | nda::sinh (S s) |
| Function sinh for nda::Scalar types (uses std::sinh). | |
| template<Array A> requires (get_algebra<A> != 'M') | |
| auto | nda::sqrt (A &&a) |
| Function sqrt for non-matrix nda::Array types (lazy and coefficient-wise). | |
| template<Scalar S> | |
| auto | nda::sqrt (S s) |
| Function sqrt for nda::Scalar types (uses std::sqrt). | |
| template<Array A> requires (get_algebra<A> != 'M') | |
| auto | nda::tan (A &&a) |
| Function tan for non-matrix nda::Array types (lazy and coefficient-wise). | |
| template<Scalar S> | |
| auto | nda::tan (S s) |
| Function tan for nda::Scalar types (uses std::tan). | |
| template<Array A> requires (get_algebra<A> != 'M') | |
| auto | nda::tanh (A &&a) |
| Function tanh for non-matrix nda::Array types (lazy and coefficient-wise). | |
| template<Scalar S> | |
| auto | nda::tanh (S s) |
| Function tanh for nda::Scalar types (uses std::tanh). | |
| template<ArrayOfRank< 2 > M> | |
| auto | nda::trace (M const &m) |
| Get the trace of a 2-dimensional square array/view. | |
| auto nda::abs | ( | A && | a | ) |
#include <nda/mapped_functions.hpp>
Function abs for nda::Array types (lazy and coefficient-wise).
| A | nda::Array type. |
| a | nda::Array object. |
Definition at line 194 of file mapped_functions.hpp.
| auto nda::abs2 | ( | A && | a | ) |
#include <nda/mapped_functions.hpp>
Function abs2 for nda::ArrayOrScalar types (lazy and coefficient-wise for nda::Array types).
| A | nda::ArrayOrScalar type.. |
| a | nda::ArrayOrScalar object. |
Definition at line 244 of file mapped_functions.hpp.
| auto nda::acos | ( | A && | a | ) |
#include <nda/mapped_functions.hpp>
Function acos for non-matrix nda::Array types (lazy and coefficient-wise).
| A | nda::Array type. |
| a | nda::Array object. |
Definition at line 417 of file mapped_functions.hpp.
| auto nda::asin | ( | A && | a | ) |
#include <nda/mapped_functions.hpp>
Function asin for non-matrix nda::Array types (lazy and coefficient-wise).
| A | nda::Array type. |
| a | nda::Array object. |
Definition at line 436 of file mapped_functions.hpp.
| auto nda::atan | ( | A && | a | ) |
#include <nda/mapped_functions.hpp>
Function atan for non-matrix nda::Array types (lazy and coefficient-wise).
| A | nda::Array type. |
| a | nda::Array object. |
Definition at line 455 of file mapped_functions.hpp.
| decltype(auto) nda::conj | ( | A && | a | ) |
#include <nda/mapped_functions.hpp>
Function conj for nda::ArrayOrScalar types (lazy and coefficient-wise for nda::Array types with a complex value type).
| A | nda::ArrayOrScalar type. |
| a | nda::ArrayOrScalar object. |
Definition at line 112 of file mapped_functions.hpp.
| auto nda::cos | ( | A && | a | ) |
#include <nda/mapped_functions.hpp>
Function cos for non-matrix nda::Array types (lazy and coefficient-wise).
| A | nda::Array type. |
| a | nda::Array object. |
Definition at line 303 of file mapped_functions.hpp.
| auto nda::cosh | ( | A && | a | ) |
#include <nda/mapped_functions.hpp>
Function cosh for non-matrix nda::Array types (lazy and coefficient-wise).
| A | nda::Array type. |
| a | nda::Array object. |
Definition at line 360 of file mapped_functions.hpp.
| ArrayOfRank< 2 > auto nda::dagger | ( | M const & | m | ) |
#include <nda/matrix_functions.hpp>
Get the conjugate transpose of 2-dimensional array/view.
It first calls nda::transpose and then the lazy nda::conj function in case the array/view is complex valued.
| M | nda::ArrayOfRank<2> type. |
| m | 2-dimensional array/view. |
Definition at line 81 of file matrix_functions.hpp.
| auto nda::exp | ( | A && | a | ) |
#include <nda/mapped_functions.hpp>
Function exp for non-matrix nda::Array types (lazy and coefficient-wise).
| A | nda::Array type. |
| a | nda::Array object. |
Definition at line 284 of file mapped_functions.hpp.
| auto nda::floor | ( | A && | a | ) |
#include <nda/mapped_functions.hpp>
Function floor for nda::Array types (lazy and coefficient-wise).
| A | nda::Array type. |
| a | nda::Array object. |
Definition at line 224 of file mapped_functions.hpp.
| auto nda::frobenius_norm | ( | A const & | a | ) |
#include <nda/algorithms.hpp>
Calculate the Frobenius norm of a 2-dimensional array.
It takes the square root of the sum of squared absolute values. The return type matches std::norm applied to a scalar element.
| A | nda::ArrayOfRank<2> type. |
| a | Array object. |
Definition at line 184 of file algorithms.hpp.
| auto nda::imag | ( | A && | a | ) |
#include <nda/mapped_functions.hpp>
Function imag for nda::ArrayOrScalar types (lazy and coefficient-wise for nda::Array types).
| A | nda::ArrayOrScalar type. |
| a | nda::ArrayOrScalar object. |
Definition at line 204 of file mapped_functions.hpp.
| auto nda::isnan | ( | A && | a | ) |
#include <nda/mapped_functions.hpp>
Function isnan for nda::Array types and complex nda::Scalar types (lazy and coefficient-wise for nda::Array types).
A complex scalar is NaN if either component is NaN.
| A | nda::Array or complex nda::Scalar type. |
| a | nda::Array or complex nda::Scalar object. |
Definition at line 267 of file mapped_functions.hpp.
| auto nda::log | ( | A && | a | ) |
#include <nda/mapped_functions.hpp>
Function log for non-matrix nda::Array types (lazy and coefficient-wise).
| A | nda::Array type. |
| a | nda::Array object. |
Definition at line 474 of file mapped_functions.hpp.
| mapped< F > nda::map | ( | F | f | ) |
#include <nda/map.hpp>
Create a lazy function call expression on arrays/views.
The callable should take the array/view elements as arguments.
| F | Callable type. |
| f | Callable object. |
|
nodiscard |
#include <nda/mapped_functions.hpp>
Function max for nda::ArrayOrScalar types (lazy and coefficient-wise for nda::Array types).
| A | nda::ArrayOrScalar type. |
| B | nda::ArrayOrScalar type. |
| a | First operand. |
| b | Second operand. |
Definition at line 155 of file mapped_functions.hpp.
|
nodiscard |
#include <nda/mapped_functions.hpp>
Function min for nda::ArrayOrScalar types (lazy and coefficient-wise for nda::Array types).
| A | nda::ArrayOrScalar type. |
| B | nda::ArrayOrScalar type. |
| a | First operand. |
| b | Second operand. |
Definition at line 174 of file mapped_functions.hpp.
| auto nda::pow | ( | A && | a, |
| S | p ) |
#include <nda/mapped_functions.hpp>
Function pow for nda::Array types (lazy and coefficient-wise).
| A | nda::Array type. |
| S | nda::Scalar exponent type. |
| a | nda::Array object. |
| p | Exponent value. |
Definition at line 98 of file mapped_functions.hpp.
| auto nda::real | ( | A && | a | ) |
#include <nda/mapped_functions.hpp>
Function real for nda::ArrayOrScalar types (lazy and coefficient-wise for nda::Array types).
| A | nda::ArrayOrScalar type.. |
| a | nda::ArrayOrScalar object. |
Definition at line 234 of file mapped_functions.hpp.
| auto nda::reciprocal | ( | A && | a | ) |
#include <nda/mapped_functions.hpp>
Reciprocal function for nda::ArrayOrScalar types (lazy and coefficient-wise for nda::Array types).
| A | nda::ArrayOrScalar type. |
| a | nda::ArrayOrScalar object. |
Definition at line 128 of file mapped_functions.hpp.
| auto nda::sin | ( | A && | a | ) |
#include <nda/mapped_functions.hpp>
Function sin for non-matrix nda::Array types (lazy and coefficient-wise).
| A | nda::Array type. |
| a | nda::Array object. |
Definition at line 322 of file mapped_functions.hpp.
| auto nda::sinh | ( | A && | a | ) |
#include <nda/mapped_functions.hpp>
Function sinh for non-matrix nda::Array types (lazy and coefficient-wise).
| A | nda::Array type. |
| a | nda::Array object. |
Definition at line 379 of file mapped_functions.hpp.
| auto nda::sqrt | ( | A && | a | ) |
#include <nda/mapped_functions.hpp>
Function sqrt for non-matrix nda::Array types (lazy and coefficient-wise).
| A | nda::Array type. |
| a | nda::Array object. |
Definition at line 493 of file mapped_functions.hpp.
| auto nda::tan | ( | A && | a | ) |
#include <nda/mapped_functions.hpp>
Function tan for non-matrix nda::Array types (lazy and coefficient-wise).
| A | nda::Array type. |
| a | nda::Array object. |
Definition at line 341 of file mapped_functions.hpp.
| auto nda::tanh | ( | A && | a | ) |
#include <nda/mapped_functions.hpp>
Function tanh for non-matrix nda::Array types (lazy and coefficient-wise).
| A | nda::Array type. |
| a | nda::Array object. |
Definition at line 398 of file mapped_functions.hpp.
| auto nda::trace | ( | M const & | m | ) |
#include <nda/matrix_functions.hpp>
Get the trace of a 2-dimensional square array/view.
| M | nda::ArrayOfRank<2> type. |
| m | 2-dimensional array/view. |
Definition at line 60 of file matrix_functions.hpp.