26#include <Eigen/SparseCore>
41template <num_collect::base::concepts::sparse_matrix Matrix>
60 typename Matrix::value_type grid_width)
122 [[nodiscard]]
auto mat() const noexcept -> const Matrix& {
return mat_; }
149 std::vector<Eigen::Triplet<scalar_type>> triplets;
150 const std::size_t approx_elements =
151 9U *
static_cast<std::size_t
>(
mat_size_);
152 triplets.reserve(approx_elements);
157 xj = std::max<num_collect::index_type>(xi - 1, 0),
158 xj_end = std::min<num_collect::index_type>(
162 yj = std::max<num_collect::index_type>(yi - 1, 0),
163 yj_end = std::min<num_collect::index_type>(
169 triplets.emplace_back(
170 static_cast<int>(i),
static_cast<int>(j), coeff);
176 mat_.setFromTriplets(triplets.begin(), triplets.end());
Definition of assertion macros.
#define NUM_COLLECT_ASSERT(CONDITION)
Macro to check whether a condition is satisfied.
Class to create matrices of Laplacian on a 2-dimensional grid.
auto grid_cols() const noexcept -> num_collect::index_type
Get the number of columns in the grid.
typename Matrix::Scalar scalar_type
Type of the scalars.
Matrix mat_
Laplacian matrix.
auto diag_coeff() const noexcept -> scalar_type
Get the coefficient of diagonal elements.
num_collect::index_type mat_size_
Number of rows in the Laplacian matrix.
auto off_diag_coeff() const noexcept -> scalar_type
Get the coefficient of off-diagonal elements.
auto grid_rows() const noexcept -> num_collect::index_type
Get the number of rows in the grid.
num_collect::index_type grid_rows_
Number of rows in the grid.
Matrix matrix_type
Type of the matrix.
auto index(num_collect::index_type x, num_collect::index_type y) const noexcept -> num_collect::index_type
Calculate an index in the matrix.
scalar_type grid_width_
Width of squares in the grid.
scalar_type diag_coeff_
Coefficient of diagonal elements.
num_collect::index_type grid_cols_
Number of columns in the grid.
auto mat() const noexcept -> const Matrix &
Get the Laplacian matrix.
scalar_type off_diag_coeff_
Coefficient of off-diagonal elements.
laplacian_2d_grid(num_collect::index_type grid_rows, num_collect::index_type grid_cols, typename Matrix::value_type grid_width)
Constructor.
auto mat_size() const noexcept -> num_collect::index_type
Get the size of the matrix.
void calc()
Calculate matrices.
Definition of index_type type.
std::ptrdiff_t index_type
Type of indices in this library.
Namespace of num_collect source codes.
Namespace of linear equations.
Definition of sparse_matrix concept.