| 182 | } |
| 183 | |
| 184 | void PythonModel::compute_jacobian_vector_product(const double* x, const double* vector, double* result) const { |
| 185 | if (this->user_model.jacobian_operator.has_value()) { |
| 186 | const auto x_py = to_const_array(x, this->number_variables); |
| 187 | const auto vector_py = to_const_array(vector, this->number_variables); |
| 188 | auto result_py = to_array(result, this->number_constraints); |
| 189 | |
| 190 | // evaluate Jacobian-vector product |
| 191 | try { |
| 192 | (*this->user_model.jacobian_operator)(x_py, true, vector_py, result_py); |
| 193 | } |
| 194 | catch (const std::exception&) { |
| 195 | throw GradientEvaluationError(); |
| 196 | } |
| 197 | } |
| 198 | else { |
| 199 | throw std::runtime_error("compute_jacobian_vector_product not implemented"); |
| 200 | } |
| 201 | } |
| 202 | |
| 203 | void PythonModel::compute_jacobian_transposed_vector_product(const double* x, const double* vector, double* result) const { |
| 204 | if (this->user_model.jacobian_transposed_operator.has_value()) { |
nothing calls this directly
no test coverage detected