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
24
namespace
num_prob_collect::roots
{
25
31
class
double_cubic_test_function
{
32
public
:
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
73
private
:
75
variable_type
value_
{};
76
78
jacobian_type
jacobian_
{};
79
};
80
81
}
// namespace num_prob_collect::roots
num_prob_collect::roots::double_cubic_test_function
Class of test function with two cubic functions.
Definition
double_cubic_test_function.h:31
num_prob_collect::roots::double_cubic_test_function::variable_type
Eigen::Vector2d variable_type
Type of variables.
Definition
double_cubic_test_function.h:34
num_prob_collect::roots::double_cubic_test_function::jacobian
auto jacobian() const noexcept -> const jacobian_type &
Get Jacobian matrix.
Definition
double_cubic_test_function.h:69
num_prob_collect::roots::double_cubic_test_function::value
auto value() const noexcept -> const variable_type &
Get function value.
Definition
double_cubic_test_function.h:60
num_prob_collect::roots::double_cubic_test_function::jacobian_
jacobian_type jacobian_
Jacobian matrix.
Definition
double_cubic_test_function.h:78
num_prob_collect::roots::double_cubic_test_function::evaluate_on
void evaluate_on(const variable_type &variable)
Evaluate on a variable.
Definition
double_cubic_test_function.h:44
num_prob_collect::roots::double_cubic_test_function::value_
variable_type value_
Function value.
Definition
double_cubic_test_function.h:75
num_prob_collect::roots::double_cubic_test_function::jacobian_type
Eigen::Matrix2d jacobian_type
Type of Jacobian matrices.
Definition
double_cubic_test_function.h:37
num_prob_collect::roots
Namespace of root-finding problems.
Definition
namespaces.h:31
problems
include
num_prob_collect
roots
double_cubic_test_function.h
Generated on Sat Jan 18 2025 03:47:34 for numerical-collection-cpp by
1.12.0