Coverage Report

Created: 2024-12-20 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/logging/logging_macros.h"
30
#include "num_collect/rbf/polynomial_calculator.h"
31
32
namespace num_collect::rbf {
33
34
/*!
35
 * \brief Compute a matrix of polynomial terms in RBF interpolation.
36
 *
37
 * \tparam PolynomialDegree Degree of polynomials.
38
 * \tparam Variable Type of variables.
39
 * \tparam Matrix Type of the matrix.
40
 * \param[in] variables Variables.
41
 * \param[out] matrix Matrix.
42
 */
43
template <index_type PolynomialDegree, base::concepts::real_scalar Variable,
44
    base::concepts::dense_matrix_of<Variable> Matrix>
45
    requires(PolynomialDegree >= 0)
46
inline void compute_polynomial_term_matrix(
47
5
    const std::vector<Variable>& variables, Matrix& matrix) {
48
5
    polynomial_calculator<Variable, PolynomialDegree> calculator;
49
5
    calculator.prepare(1);
50
5
    calculator.compute_polynomial_term_matrix(variables, matrix);
51
5
}
_ZN11num_collect3rbf30compute_polynomial_term_matrixILl0ETkNS_4base8concepts11real_scalarEdTkNS3_15dense_matrix_ofIT0_EEN5Eigen6MatrixIdLin1ELin1ELi0ELin1ELin1EEEQgeT_Li0EEEvRKNSt3__16vectorIS5_NS9_9allocatorIS5_EEEERT1_
Line
Count
Source
47
1
    const std::vector<Variable>& variables, Matrix& matrix) {
48
1
    polynomial_calculator<Variable, PolynomialDegree> calculator;
49
1
    calculator.prepare(1);
50
1
    calculator.compute_polynomial_term_matrix(variables, matrix);
51
1
}
_ZN11num_collect3rbf30compute_polynomial_term_matrixILl1ETkNS_4base8concepts11real_scalarEdTkNS3_15dense_matrix_ofIT0_EEN5Eigen6MatrixIdLin1ELin1ELi0ELin1ELin1EEEQgeT_Li0EEEvRKNSt3__16vectorIS5_NS9_9allocatorIS5_EEEERT1_
Line
Count
Source
47
3
    const std::vector<Variable>& variables, Matrix& matrix) {
48
3
    polynomial_calculator<Variable, PolynomialDegree> calculator;
49
3
    calculator.prepare(1);
50
3
    calculator.compute_polynomial_term_matrix(variables, matrix);
51
3
}
_ZN11num_collect3rbf30compute_polynomial_term_matrixILl2ETkNS_4base8concepts11real_scalarEdTkNS3_15dense_matrix_ofIT0_EEN5Eigen6MatrixIdLin1ELin1ELi0ELin1ELin1EEEQgeT_Li0EEEvRKNSt3__16vectorIS5_NS9_9allocatorIS5_EEEERT1_
Line
Count
Source
47
1
    const std::vector<Variable>& variables, Matrix& matrix) {
48
1
    polynomial_calculator<Variable, PolynomialDegree> calculator;
49
1
    calculator.prepare(1);
50
1
    calculator.compute_polynomial_term_matrix(variables, matrix);
51
1
}
52
53
/*!
54
 * \brief Compute a matrix of polynomial terms in RBF interpolation.
55
 *
56
 * \tparam PolynomialDegree Degree of polynomials.
57
 * \tparam Variable Type of variables.
58
 * \tparam Matrix Type of the matrix.
59
 * \param[in] variables Variables.
60
 * \param[out] matrix Matrix.
61
 */
62
template <index_type PolynomialDegree, base::concepts::dense_vector Variable,
63
    base::concepts::dense_matrix_of<typename Variable::Scalar> Matrix>
64
    requires(PolynomialDegree >= 0)
65
inline void compute_polynomial_term_matrix(
66
2
    const std::vector<Variable>& variables, Matrix& matrix) {
67
2
    static_assert(
68
2
        PolynomialDegree < 2, "Currently, up to 1 degree is supported.");
69
70
2
    using scalar_type = typename Matrix::Scalar;
71
72
2
    const auto num_variables = static_cast<index_type>(variables.size());
73
2
    if (num_variables == 0) {
74
0
        NUM_COLLECT_LOG_AND_THROW(invalid_argument, "No variable is given.");
75
0
    }
76
2
    const auto num_dimensions = variables.front().size();
77
78
2
    polynomial_calculator<Variable, PolynomialDegree> calculator;
79
2
    calculator.prepare(num_dimensions);
80
2
    calculator.compute_polynomial_term_matrix(variables, matrix);
81
2
}
_ZN11num_collect3rbf30compute_polynomial_term_matrixILl0ETkNS_4base8concepts12dense_vectorEN5Eigen6MatrixIdLi2ELi1ELi0ELi2ELi1EEETkNS3_15dense_matrix_ofINT0_6ScalarEEENS5_IdLin1ELin1ELi0ELin1ELin1EEEQgeT_Li0EEEvRKNSt3__16vectorIS8_NSB_9allocatorIS8_EEEERT1_
Line
Count
Source
66
1
    const std::vector<Variable>& variables, Matrix& matrix) {
67
1
    static_assert(
68
1
        PolynomialDegree < 2, "Currently, up to 1 degree is supported.");
69
70
1
    using scalar_type = typename Matrix::Scalar;
71
72
1
    const auto num_variables = static_cast<index_type>(variables.size());
73
1
    if (num_variables == 0) {
74
0
        NUM_COLLECT_LOG_AND_THROW(invalid_argument, "No variable is given.");
75
0
    }
76
1
    const auto num_dimensions = variables.front().size();
77
78
1
    polynomial_calculator<Variable, PolynomialDegree> calculator;
79
1
    calculator.prepare(num_dimensions);
80
1
    calculator.compute_polynomial_term_matrix(variables, matrix);
81
1
}
_ZN11num_collect3rbf30compute_polynomial_term_matrixILl1ETkNS_4base8concepts12dense_vectorEN5Eigen6MatrixIdLi2ELi1ELi0ELi2ELi1EEETkNS3_15dense_matrix_ofINT0_6ScalarEEENS5_IdLin1ELin1ELi0ELin1ELin1EEEQgeT_Li0EEEvRKNSt3__16vectorIS8_NSB_9allocatorIS8_EEEERT1_
Line
Count
Source
66
1
    const std::vector<Variable>& variables, Matrix& matrix) {
67
1
    static_assert(
68
1
        PolynomialDegree < 2, "Currently, up to 1 degree is supported.");
69
70
1
    using scalar_type = typename Matrix::Scalar;
71
72
1
    const auto num_variables = static_cast<index_type>(variables.size());
73
1
    if (num_variables == 0) {
74
0
        NUM_COLLECT_LOG_AND_THROW(invalid_argument, "No variable is given.");
75
0
    }
76
1
    const auto num_dimensions = variables.front().size();
77
78
1
    polynomial_calculator<Variable, PolynomialDegree> calculator;
79
1
    calculator.prepare(num_dimensions);
80
1
    calculator.compute_polynomial_term_matrix(variables, matrix);
81
1
}
82
83
}  // namespace num_collect::rbf