Coverage Report

Created: 2025-01-24 06:23

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/builds/MusicScience37Projects/numerical-analysis/numerical-collection-cpp/include/num_collect/rbf/compute_polynomial_term_matrix.h
Line
Count
Source
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
 */
16
/*!
17
 * \file
18
 * \brief Definition of compute_polynomial_term_matrix function.
19
 */
20
#pragma once
21
22
#include <vector>
23
24
#include "num_collect/base/concepts/dense_matrix_of.h"
25
#include "num_collect/base/concepts/dense_vector.h"
26
#include "num_collect/base/concepts/real_scalar.h"
27
#include "num_collect/base/exception.h"
28
#include "num_collect/base/index_type.h"
29
#include "num_collect/base/precondition.h"
30
#include "num_collect/logging/logging_macros.h"
31
#include "num_collect/rbf/polynomial_calculator.h"
32
33
namespace num_collect::rbf {
34
35
/*!
36
 * \brief Compute a matrix of polynomial terms in RBF interpolation.
37
 *
38
 * \tparam PolynomialDegree Degree of polynomials.
39
 * \tparam Variable Type of variables.
40
 * \tparam Matrix Type of the matrix.
41
 * \param[in] variables Variables.
42
 * \param[out] matrix Matrix.
43
 */
44
template <index_type PolynomialDegree, base::concepts::real_scalar Variable,
45
    base::concepts::dense_matrix_of<Variable> Matrix>
46
    requires(PolynomialDegree >= 0)
47
inline void compute_polynomial_term_matrix(
48
5
    const std::vector<Variable>& variables, Matrix& matrix) {
49
5
    polynomial_calculator<Variable, PolynomialDegree> calculator;
50
5
    calculator.prepare(1);
51
5
    calculator.compute_polynomial_term_matrix(variables, matrix);
52
5
}
_ZN11num_collect3rbf30compute_polynomial_term_matrixILl0ETkNS_4base8concepts11real_scalarEdTkNS3_15dense_matrix_ofIT0_EEN5Eigen6MatrixIdLin1ELin1ELi0ELin1ELin1EEEQgeT_Li0EEEvRKNSt3__16vectorIS5_NS9_9allocatorIS5_EEEERT1_
Line
Count
Source
48
1
    const std::vector<Variable>& variables, Matrix& matrix) {
49
1
    polynomial_calculator<Variable, PolynomialDegree> calculator;
50
1
    calculator.prepare(1);
51
1
    calculator.compute_polynomial_term_matrix(variables, matrix);
52
1
}
_ZN11num_collect3rbf30compute_polynomial_term_matrixILl1ETkNS_4base8concepts11real_scalarEdTkNS3_15dense_matrix_ofIT0_EEN5Eigen6MatrixIdLin1ELin1ELi0ELin1ELin1EEEQgeT_Li0EEEvRKNSt3__16vectorIS5_NS9_9allocatorIS5_EEEERT1_
Line
Count
Source
48
3
    const std::vector<Variable>& variables, Matrix& matrix) {
49
3
    polynomial_calculator<Variable, PolynomialDegree> calculator;
50
3
    calculator.prepare(1);
51
3
    calculator.compute_polynomial_term_matrix(variables, matrix);
52
3
}
_ZN11num_collect3rbf30compute_polynomial_term_matrixILl2ETkNS_4base8concepts11real_scalarEdTkNS3_15dense_matrix_ofIT0_EEN5Eigen6MatrixIdLin1ELin1ELi0ELin1ELin1EEEQgeT_Li0EEEvRKNSt3__16vectorIS5_NS9_9allocatorIS5_EEEERT1_
Line
Count
Source
48
1
    const std::vector<Variable>& variables, Matrix& matrix) {
49
1
    polynomial_calculator<Variable, PolynomialDegree> calculator;
50
1
    calculator.prepare(1);
51
1
    calculator.compute_polynomial_term_matrix(variables, matrix);
52
1
}
53
54
/*!
55
 * \brief Compute a matrix of polynomial terms in RBF interpolation.
56
 *
57
 * \tparam PolynomialDegree Degree of polynomials.
58
 * \tparam Variable Type of variables.
59
 * \tparam Matrix Type of the matrix.
60
 * \param[in] variables Variables.
61
 * \param[out] matrix Matrix.
62
 */
63
template <index_type PolynomialDegree, base::concepts::dense_vector Variable,
64
    base::concepts::dense_matrix_of<typename Variable::Scalar> Matrix>
65
    requires(PolynomialDegree >= 0)
66
inline void compute_polynomial_term_matrix(
67
2
    const std::vector<Variable>& variables, Matrix& matrix) {
68
2
    static_assert(
69
2
        PolynomialDegree < 2, "Currently, up to 1 degree is supported.");
70
71
2
    using scalar_type = typename Matrix::Scalar;
72
73
2
    const auto num_variables = static_cast<index_type>(variables.size());
74
2
    NUM_COLLECT_PRECONDITION(num_variables > 0, "Variables must be given.");
75
2
    const auto num_dimensions = variables.front().size();
76
77
2
    polynomial_calculator<Variable, PolynomialDegree> calculator;
78
2
    calculator.prepare(num_dimensions);
79
2
    calculator.compute_polynomial_term_matrix(variables, matrix);
80
2
}
_ZN11num_collect3rbf30compute_polynomial_term_matrixILl0ETkNS_4base8concepts12dense_vectorEN5Eigen6MatrixIdLi2ELi1ELi0ELi2ELi1EEETkNS3_15dense_matrix_ofINT0_6ScalarEEENS5_IdLin1ELin1ELi0ELin1ELin1EEEQgeT_Li0EEEvRKNSt3__16vectorIS8_NSB_9allocatorIS8_EEEERT1_
Line
Count
Source
67
1
    const std::vector<Variable>& variables, Matrix& matrix) {
68
1
    static_assert(
69
1
        PolynomialDegree < 2, "Currently, up to 1 degree is supported.");
70
71
1
    using scalar_type = typename Matrix::Scalar;
72
73
1
    const auto num_variables = static_cast<index_type>(variables.size());
74
1
    NUM_COLLECT_PRECONDITION(num_variables > 0, "Variables must be given.");
75
1
    const auto num_dimensions = variables.front().size();
76
77
1
    polynomial_calculator<Variable, PolynomialDegree> calculator;
78
1
    calculator.prepare(num_dimensions);
79
1
    calculator.compute_polynomial_term_matrix(variables, matrix);
80
1
}
_ZN11num_collect3rbf30compute_polynomial_term_matrixILl1ETkNS_4base8concepts12dense_vectorEN5Eigen6MatrixIdLi2ELi1ELi0ELi2ELi1EEETkNS3_15dense_matrix_ofINT0_6ScalarEEENS5_IdLin1ELin1ELi0ELin1ELin1EEEQgeT_Li0EEEvRKNSt3__16vectorIS8_NSB_9allocatorIS8_EEEERT1_
Line
Count
Source
67
1
    const std::vector<Variable>& variables, Matrix& matrix) {
68
1
    static_assert(
69
1
        PolynomialDegree < 2, "Currently, up to 1 degree is supported.");
70
71
1
    using scalar_type = typename Matrix::Scalar;
72
73
1
    const auto num_variables = static_cast<index_type>(variables.size());
74
1
    NUM_COLLECT_PRECONDITION(num_variables > 0, "Variables must be given.");
75
1
    const auto num_dimensions = variables.front().size();
76
77
1
    polynomial_calculator<Variable, PolynomialDegree> calculator;
78
1
    calculator.prepare(num_dimensions);
79
1
    calculator.compute_polynomial_term_matrix(variables, matrix);
80
1
}
81
82
}  // namespace num_collect::rbf