15#ifndef dealii_sparse_matrix_ez_h
16#define dealii_sparse_matrix_ez_h
35template <
typename number>
37template <
typename number>
105template <
typename number>
173 static_cast<unsigned short>(-1);
195 const unsigned short index);
247 const unsigned short index);
419 template <
typename StreamType>
493 template <
typename number2>
495 add(
const std::vector<size_type> &indices,
504 template <
typename number2>
506 add(
const std::vector<size_type> &row_indices,
520 template <
typename number2>
524 const std::vector<number2> &values,
536 template <
typename number2>
566 template <
typename MatrixType>
577 template <
typename MatrixType>
579 add(
const number factor,
const MatrixType &matrix);
612 template <
typename somenumber>
621 template <
typename somenumber>
629 template <
typename somenumber>
638 template <
typename somenumber>
661 template <
typename somenumber>
665 const number omega = 1.)
const;
670 template <
typename somenumber>
674 const number
om = 1.,
676 std::vector<std::size_t>())
const;
682 template <
typename somenumber>
686 const number
om = 1.)
const;
692 template <
typename somenumber>
696 const number
om = 1.)
const;
706 template <
typename MatrixTypeA,
typename MatrixTypeB>
777 const unsigned int precision = 3,
778 const bool scientific =
true,
779 const unsigned int width = 0,
782 const char *separator =
" ")
const;
822 <<
"The entry with index (" <<
arg1 <<
',' <<
arg2
823 <<
") does not exist.");
828 <<
"An entry with index (" <<
arg1 <<
',' <<
arg2
829 <<
") cannot be allocated.");
857 template <
typename somenumber>
869 template <
typename somenumber>
881 template <
typename somenumber>
920template <
typename number>
929template <
typename number>
936template <
typename number>
940 , diagonal(invalid_diagonal)
945template <
typename number>
949 const unsigned short i)
956template <
typename number>
964template <
typename number>
968 return matrix->data[matrix->row_info[a_row].start + a_index].column;
972template <
typename number>
981template <
typename number>
985 return matrix->data[matrix->row_info[a_row].start + a_index].value;
989template <
typename number>
993 const unsigned short i)
1023template <
typename number>
1030 ++(accessor.a_index);
1034 if (accessor.a_index >= accessor.matrix->row_info[accessor.a_row].length)
1036 accessor.a_index = 0;
1043 while (accessor.a_row < accessor.matrix->m() &&
1044 accessor.matrix->row_info[accessor.a_row].length == 0);
1050template <
typename number>
1058template <
typename number>
1066template <
typename number>
1071 return (accessor.row() ==
other.accessor.row() &&
1072 accessor.index() ==
other.accessor.index());
1076template <
typename number>
1081 return !(*
this ==
other);
1085template <
typename number>
1090 return (accessor.row() <
other.accessor.row() ||
1091 (accessor.row() ==
other.accessor.row() &&
1092 accessor.index() <
other.accessor.index()));
1097template <
typename number>
1105template <
typename number>
1113template <
typename number>
1125 if (entry->
column == col)
1135template <
typename number>
1140 return t->locate(row, col);
1144template <
typename number>
1161 while (i <
end &&
data[i].column < col)
1165 if (i !=
end &&
data[i].column == col)
1214 r.diagonal = i -
r.start;
1242template <
typename number>
1257 if (entry !=
nullptr)
1263 entry->
value = value;
1269template <
typename number>
1285 entry->
value += value;
1289template <
typename number>
1290template <
typename number2>
1297 for (
size_type i = 0; i < indices.size(); ++i)
1305template <
typename number>
1306template <
typename number2>
1314 for (
size_type i = 0; i < row_indices.size(); ++i)
1322template <
typename number>
1323template <
typename number2>
1327 const std::vector<number2> &values,
1338template <
typename number>
1339template <
typename number2>
1356template <
typename number>
1362 return entry->
value;
1368template <
typename number>
1374 return entry->
value;
1380template <
typename number>
1388template <
typename number>
1395template <
typename number>
1404template <
typename number>
1413template <
typename number>
1414template <
typename MatrixType>
1426 const typename MatrixType::const_iterator
end_row =
M.end(row);
1427 for (
typename MatrixType::const_iterator entry =
M.begin(row);
1436template <
typename number>
1437template <
typename MatrixType>
1452 const typename MatrixType::const_iterator
end_row =
M.end(row);
1453 for (
typename MatrixType::const_iterator entry =
M.begin(row);
1456 if (entry->value() != 0)
1457 add(row, entry->column(), factor * entry->value());
1463template <
typename number>
1464template <
typename MatrixTypeA,
typename MatrixTypeB>
1486 typename MatrixTypeB::const_iterator b1 =
B.begin();
1487 const typename MatrixTypeB::const_iterator
b_final =
B.end();
1493 typename MatrixTypeB::const_iterator b2 =
B.begin();
1502 add(i,
j, a * b1->value() * b2->value());
1513 std::vector<size_type>
minrow(
B.n(),
B.m());
1514 std::vector<size_type>
maxrow(
B.n(), 0);
1525 typename MatrixTypeA::const_iterator
ai = A.begin();
1526 const typename MatrixTypeA::const_iterator
ae = A.end();
1541 const typename MatrixTypeB::const_iterator
be1 =
1543 const typename MatrixTypeB::const_iterator
be2 =
1548 const double b1v = b1->value();
1553 if (b1->column() ==
ai->row() && (
b1v != 0.))
1557 typename MatrixTypeB::const_iterator b2 =
1561 if (b2->column() ==
ai->column())
1564 add(i,
j, a *
b1v * b2->value());
1577template <
typename number>
1578template <
typename StreamType>
1589 out <<
"SparseMatrixEZ:used entries:" << used << std::endl
1590 <<
"SparseMatrixEZ:allocated entries:" <<
allocated << std::endl
1591 <<
"SparseMatrixEZ:reserved entries:" <<
reserved << std::endl;
1597 out <<
"SparseMatrixEZ:entries\t" << i <<
"\trows\t"
unsigned short index() const
const SparseMatrixEZ< number > * matrix
Accessor(const SparseMatrixEZ< number > *matrix, const size_type row, const unsigned short index)
const Accessor & operator*() const
const_iterator(const SparseMatrixEZ< number > *matrix, const size_type row, const unsigned short index)
bool operator<(const const_iterator &) const
bool operator==(const const_iterator &) const
bool operator!=(const const_iterator &) const
const_iterator & operator++()
const Accessor * operator->() const
void print_formatted(std::ostream &out, const unsigned int precision=3, const bool scientific=true, const unsigned int width=0, const char *zero_string=" ", const double denominator=1., const char *separator=" ") const
void block_read(std::istream &in)
SparseMatrixEZ< number > & copy_from(const MatrixType &source, const bool elide_zero_values=true)
std::vector< Entry > data
void reinit(const size_type n_rows, const size_type n_columns, size_type default_row_length=0, unsigned int default_increment=1, size_type reserve=0)
void print_statistics(StreamType &s, bool full=false)
void Tvmult_add(Vector< somenumber > &dst, const Vector< somenumber > &src) const
void block_write(std::ostream &out) const
void compute_statistics(size_type &used, size_type &allocated, size_type &reserved, std::vector< size_type > &used_by_line, const bool compute_by_line) const
SparseMatrixEZ(const SparseMatrixEZ &)
number operator()(const size_type i, const size_type j) const
const Entry * locate(const size_type row, const size_type col) const
~SparseMatrixEZ() override=default
Entry * allocate(const size_type row, const size_type col)
void threaded_matrix_scalar_product(const Vector< somenumber > &u, const Vector< somenumber > &v, const size_type begin_row, const size_type end_row, somenumber *partial_sum) const
size_type get_row_length(const size_type row) const
void precondition_TSOR(Vector< somenumber > &dst, const Vector< somenumber > &src, const number om=1.) const
std::size_t memory_consumption() const
size_type n_nonzero_elements() const
void print(std::ostream &out) const
SparseMatrixEZ< number > & operator=(const SparseMatrixEZ< number > &)
SparseMatrixEZ(const size_type n_rows, const size_type n_columns, const size_type default_row_length=0, const unsigned int default_increment=1)
void conjugate_add(const MatrixTypeA &A, const MatrixTypeB &B, const bool transpose=false)
void Tvmult(Vector< somenumber > &dst, const Vector< somenumber > &src) const
SparseMatrixEZ< number > & operator=(const double d)
void threaded_vmult(Vector< somenumber > &dst, const Vector< somenumber > &src, const size_type begin_row, const size_type end_row) const
void vmult_add(Vector< somenumber > &dst, const Vector< somenumber > &src) const
void precondition_Jacobi(Vector< somenumber > &dst, const Vector< somenumber > &src, const number omega=1.) const
const_iterator end() const
void precondition_SSOR(Vector< somenumber > &dst, const Vector< somenumber > &src, const number om=1., const std::vector< std::size_t > &pos_right_of_diagonal=std::vector< std::size_t >()) const
std::vector< RowInfo > row_info
number el(const size_type i, const size_type j) const
const_iterator begin() const
void threaded_matrix_norm_square(const Vector< somenumber > &v, const size_type begin_row, const size_type end_row, somenumber *partial_sum) const
unsigned int saved_default_row_length
void set(const size_type i, const size_type j, const number value, const bool elide_zero_values=true)
void add(const size_type i, const size_type j, const number value)
void precondition_SOR(Vector< somenumber > &dst, const Vector< somenumber > &src, const number om=1.) const
void vmult(Vector< somenumber > &dst, const Vector< somenumber > &src) const
std::conditional_t< rank_==1, Number, Tensor< rank_ - 1, dim, Number > > value_type
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
#define DeclException0(Exception0)
static ::ExceptionBase & ExcInvalidEntry(int arg1, int arg2)
static ::ExceptionBase & ExcNoDiagonal()
#define Assert(cond, exc)
static ::ExceptionBase & ExcIteratorPastEnd()
#define AssertIsFinite(number)
#define DeclException2(Exception2, type1, type2, outsequence)
static ::ExceptionBase & ExcEntryAllocationFailure(int arg1, int arg2)
#define AssertIndexRange(index, range)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
constexpr types::global_dof_index invalid_size_type
::VectorizedArray< Number, width > abs(const ::VectorizedArray< Number, width > &)
unsigned int global_dof_index
static const size_type invalid
static const unsigned short invalid_diagonal
RowInfo(const size_type start=Entry::invalid)