Discontinuous Galerkin Library
#include "dg/algorithm.h"
Composition of two or more functors
Collaboration diagram for Composition of two or more functors:

Functions

template<class UnaryOp , class Functor >
auto dg::compose (UnaryOp f, Functor g)
 Create Composition functor \( f(g(x_0,x_1,...)) \). More...
 
template<class UnaryOp , typename... Functors>
auto dg::compose (UnaryOp f0, Functors... fs)
 Create Composition funtor of an arbitrary number of functions \( f_0(f_1(f_2( ... f_s(x_0, x_1, ...)))\). More...
 

Detailed Description

Function Documentation

◆ compose() [1/2]

template<class UnaryOp , class Functor >
auto dg::compose ( UnaryOp  f,
Functor  g 
)

Create Composition functor \( f(g(x_0,x_1,...)) \).

dg::Grid2d grid2d( -1., 1., -1., 1., 3, 40, 40);
//Mark everything above 2 with 1s and below with 0s
dg::HVec fg = dg::evaluate( dg::compose( dg::Heaviside( 2.), dg::Gaussian( 0., 0., 2., 2., 4.)), grid2d);
auto compose(UnaryOp f, Functor g)
Create Composition functor .
Definition: subroutines.h:380
thrust::host_vector< real_type > evaluate(UnaryOp f, const RealGrid1d< real_type > &g)
Evaluate a 1d function on grid coordinates.
Definition: evaluation.h:67
thrust::host_vector< double > HVec
Host Vector.
Definition: typedefs.h:19
Definition: functors.h:630
Definition: functors.h:509
Template Parameters
UnaryOpModel of Unary Function taking the return type of g return_type_f f(return_type_g)
FunctorInner functor, takes an arbitrary number of parameters and returns one return_type_g g(value_type0,value_type1,...)
Parameters
fouter functor
ginner functor
Attention
only works for host functions. The rationale is that this function is intended to work with lambda functions and previously nvcc did not support lambdas. If a version for device functions is ever needed it can be provided.
Returns
a function object that forwards all parameters to g and returns the return value of f, which is \( f(g(x_0,x_1,...)) \)

◆ compose() [2/2]

template<class UnaryOp , typename... Functors>
auto dg::compose ( UnaryOp  f0,
Functors...  fs 
)

Create Composition funtor of an arbitrary number of functions \( f_0(f_1(f_2( ... f_s(x_0, x_1, ...)))\).

Template Parameters
UnaryOpModel of Unary Function taking the return type of f_1 return_type_f0 f0(return_type_f1)
FsUnaryOps except the innermost functor, which takes an arbitrary number of parameters and returns one return_type_fs f_s(value_type0,value_type1,...)