TRIQS/nda 2.0.0
Multi-dimensional array library for C++
Loading...
Searching...
No Matches
nda::expr_call< F, As >

#include <nda/map.hpp>

Detailed Description

template<typename F, Array... As>
struct nda::expr_call< F, As >

A lazy function call expression on arrays/views.

The lazy expression call fulfils the nda::Array concept and can therefore be assigned to other nda::basic_array or nda::basic_array_view objects. For example:

nda::matrix<int> mat{{1, 2}, {3, 4}};
nda::matrix<int> pmat = nda::pow(mat, 2);
auto pow(A &&a, double p)
Function pow for nda::ArrayOrScalar types (lazy and coefficient-wise for nda::Array types).
basic_array< ValueType, 2, Layout, 'M', ContainerPolicy > matrix
Alias template of an nda::basic_array with rank 2 and an 'M' algebra.

Here, nda::pow(mat, 2) returns a lazy expression call object which is then used in the constructor of pmat.

The callable object should take the array/view elements as arguments.

Template Parameters
FCallable type.
Asnda::Array argument types.

Definition at line 83 of file map.hpp.

Public Member Functions

template<size_t I = 0>
auto & operand ()
 Get one of the nda::Array arguments of the expression.
template<size_t I = 0>
auto const & operand () const
 Const overload of expr_call::operand.
template<typename... Args>
auto operator() (Args const &...args) const
 Function call operator.
template<typename Arg>
auto operator[] (Arg const &arg) const
 Subscript operator.
auto shape () const
 Get the shape of the nda::Array objects.
long size () const
 Get the total size of the nda::Array objects.

Public Attributes

std::tuple< As... > a
 Tuple containing the nda::Array arguments.
f
 Callable object of the expression.

Member Function Documentation

◆ operand()

template<typename F, Array... As>
template<size_t I = 0>
auto & nda::expr_call< F, As >::operand ( )
inlinenodiscard

Get one of the nda::Array arguments of the expression.

The returned reference carries the constness of the expression object, i.e. a const expression never hands out a writable operand.

Template Parameters
IIndex of the argument in the tuple expr_call::a.
Returns
Reference to the I-th nda::Array argument.

Definition at line 175 of file map.hpp.

◆ operator()()

template<typename F, Array... As>
template<typename... Args>
auto nda::expr_call< F, As >::operator() ( Args const &... args) const
inline

Function call operator.

The arguments (usually multi-dimensional indices) are passed to all the nda::Array objects stored in the tuple and the results are then passed to the callable object.

If the arguments contain a range, a new lazy function call expression is returned.

Template Parameters
ArgsArgument types.
Parameters
argsFunction call arguments.
Returns
The result of the function call (depends on the callable and the arguments).

Definition at line 131 of file map.hpp.

◆ operator[]()

template<typename F, Array... As>
template<typename Arg>
auto nda::expr_call< F, As >::operator[] ( Arg const & arg) const
inline

Subscript operator.

The argument (usually a 1-dimensional index) is passed to all the nda::Array objects stored in the tuple and the results are then passed to the callable object.

If the argument is a range, a new lazy function call expression is returned.

Template Parameters
ArgArgument types.
Parameters
argSubscript argument.
Returns
The result of the subscript operation (depends on the callable and the arguments).

Definition at line 148 of file map.hpp.

◆ shape()

template<typename F, Array... As>
auto nda::expr_call< F, As >::shape ( ) const
inlinenodiscard

Get the shape of the nda::Array objects.

Returns
std::array<long, Rank> object specifying the shape of each nda::Array object.

Definition at line 157 of file map.hpp.

◆ size()

template<typename F, Array... As>
long nda::expr_call< F, As >::size ( ) const
inlinenodiscard

Get the total size of the nda::Array objects.

Returns
Number of elements contained in each nda::Array object.

Definition at line 163 of file map.hpp.

Member Data Documentation

◆ a

template<typename F, Array... As>
std::tuple<As...> nda::expr_call< F, As >::a

Tuple containing the nda::Array arguments.

Lvalue operands are stored by reference, so reading this member directly can hand out a writable operand even from a const expression. Access it through expr_call::operand instead, which propagates the constness of the expression object.

Definition at line 94 of file map.hpp.


The documentation for this struct was generated from the following file: