Himalaya
Classes | Namespaces | Macros | Functions
Sum.hpp File Reference

Contains the definition of the SUM macro. More...

#include <type_traits>
#include <cstddef>
#include <Eigen/Core>
Include dependency graph for Sum.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  himalaya::mh2_fo::is_eigen_type< T >
 
struct  himalaya::mh2_fo::EvalEigenXprImpl< Idx, Function, isEigenType >
 
struct  himalaya::mh2_fo::EvalEigenXprImpl< Idx, Function, true >
 
struct  himalaya::mh2_fo::create_zero< T, isEigenType >
 
struct  himalaya::mh2_fo::create_zero< T, true >
 

Namespaces

 himalaya
 
 himalaya::mh2_fo
 

Macros

#define SUM(...)   (get_sum(__VA_ARGS__)(__VA_ARGS__))
 
#define get_sum(...)   get_sum_macro(__VA_ARGS__, sum_user_t, sum_ptrdiff_t,)
 
#define get_sum_macro(_1, _2, _3, _4, _5, name, ...)   name
 
#define sum_ptrdiff_t(idx, ini, fin, expr)   sum<std::ptrdiff_t>((ini), (fin), [&](std::ptrdiff_t (idx)) { return (expr); })
 
#define sum_user_t(type, idx, ini, fin, expr)   sum<type>((ini), (fin), [&](type (idx)) { return (expr); })
 

Functions

template<typename Idx , typename Function >
auto himalaya::mh2_fo::EvalEigenXpr (Idx i, Function f) -> decltype(EvalEigenXprImpl< Idx, Function, is_eigen_type< decltype(f(i))>::value >::eval(i, f))
 
template<class Idx , class Function >
auto himalaya::mh2_fo::sum (Idx ini, Idx fin, Function f) -> decltype(EvalEigenXpr< Idx >(ini, f))
 

Detailed Description

Contains the definition of the SUM macro.

Usage example of the SUM macro:

Calculate $\sum_{n=1}^{10} n^2$

const double s = SUM(n,1,10,n*n);

Definition in file Sum.hpp.

Macro Definition Documentation

◆ get_sum

#define get_sum (   ...)    get_sum_macro(__VA_ARGS__, sum_user_t, sum_ptrdiff_t,)

Definition at line 33 of file Sum.hpp.

◆ get_sum_macro

#define get_sum_macro (   _1,
  _2,
  _3,
  _4,
  _5,
  name,
  ... 
)    name

Definition at line 35 of file Sum.hpp.

◆ SUM

#define SUM (   ...)    (get_sum(__VA_ARGS__)(__VA_ARGS__))

Definition at line 31 of file Sum.hpp.

◆ sum_ptrdiff_t

#define sum_ptrdiff_t (   idx,
  ini,
  fin,
  expr 
)    sum<std::ptrdiff_t>((ini), (fin), [&](std::ptrdiff_t (idx)) { return (expr); })

Definition at line 37 of file Sum.hpp.

◆ sum_user_t

#define sum_user_t (   type,
  idx,
  ini,
  fin,
  expr 
)    sum<type>((ini), (fin), [&](type (idx)) { return (expr); })

Definition at line 40 of file Sum.hpp.