| 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 { |
nothing calls this directly
no outgoing calls
no test coverage detected