69template <
typename FunctionSignature,
94template <
typename Variable,
typename FunctionValue,
concepts::rbf RBF,
99 PolynomialDegree, KernelMatrixType, DistanceFunction,
118 static constexpr bool uses_global_length_parameter =
119 length_parameter_calculator_type::uses_global_length_parameter;
128 uses_global_length_parameter>;
132 typename equation_solver_type::kernel_matrix_type;
136 typename equation_solver_type::additional_matrix_type;
142 static constexpr index_type default_max_mle_evaluations = 20;
154 distance_function_(
std::move(distance_function)),
155 rbf_(
std::move(rbf)) {}
166 void compute(
const std::vector<variable_type>& variables,
168 const auto num_variables =
static_cast<index_type>(variables.size());
170 num_variables > 0, this->logger(),
"Variables must be given.");
172 polynomial_calculator_.prepare(num_dimensions);
175 length_parameter_calculator_, variables, kernel_matrix_);
176 polynomial_calculator_.compute_polynomial_term_matrix(
177 variables, polynomial_matrix_);
178 equation_solver_.compute(
179 kernel_matrix_, polynomial_matrix_, function_values);
180 equation_solver_.solve(kernel_coeffs_, polynomial_coeffs_, reg_param);
181 variables_ = &variables;
194 for (std::size_t i = 0; i < variables_->size(); ++i) {
196 distance_function_(variable, (*variables_)[i]) /
197 length_parameter_calculator_.length_parameter_at(
200 if (distance_rate < rbf_type::support_boundary()) {
201 value += kernel_coeffs_(
static_cast<index_type>(i)) *
205 value += kernel_coeffs_(
static_cast<index_type>(i)) *
210 value += polynomial_calculator_.evaluate_polynomial_for_variable(
211 variable, polynomial_coeffs_);
222 length_parameter_calculator_.scale(value);
238 const std::vector<variable_type>& variables,
240 index_type max_mle_evaluations = default_max_mle_evaluations)
241 requires uses_global_length_parameter
243 const auto num_variables =
static_cast<index_type>(variables.size());
245 num_variables > 0, this->logger(),
"Variables must be given.");
247 polynomial_calculator_.prepare(num_dimensions);
250 auto objective_function =
251 [
this, &variables, &function_values](
254 length_parameter_calculator_.scale(scale);
256 length_parameter_calculator_, variables, kernel_matrix_);
257 polynomial_calculator_.compute_polynomial_term_matrix(
258 variables, polynomial_matrix_);
259 equation_solver_.compute(
260 kernel_matrix_, polynomial_matrix_, function_values);
261 return std::log10(equation_solver_.calc_mle_objective(reg_param));
264 using objective_function_object_type =
decltype(objective_function);
265 using objective_function_wrapper_type =
267 objective_function_object_type>;
268 using optimizer_type =
271 optimizer_type optimizer{
272 objective_function_wrapper_type{objective_function}};
273 configure_child_algorithm_logger_if_exists(optimizer);
276 optimizer.max_evaluations(max_mle_evaluations);
277 optimizer.init(lower_boundary, upper_boundary);
283 "Selected an optimized scale of length parameters: {}", scale);
284 this->length_parameter_calculator_.scale(scale);
294 return distance_function_;
302 [[nodiscard]]
auto rbf() const noexcept -> const
rbf_type& {
return rbf_; }
311 return length_parameter_calculator_;
321 return kernel_coeffs_;
331 return polynomial_coeffs_;
351 polynomial_calculator_{};
360 const std::vector<variable_type>* variables_{
nullptr};
383template <
typename FunctionSignature,
385 rbfs::gaussian_rbf<impl::get_default_scalar_type<FunctionSignature>>,
388 concepts::distance_function DistanceFunction =
389 distance_functions::euclidean_distance_function<
393 KernelMatrixType, DistanceFunction,
Class of tags of logs without memory management.
Class to incorporate logging in algorithms.
Class of dividing rectangles (DIRECT) method jones1993 for optimization.
Wrapper class of a function object to use as an objective function.
Class to calculate Euclidean distance.
Class to calculate length parameters for RBF using global fixed length parameter.
Class to calculate length parameters for RBF using length parameters localized for each sample point.
Class to calculate polynomials used with RBF interpolation.
typename equation_solver_type::kernel_matrix_type kernel_matrix_type
Type of kernel matrices.
auto interpolate(const variable_type &variable) const -> function_value_type
Interpolate for a variable.
void optimize_length_parameter_scale(const std::vector< variable_type > &variables, const function_value_vector_type &function_values, index_type max_mle_evaluations=default_max_mle_evaluations)
Set the scale of length parameters with optimization using MLE scheuerer2011.
rbf_polynomial_interpolator(distance_function_type distance_function=distance_function_type(), rbf_type rbf=rbf_type())
Constructor.
auto rbf() const noexcept -> const rbf_type &
Get the RBF.
typename equation_solver_type::additional_matrix_type polynomial_matrix_type
Type of matrices of polynomial terms.
RBF rbf_type
Type of the RBF.
DistanceFunction distance_function_type
Type of the distance function.
auto polynomial_coeffs() const noexcept -> const function_value_vector_type &
Get the coefficients for polynomials.
auto kernel_coeffs() const noexcept -> const function_value_vector_type &
Get the coefficients for kernels.
auto length_parameter_calculator() const noexcept -> const length_parameter_calculator_type &
Get the calculator of length parameters.
Variable variable_type
Type of variables.
void fix_length_parameter_scale(kernel_value_type value)
Set the scale of length parameters to a fixed value.
LengthParameterCalculator length_parameter_calculator_type
Type of the calculator of length parameters.
FunctionValue function_value_type
Type of function values.
typename DistanceFunction::value_type kernel_value_type
Type of kernel values.
distance_function_type distance_function_
Distance function.
void compute(const std::vector< variable_type > &variables, const function_value_vector_type &function_values)
Compute parameters for interpolation.
auto distance_function() const noexcept -> const distance_function_type &
Get the distance function.
Eigen::VectorX< function_value_type > function_value_vector_type
Type of vectors of function values.
Class to interpolate using RBF and polynomials.
Class of Gaussian RBF fornberg2015.
Definition of compute_kernel_matrix function.
Concept of CSRBFs (compactly supported RBFs).
Concept of distance functions.
Concept of calculator of length parameters.
Definition of csrbf concept.
Definition of distance_function concept.
Definition of dividing_rectangles class.
Definition of euclidean_distance_function class.
Definition of exceptions.
Definition of function_object_wrapper class.
Definition of gaussian_rbf class.
Definition of general_spline_equation_solver class.
Definition of get_default_scalar_type type.
Definition of get_size class.
Definition of get_variable_type class.
Definition of global_length_parameter_calculator class.
Definition of index_type type.
Definition of kernel_matrix_type enumeration.
Definition of length_parameter_calculator concept.
Definition of local_length_parameter_calculator class.
Definition of log_tag_view class.
Definition of macros for logging.
#define NUM_COLLECT_LOG_DEBUG(LOGGER,...)
Write a debug log.
Definition of logging_mixin class.
std::ptrdiff_t index_type
Type of indices in this library.
auto get_size(const Matrix &matrix) -> index_type
Get the size.
typename get_variable_type< FunctionSignature >::type get_variable_type_t
Get the type of variables from function signature.
Namespace of RBF interpolation.
constexpr auto rbf_polynomial_interpolator_tag
Tag of rbf_polynomial_interpolator.
kernel_matrix_type
Enumeration of types of kernel matrices.
void compute_kernel_matrix(const DistanceFunction &distance_function, const RBF &rbf, LengthParameterCalculator &length_parameter_calculator, const std::vector< typename DistanceFunction::variable_type > &variables, KernelMatrix &kernel_matrix)
Compute a kernel matrix.
Definition of polynomial_calculator class.
Definition of NUM_COLLECT_PRECONDITION macro.
#define NUM_COLLECT_PRECONDITION(CONDITION,...)
Check whether a precondition is satisfied and throw an exception if not.
Definition of rbf concept.