MCPcopy Create free account
hub / github.com/PatWie/CppNumericalSolvers / operator()

Method operator()

include/cppoptlib/function_base.h:103–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

101 static constexpr DifferentiabilityMode Differentiability = TMode;
102
103 virtual TScalar operator()(const VectorType& x, VectorType* grad = nullptr,
104 MatrixType* hess = nullptr) const override {
105 if constexpr (TMode == DifferentiabilityMode::None) {
106 return static_cast<const Derived*>(this)->operator()(x);
107 } else if constexpr (TMode == DifferentiabilityMode::First) {
108 if (hess) {
109#if defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)
110 throw std::runtime_error(
111 "Hessian not available for first order function.");
112#else
113 std::abort();
114#endif
115 }
116 return static_cast<const Derived*>(this)->operator()(x, grad);
117 } else { // DifferentiabilityMode::Second
118 return static_cast<const Derived*>(this)->operator()(x, grad, hess);
119 }
120 }
121
122 virtual std::unique_ptr<FunctionInterface<TScalar, TMode, TDimension>> clone()
123 const override {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected