OGS
NumLib::detail::ComputeDerivativeWrtOneScalar_CD Struct Reference

Detailed Description

Central differences derivative of a function with respect to a single scalar variable.

See also NumLib::CentralDifferencesStrategy.

Definition at line 57 of file NumericalDifferentiation.h.

#include <NumericalDifferentiation.h>

Public Member Functions

template<typename Function , typename TupleOfArgs , typename PerturbationStrategy , std::size_t PerturbedArgIdx, std::size_t... AllArgIdcs>
auto operator() (Function const &f, TupleOfArgs const &args, PerturbationStrategy const &pert_strat, std::integral_constant< std::size_t, PerturbedArgIdx >, Eigen::Index const perturbed_arg_component, std::index_sequence< AllArgIdcs... >) const
 

Member Function Documentation

◆ operator()()

template<typename Function , typename TupleOfArgs , typename PerturbationStrategy , std::size_t PerturbedArgIdx, std::size_t... AllArgIdcs>
auto NumLib::detail::ComputeDerivativeWrtOneScalar_CD::operator() ( Function const & f,
TupleOfArgs const & args,
PerturbationStrategy const & pert_strat,
std::integral_constant< std::size_t, PerturbedArgIdx > ,
Eigen::Index const perturbed_arg_component,
std::index_sequence< AllArgIdcs... >  ) const
inline

Definition at line 62 of file NumericalDifferentiation.h.

67 {
68 auto const value_plus = f(pert_strat.perturbIf(
69 std::bool_constant<PerturbedArgIdx == AllArgIdcs>{},
70 std::get<AllArgIdcs>(args), 1.0, perturbed_arg_component)...);
71
72 auto const value_minus = f(pert_strat.perturbIf(
73 std::bool_constant<PerturbedArgIdx == AllArgIdcs>{},
74 std::get<AllArgIdcs>(args), -1.0, perturbed_arg_component)...);
75
76 auto const pert = pert_strat.getPerturbation(
78 args, perturbed_arg_component));
79
80 // decltype enforces evaluation of Eigen expressions
81 decltype(value_plus) deriv = (value_plus - value_minus) / (2 * pert);
82
83 return deriv;
84 }
double getScalarOrVectorComponent(Tuple const &tuple, Eigen::Index component)

References NumLib::detail::getScalarOrVectorComponent().


The documentation for this struct was generated from the following file: