3 #include "../../types.hpp" 4 #include "../../utilities/evaluations.hpp" 15 namespace localQuadratic
30 template <
class Subtype,
class Basis>
38 const argument_type &arg,
39 const argument_type &position )
const {
40 return static_cast<const Subtype*
>(
this)->evaluate_local_quadratic_at_implementation( arg,position );
43 template <
template <
typename...>
class grid_in = std::vector,
44 template <
typename...>
class grid_out = grid_in >
46 const grid_in<argument_type > &args,
47 argument_type position )
const {
49 potential_evaluation_type,
55 std::placeholders::_1,
70 template <
class TaylorImpl,
class Basis>
79 jacobian_type jacobian,
80 hessian_type hessian )
81 : TaylorImpl( potential, jacobian, hessian ) {
85 const argument_type &x,
86 const argument_type &q )
const {
88 potential_evaluation_type result_matrix;
90 auto V_mat = TaylorImpl::evaluate_at(q );
91 auto J_mat = TaylorImpl::evaluate_jacobian_at(q );
92 auto H_mat = TaylorImpl::evaluate_hessian_at(q );
94 for (
int l = 0; l < Basis::number_of_levels; ++l ) {
95 for (
int m = 0; m < Basis::number_of_columns; ++m ) {
96 const auto& V = V_mat(l,m);
97 const auto& J = J_mat(l,m);
98 const auto& H = H_mat(l,m);
102 for (
int i = 0; i < Basis::argument_dimension; ++i ) {
103 auto xmqi = x[i] - q[i];
104 result += J[i] * ( xmqi );
106 for (
int j = 0; j < Basis::argument_dimension; ++j ) {
107 result += 0.5 * xmqi * H( i, j ) * ( x[j] - q[j] );
111 result_matrix(l,m) = result;
115 return result_matrix;
132 template <
class TaylorImpl,
template <
int,
int,
int>
class B,
int N,
int C>
133 class Standard<TaylorImpl, B<N, 1, C>> :
public Abstract<Standard<TaylorImpl, B<N,1, C>>, B<N,1, C>>,
142 jacobian_type jacobian,
143 hessian_type hessian )
144 : TaylorImpl( potential, jacobian, hessian ) {
148 const argument_type &x,
149 const argument_type &q )
const {
152 potential_evaluation_type result_matrix;
154 auto V_mat = TaylorImpl::evaluate_at(q );
155 auto J_mat = TaylorImpl::evaluate_jacobian_at(q );
156 auto H_mat = TaylorImpl::evaluate_hessian_at(q );
158 for (
int l = 0; l < Basis::number_of_levels; ++l ) {
159 for (
int m = 0; m < Basis::number_of_columns; ++m ) {
160 const auto& V = V_mat(l,m);
161 const auto& J = J_mat(l,m);
162 const auto& H = H_mat(l,m);
165 result_matrix(l,m) = V + J*xmq + 0.5*xmq*H*xmq;
169 return result_matrix;
187 template <
class TaylorImpl,
template <
int,
int,
int>
class B,
int D,
int C>
189 Standard<TaylorImpl, B<1,D,C>>, B<1,D,C> >,
public TaylorImpl
196 jacobian_type jacobian,
197 hessian_type hessian )
198 : TaylorImpl( potential, jacobian, hessian ) {
202 const argument_type &x,
203 const argument_type &q )
const {
204 auto V = TaylorImpl::evaluate_at( q );
205 auto J = TaylorImpl::evaluate_jacobian_at(q );
206 auto H = TaylorImpl::evaluate_hessian_at(q );
210 for (
int i = 0; i < D; ++i ) {
211 auto xmqi = x[i] - q[i];
212 result += J[i] * ( xmqi );
214 for (
int j = 0; j < D; ++j ) {
215 result += 0.5 * xmqi * H( i, j ) * ( x[j] - q[j] );
234 template <
class TaylorImpl,
template <
int,
int,
int>
class B,
int C>
235 class Standard<TaylorImpl, B<1,1,C>> :
public Abstract<Standard<TaylorImpl, B<1, 1,C>>, B<1, 1,C>>,
244 jacobian_type jacobian,
245 hessian_type hessian )
246 : TaylorImpl( potential, jacobian, hessian ) {
250 const argument_type &x,
251 const argument_type &q )
const {
254 auto V = TaylorImpl::evaluate_at(q );
255 auto J = TaylorImpl::evaluate_jacobian_at(q );
256 auto H = TaylorImpl::evaluate_hessian_at(q );
258 return V + J*xmq + 0.5*xmq*H*xmq;
263 template <
class Basis>
potential_evaluation_type evaluate_local_quadratic_at_implementation(const argument_type &x, const argument_type &q) const
Definition: localQuadratic.hpp:249
Definition: coefficients_file_parser.cpp:10
B< 1, D, C > Basis
Definition: localQuadratic.hpp:192
G_out< R > evaluate_function_in_grid(const F< R(A)> &f, const G_in< A > &g)
Evaluate a function in multiple points at once.
Definition: evaluations.hpp:130
potential_evaluation_type evaluate_local_quadratic_at_implementation(const argument_type &x, const argument_type &q) const
Definition: localQuadratic.hpp:84
Abstract class for local quadratic evaluation.
Definition: localQuadratic.hpp:31
B< N, 1, C > Basis
Definition: localQuadratic.hpp:137
potential_evaluation_type evaluate_local_quadratic_at(const argument_type &arg, const argument_type &position) const
Definition: localQuadratic.hpp:37
std::function< P > function_t
Definition: types.hpp:57
potential_evaluation_type evaluate_local_quadratic_at_implementation(const argument_type &x, const argument_type &q) const
Definition: localQuadratic.hpp:201
Standard(potential_type potential, jacobian_type jacobian, hessian_type hessian)
Definition: localQuadratic.hpp:78
#define IMPORT_TYPES_FROM(B)
Definition: bases.hpp:3
grid_out< potential_evaluation_type > evaluate_local_remainder(const grid_in< argument_type > &args, argument_type position) const
Definition: localQuadratic.hpp:45
B< 1, 1, C > Basis
Definition: localQuadratic.hpp:239
potential_evaluation_type evaluate_local_quadratic_at_implementation(const argument_type &x, const argument_type &q) const
Definition: localQuadratic.hpp:147
Helper class for easier template specialization.
Definition: localQuadratic.hpp:71