numerical-collection-cpp 0.10.0
A collection of algorithms in numerical analysis implemented in C++
Loading...
Searching...
No Matches
double_cubic_test_function.h
Go to the documentation of this file.
1/*
2 * Copyright 2021 MusicScience37 (Kenta Kabashima)
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
20#pragma once
21
22#include <Eigen/Core>
23
25
32public:
34 using variable_type = Eigen::Vector2d;
35
37 using jacobian_type = Eigen::Matrix2d;
38
44 void evaluate_on(const variable_type& variable) {
45 const variable_type cubic = variable.array().pow(3);
46 const variable_type dif = 3.0 * variable.array().pow(2); // NOLINT
47 value_[0] = cubic[0] * 2.0 - cubic[1] - 46.0; // NOLINT
48 value_[1] = cubic[1] - 8.0; // NOLINT
49 jacobian_(0, 0) = 2.0 * dif[0]; // NOLINT
50 jacobian_(0, 1) = -dif[1]; // NOLINT
51 jacobian_(1, 0) = dif[0]; // NOLINT
52 jacobian_(1, 1) = 0.0; // NOLINT
53 }
54
60 [[nodiscard]] auto value() const noexcept -> const variable_type& {
61 return value_;
62 }
63
69 [[nodiscard]] auto jacobian() const noexcept -> const jacobian_type& {
70 return jacobian_;
71 }
72
73private:
76
79};
80
81} // namespace num_prob_collect::roots
Class of test function with two cubic functions.
auto jacobian() const noexcept -> const jacobian_type &
Get Jacobian matrix.
auto value() const noexcept -> const variable_type &
Get function value.
void evaluate_on(const variable_type &variable)
Evaluate on a variable.
Eigen::Matrix2d jacobian_type
Type of Jacobian matrices.
Namespace of root-finding problems.
Definition namespaces.h:31