TRIQS/nda 1.3.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);
A generic multi-dimensional array.
T pow(T x, int n)
Calculate the integer power of an integer.

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 90 of file map.hpp.

Public Member Functions

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< const As... > a
 Tuple containing the nda::Array arguments.
 
f
 Callable object of the expression.
 

Member Function Documentation

◆ 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 129 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 146 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 155 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 161 of file map.hpp.


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