/builds/MusicScience37Projects/numerical-analysis/numerical-collection-cpp/include/num_collect/rbf/generate_halton_nodes.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 generate_halton_nodes function. |
19 | | */ |
20 | | #pragma once |
21 | | |
22 | | #include <algorithm> |
23 | | #include <array> |
24 | | #include <cstddef> |
25 | | #include <vector> |
26 | | |
27 | | #include <Eigen/Core> |
28 | | |
29 | | #include "num_collect/base/concepts/real_scalar.h" |
30 | | #include "num_collect/base/index_type.h" |
31 | | |
32 | | namespace num_collect::rbf { |
33 | | |
34 | | namespace impl { |
35 | | |
36 | | /*! |
37 | | * \brief Generate a vector of Halton sequence for a single dimension |
38 | | * \cite Fornberg2015. |
39 | | * |
40 | | * \tparam Scalar Type of scalars. |
41 | | * \param[out] buffer Buffer to generate the sequence. |
42 | | * (Values from the second element must be used for the final output.) |
43 | | * \param[in] num_nodes Number of nodes. |
44 | | * \param[in] base_sequence_size Size of the first sequence. |
45 | | */ |
46 | | template <base::concepts::real_scalar Scalar> |
47 | | void generate_halton_nodes_impl(Eigen::VectorX<Scalar>& buffer, |
48 | 356 | index_type num_nodes, index_type base_sequence_size) { |
49 | 356 | buffer = Eigen::VectorX<Scalar>::Zero(num_nodes + 1); |
50 | 356 | index_type current_size = 1; |
51 | 356 | Scalar sequence_interval = |
52 | 356 | static_cast<Scalar>(1) / static_cast<Scalar>(base_sequence_size); |
53 | 1.58k | while (current_size <= num_nodes) { |
54 | 1.22k | const index_type current_sequence_size = std::max<index_type>(2, |
55 | 1.22k | std::min<index_type>( |
56 | 1.22k | base_sequence_size, (num_nodes + current_size) / current_size)); |
57 | 1.22k | index_type dest_end = current_size; // save the last index. |
58 | 4.78k | for (index_type i = 1; i < current_sequence_size; ++i) { |
59 | 3.55k | const index_type dest_begin = current_size * i; |
60 | 3.55k | dest_end = dest_begin + current_size; |
61 | 3.55k | if (dest_end > num_nodes + 1 || dest_end < 0) { |
62 | 324 | dest_end = num_nodes + 1; |
63 | 324 | } |
64 | 3.55k | if (dest_end <= dest_begin) { |
65 | 0 | break; |
66 | 0 | } |
67 | 3.55k | const index_type dest_size = dest_end - dest_begin; |
68 | 3.55k | const Scalar value_offset = |
69 | 3.55k | static_cast<Scalar>(i) * sequence_interval; |
70 | 3.55k | buffer.segment(dest_begin, dest_size) = |
71 | 3.55k | buffer.head(dest_size).array() + value_offset; |
72 | 3.55k | } |
73 | 1.22k | current_size = dest_end; |
74 | 1.22k | sequence_interval /= static_cast<Scalar>(base_sequence_size); |
75 | 1.22k | } |
76 | 356 | } _ZN11num_collect3rbf4impl26generate_halton_nodes_implITkNS_4base8concepts11real_scalarEdEEvRN5Eigen6MatrixIT_Lin1ELi1ELi0ELin1ELi1EEEll Line | Count | Source | 48 | 332 | index_type num_nodes, index_type base_sequence_size) { | 49 | 332 | buffer = Eigen::VectorX<Scalar>::Zero(num_nodes + 1); | 50 | 332 | index_type current_size = 1; | 51 | 332 | Scalar sequence_interval = | 52 | 332 | static_cast<Scalar>(1) / static_cast<Scalar>(base_sequence_size); | 53 | 1.43k | while (current_size <= num_nodes) { | 54 | 1.10k | const index_type current_sequence_size = std::max<index_type>(2, | 55 | 1.10k | std::min<index_type>( | 56 | 1.10k | base_sequence_size, (num_nodes + current_size) / current_size)); | 57 | 1.10k | index_type dest_end = current_size; // save the last index. | 58 | 4.38k | for (index_type i = 1; i < current_sequence_size; ++i) { | 59 | 3.27k | const index_type dest_begin = current_size * i; | 60 | 3.27k | dest_end = dest_begin + current_size; | 61 | 3.27k | if (dest_end > num_nodes + 1 || dest_end < 0) { | 62 | 306 | dest_end = num_nodes + 1; | 63 | 306 | } | 64 | 3.27k | if (dest_end <= dest_begin) { | 65 | 0 | break; | 66 | 0 | } | 67 | 3.27k | const index_type dest_size = dest_end - dest_begin; | 68 | 3.27k | const Scalar value_offset = | 69 | 3.27k | static_cast<Scalar>(i) * sequence_interval; | 70 | 3.27k | buffer.segment(dest_begin, dest_size) = | 71 | 3.27k | buffer.head(dest_size).array() + value_offset; | 72 | 3.27k | } | 73 | 1.10k | current_size = dest_end; | 74 | 1.10k | sequence_interval /= static_cast<Scalar>(base_sequence_size); | 75 | 1.10k | } | 76 | 332 | } |
_ZN11num_collect3rbf4impl26generate_halton_nodes_implITkNS_4base8concepts11real_scalarEfEEvRN5Eigen6MatrixIT_Lin1ELi1ELi0ELin1ELi1EEEll Line | Count | Source | 48 | 12 | index_type num_nodes, index_type base_sequence_size) { | 49 | 12 | buffer = Eigen::VectorX<Scalar>::Zero(num_nodes + 1); | 50 | 12 | index_type current_size = 1; | 51 | 12 | Scalar sequence_interval = | 52 | 12 | static_cast<Scalar>(1) / static_cast<Scalar>(base_sequence_size); | 53 | 73 | while (current_size <= num_nodes) { | 54 | 61 | const index_type current_sequence_size = std::max<index_type>(2, | 55 | 61 | std::min<index_type>( | 56 | 61 | base_sequence_size, (num_nodes + current_size) / current_size)); | 57 | 61 | index_type dest_end = current_size; // save the last index. | 58 | 200 | for (index_type i = 1; i < current_sequence_size; ++i) { | 59 | 139 | const index_type dest_begin = current_size * i; | 60 | 139 | dest_end = dest_begin + current_size; | 61 | 139 | if (dest_end > num_nodes + 1 || dest_end < 0) { | 62 | 9 | dest_end = num_nodes + 1; | 63 | 9 | } | 64 | 139 | if (dest_end <= dest_begin) { | 65 | 0 | break; | 66 | 0 | } | 67 | 139 | const index_type dest_size = dest_end - dest_begin; | 68 | 139 | const Scalar value_offset = | 69 | 139 | static_cast<Scalar>(i) * sequence_interval; | 70 | 139 | buffer.segment(dest_begin, dest_size) = | 71 | 139 | buffer.head(dest_size).array() + value_offset; | 72 | 139 | } | 73 | 61 | current_size = dest_end; | 74 | 61 | sequence_interval /= static_cast<Scalar>(base_sequence_size); | 75 | 61 | } | 76 | 12 | } |
_ZN11num_collect3rbf4impl26generate_halton_nodes_implITkNS_4base8concepts11real_scalarEeEEvRN5Eigen6MatrixIT_Lin1ELi1ELi0ELin1ELi1EEEll Line | Count | Source | 48 | 12 | index_type num_nodes, index_type base_sequence_size) { | 49 | 12 | buffer = Eigen::VectorX<Scalar>::Zero(num_nodes + 1); | 50 | 12 | index_type current_size = 1; | 51 | 12 | Scalar sequence_interval = | 52 | 12 | static_cast<Scalar>(1) / static_cast<Scalar>(base_sequence_size); | 53 | 73 | while (current_size <= num_nodes) { | 54 | 61 | const index_type current_sequence_size = std::max<index_type>(2, | 55 | 61 | std::min<index_type>( | 56 | 61 | base_sequence_size, (num_nodes + current_size) / current_size)); | 57 | 61 | index_type dest_end = current_size; // save the last index. | 58 | 200 | for (index_type i = 1; i < current_sequence_size; ++i) { | 59 | 139 | const index_type dest_begin = current_size * i; | 60 | 139 | dest_end = dest_begin + current_size; | 61 | 139 | if (dest_end > num_nodes + 1 || dest_end < 0) { | 62 | 9 | dest_end = num_nodes + 1; | 63 | 9 | } | 64 | 139 | if (dest_end <= dest_begin) { | 65 | 0 | break; | 66 | 0 | } | 67 | 139 | const index_type dest_size = dest_end - dest_begin; | 68 | 139 | const Scalar value_offset = | 69 | 139 | static_cast<Scalar>(i) * sequence_interval; | 70 | 139 | buffer.segment(dest_begin, dest_size) = | 71 | 139 | buffer.head(dest_size).array() + value_offset; | 72 | 139 | } | 73 | 61 | current_size = dest_end; | 74 | 61 | sequence_interval /= static_cast<Scalar>(base_sequence_size); | 75 | 61 | } | 76 | 12 | } |
|
77 | | |
78 | | } // namespace impl |
79 | | |
80 | | /*! |
81 | | * \brief Generate Halton nodes \cite Fornberg2015. |
82 | | * |
83 | | * \tparam Scalar Type of scalars. |
84 | | * \tparam Dimensions Number of dimensions of the space |
85 | | * in which nodes are generated. |
86 | | * \param[in] num_nodes Number of nodes. |
87 | | * \return Generated nodes. |
88 | | */ |
89 | | template <base::concepts::real_scalar Scalar, index_type Dimensions> |
90 | | [[nodiscard]] auto generate_halton_nodes(index_type num_nodes) |
91 | 29 | -> std::vector<Eigen::Vector<Scalar, Dimensions>> { |
92 | 29 | std::vector<Eigen::Vector<Scalar, Dimensions>> nodes( |
93 | 29 | static_cast<std::size_t>(num_nodes)); |
94 | | |
95 | 29 | constexpr index_type supported_dimensions = 6; |
96 | 29 | static_assert(Dimensions <= supported_dimensions); |
97 | 29 | static_assert(Dimensions > 1); |
98 | 29 | constexpr std::array<index_type, |
99 | 29 | static_cast<std::size_t>(supported_dimensions)> |
100 | 29 | base_sequence_sizes{2, 3, 5, 7, 11, 13}; |
101 | | |
102 | 29 | Eigen::VectorX<Scalar> buffer; |
103 | 142 | for (index_type d = 0; d < Dimensions; ++d) { |
104 | 113 | impl::generate_halton_nodes_impl(buffer, num_nodes, |
105 | 113 | base_sequence_sizes[static_cast<std::size_t>(d)]); |
106 | 12.3k | for (index_type i = 0; i < num_nodes; ++i) { |
107 | 12.1k | nodes[static_cast<std::size_t>(i)](d) = buffer(i + 1); |
108 | 12.1k | } |
109 | 113 | } |
110 | | |
111 | 29 | return nodes; |
112 | 29 | } _ZN11num_collect3rbf21generate_halton_nodesITkNS_4base8concepts11real_scalarEdLl2EEENSt3__16vectorIN5Eigen6MatrixIT_XT0_ELi1EXorLNS6_14StorageOptionsE0EquaaeqT0_Li1EneLi1ELi1ELS9_1EquaaeqLi1ELi1EneT0_Li1ELS9_0ELS9_0EEXT0_ELi1EEENS4_9allocatorISA_EEEEl Line | Count | Source | 91 | 5 | -> std::vector<Eigen::Vector<Scalar, Dimensions>> { | 92 | 5 | std::vector<Eigen::Vector<Scalar, Dimensions>> nodes( | 93 | 5 | static_cast<std::size_t>(num_nodes)); | 94 | | | 95 | 5 | constexpr index_type supported_dimensions = 6; | 96 | 5 | static_assert(Dimensions <= supported_dimensions); | 97 | 5 | static_assert(Dimensions > 1); | 98 | 5 | constexpr std::array<index_type, | 99 | 5 | static_cast<std::size_t>(supported_dimensions)> | 100 | 5 | base_sequence_sizes{2, 3, 5, 7, 11, 13}; | 101 | | | 102 | 5 | Eigen::VectorX<Scalar> buffer; | 103 | 15 | for (index_type d = 0; d < Dimensions; ++d) { | 104 | 10 | impl::generate_halton_nodes_impl(buffer, num_nodes, | 105 | 10 | base_sequence_sizes[static_cast<std::size_t>(d)]); | 106 | 1.06k | for (index_type i = 0; i < num_nodes; ++i) { | 107 | 1.05k | nodes[static_cast<std::size_t>(i)](d) = buffer(i + 1); | 108 | 1.05k | } | 109 | 10 | } | 110 | | | 111 | 5 | return nodes; | 112 | 5 | } |
_ZN11num_collect3rbf21generate_halton_nodesITkNS_4base8concepts11real_scalarEdLl3EEENSt3__16vectorIN5Eigen6MatrixIT_XT0_ELi1EXorLNS6_14StorageOptionsE0EquaaeqT0_Li1EneLi1ELi1ELS9_1EquaaeqLi1ELi1EneT0_Li1ELS9_0ELS9_0EEXT0_ELi1EEENS4_9allocatorISA_EEEEl Line | Count | Source | 91 | 5 | -> std::vector<Eigen::Vector<Scalar, Dimensions>> { | 92 | 5 | std::vector<Eigen::Vector<Scalar, Dimensions>> nodes( | 93 | 5 | static_cast<std::size_t>(num_nodes)); | 94 | | | 95 | 5 | constexpr index_type supported_dimensions = 6; | 96 | 5 | static_assert(Dimensions <= supported_dimensions); | 97 | 5 | static_assert(Dimensions > 1); | 98 | 5 | constexpr std::array<index_type, | 99 | 5 | static_cast<std::size_t>(supported_dimensions)> | 100 | 5 | base_sequence_sizes{2, 3, 5, 7, 11, 13}; | 101 | | | 102 | 5 | Eigen::VectorX<Scalar> buffer; | 103 | 20 | for (index_type d = 0; d < Dimensions; ++d) { | 104 | 15 | impl::generate_halton_nodes_impl(buffer, num_nodes, | 105 | 15 | base_sequence_sizes[static_cast<std::size_t>(d)]); | 106 | 1.59k | for (index_type i = 0; i < num_nodes; ++i) { | 107 | 1.58k | nodes[static_cast<std::size_t>(i)](d) = buffer(i + 1); | 108 | 1.58k | } | 109 | 15 | } | 110 | | | 111 | 5 | return nodes; | 112 | 5 | } |
_ZN11num_collect3rbf21generate_halton_nodesITkNS_4base8concepts11real_scalarEdLl4EEENSt3__16vectorIN5Eigen6MatrixIT_XT0_ELi1EXorLNS6_14StorageOptionsE0EquaaeqT0_Li1EneLi1ELi1ELS9_1EquaaeqLi1ELi1EneT0_Li1ELS9_0ELS9_0EEXT0_ELi1EEENS4_9allocatorISA_EEEEl Line | Count | Source | 91 | 4 | -> std::vector<Eigen::Vector<Scalar, Dimensions>> { | 92 | 4 | std::vector<Eigen::Vector<Scalar, Dimensions>> nodes( | 93 | 4 | static_cast<std::size_t>(num_nodes)); | 94 | | | 95 | 4 | constexpr index_type supported_dimensions = 6; | 96 | 4 | static_assert(Dimensions <= supported_dimensions); | 97 | 4 | static_assert(Dimensions > 1); | 98 | 4 | constexpr std::array<index_type, | 99 | 4 | static_cast<std::size_t>(supported_dimensions)> | 100 | 4 | base_sequence_sizes{2, 3, 5, 7, 11, 13}; | 101 | | | 102 | 4 | Eigen::VectorX<Scalar> buffer; | 103 | 20 | for (index_type d = 0; d < Dimensions; ++d) { | 104 | 16 | impl::generate_halton_nodes_impl(buffer, num_nodes, | 105 | 16 | base_sequence_sizes[static_cast<std::size_t>(d)]); | 106 | 1.61k | for (index_type i = 0; i < num_nodes; ++i) { | 107 | 1.60k | nodes[static_cast<std::size_t>(i)](d) = buffer(i + 1); | 108 | 1.60k | } | 109 | 16 | } | 110 | | | 111 | 4 | return nodes; | 112 | 4 | } |
_ZN11num_collect3rbf21generate_halton_nodesITkNS_4base8concepts11real_scalarEdLl5EEENSt3__16vectorIN5Eigen6MatrixIT_XT0_ELi1EXorLNS6_14StorageOptionsE0EquaaeqT0_Li1EneLi1ELi1ELS9_1EquaaeqLi1ELi1EneT0_Li1ELS9_0ELS9_0EEXT0_ELi1EEENS4_9allocatorISA_EEEEl Line | Count | Source | 91 | 4 | -> std::vector<Eigen::Vector<Scalar, Dimensions>> { | 92 | 4 | std::vector<Eigen::Vector<Scalar, Dimensions>> nodes( | 93 | 4 | static_cast<std::size_t>(num_nodes)); | 94 | | | 95 | 4 | constexpr index_type supported_dimensions = 6; | 96 | 4 | static_assert(Dimensions <= supported_dimensions); | 97 | 4 | static_assert(Dimensions > 1); | 98 | 4 | constexpr std::array<index_type, | 99 | 4 | static_cast<std::size_t>(supported_dimensions)> | 100 | 4 | base_sequence_sizes{2, 3, 5, 7, 11, 13}; | 101 | | | 102 | 4 | Eigen::VectorX<Scalar> buffer; | 103 | 24 | for (index_type d = 0; d < Dimensions; ++d) { | 104 | 20 | impl::generate_halton_nodes_impl(buffer, num_nodes, | 105 | 20 | base_sequence_sizes[static_cast<std::size_t>(d)]); | 106 | 2.02k | for (index_type i = 0; i < num_nodes; ++i) { | 107 | 2.00k | nodes[static_cast<std::size_t>(i)](d) = buffer(i + 1); | 108 | 2.00k | } | 109 | 20 | } | 110 | | | 111 | 4 | return nodes; | 112 | 4 | } |
_ZN11num_collect3rbf21generate_halton_nodesITkNS_4base8concepts11real_scalarEdLl6EEENSt3__16vectorIN5Eigen6MatrixIT_XT0_ELi1EXorLNS6_14StorageOptionsE0EquaaeqT0_Li1EneLi1ELi1ELS9_1EquaaeqLi1ELi1EneT0_Li1ELS9_0ELS9_0EEXT0_ELi1EEENS4_9allocatorISA_EEEEl Line | Count | Source | 91 | 5 | -> std::vector<Eigen::Vector<Scalar, Dimensions>> { | 92 | 5 | std::vector<Eigen::Vector<Scalar, Dimensions>> nodes( | 93 | 5 | static_cast<std::size_t>(num_nodes)); | 94 | | | 95 | 5 | constexpr index_type supported_dimensions = 6; | 96 | 5 | static_assert(Dimensions <= supported_dimensions); | 97 | 5 | static_assert(Dimensions > 1); | 98 | 5 | constexpr std::array<index_type, | 99 | 5 | static_cast<std::size_t>(supported_dimensions)> | 100 | 5 | base_sequence_sizes{2, 3, 5, 7, 11, 13}; | 101 | | | 102 | 5 | Eigen::VectorX<Scalar> buffer; | 103 | 35 | for (index_type d = 0; d < Dimensions; ++d) { | 104 | 30 | impl::generate_halton_nodes_impl(buffer, num_nodes, | 105 | 30 | base_sequence_sizes[static_cast<std::size_t>(d)]); | 106 | 3.19k | for (index_type i = 0; i < num_nodes; ++i) { | 107 | 3.16k | nodes[static_cast<std::size_t>(i)](d) = buffer(i + 1); | 108 | 3.16k | } | 109 | 30 | } | 110 | | | 111 | 5 | return nodes; | 112 | 5 | } |
_ZN11num_collect3rbf21generate_halton_nodesITkNS_4base8concepts11real_scalarEfLl2EEENSt3__16vectorIN5Eigen6MatrixIT_XT0_ELi1EXorLNS6_14StorageOptionsE0EquaaeqT0_Li1EneLi1ELi1ELS9_1EquaaeqLi1ELi1EneT0_Li1ELS9_0ELS9_0EEXT0_ELi1EEENS4_9allocatorISA_EEEEl Line | Count | Source | 91 | 1 | -> std::vector<Eigen::Vector<Scalar, Dimensions>> { | 92 | 1 | std::vector<Eigen::Vector<Scalar, Dimensions>> nodes( | 93 | 1 | static_cast<std::size_t>(num_nodes)); | 94 | | | 95 | 1 | constexpr index_type supported_dimensions = 6; | 96 | 1 | static_assert(Dimensions <= supported_dimensions); | 97 | 1 | static_assert(Dimensions > 1); | 98 | 1 | constexpr std::array<index_type, | 99 | 1 | static_cast<std::size_t>(supported_dimensions)> | 100 | 1 | base_sequence_sizes{2, 3, 5, 7, 11, 13}; | 101 | | | 102 | 1 | Eigen::VectorX<Scalar> buffer; | 103 | 3 | for (index_type d = 0; d < Dimensions; ++d) { | 104 | 2 | impl::generate_halton_nodes_impl(buffer, num_nodes, | 105 | 2 | base_sequence_sizes[static_cast<std::size_t>(d)]); | 106 | 256 | for (index_type i = 0; i < num_nodes; ++i) { | 107 | 254 | nodes[static_cast<std::size_t>(i)](d) = buffer(i + 1); | 108 | 254 | } | 109 | 2 | } | 110 | | | 111 | 1 | return nodes; | 112 | 1 | } |
_ZN11num_collect3rbf21generate_halton_nodesITkNS_4base8concepts11real_scalarEfLl3EEENSt3__16vectorIN5Eigen6MatrixIT_XT0_ELi1EXorLNS6_14StorageOptionsE0EquaaeqT0_Li1EneLi1ELi1ELS9_1EquaaeqLi1ELi1EneT0_Li1ELS9_0ELS9_0EEXT0_ELi1EEENS4_9allocatorISA_EEEEl Line | Count | Source | 91 | 1 | -> std::vector<Eigen::Vector<Scalar, Dimensions>> { | 92 | 1 | std::vector<Eigen::Vector<Scalar, Dimensions>> nodes( | 93 | 1 | static_cast<std::size_t>(num_nodes)); | 94 | | | 95 | 1 | constexpr index_type supported_dimensions = 6; | 96 | 1 | static_assert(Dimensions <= supported_dimensions); | 97 | 1 | static_assert(Dimensions > 1); | 98 | 1 | constexpr std::array<index_type, | 99 | 1 | static_cast<std::size_t>(supported_dimensions)> | 100 | 1 | base_sequence_sizes{2, 3, 5, 7, 11, 13}; | 101 | | | 102 | 1 | Eigen::VectorX<Scalar> buffer; | 103 | 4 | for (index_type d = 0; d < Dimensions; ++d) { | 104 | 3 | impl::generate_halton_nodes_impl(buffer, num_nodes, | 105 | 3 | base_sequence_sizes[static_cast<std::size_t>(d)]); | 106 | 384 | for (index_type i = 0; i < num_nodes; ++i) { | 107 | 381 | nodes[static_cast<std::size_t>(i)](d) = buffer(i + 1); | 108 | 381 | } | 109 | 3 | } | 110 | | | 111 | 1 | return nodes; | 112 | 1 | } |
_ZN11num_collect3rbf21generate_halton_nodesITkNS_4base8concepts11real_scalarEfLl6EEENSt3__16vectorIN5Eigen6MatrixIT_XT0_ELi1EXorLNS6_14StorageOptionsE0EquaaeqT0_Li1EneLi1ELi1ELS9_1EquaaeqLi1ELi1EneT0_Li1ELS9_0ELS9_0EEXT0_ELi1EEENS4_9allocatorISA_EEEEl Line | Count | Source | 91 | 1 | -> std::vector<Eigen::Vector<Scalar, Dimensions>> { | 92 | 1 | std::vector<Eigen::Vector<Scalar, Dimensions>> nodes( | 93 | 1 | static_cast<std::size_t>(num_nodes)); | 94 | | | 95 | 1 | constexpr index_type supported_dimensions = 6; | 96 | 1 | static_assert(Dimensions <= supported_dimensions); | 97 | 1 | static_assert(Dimensions > 1); | 98 | 1 | constexpr std::array<index_type, | 99 | 1 | static_cast<std::size_t>(supported_dimensions)> | 100 | 1 | base_sequence_sizes{2, 3, 5, 7, 11, 13}; | 101 | | | 102 | 1 | Eigen::VectorX<Scalar> buffer; | 103 | 7 | for (index_type d = 0; d < Dimensions; ++d) { | 104 | 6 | impl::generate_halton_nodes_impl(buffer, num_nodes, | 105 | 6 | base_sequence_sizes[static_cast<std::size_t>(d)]); | 106 | 768 | for (index_type i = 0; i < num_nodes; ++i) { | 107 | 762 | nodes[static_cast<std::size_t>(i)](d) = buffer(i + 1); | 108 | 762 | } | 109 | 6 | } | 110 | | | 111 | 1 | return nodes; | 112 | 1 | } |
_ZN11num_collect3rbf21generate_halton_nodesITkNS_4base8concepts11real_scalarEeLl2EEENSt3__16vectorIN5Eigen6MatrixIT_XT0_ELi1EXorLNS6_14StorageOptionsE0EquaaeqT0_Li1EneLi1ELi1ELS9_1EquaaeqLi1ELi1EneT0_Li1ELS9_0ELS9_0EEXT0_ELi1EEENS4_9allocatorISA_EEEEl Line | Count | Source | 91 | 1 | -> std::vector<Eigen::Vector<Scalar, Dimensions>> { | 92 | 1 | std::vector<Eigen::Vector<Scalar, Dimensions>> nodes( | 93 | 1 | static_cast<std::size_t>(num_nodes)); | 94 | | | 95 | 1 | constexpr index_type supported_dimensions = 6; | 96 | 1 | static_assert(Dimensions <= supported_dimensions); | 97 | 1 | static_assert(Dimensions > 1); | 98 | 1 | constexpr std::array<index_type, | 99 | 1 | static_cast<std::size_t>(supported_dimensions)> | 100 | 1 | base_sequence_sizes{2, 3, 5, 7, 11, 13}; | 101 | | | 102 | 1 | Eigen::VectorX<Scalar> buffer; | 103 | 3 | for (index_type d = 0; d < Dimensions; ++d) { | 104 | 2 | impl::generate_halton_nodes_impl(buffer, num_nodes, | 105 | 2 | base_sequence_sizes[static_cast<std::size_t>(d)]); | 106 | 256 | for (index_type i = 0; i < num_nodes; ++i) { | 107 | 254 | nodes[static_cast<std::size_t>(i)](d) = buffer(i + 1); | 108 | 254 | } | 109 | 2 | } | 110 | | | 111 | 1 | return nodes; | 112 | 1 | } |
_ZN11num_collect3rbf21generate_halton_nodesITkNS_4base8concepts11real_scalarEeLl3EEENSt3__16vectorIN5Eigen6MatrixIT_XT0_ELi1EXorLNS6_14StorageOptionsE0EquaaeqT0_Li1EneLi1ELi1ELS9_1EquaaeqLi1ELi1EneT0_Li1ELS9_0ELS9_0EEXT0_ELi1EEENS4_9allocatorISA_EEEEl Line | Count | Source | 91 | 1 | -> std::vector<Eigen::Vector<Scalar, Dimensions>> { | 92 | 1 | std::vector<Eigen::Vector<Scalar, Dimensions>> nodes( | 93 | 1 | static_cast<std::size_t>(num_nodes)); | 94 | | | 95 | 1 | constexpr index_type supported_dimensions = 6; | 96 | 1 | static_assert(Dimensions <= supported_dimensions); | 97 | 1 | static_assert(Dimensions > 1); | 98 | 1 | constexpr std::array<index_type, | 99 | 1 | static_cast<std::size_t>(supported_dimensions)> | 100 | 1 | base_sequence_sizes{2, 3, 5, 7, 11, 13}; | 101 | | | 102 | 1 | Eigen::VectorX<Scalar> buffer; | 103 | 4 | for (index_type d = 0; d < Dimensions; ++d) { | 104 | 3 | impl::generate_halton_nodes_impl(buffer, num_nodes, | 105 | 3 | base_sequence_sizes[static_cast<std::size_t>(d)]); | 106 | 384 | for (index_type i = 0; i < num_nodes; ++i) { | 107 | 381 | nodes[static_cast<std::size_t>(i)](d) = buffer(i + 1); | 108 | 381 | } | 109 | 3 | } | 110 | | | 111 | 1 | return nodes; | 112 | 1 | } |
_ZN11num_collect3rbf21generate_halton_nodesITkNS_4base8concepts11real_scalarEeLl6EEENSt3__16vectorIN5Eigen6MatrixIT_XT0_ELi1EXorLNS6_14StorageOptionsE0EquaaeqT0_Li1EneLi1ELi1ELS9_1EquaaeqLi1ELi1EneT0_Li1ELS9_0ELS9_0EEXT0_ELi1EEENS4_9allocatorISA_EEEEl Line | Count | Source | 91 | 1 | -> std::vector<Eigen::Vector<Scalar, Dimensions>> { | 92 | 1 | std::vector<Eigen::Vector<Scalar, Dimensions>> nodes( | 93 | 1 | static_cast<std::size_t>(num_nodes)); | 94 | | | 95 | 1 | constexpr index_type supported_dimensions = 6; | 96 | 1 | static_assert(Dimensions <= supported_dimensions); | 97 | 1 | static_assert(Dimensions > 1); | 98 | 1 | constexpr std::array<index_type, | 99 | 1 | static_cast<std::size_t>(supported_dimensions)> | 100 | 1 | base_sequence_sizes{2, 3, 5, 7, 11, 13}; | 101 | | | 102 | 1 | Eigen::VectorX<Scalar> buffer; | 103 | 7 | for (index_type d = 0; d < Dimensions; ++d) { | 104 | 6 | impl::generate_halton_nodes_impl(buffer, num_nodes, | 105 | 6 | base_sequence_sizes[static_cast<std::size_t>(d)]); | 106 | 768 | for (index_type i = 0; i < num_nodes; ++i) { | 107 | 762 | nodes[static_cast<std::size_t>(i)](d) = buffer(i + 1); | 108 | 762 | } | 109 | 6 | } | 110 | | | 111 | 1 | return nodes; | 112 | 1 | } |
|
113 | | |
114 | | /*! |
115 | | * \brief Generate Halton nodes in 1 dimension \cite Fornberg2015. |
116 | | * |
117 | | * \tparam Scalar Type of scalars. |
118 | | * \param[in] num_nodes Number of nodes. |
119 | | * \return Generated nodes. |
120 | | */ |
121 | | template <base::concepts::real_scalar Scalar> |
122 | | [[nodiscard]] auto generate_1d_halton_nodes(index_type num_nodes) |
123 | 3 | -> std::vector<Scalar> { |
124 | 3 | Eigen::VectorX<Scalar> buffer; |
125 | 3 | constexpr index_type base_sequence_size = 2; |
126 | 3 | impl::generate_halton_nodes_impl(buffer, num_nodes, base_sequence_size); |
127 | | |
128 | 3 | std::vector<Scalar> nodes; |
129 | 3 | nodes.reserve(static_cast<std::size_t>(num_nodes)); |
130 | 996 | for (index_type i = 1; i <= num_nodes; ++i) { |
131 | 993 | nodes.push_back(buffer(i)); |
132 | 993 | } |
133 | 3 | return nodes; |
134 | 3 | } _ZN11num_collect3rbf24generate_1d_halton_nodesITkNS_4base8concepts11real_scalarEfEENSt3__16vectorIT_NS4_9allocatorIS6_EEEEl Line | Count | Source | 123 | 1 | -> std::vector<Scalar> { | 124 | 1 | Eigen::VectorX<Scalar> buffer; | 125 | 1 | constexpr index_type base_sequence_size = 2; | 126 | 1 | impl::generate_halton_nodes_impl(buffer, num_nodes, base_sequence_size); | 127 | | | 128 | 1 | std::vector<Scalar> nodes; | 129 | 1 | nodes.reserve(static_cast<std::size_t>(num_nodes)); | 130 | 332 | for (index_type i = 1; i <= num_nodes; ++i) { | 131 | 331 | nodes.push_back(buffer(i)); | 132 | 331 | } | 133 | 1 | return nodes; | 134 | 1 | } |
_ZN11num_collect3rbf24generate_1d_halton_nodesITkNS_4base8concepts11real_scalarEdEENSt3__16vectorIT_NS4_9allocatorIS6_EEEEl Line | Count | Source | 123 | 1 | -> std::vector<Scalar> { | 124 | 1 | Eigen::VectorX<Scalar> buffer; | 125 | 1 | constexpr index_type base_sequence_size = 2; | 126 | 1 | impl::generate_halton_nodes_impl(buffer, num_nodes, base_sequence_size); | 127 | | | 128 | 1 | std::vector<Scalar> nodes; | 129 | 1 | nodes.reserve(static_cast<std::size_t>(num_nodes)); | 130 | 332 | for (index_type i = 1; i <= num_nodes; ++i) { | 131 | 331 | nodes.push_back(buffer(i)); | 132 | 331 | } | 133 | 1 | return nodes; | 134 | 1 | } |
_ZN11num_collect3rbf24generate_1d_halton_nodesITkNS_4base8concepts11real_scalarEeEENSt3__16vectorIT_NS4_9allocatorIS6_EEEEl Line | Count | Source | 123 | 1 | -> std::vector<Scalar> { | 124 | 1 | Eigen::VectorX<Scalar> buffer; | 125 | 1 | constexpr index_type base_sequence_size = 2; | 126 | 1 | impl::generate_halton_nodes_impl(buffer, num_nodes, base_sequence_size); | 127 | | | 128 | 1 | std::vector<Scalar> nodes; | 129 | 1 | nodes.reserve(static_cast<std::size_t>(num_nodes)); | 130 | 332 | for (index_type i = 1; i <= num_nodes; ++i) { | 131 | 331 | nodes.push_back(buffer(i)); | 132 | 331 | } | 133 | 1 | return nodes; | 134 | 1 | } |
|
135 | | |
136 | | } // namespace num_collect::rbf |