TRIQS/nda 1.3.0
Multi-dimensional array library for C++
Loading...
Searching...
No Matches
nda::expr< OP, L, R >

#include <nda/arithmetic.hpp>

Detailed Description

template<char OP, ArrayOrScalar L, ArrayOrScalar R>
struct nda::expr< OP, L, R >

Lazy binary expression for nda::ArrayOrScalar types.

A lazy binary expression contains a two operands and a binary operation. It fulfills the nda::Array concept and can therefore be used in any other expression or function that expects an nda::Array type.

The supported binary operations are addition ('+'), subtraction ('-'), multiplication ('*') and division ('/').

Template Parameters
OPChar representing the unary operation.
Parameters
Lnda::ArrayOrScalar type of left hand side.
Rnda::ArrayOrScalar type of right hand side.

Definition at line 106 of file arithmetic.hpp.

Public Types

using L_t = std::decay_t<L>
 Decay type of the left hand side operand.
 
using R_t = std::decay_t<R>
 Decay type of the right hand side operand.
 

Public Member Functions

template<typename... Args>
auto operator() (Args const &...args) const
 Function call operator.
 
template<typename Arg >
auto operator[] (Arg &&arg) const
 Subscript operator.
 
constexpr decltype(auto) shape () const
 Get the shape of the expression (result of the operation).
 
constexpr long size () const
 Get the total size of the expression (result of the operation).
 

Static Public Member Functions

static constexpr layout_info_t compute_layout_info ()
 Compute the layout information of the expression.
 

Public Attributes

l
 nda::ArrayOrScalar left hand side operand.
 
r
 nda::ArrayOrScalar right hand side operand.
 

Static Public Attributes

static constexpr char algebra = (l_is_scalar ? get_algebra<R> : get_algebra<L>)
 Constexpr variable specifying the algebra of one of the non-scalar operands.
 
static constexpr bool l_is_scalar = nda::is_scalar_v<L>
 Constexpr variable that is true if the left hand side operand is a scalar.
 
static constexpr bool r_is_scalar = nda::is_scalar_v<R>
 Constexpr variable that is true if the right hand side operand is a scalar.
 

Member Function Documentation

◆ compute_layout_info()

template<char OP, ArrayOrScalar L, ArrayOrScalar R>
static constexpr layout_info_t nda::expr< OP, L, R >::compute_layout_info ( )
inlinestaticconstexpr

Compute the layout information of the expression.

Returns
nda::layout_info_t object.

Definition at line 133 of file arithmetic.hpp.

◆ operator()()

template<char OP, ArrayOrScalar L, ArrayOrScalar R>
template<typename... Args>
auto nda::expr< OP, L, R >::operator() ( Args const &... args) const
inline

Function call operator.

Forwards the arguments to the nda::Array operands and performs the binary operation.

Template Parameters
ArgsTypes of the arguments.
Parameters
argsFunction call arguments.
Returns
If the result of the forwarded function calls contains another nda::Array, a new lazy expression is returned. Otherwise the result of the binary operation is returned.

Definition at line 180 of file arithmetic.hpp.

◆ operator[]()

template<char OP, ArrayOrScalar L, ArrayOrScalar R>
template<typename Arg >
auto nda::expr< OP, L, R >::operator[] ( Arg && arg) const
inline

Subscript operator.

Simply forwards the argument to the function call operator.

Template Parameters
ArgType of the argument.
Parameters
argSubscript argument.
Returns
Result of the corresponding function call.

Definition at line 269 of file arithmetic.hpp.

◆ shape()

template<char OP, ArrayOrScalar L, ArrayOrScalar R>
decltype(auto) nda::expr< OP, L, R >::shape ( ) const
inlinenodiscardconstexpr

Get the shape of the expression (result of the operation).

Returns
std::array<long, Rank> object specifying the shape of the expression.

Definition at line 143 of file arithmetic.hpp.

◆ size()

template<char OP, ArrayOrScalar L, ArrayOrScalar R>
long nda::expr< OP, L, R >::size ( ) const
inlinenodiscardconstexpr

Get the total size of the expression (result of the operation).

Returns
Number of elements contained in the expression.

Definition at line 158 of file arithmetic.hpp.


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