45 transposed_connections,
47 using storage_index_type =
typename Matrix::StorageIndex;
48 using scalar_type =
typename Matrix::Scalar;
50 const auto num_nodes =
51 static_cast<storage_index_type
>(node_classification.
size());
54 storage_index_type num_coarse_grid_nodes = 0;
55 coarse_grid_indices.
reserve(num_nodes);
56 for (
const node_layer node_class : node_classification) {
58 coarse_grid_indices.
push_back(num_coarse_grid_nodes);
59 ++num_coarse_grid_nodes;
65 std::vector<Eigen::Triplet<scalar_type, storage_index_type>> triplets;
66 for (storage_index_type row_index = 0; row_index < num_nodes; ++row_index) {
68 const storage_index_type col_index = coarse_grid_indices[row_index];
69 const auto value =
static_cast<scalar_type
>(1);
70 triplets.emplace_back(row_index, col_index, value);
72 storage_index_type num_connected_nodes = 0;
73 for (
const storage_index_type connected_node_index :
75 if (node_classification[connected_node_index] ==
77 ++num_connected_nodes;
83 const scalar_type value =
static_cast<scalar_type
>(1) /
84 static_cast<scalar_type
>(num_connected_nodes);
85 for (
const storage_index_type connected_node_index :
87 if (node_classification[connected_node_index] ==
89 const storage_index_type col_index =
90 coarse_grid_indices[connected_node_index];
91 triplets.emplace_back(row_index, col_index, value);
97 prolongation_matrix.resize(num_nodes, num_coarse_grid_nodes);
98 prolongation_matrix.setFromTriplets(triplets.begin(), triplets.end());