numerical-collection-cpp 0.10.0
A collection of algorithms in numerical analysis implemented in C++
Loading...
Searching...
No Matches
compute_polynomial_term_matrix.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 <vector>
23
32
33namespace num_collect::rbf {
34
44template <index_type PolynomialDegree, base::concepts::real_scalar Variable,
45 base::concepts::dense_matrix_of<Variable> Matrix>
46 requires(PolynomialDegree >= 0)
48 const std::vector<Variable>& variables, Matrix& matrix) {
50 calculator.prepare(1);
51 calculator.compute_polynomial_term_matrix(variables, matrix);
52}
53
63template <index_type PolynomialDegree, base::concepts::dense_vector Variable,
65 requires(PolynomialDegree >= 0)
67 const std::vector<Variable>& variables, Matrix& matrix) {
68 static_assert(
69 PolynomialDegree < 2, "Currently, up to 1 degree is supported.");
70
71 using scalar_type = typename Matrix::Scalar;
72
73 const auto num_variables = static_cast<index_type>(variables.size());
74 NUM_COLLECT_PRECONDITION(num_variables > 0, "Variables must be given.");
75 const auto num_dimensions = variables.front().size();
76
77 polynomial_calculator<Variable, PolynomialDegree> calculator;
78 calculator.prepare(num_dimensions);
79 calculator.compute_polynomial_term_matrix(variables, matrix);
80}
81
82} // namespace num_collect::rbf
Class to calculate polynomials used with RBF interpolation.
Concept of Eigen's dense matrices with scalars of the given type.
Concept of Eigen's dense vectors.
Definition of dense_matrix_of concept.
Definition of dense_vector concept.
Definition of exceptions.
Definition of index_type type.
Definition of macros for logging.
std::ptrdiff_t index_type
Type of indices in this library.
Definition index_type.h:33
Namespace of RBF interpolation.
void compute_polynomial_term_matrix(const std::vector< Variable > &variables, Matrix &matrix)
Compute a matrix of polynomial terms in RBF interpolation.
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 real_scalar concept.