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/integration/gauss_legendre_integrator.h
Line
Count
Source
1
/*
2
 * Copyright 2021 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 legendre_roots function.
19
 */
20
#pragma once
21
22
// IWYU pragma: no_include <complex>
23
24
#include <type_traits>
25
26
#include <Eigen/Core>
27
28
#include "num_collect/base/concepts/invocable_as.h"
29
#include "num_collect/base/concepts/real_scalar.h"
30
#include "num_collect/base/index_type.h"
31
#include "num_collect/base/precondition.h"
32
#include "num_collect/constants/half.h"  // IWYU pragma: keep
33
#include "num_collect/constants/one.h"   // IWYU pragma: keep
34
#include "num_collect/constants/two.h"   // IWYU pragma: keep
35
#include "num_collect/functions/legendre.h"
36
#include "num_collect/functions/legendre_roots.h"
37
#include "num_collect/logging/log_tag_view.h"
38
#include "num_collect/logging/logging_mixin.h"
39
40
namespace num_collect::integration {
41
42
//! Tag of gauss_legendre_integrator.
43
constexpr auto gauss_legendre_integrator_tag = logging::log_tag_view(
44
    "num_collect::integration::gauss_legendre_integrator");
45
46
/*!
47
 * \brief Class to perform numerical integration with Gauss-Legendre formula.
48
 *
49
 * \tparam Signature Function signature.
50
 */
51
template <typename Signature>
52
class gauss_legendre_integrator;
53
54
/*!
55
 * \brief Class to perform numerical integration with Gauss-Legendre formula.
56
 *
57
 * \tparam Result Type of results.
58
 * \tparam Variable Type of variables.
59
 */
60
template <typename Result, base::concepts::real_scalar Variable>
61
class gauss_legendre_integrator<Result(Variable)>
62
    : public logging::logging_mixin {
63
public:
64
    //! Type of variables.
65
    using variable_type = std::decay_t<Variable>;
66
67
    //! Type of results.
68
    using result_type = std::decay_t<Result>;
69
70
    //! Default degree.
71
    static constexpr index_type default_degree = 20;
72
73
    /*!
74
     * \brief Constructor.
75
     *
76
     * \param[in] degree Degree.
77
     */
78
    explicit gauss_legendre_integrator(index_type degree = default_degree)
79
22
        : logging::logging_mixin(gauss_legendre_integrator_tag),
80
22
          roots_(degree) {
81
22
        NUM_COLLECT_PRECONDITION(degree >= 1, this->logger(),
82
22
            "Degree of Legendre function must be at least one.");
83
22
        update_weight();
84
22
    }
_ZN11num_collect11integration25gauss_legendre_integratorIFN5Eigen6MatrixIdLi2ELi1ELi0ELi2ELi1EEEdEEC2El
Line
Count
Source
79
12
        : logging::logging_mixin(gauss_legendre_integrator_tag),
80
12
          roots_(degree) {
81
12
        NUM_COLLECT_PRECONDITION(degree >= 1, this->logger(),
82
12
            "Degree of Legendre function must be at least one.");
83
12
        update_weight();
84
12
    }
_ZN11num_collect11integration25gauss_legendre_integratorIFffEEC2El
Line
Count
Source
79
4
        : logging::logging_mixin(gauss_legendre_integrator_tag),
80
4
          roots_(degree) {
81
4
        NUM_COLLECT_PRECONDITION(degree >= 1, this->logger(),
82
4
            "Degree of Legendre function must be at least one.");
83
4
        update_weight();
84
4
    }
_ZN11num_collect11integration25gauss_legendre_integratorIFNSt3__17complexIfEEfEEC2El
Line
Count
Source
79
1
        : logging::logging_mixin(gauss_legendre_integrator_tag),
80
1
          roots_(degree) {
81
1
        NUM_COLLECT_PRECONDITION(degree >= 1, this->logger(),
82
1
            "Degree of Legendre function must be at least one.");
83
1
        update_weight();
84
1
    }
_ZN11num_collect11integration25gauss_legendre_integratorIFddEEC2El
Line
Count
Source
79
4
        : logging::logging_mixin(gauss_legendre_integrator_tag),
80
4
          roots_(degree) {
81
4
        NUM_COLLECT_PRECONDITION(degree >= 1, this->logger(),
82
4
            "Degree of Legendre function must be at least one.");
83
4
        update_weight();
84
4
    }
_ZN11num_collect11integration25gauss_legendre_integratorIFNSt3__17complexIdEEdEEC2El
Line
Count
Source
79
1
        : logging::logging_mixin(gauss_legendre_integrator_tag),
80
1
          roots_(degree) {
81
1
        NUM_COLLECT_PRECONDITION(degree >= 1, this->logger(),
82
1
            "Degree of Legendre function must be at least one.");
83
1
        update_weight();
84
1
    }
85
86
    /*!
87
     * \brief Compute internal variables for integration.
88
     *
89
     * \param[in] degree Degree.
90
     */
91
2
    void prepare(index_type degree) {
92
2
        NUM_COLLECT_PRECONDITION(degree >= 1, this->logger(),
93
2
            "Degree of Legendre function must be at least one.");
94
2
        roots_.compute(degree);
95
2
        update_weight();
96
2
    }
_ZN11num_collect11integration25gauss_legendre_integratorIFffEE7prepareEl
Line
Count
Source
91
1
    void prepare(index_type degree) {
92
1
        NUM_COLLECT_PRECONDITION(degree >= 1, this->logger(),
93
1
            "Degree of Legendre function must be at least one.");
94
1
        roots_.compute(degree);
95
1
        update_weight();
96
1
    }
_ZN11num_collect11integration25gauss_legendre_integratorIFddEE7prepareEl
Line
Count
Source
91
1
    void prepare(index_type degree) {
92
1
        NUM_COLLECT_PRECONDITION(degree >= 1, this->logger(),
93
1
            "Degree of Legendre function must be at least one.");
94
1
        roots_.compute(degree);
95
1
        update_weight();
96
1
    }
97
98
    /*!
99
     * \brief Integrate a function.
100
     *
101
     * \tparam Function Type of function.
102
     * \param[in] function Function.
103
     * \param[in] left Left boundary.
104
     * \param[in] right Right boundary.
105
     * \return Result.
106
     */
107
    template <base::concepts::invocable_as<result_type(variable_type)> Function>
108
    [[nodiscard]] auto integrate(const Function& function, variable_type left,
109
4.16k
        variable_type right) const -> result_type {
110
4.16k
        const auto degree = roots_.degree();
111
4.16k
        const auto mean = constants::half<variable_type> * (left + right);
112
4.16k
        const auto half_width = constants::half<variable_type> * (right - left);
113
4.16k
        Result sum = function(mean) * constants::zero<variable_type>;
114
25.2k
        for (index_type i = 0; i < degree; ++i) {
115
21.0k
            const variable_type x = mean + half_width * roots_[i];
116
21.0k
            const variable_type weight = weights_[i];
117
21.0k
            sum += weight * function(x);
118
21.0k
        }
119
4.16k
        return sum * half_width;
120
4.16k
    }
_ZNK11num_collect11integration25gauss_legendre_integratorIFN5Eigen6MatrixIdLi2ELi1ELi0ELi2ELi1EEEdEE9integrateITkNS_4base8concepts12invocable_asIFu7__decayIT_Eu7__decayIT0_EEEENS_3ode3avf4impl13avf_integrandIN16num_prob_collect3ode23spring_movement_problemEEEEES4_RKSB_dd
Line
Count
Source
109
4.15k
        variable_type right) const -> result_type {
110
4.15k
        const auto degree = roots_.degree();
111
4.15k
        const auto mean = constants::half<variable_type> * (left + right);
112
4.15k
        const auto half_width = constants::half<variable_type> * (right - left);
113
4.15k
        Result sum = function(mean) * constants::zero<variable_type>;
114
24.9k
        for (index_type i = 0; i < degree; ++i) {
115
20.7k
            const variable_type x = mean + half_width * roots_[i];
116
20.7k
            const variable_type weight = weights_[i];
117
20.7k
            sum += weight * function(x);
118
20.7k
        }
119
4.15k
        return sum * half_width;
120
4.15k
    }
gauss_legendre_integrator_test.cpp:_ZNK11num_collect11integration25gauss_legendre_integratorIFffEE9integrateITkNS_4base8concepts12invocable_asIFu7__decayIT_Eu7__decayIT0_EEEEZL31CATCH2_INTERNAL_TEMPLATE_TEST_0IfEvvEUlfE_EEfRKS8_ff
Line
Count
Source
109
1
        variable_type right) const -> result_type {
110
1
        const auto degree = roots_.degree();
111
1
        const auto mean = constants::half<variable_type> * (left + right);
112
1
        const auto half_width = constants::half<variable_type> * (right - left);
113
1
        Result sum = function(mean) * constants::zero<variable_type>;
114
21
        for (index_type i = 0; i < degree; ++i) {
115
20
            const variable_type x = mean + half_width * roots_[i];
116
20
            const variable_type weight = weights_[i];
117
20
            sum += weight * function(x);
118
20
        }
119
1
        return sum * half_width;
120
1
    }
gauss_legendre_integrator_test.cpp:_ZNK11num_collect11integration25gauss_legendre_integratorIFffEE9integrateITkNS_4base8concepts12invocable_asIFu7__decayIT_Eu7__decayIT0_EEEEZL31CATCH2_INTERNAL_TEMPLATE_TEST_0IfEvvEUlfE0_EEfRKS8_ff
Line
Count
Source
109
1
        variable_type right) const -> result_type {
110
1
        const auto degree = roots_.degree();
111
1
        const auto mean = constants::half<variable_type> * (left + right);
112
1
        const auto half_width = constants::half<variable_type> * (right - left);
113
1
        Result sum = function(mean) * constants::zero<variable_type>;
114
21
        for (index_type i = 0; i < degree; ++i) {
115
20
            const variable_type x = mean + half_width * roots_[i];
116
20
            const variable_type weight = weights_[i];
117
20
            sum += weight * function(x);
118
20
        }
119
1
        return sum * half_width;
120
1
    }
gauss_legendre_integrator_test.cpp:_ZNK11num_collect11integration25gauss_legendre_integratorIFffEE9integrateITkNS_4base8concepts12invocable_asIFu7__decayIT_Eu7__decayIT0_EEEEZL31CATCH2_INTERNAL_TEMPLATE_TEST_0IfEvvEUlfE1_EEfRKS8_ff
Line
Count
Source
109
1
        variable_type right) const -> result_type {
110
1
        const auto degree = roots_.degree();
111
1
        const auto mean = constants::half<variable_type> * (left + right);
112
1
        const auto half_width = constants::half<variable_type> * (right - left);
113
1
        Result sum = function(mean) * constants::zero<variable_type>;
114
51
        for (index_type i = 0; i < degree; ++i) {
115
50
            const variable_type x = mean + half_width * roots_[i];
116
50
            const variable_type weight = weights_[i];
117
50
            sum += weight * function(x);
118
50
        }
119
1
        return sum * half_width;
120
1
    }
gauss_legendre_integrator_test.cpp:_ZNK11num_collect11integration25gauss_legendre_integratorIFffEE9integrateITkNS_4base8concepts12invocable_asIFu7__decayIT_Eu7__decayIT0_EEEEZL31CATCH2_INTERNAL_TEMPLATE_TEST_0IfEvvEUlfE2_EEfRKS8_ff
Line
Count
Source
109
1
        variable_type right) const -> result_type {
110
1
        const auto degree = roots_.degree();
111
1
        const auto mean = constants::half<variable_type> * (left + right);
112
1
        const auto half_width = constants::half<variable_type> * (right - left);
113
1
        Result sum = function(mean) * constants::zero<variable_type>;
114
51
        for (index_type i = 0; i < degree; ++i) {
115
50
            const variable_type x = mean + half_width * roots_[i];
116
50
            const variable_type weight = weights_[i];
117
50
            sum += weight * function(x);
118
50
        }
119
1
        return sum * half_width;
120
1
    }
gauss_legendre_integrator_test.cpp:_ZNK11num_collect11integration25gauss_legendre_integratorIFNSt3__17complexIfEEfEE9integrateITkNS_4base8concepts12invocable_asIFu7__decayIT_Eu7__decayIT0_EEEEZL31CATCH2_INTERNAL_TEMPLATE_TEST_0IfEvvEUlfE3_EES4_RKSB_ff
Line
Count
Source
109
1
        variable_type right) const -> result_type {
110
1
        const auto degree = roots_.degree();
111
1
        const auto mean = constants::half<variable_type> * (left + right);
112
1
        const auto half_width = constants::half<variable_type> * (right - left);
113
1
        Result sum = function(mean) * constants::zero<variable_type>;
114
21
        for (index_type i = 0; i < degree; ++i) {
115
20
            const variable_type x = mean + half_width * roots_[i];
116
20
            const variable_type weight = weights_[i];
117
20
            sum += weight * function(x);
118
20
        }
119
1
        return sum * half_width;
120
1
    }
gauss_legendre_integrator_test.cpp:_ZNK11num_collect11integration25gauss_legendre_integratorIFddEE9integrateITkNS_4base8concepts12invocable_asIFu7__decayIT_Eu7__decayIT0_EEEEZL31CATCH2_INTERNAL_TEMPLATE_TEST_0IdEvvEUldE_EEdRKS8_dd
Line
Count
Source
109
1
        variable_type right) const -> result_type {
110
1
        const auto degree = roots_.degree();
111
1
        const auto mean = constants::half<variable_type> * (left + right);
112
1
        const auto half_width = constants::half<variable_type> * (right - left);
113
1
        Result sum = function(mean) * constants::zero<variable_type>;
114
21
        for (index_type i = 0; i < degree; ++i) {
115
20
            const variable_type x = mean + half_width * roots_[i];
116
20
            const variable_type weight = weights_[i];
117
20
            sum += weight * function(x);
118
20
        }
119
1
        return sum * half_width;
120
1
    }
gauss_legendre_integrator_test.cpp:_ZNK11num_collect11integration25gauss_legendre_integratorIFddEE9integrateITkNS_4base8concepts12invocable_asIFu7__decayIT_Eu7__decayIT0_EEEEZL31CATCH2_INTERNAL_TEMPLATE_TEST_0IdEvvEUldE0_EEdRKS8_dd
Line
Count
Source
109
1
        variable_type right) const -> result_type {
110
1
        const auto degree = roots_.degree();
111
1
        const auto mean = constants::half<variable_type> * (left + right);
112
1
        const auto half_width = constants::half<variable_type> * (right - left);
113
1
        Result sum = function(mean) * constants::zero<variable_type>;
114
21
        for (index_type i = 0; i < degree; ++i) {
115
20
            const variable_type x = mean + half_width * roots_[i];
116
20
            const variable_type weight = weights_[i];
117
20
            sum += weight * function(x);
118
20
        }
119
1
        return sum * half_width;
120
1
    }
gauss_legendre_integrator_test.cpp:_ZNK11num_collect11integration25gauss_legendre_integratorIFddEE9integrateITkNS_4base8concepts12invocable_asIFu7__decayIT_Eu7__decayIT0_EEEEZL31CATCH2_INTERNAL_TEMPLATE_TEST_0IdEvvEUldE1_EEdRKS8_dd
Line
Count
Source
109
1
        variable_type right) const -> result_type {
110
1
        const auto degree = roots_.degree();
111
1
        const auto mean = constants::half<variable_type> * (left + right);
112
1
        const auto half_width = constants::half<variable_type> * (right - left);
113
1
        Result sum = function(mean) * constants::zero<variable_type>;
114
51
        for (index_type i = 0; i < degree; ++i) {
115
50
            const variable_type x = mean + half_width * roots_[i];
116
50
            const variable_type weight = weights_[i];
117
50
            sum += weight * function(x);
118
50
        }
119
1
        return sum * half_width;
120
1
    }
gauss_legendre_integrator_test.cpp:_ZNK11num_collect11integration25gauss_legendre_integratorIFddEE9integrateITkNS_4base8concepts12invocable_asIFu7__decayIT_Eu7__decayIT0_EEEEZL31CATCH2_INTERNAL_TEMPLATE_TEST_0IdEvvEUldE2_EEdRKS8_dd
Line
Count
Source
109
1
        variable_type right) const -> result_type {
110
1
        const auto degree = roots_.degree();
111
1
        const auto mean = constants::half<variable_type> * (left + right);
112
1
        const auto half_width = constants::half<variable_type> * (right - left);
113
1
        Result sum = function(mean) * constants::zero<variable_type>;
114
51
        for (index_type i = 0; i < degree; ++i) {
115
50
            const variable_type x = mean + half_width * roots_[i];
116
50
            const variable_type weight = weights_[i];
117
50
            sum += weight * function(x);
118
50
        }
119
1
        return sum * half_width;
120
1
    }
gauss_legendre_integrator_test.cpp:_ZNK11num_collect11integration25gauss_legendre_integratorIFNSt3__17complexIdEEdEE9integrateITkNS_4base8concepts12invocable_asIFu7__decayIT_Eu7__decayIT0_EEEEZL31CATCH2_INTERNAL_TEMPLATE_TEST_0IdEvvEUldE3_EES4_RKSB_dd
Line
Count
Source
109
1
        variable_type right) const -> result_type {
110
1
        const auto degree = roots_.degree();
111
1
        const auto mean = constants::half<variable_type> * (left + right);
112
1
        const auto half_width = constants::half<variable_type> * (right - left);
113
1
        Result sum = function(mean) * constants::zero<variable_type>;
114
21
        for (index_type i = 0; i < degree; ++i) {
115
20
            const variable_type x = mean + half_width * roots_[i];
116
20
            const variable_type weight = weights_[i];
117
20
            sum += weight * function(x);
118
20
        }
119
1
        return sum * half_width;
120
1
    }
121
122
    /*!
123
     * \brief Integrate a function.
124
     *
125
     * \tparam Function Type of function.
126
     * \param[in] function Function.
127
     * \param[in] left Left boundary.
128
     * \param[in] right Right boundary.
129
     * \return Result.
130
     */
131
    template <base::concepts::invocable_as<result_type(variable_type)> Function>
132
    [[nodiscard]] auto operator()(const Function& function, variable_type left,
133
4.16k
        variable_type right) const -> result_type {
134
4.16k
        return integrate(function, left, right);
135
4.16k
    }
_ZNK11num_collect11integration25gauss_legendre_integratorIFN5Eigen6MatrixIdLi2ELi1ELi0ELi2ELi1EEEdEEclITkNS_4base8concepts12invocable_asIFu7__decayIT_Eu7__decayIT0_EEEENS_3ode3avf4impl13avf_integrandIN16num_prob_collect3ode23spring_movement_problemEEEEES4_RKSB_dd
Line
Count
Source
133
4.15k
        variable_type right) const -> result_type {
134
4.15k
        return integrate(function, left, right);
135
4.15k
    }
gauss_legendre_integrator_test.cpp:_ZNK11num_collect11integration25gauss_legendre_integratorIFffEEclITkNS_4base8concepts12invocable_asIFu7__decayIT_Eu7__decayIT0_EEEEZL31CATCH2_INTERNAL_TEMPLATE_TEST_0IfEvvEUlfE_EEfRKS8_ff
Line
Count
Source
133
1
        variable_type right) const -> result_type {
134
1
        return integrate(function, left, right);
135
1
    }
gauss_legendre_integrator_test.cpp:_ZNK11num_collect11integration25gauss_legendre_integratorIFffEEclITkNS_4base8concepts12invocable_asIFu7__decayIT_Eu7__decayIT0_EEEEZL31CATCH2_INTERNAL_TEMPLATE_TEST_0IfEvvEUlfE0_EEfRKS8_ff
Line
Count
Source
133
1
        variable_type right) const -> result_type {
134
1
        return integrate(function, left, right);
135
1
    }
gauss_legendre_integrator_test.cpp:_ZNK11num_collect11integration25gauss_legendre_integratorIFffEEclITkNS_4base8concepts12invocable_asIFu7__decayIT_Eu7__decayIT0_EEEEZL31CATCH2_INTERNAL_TEMPLATE_TEST_0IfEvvEUlfE1_EEfRKS8_ff
Line
Count
Source
133
1
        variable_type right) const -> result_type {
134
1
        return integrate(function, left, right);
135
1
    }
gauss_legendre_integrator_test.cpp:_ZNK11num_collect11integration25gauss_legendre_integratorIFffEEclITkNS_4base8concepts12invocable_asIFu7__decayIT_Eu7__decayIT0_EEEEZL31CATCH2_INTERNAL_TEMPLATE_TEST_0IfEvvEUlfE2_EEfRKS8_ff
Line
Count
Source
133
1
        variable_type right) const -> result_type {
134
1
        return integrate(function, left, right);
135
1
    }
gauss_legendre_integrator_test.cpp:_ZNK11num_collect11integration25gauss_legendre_integratorIFNSt3__17complexIfEEfEEclITkNS_4base8concepts12invocable_asIFu7__decayIT_Eu7__decayIT0_EEEEZL31CATCH2_INTERNAL_TEMPLATE_TEST_0IfEvvEUlfE3_EES4_RKSB_ff
Line
Count
Source
133
1
        variable_type right) const -> result_type {
134
1
        return integrate(function, left, right);
135
1
    }
gauss_legendre_integrator_test.cpp:_ZNK11num_collect11integration25gauss_legendre_integratorIFddEEclITkNS_4base8concepts12invocable_asIFu7__decayIT_Eu7__decayIT0_EEEEZL31CATCH2_INTERNAL_TEMPLATE_TEST_0IdEvvEUldE_EEdRKS8_dd
Line
Count
Source
133
1
        variable_type right) const -> result_type {
134
1
        return integrate(function, left, right);
135
1
    }
gauss_legendre_integrator_test.cpp:_ZNK11num_collect11integration25gauss_legendre_integratorIFddEEclITkNS_4base8concepts12invocable_asIFu7__decayIT_Eu7__decayIT0_EEEEZL31CATCH2_INTERNAL_TEMPLATE_TEST_0IdEvvEUldE0_EEdRKS8_dd
Line
Count
Source
133
1
        variable_type right) const -> result_type {
134
1
        return integrate(function, left, right);
135
1
    }
gauss_legendre_integrator_test.cpp:_ZNK11num_collect11integration25gauss_legendre_integratorIFddEEclITkNS_4base8concepts12invocable_asIFu7__decayIT_Eu7__decayIT0_EEEEZL31CATCH2_INTERNAL_TEMPLATE_TEST_0IdEvvEUldE1_EEdRKS8_dd
Line
Count
Source
133
1
        variable_type right) const -> result_type {
134
1
        return integrate(function, left, right);
135
1
    }
gauss_legendre_integrator_test.cpp:_ZNK11num_collect11integration25gauss_legendre_integratorIFddEEclITkNS_4base8concepts12invocable_asIFu7__decayIT_Eu7__decayIT0_EEEEZL31CATCH2_INTERNAL_TEMPLATE_TEST_0IdEvvEUldE2_EEdRKS8_dd
Line
Count
Source
133
1
        variable_type right) const -> result_type {
134
1
        return integrate(function, left, right);
135
1
    }
gauss_legendre_integrator_test.cpp:_ZNK11num_collect11integration25gauss_legendre_integratorIFNSt3__17complexIdEEdEEclITkNS_4base8concepts12invocable_asIFu7__decayIT_Eu7__decayIT0_EEEEZL31CATCH2_INTERNAL_TEMPLATE_TEST_0IdEvvEUldE3_EES4_RKSB_dd
Line
Count
Source
133
1
        variable_type right) const -> result_type {
134
1
        return integrate(function, left, right);
135
1
    }
136
137
private:
138
    /*!
139
     * \brief Update weight for roots.
140
     */
141
24
    void update_weight() {
142
24
        const auto degree = roots_.degree();
143
24
        weights_.resize(degree);
144
444
        for (index_type i = 0; i < degree; ++i) {
145
420
            const variable_type x = roots_[i];
146
420
            const auto temp = static_cast<variable_type>(degree) *
147
420
                functions::legendre(x, degree - 1);
148
420
            weights_[i] = constants::two<variable_type> *
149
420
                (constants::one<variable_type> - x * x) / (temp * temp);
150
420
        }
151
24
    }
_ZN11num_collect11integration25gauss_legendre_integratorIFN5Eigen6MatrixIdLi2ELi1ELi0ELi2ELi1EEEdEE13update_weightEv
Line
Count
Source
141
12
    void update_weight() {
142
12
        const auto degree = roots_.degree();
143
12
        weights_.resize(degree);
144
72
        for (index_type i = 0; i < degree; ++i) {
145
60
            const variable_type x = roots_[i];
146
60
            const auto temp = static_cast<variable_type>(degree) *
147
60
                functions::legendre(x, degree - 1);
148
60
            weights_[i] = constants::two<variable_type> *
149
60
                (constants::one<variable_type> - x * x) / (temp * temp);
150
60
        }
151
12
    }
_ZN11num_collect11integration25gauss_legendre_integratorIFffEE13update_weightEv
Line
Count
Source
141
5
    void update_weight() {
142
5
        const auto degree = roots_.degree();
143
5
        weights_.resize(degree);
144
165
        for (index_type i = 0; i < degree; ++i) {
145
160
            const variable_type x = roots_[i];
146
160
            const auto temp = static_cast<variable_type>(degree) *
147
160
                functions::legendre(x, degree - 1);
148
160
            weights_[i] = constants::two<variable_type> *
149
160
                (constants::one<variable_type> - x * x) / (temp * temp);
150
160
        }
151
5
    }
_ZN11num_collect11integration25gauss_legendre_integratorIFNSt3__17complexIfEEfEE13update_weightEv
Line
Count
Source
141
1
    void update_weight() {
142
1
        const auto degree = roots_.degree();
143
1
        weights_.resize(degree);
144
21
        for (index_type i = 0; i < degree; ++i) {
145
20
            const variable_type x = roots_[i];
146
20
            const auto temp = static_cast<variable_type>(degree) *
147
20
                functions::legendre(x, degree - 1);
148
20
            weights_[i] = constants::two<variable_type> *
149
20
                (constants::one<variable_type> - x * x) / (temp * temp);
150
20
        }
151
1
    }
_ZN11num_collect11integration25gauss_legendre_integratorIFddEE13update_weightEv
Line
Count
Source
141
5
    void update_weight() {
142
5
        const auto degree = roots_.degree();
143
5
        weights_.resize(degree);
144
165
        for (index_type i = 0; i < degree; ++i) {
145
160
            const variable_type x = roots_[i];
146
160
            const auto temp = static_cast<variable_type>(degree) *
147
160
                functions::legendre(x, degree - 1);
148
160
            weights_[i] = constants::two<variable_type> *
149
160
                (constants::one<variable_type> - x * x) / (temp * temp);
150
160
        }
151
5
    }
_ZN11num_collect11integration25gauss_legendre_integratorIFNSt3__17complexIdEEdEE13update_weightEv
Line
Count
Source
141
1
    void update_weight() {
142
1
        const auto degree = roots_.degree();
143
1
        weights_.resize(degree);
144
21
        for (index_type i = 0; i < degree; ++i) {
145
20
            const variable_type x = roots_[i];
146
20
            const auto temp = static_cast<variable_type>(degree) *
147
20
                functions::legendre(x, degree - 1);
148
20
            weights_[i] = constants::two<variable_type> *
149
20
                (constants::one<variable_type> - x * x) / (temp * temp);
150
20
        }
151
1
    }
152
153
    //! Roots of Legendre function.
154
    functions::legendre_roots<variable_type> roots_;
155
156
    //! List of weights for roots.
157
    Eigen::Matrix<variable_type, Eigen::Dynamic, 1> weights_{};
158
};
159
160
}  // namespace num_collect::integration