numerical-collection-cpp 0.10.0
A collection of algorithms in numerical analysis implemented in C++
Loading...
Searching...
No Matches
euclidean_distance_function.h
Go to the documentation of this file.
1/*
2 * Copyright 2024 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 <cmath>
23
27
29
35template <typename Variable>
37
43template <base::concepts::real_scalar_dense_vector Variable>
44class euclidean_distance_function<Variable> {
45public:
47 using variable_type = Variable;
48
50 using value_type = typename Variable::Scalar;
51
59 [[nodiscard]] auto operator()(const variable_type& var1,
60 const variable_type& var2) const noexcept -> value_type {
61 return norm(var1 - var2);
62 }
63};
64
70template <base::concepts::real_scalar Variable>
72public:
74 using variable_type = Variable;
75
77 using value_type = Variable;
78
86 [[nodiscard]] auto operator()(const variable_type& var1,
87 const variable_type& var2) const noexcept -> value_type {
88 using std::abs;
89 return abs(var1 - var2);
90 }
91};
92
93} // namespace num_collect::rbf::distance_functions
auto operator()(const variable_type &var1, const variable_type &var2) const noexcept -> value_type
Calculate a distance.
auto norm(const Matrix &matrix)
Calculate norm of a matrix.
Definition norm.h:39
Namespace of distance functions for RBF interpolation.
Definition of norm class.
Definition of real_scalar concept.
Definition of real_scalar_dense_vector concept.