numerical-collection-cpp 0.10.0
A collection of algorithms in numerical analysis implemented in C++
Loading...
Searching...
No Matches
wendland_csrbf.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
26
27namespace num_collect::rbf::rbfs {
28
39template <base::concepts::real_scalar Scalar, index_type L, index_type K>
41
50template <base::concepts::real_scalar Scalar, index_type L>
51 requires(L >= 1)
53public:
55 using scalar_type = Scalar;
56
62 [[nodiscard]] static constexpr auto support_boundary() noexcept
63 -> scalar_type {
64 return static_cast<scalar_type>(1);
65 }
66
73 [[nodiscard]] auto operator()(
74 const scalar_type& distance_rate) const noexcept -> scalar_type {
75 using std::pow;
76 if (distance_rate > static_cast<scalar_type>(1)) {
77 return static_cast<scalar_type>(0);
78 }
79 // pow function wrongly returns double even when scalar_type is float.
80 return static_cast<scalar_type>(
81 pow(static_cast<scalar_type>(1) - distance_rate, L));
82 }
83};
84
93template <base::concepts::real_scalar Scalar, index_type L>
94 requires(L >= 1)
96public:
98 using scalar_type = Scalar;
99
105 [[nodiscard]] static constexpr auto support_boundary() noexcept
106 -> scalar_type {
107 return static_cast<scalar_type>(1);
108 }
109
116 [[nodiscard]] auto operator()(
117 const scalar_type& distance_rate) const noexcept -> scalar_type {
118 using std::pow;
119 if (distance_rate > static_cast<scalar_type>(1)) {
120 return static_cast<scalar_type>(0);
121 }
122
123 static constexpr scalar_type scale_coeff = static_cast<scalar_type>(1) /
124 (static_cast<scalar_type>(L + 1) * static_cast<scalar_type>(L + 2));
125
126 // pow function wrongly returns double even when scalar_type is float.
127 const auto pow_value = static_cast<scalar_type>(
128 pow(static_cast<scalar_type>(1) - distance_rate, L + 1));
129
130 static constexpr auto first_order_term_coeff =
131 static_cast<scalar_type>(L + 1);
132 static constexpr auto constant_term = static_cast<scalar_type>(1);
133 return scale_coeff * pow_value *
134 (first_order_term_coeff * distance_rate + constant_term);
135 }
136};
137
146template <base::concepts::real_scalar Scalar, index_type L>
147 requires(L >= 1)
149public:
151 using scalar_type = Scalar;
152
158 [[nodiscard]] static constexpr auto support_boundary() noexcept
159 -> scalar_type {
160 return static_cast<scalar_type>(1);
161 }
162
169 [[nodiscard]] auto operator()(
170 const scalar_type& distance_rate) const noexcept -> scalar_type {
171 using std::pow;
172 if (distance_rate > static_cast<scalar_type>(1)) {
173 return static_cast<scalar_type>(0);
174 }
175
176 static constexpr scalar_type scale_coeff = static_cast<scalar_type>(1) /
177 (static_cast<scalar_type>(L + 1) * static_cast<scalar_type>(L + 2) *
178 static_cast<scalar_type>(L + 3) *
179 static_cast<scalar_type>(L + 4));
180
181 // pow function wrongly returns double even when scalar_type is float.
182 const auto pow_value = static_cast<scalar_type>(
183 pow(static_cast<scalar_type>(1) - distance_rate, L + 2));
184
185 static constexpr auto second_order_term_coeff =
186 static_cast<scalar_type>(L + 1) * static_cast<scalar_type>(L + 3);
187 static constexpr auto first_order_term_coeff =
188 static_cast<scalar_type>(3) * static_cast<scalar_type>(L + 2);
189 static constexpr auto constant_term = static_cast<scalar_type>(3);
190 return scale_coeff * pow_value *
191 (second_order_term_coeff * distance_rate * distance_rate +
192 first_order_term_coeff * distance_rate + constant_term);
193 }
194};
195
196} // namespace num_collect::rbf::rbfs
static constexpr auto support_boundary() noexcept -> scalar_type
Get the boundary of the support of this CSRBF.
auto operator()(const scalar_type &distance_rate) const noexcept -> scalar_type
Calculate a function value of RBF.
auto operator()(const scalar_type &distance_rate) const noexcept -> scalar_type
Calculate a function value of RBF.
static constexpr auto support_boundary() noexcept -> scalar_type
Get the boundary of the support of this CSRBF.
static constexpr auto support_boundary() noexcept -> scalar_type
Get the boundary of the support of this CSRBF.
auto operator()(const scalar_type &distance_rate) const noexcept -> scalar_type
Calculate a function value of RBF.
Class of Wendland's Compactly Supported RBF wendland1995.
Definition of index_type type.
Namespace of RBFs.
Definition of real_scalar concept.