1
0
Fork 0
mirror of https://github.com/cosmo-sims/monofonIC.git synced 2024-09-19 17:03:45 +02:00
monofonIC/include/operators.hh
2019-10-27 19:49:54 +01:00

23 lines
710 B
C++

#pragma once
namespace op{
template< typename field>
inline auto assign_to( field& g ){return [&g](auto i, auto v){ g[i] = v; };}
template< typename field, typename val >
inline auto multiply_add_to( field& g, val x ){return [&g,x](auto i, auto v){ g[i] += v*x; };}
template< typename field>
inline auto add_to( field& g ){return [&g](auto i, auto v){ g[i] += v; };}
template< typename field>
inline auto add_twice_to( field& g ){return [&g](auto i, auto v){ g[i] += 2*v; };}
template< typename field>
inline auto subtract_from( field& g ){return [&g](auto i, auto v){ g[i] -= v; };}
template< typename field>
inline auto subtract_twice_from( field& g ){return [&g](auto i, auto v){ g[i] -= 2*v; };}
}