2019-10-10 21:44:57 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
namespace op{
|
2019-10-24 17:12:43 +02:00
|
|
|
|
2019-10-27 19:49:54 +01:00
|
|
|
template< typename field>
|
|
|
|
inline auto assign_to( field& g ){return [&g](auto i, auto v){ g[i] = v; };}
|
2019-10-24 17:12:43 +02:00
|
|
|
|
2019-10-27 19:49:54 +01:00
|
|
|
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; };}
|
2019-10-24 17:12:43 +02:00
|
|
|
|
2019-10-27 19:49:54 +01:00
|
|
|
template< typename field>
|
|
|
|
inline auto add_to( field& g ){return [&g](auto i, auto v){ g[i] += v; };}
|
2019-10-24 17:12:43 +02:00
|
|
|
|
2019-10-27 19:49:54 +01:00
|
|
|
template< typename field>
|
|
|
|
inline auto add_twice_to( field& g ){return [&g](auto i, auto v){ g[i] += 2*v; };}
|
2019-10-24 17:12:43 +02:00
|
|
|
|
2019-10-27 19:49:54 +01:00
|
|
|
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; };}
|
2019-10-24 17:12:43 +02:00
|
|
|
|
2019-10-12 15:06:49 +02:00
|
|
|
}
|