1 #ifndef SOPT_CHAINED_OPERATORS_H 
    2 #define SOPT_CHAINED_OPERATORS_H 
    4 #include "sopt/config.h" 
   11 template <
typename T0, 
typename... T>
 
   13   if (
sizeof...(args) == 0) 
return arg0;
 
   15   std::vector<OperatorFunction<T0>> 
const funcs = {arg0, args...};
 
   16   const std::shared_ptr<T0> buffer = std::make_shared<T0>();
 
   18     auto first = funcs.rbegin();
 
   19     auto const last = funcs.rend();
 
   20     if (funcs.size() == 1)
 
   21       (*first)(output, input);
 
   22     else if (funcs.size() % 2 == 1)
 
   23       (*first)(output, input);
 
   25       (*first)(*buffer, input);
 
   27       (*first)(output, *buffer);
 
   29     for (++first; first != last; first++) {
 
   30       (*first)(*buffer, output);
 
   32       (*first)(output, *buffer);
 
OperatorFunction< T0 > chained_operators(OperatorFunction< T0 > const &arg0, T const &... args)
 
std::function< void(VECTOR &, VECTOR const &)> OperatorFunction
Typical function out = A*x.