Loading [MathJax]/extensions/TeX/AMSsymbols.js
Automatic Differentiation
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches

◆ filter_map()

template<template< typename... > class Filter, bool InVector = false, bool InTuple = false, typename F , typename T >
constexpr decltype(auto) stan::math::internal::filter_map ( F &&  f,
T &&  x 
)
inlineconstexpr

Filter a tuple and apply a functor to each element that passes the filter.

Note
The Filter must have a static constexpr bool member named value that is true if the type should be included in the output tuple. Note that this function automatically inspects into tuples and std::vector<T>::value_type's. The filter_map will recursively apply itself to inner containers as long as it sees a tuple in type type. So for instance if your type is a tuple<vector<tuple<vector<vector<double>>>> your functor f must support operationg on vector<vector<double>> types.
Template Parameters
Filtera struct that accepts one template parameter and has a static constexpr bool member named value that is true if the type should be included in the output tuple.
InVectorFor internal use. If true then we assume we are inside of a std::vector and the return type should not be wrapped in a tuple.
InTupleFor internal use. If true then we assume we are inside of a tuple and any subtuples should be double wrapped so that tuple_concat produces a tuple for this element.
FType of functor
TAny type
Parameters
ffunctor callable
xAny type
Returns
a tuple with the functor applied to each element which passed the filter.

If we are in at this stage, we want tuple_concat to return a tuple here So we return a tuple(tuple()) so that tuple_cat concats the first layer of tuple. For example, if our input is a tuple(double, tuple(double, vec<double>)) with an identity filter we want tuple_concat to return a tuple(double, tuple(double, vec<double>)). Without the double tuple we would get back a tuple(double, double, vec<double>).

Definition at line 73 of file filter_map.hpp.