numerical-collection-cpp 0.10.0
A collection of algorithms in numerical analysis implemented in C++
Loading...
Searching...
No Matches
cubic_root_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
23
28public:
30 using variable_type = double;
31
33 using jacobian_type = double;
34
40 explicit cubic_root_test_function(variable_type target) : target_(target) {}
41
47 void evaluate_on(const variable_type& variable) {
48 value_ = variable * variable * variable - target_;
49 jacobian_ = 3.0 * variable * variable; // NOLINT
50 }
51
57 [[nodiscard]] auto value() const noexcept -> const variable_type& {
58 return value_;
59 }
60
66 [[nodiscard]] auto jacobian() const noexcept -> const jacobian_type& {
67 return jacobian_;
68 }
69
70private:
73
76
79};
80
81} // namespace num_prob_collect::roots
Class of test function to calculate cubic root of a number.
void evaluate_on(const variable_type &variable)
Evaluate on a variable.
variable_type target_
Value to calculate cubic root of.
auto jacobian() const noexcept -> const jacobian_type &
Get Jacobian matrix.
auto value() const noexcept -> const variable_type &
Get function value.
Namespace of root-finding problems.
Definition namespaces.h:31