31template <
typename SPARSITY_PATTERN>
32struct SetMatrixSparsity<LisMatrix, SPARSITY_PATTERN>;
110 void write(
const std::string& filename)
const;
117 template <
class T_DENSE_MATRIX>
118 void add(std::vector<IndexType>
const& row_pos,
119 const T_DENSE_MATRIX& sub_matrix,
122 this->
add(row_pos, row_pos, sub_matrix, fkt);
126 template <
class T_DENSE_MATRIX>
128 const T_DENSE_MATRIX& sub_matrix,
134 template <
class T_DENSE_MATRIX>
135 void add(std::vector<IndexType>
const& row_pos,
136 std::vector<IndexType>
const& col_pos,
137 const T_DENSE_MATRIX& sub_matrix,
double fkt = 1.0);
160 template <
typename MATRIX,
typename SPARSITY_PATTERN>
164template <
class T_DENSE_MATRIX>
166 std::vector<IndexType>
const& col_pos,
167 const T_DENSE_MATRIX& sub_matrix,
double fkt)
169 auto const n_rows = row_pos.size();
170 auto const n_cols = col_pos.size();
171 for (
auto i =
decltype(n_rows){0}; i < n_rows; i++)
173 auto const row = row_pos[i];
174 for (
auto j =
decltype(n_cols){0}; j < n_cols; j++)
176 auto const col = col_pos[j];
177 add(row, col, fkt * sub_matrix(i, j));
186template <
typename SPARSITY_PATTERN>
190 SPARSITY_PATTERN
const& sparsity_pattern)
const
193 std::vector<LisMatrix::IndexType> row_sizes;
194 row_sizes.reserve(n_rows);
197 transform(cbegin(sparsity_pattern), cend(sparsity_pattern),
198 back_inserter(row_sizes), [](
auto const i) {
return i + 1; });
200 int ierr = lis_matrix_malloc(matrix.
AA_, 0, row_sizes.data());
LisMatrix is a wrapper class for matrix types of the linear iterative solvers library.
IndexType ie_
location where the partial matrix AA_ ends in global matrix.
LisMatrix(std::size_t n_rows, MatrixType mat_type=MatrixType::CRS)
std::size_t getRangeBegin() const
return a start index of the active data range
std::size_t const n_rows_
std::size_t getNumberOfColumns() const
return the number of columns
MatrixType const mat_type_
std::size_t getNumberOfRows() const
return the number of rows
int setValue(IndexType rowId, IndexType colId, double v)
set entry
std::size_t getRangeEnd() const
return an end index of the active data range
int add(IndexType rowId, IndexType colId, double v)
add value
void add(std::vector< IndexType > const &row_pos, const T_DENSE_MATRIX &sub_matrix, double fkt=1.0)
void setZero()
reset this matrix with keeping its original dimension
MatrixType getMatrixType() const
get this matrix type
bool use_external_arrays_
friend bool finalizeMatrixAssembly(LisMatrix &mat)
finish assembly to make this matrix be ready for use
void write(const std::string &filename) const
printout this equation for debugging
LIS_MATRIX & getRawMatrix()
return a raw Lis matrix object
void add(RowColumnIndices< IndexType > const &indices, const T_DENSE_MATRIX &sub_matrix, double fkt=1.0)
Add sub-matrix at positions given by indices.
bool isAssembled() const
return if this matrix is already assembled or not
bool checkLisError(int err)
bool finalizeMatrixAssembly(MAT_T &)
LineIndex const & columns
void operator()(LisMatrix &matrix, SPARSITY_PATTERN const &sparsity_pattern) const