8 #include <boost/numeric/mtl/matrix/compressed2D.hpp> 9 #include <boost/numeric/mtl/matrix/inserter.hpp> 10 #include <boost/numeric/mtl/utility/property_map.hpp> 11 #include <boost/numeric/mtl/utility/range_wrapper.hpp> 13 #include <amdis/Output.hpp> 14 #include <amdis/linearalgebra/SymmetryStructure.hpp> 15 #include <amdis/linearalgebra/mtl/SlotSize.hpp> 35 using Inserter = mtl::mat::inserter<BaseMatrix, mtl::operations::update_plus<value_type>>;
42 template <
class Basis>
63 test_exit(!inserter_,
"Matrix already in insertion mode!");
65 std::size_t slotSize =
nnz() > 0 ? 6*
nnz() / (5*num_rows(matrix_))
67 matrix_.change_dim(pattern.
rows(), pattern.
cols());
71 inserter_ =
new Inserter(matrix_, slotSize);
78 test_exit(!inserter_,
"Matrix already in insertion mode!");
80 std::size_t slotSize = 6*
nnz() / (5*num_rows(matrix_));
83 inserter_ =
new Inserter(matrix_, slotSize);
102 test_exit_dbg(r < num_rows(matrix_) && c < num_cols(matrix_),
103 "Indices out of range [0,{})x[0,{})", num_rows(matrix_), num_cols(matrix_));
105 (*inserter_)[r][c] += value;
108 template <
class Ind,
class LocalMat>
109 void scatter(Ind
const& idx, LocalMat
const& mat)
111 scatter(idx, idx, mat);
114 template <
class RowInd,
class ColInd,
class LocalMat>
115 void scatter(RowInd
const& rows, ColInd
const& cols, LocalMat
const& mat)
121 (*inserter_)[rows[i]][cols[j]] += mat[i][j];
127 return matrix_.nnz();
141 Inserter* inserter_ =
nullptr;
144 SymmetryStructure symmetry_ = SymmetryStructure::unknown;
BaseMatrix & matrix()
Return a reference to the data-matrix matrix.
Definition: MatrixBackend.hpp:46
void init()
Definition: MatrixBackend.hpp:76
SymmetryStructure symmetry() const
Symmetry of the matrix entries.
Definition: MatrixBackend.hpp:131
std::size_t rowSizeEstimate() const
Estimate of the non-zeros per row.
Definition: SlotSize.hpp:41
void test_exit_dbg(bool condition, Args &&... args)
call assert_msg, in debug mode only
Definition: Output.hpp:205
mtl::compressed2D< T > BaseMatrix
The matrix type of the underlying base matrix.
Definition: MatrixBackend.hpp:25
BaseMatrix const & matrix() const
Return a reference to the data-matrix matrix.
Definition: MatrixBackend.hpp:53
MTLSparseMatrix(Basis const &, Basis const &)
Constructor. Constructs new BaseMatrix.
Definition: MatrixBackend.hpp:43
Contains all classes needed for solving linear and non linear equation systems.
Definition: AdaptBase.hpp:6
std::size_t cols() const
Number of columns in the matrix.
Definition: SlotSize.hpp:35
typename BaseMatrix::size_type size_type
The index/size - type.
Definition: MatrixBackend.hpp:31
std::size_t rows() const
Number of rows in the matrix.
Definition: SlotSize.hpp:29
SymmetryStructure symmetry() const
Symmetry of the matrix entries.
Definition: SlotSize.hpp:47
void init(Pattern const &pattern)
Definition: MatrixBackend.hpp:61
The basic container that stores a base matrix.
Definition: MatrixBackend.hpp:21
std::size_t nnz() const
Return the number of nonzeros in the matrix.
Definition: MatrixBackend.hpp:125
Definition: SlotSize.hpp:15
typename BaseMatrix::value_type value_type
The type of the elements of the DOFMatrix.
Definition: MatrixBackend.hpp:28
void insert(size_type r, size_type c, value_type const &value)
Returns an update-proxy of the inserter, to insert/update a value at position (r, c) in the matrix...
Definition: MatrixBackend.hpp:99
void test_exit(bool condition, std::string const &str, Args &&... args)
test for condition and in case of failure print message and exit
Definition: Output.hpp:163
void finish()
Definition: MatrixBackend.hpp:89