TRIQS/nda 1.3.0
Multi-dimensional array library for C++
Loading...
Searching...
No Matches

Detailed Description

Automatic assignment uses lazy expressions and placeholders to simplify assigning values to multi-dimensional arrays/views and other container like objects.

The following example shows how to fill a 2-dimensional nda::array of size 3 with the values 0, 1, 2, 10, 11 and 12:

a(i_, j_) << 10 * i_ + j_;
A generic multi-dimensional array.
A placeholder is an empty struct, labelled by an int.
Note
The operator<< in line 3 calls the clef_auto_assign overload for nda::array objects.

We can also use auto assignment to fill a std::vector of size 3 with the values 10, 20 and 30:

std::vector<int> v(3);
nda::clef::make_expr(v)[i_] << 10 * (i_ + 1);
auto make_expr(T &&t)
Create a terminal expression node of an object.
Definition make_lazy.hpp:45
Note
The operator<< in line 3 calls the clef_auto_assign_subscript overload for std::vector objects.

Functions

template<typename Tag , typename... Childs, typename RHS >
__inline__ void nda::clef::clef_auto_assign (expr< Tag, Childs... > const &ex, RHS const &rhs)
 Overload of clef_auto_assign function for generic expressions.
 
template<typename T , typename RHS >
__inline__ void nda::clef::clef_auto_assign (expr< tags::terminal, T > const &ex, RHS &&rhs)
 Overload of clef_auto_assign function for terminal expressions.
 
template<typename T , typename RHS >
__inline__ void nda::clef::clef_auto_assign (std::reference_wrapper< T > wrapper, RHS &&rhs)
 Overload of clef_auto_assign function for std::reference_wrapper objects.
 
template<Array A, typename F >
void nda::clef_auto_assign (A &&a, F &&f)
 Overload of nda::clef::clef_auto_assign function for nda::Array objects.
 
template<typename Tag , typename... Childs, typename RHS >
__inline__ void nda::clef::clef_auto_assign_subscript (expr< Tag, Childs... > const &ex, RHS const &rhs)
 Overload of clef_auto_assign_subscript function for generic expressions.
 
template<typename T , typename RHS >
__inline__ void nda::clef::clef_auto_assign_subscript (expr< tags::terminal, T > const &ex, RHS &&rhs)
 Overload of clef_auto_assign_subscript function for terminal expressions.
 
template<typename T , typename RHS >
__inline__ void nda::clef::clef_auto_assign_subscript (std::reference_wrapper< T > wrapper, RHS &&rhs)
 Overload of clef_auto_assign_subscript function for std::reference_wrapper objects.
 
template<typename T , typename F >
void nda::clef::clef_auto_assign_subscript (std::vector< T > &v, F f)
 Overload of clef_auto_assign_subscript function for std::vector.
 
template<typename F , typename RHS , int... Is>
__inline__ void nda::clef::operator<< (expr< tags::function, F, placeholder< Is >... > const &ex, RHS &&rhs)
 Assign values to the underlying object of a lazy function call expression.
 
template<typename T , typename RHS , int... Is>
__inline__ void nda::clef::operator<< (expr< tags::subscript, T, placeholder< Is >... > const &ex, RHS &&rhs)
 Assign values to the underlying object of a lazy subscript expression.
 

Function Documentation

◆ clef_auto_assign() [1/4]

template<typename Tag , typename... Childs, typename RHS >
__inline__ void nda::clef::clef_auto_assign ( expr< Tag, Childs... > const & ex,
RHS const & rhs )

#include <nda/clef/auto_assign.hpp>

Overload of clef_auto_assign function for generic expressions.

It calls the specialized operator<< function for the given expression and right-hand side.

Template Parameters
TagTag of the expression.
ChildsTypes of the child nodes.
RHSType of the right-hand side.
Parameters
exnda::clef::expr object.
rhsRight-hand side object.

Definition at line 83 of file auto_assign.hpp.

◆ clef_auto_assign() [2/4]

template<typename T , typename RHS >
__inline__ void nda::clef::clef_auto_assign ( expr< tags::terminal, T > const & ex,
RHS && rhs )

#include <nda/clef/auto_assign.hpp>

Overload of clef_auto_assign function for terminal expressions.

Simply calls the clef_auto_assign for the child node of the expression.

Template Parameters
TType of the expression's child node.
RHSType of the right-hand side.
Parameters
exnda::clef::expr object with the nda::clef::tags::terminal tag.
rhsRight-hand side object.

Definition at line 67 of file auto_assign.hpp.

◆ clef_auto_assign() [3/4]

template<typename T , typename RHS >
__inline__ void nda::clef::clef_auto_assign ( std::reference_wrapper< T > wrapper,
RHS && rhs )

#include <nda/clef/auto_assign.hpp>

Overload of clef_auto_assign function for std::reference_wrapper objects.

Simply calls the clef_auto_assign for the object contained in the wrapper.

Template Parameters
TType of the object stored in the std::reference_wrapper.
RHSType of the right-hand side.
Parameters
wrapperstd::reference_wrapper object.
rhsRight-hand side object.

Definition at line 52 of file auto_assign.hpp.

◆ clef_auto_assign() [4/4]

template<Array A, typename F >
void nda::clef_auto_assign ( A && a,
F && f )

#include <nda/basic_functions.hpp>

Overload of nda::clef::clef_auto_assign function for nda::Array objects.

Template Parameters
Anda::Array type.
FCallable type.
Parameters
anda::Array object.
fCallable object.

Definition at line 532 of file basic_functions.hpp.

◆ clef_auto_assign_subscript() [1/4]

template<typename Tag , typename... Childs, typename RHS >
__inline__ void nda::clef::clef_auto_assign_subscript ( expr< Tag, Childs... > const & ex,
RHS const & rhs )

#include <nda/clef/auto_assign_subscript.hpp>

Overload of clef_auto_assign_subscript function for generic expressions.

It calls the specialized operator<< function for the given expression and right-hand side.

Template Parameters
TagTag of the expression.
ChildsTypes of the child nodes.
RHSType of the right-hand side.
Parameters
exnda::clef::expr object.
rhsRight-hand side object.

Definition at line 87 of file auto_assign_subscript.hpp.

◆ clef_auto_assign_subscript() [2/4]

template<typename T , typename RHS >
__inline__ void nda::clef::clef_auto_assign_subscript ( expr< tags::terminal, T > const & ex,
RHS && rhs )

#include <nda/clef/auto_assign_subscript.hpp>

Overload of clef_auto_assign_subscript function for terminal expressions.

Simply calls the clef_auto_assign_subscript for the child node of the expression.

Template Parameters
TType of the expression's child node.
RHSType of the right-hand side.
Parameters
exnda::clef::expr object with the nda::clef::tags::terminal tag.
rhsRight-hand side object.

Definition at line 71 of file auto_assign_subscript.hpp.

◆ clef_auto_assign_subscript() [3/4]

template<typename T , typename RHS >
__inline__ void nda::clef::clef_auto_assign_subscript ( std::reference_wrapper< T > wrapper,
RHS && rhs )

#include <nda/clef/auto_assign_subscript.hpp>

Overload of clef_auto_assign_subscript function for std::reference_wrapper objects.

Simply calls the clef_auto_assign_subscript for the object contained in the wrapper.

Template Parameters
TType of the object stored in the std::reference_wrapper.
RHSType of the right-hand side.
Parameters
wrapperstd::reference_wrapper object.
rhsRight-hand side object.

Definition at line 56 of file auto_assign_subscript.hpp.

◆ clef_auto_assign_subscript() [4/4]

template<typename T , typename F >
void nda::clef::clef_auto_assign_subscript ( std::vector< T > & v,
F f )

#include <nda/clef/adapters/vector.hpp>

Overload of clef_auto_assign_subscript function for std::vector.

Template Parameters
TValue type of the std::vector.
FCallable type.
Parameters
vstd::vector object.
fCallable object.

Definition at line 61 of file vector.hpp.

◆ operator<<() [1/2]

template<typename F , typename RHS , int... Is>
__inline__ void nda::clef::operator<< ( expr< tags::function, F, placeholder< Is >... > const & ex,
RHS && rhs )

#include <nda/clef/auto_assign.hpp>

Assign values to the underlying object of a lazy function call expression.

This calls the clef_auto_assign overload for the underlying object of the given expression using ADL. It has to be implemented for all supported types.

Template Parameters
FType of the callable object in the function call expression.
RHSType of the right-hand side.
IsInteger labels of the placeholders in the function call expression.
Parameters
exnda::clef::expr object with the nda::clef::tags::function tag.
rhsRight-hand side object.

Definition at line 106 of file auto_assign.hpp.

◆ operator<<() [2/2]

template<typename T , typename RHS , int... Is>
__inline__ void nda::clef::operator<< ( expr< tags::subscript, T, placeholder< Is >... > const & ex,
RHS && rhs )

#include <nda/clef/auto_assign_subscript.hpp>

Assign values to the underlying object of a lazy subscript expression.

This calls the clef_auto_assign_subscript overload for the underlying object of the given expression using ADL. It has to be implemented for all supported types.

Template Parameters
TType of the subscripted object in the subscript expression.
RHSType of the right-hand side.
IsInteger labels of the placeholders in the subscript expression.
Parameters
exnda::clef::expr object with the nda::clef::tags::subscript tag.
rhsRight-hand side object.

Definition at line 110 of file auto_assign_subscript.hpp.