 |
Reference documentation for deal.II version 9.2.0
|
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\)
\(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\)
\(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\)
\(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Go to the documentation of this file.
16 #ifndef dealii_sparse_matrix_ez_h
17 # define dealii_sparse_matrix_ez_h
33 template <
typename number>
35 template <
typename number>
106 template <
typename number>
174 static_cast<unsigned short>(-1);
196 const unsigned short index);
248 const unsigned short index);
324 const unsigned int default_increment = 1);
359 unsigned int default_increment = 1,
418 template <
class StreamType>
435 std::vector<size_type> &used_by_line,
436 const bool compute_by_line)
const;
462 const bool elide_zero_values =
true);
486 template <
typename number2>
488 add(
const std::vector<size_type> &indices,
490 const bool elide_zero_values =
true);
497 template <
typename number2>
499 add(
const std::vector<size_type> &row_indices,
500 const std::vector<size_type> &col_indices,
502 const bool elide_zero_values =
true);
513 template <
typename number2>
516 const std::vector<size_type> &col_indices,
517 const std::vector<number2> & values,
518 const bool elide_zero_values =
true);
529 template <
typename number2>
534 const number2 * values,
535 const bool elide_zero_values =
true,
536 const bool col_indices_are_sorted =
false);
559 template <
typename MatrixType>
561 copy_from(
const MatrixType &source,
const bool elide_zero_values =
true);
570 template <
typename MatrixType>
605 template <
typename somenumber>
607 vmult(Vector<somenumber> &dst,
const Vector<somenumber> &src)
const;
614 template <
typename somenumber>
616 Tvmult(Vector<somenumber> &dst,
const Vector<somenumber> &src)
const;
622 template <
typename somenumber>
624 vmult_add(Vector<somenumber> &dst,
const Vector<somenumber> &src)
const;
631 template <
typename somenumber>
633 Tvmult_add(Vector<somenumber> &dst,
const Vector<somenumber> &src)
const;
654 template <
typename somenumber>
657 const Vector<somenumber> &src,
658 const number omega = 1.)
const;
663 template <
typename somenumber>
666 const Vector<somenumber> & src,
667 const number om = 1.,
668 const std::vector<std::size_t> &pos_right_of_diagonal =
669 std::vector<std::size_t>())
const;
675 template <
typename somenumber>
678 const Vector<somenumber> &src,
679 const number om = 1.)
const;
685 template <
typename somenumber>
688 const Vector<somenumber> &src,
689 const number om = 1.)
const;
699 template <
typename MatrixTypeA,
typename MatrixTypeB>
702 const MatrixTypeB &B,
768 const unsigned int precision = 3,
769 const bool scientific =
true,
770 const unsigned int width = 0,
771 const char * zero_string =
" ",
772 const double denominator = 1.)
const;
812 <<
"The entry with index (" << arg1 <<
',' << arg2
813 <<
") does not exist.");
818 <<
"An entry with index (" << arg1 <<
',' << arg2
819 <<
") cannot be allocated.");
847 template <
typename somenumber>
850 const Vector<somenumber> &src,
859 template <
typename somenumber>
864 somenumber * partial_sum)
const;
871 template <
typename somenumber>
874 const Vector<somenumber> &v,
877 somenumber * partial_sum)
const;
910 template <
typename number>
912 const number &
value)
919 template <
typename number>
926 template <
typename number>
935 template <
typename number>
939 const unsigned short i)
946 template <
typename number>
954 template <
typename number>
958 return matrix->data[
matrix->row_info[a_row].start + a_index].column;
962 template <
typename number>
963 inline unsigned short
971 template <
typename number>
975 return matrix->data[
matrix->row_info[a_row].start + a_index].value;
979 template <
typename number>
983 const unsigned short i)
1013 template <
typename number>
1020 ++(accessor.a_index);
1024 if (accessor.a_index >= accessor.matrix->row_info[accessor.a_row].length)
1026 accessor.a_index = 0;
1033 while (accessor.a_row < accessor.matrix->m() &&
1034 accessor.matrix->row_info[accessor.a_row].length == 0);
1040 template <
typename number>
1048 template <
typename number>
1056 template <
typename number>
1066 template <
typename number>
1071 return !(*
this == other);
1075 template <
typename number>
1087 template <
typename number>
1095 template <
typename number>
1103 template <
typename number>
1115 if (entry->
column == col)
1125 template <
typename number>
1130 return t->
locate(row, col);
1134 template <
typename number>
1151 while (i <
end &&
data[i].column < col)
1155 if (i !=
end &&
data[i].column == col)
1194 Entry temp = *entry;
1232 template <
typename number>
1237 const bool elide_zero_values)
1244 if (elide_zero_values &&
value == 0.)
1247 if (entry !=
nullptr)
1259 template <
typename number>
1271 if (std::abs(
value) == 0.)
1279 template <
typename number>
1280 template <
typename number2>
1284 const bool elide_zero_values)
1287 for (
size_type i = 0; i < indices.size(); ++i)
1288 for (
size_type j = 0; j < indices.size(); ++j)
1289 if ((full_matrix(i, j) != 0) || (elide_zero_values ==
false))
1290 add(indices[i], indices[j], full_matrix(i, j));
1295 template <
typename number>
1296 template <
typename number2>
1299 const std::vector<size_type> &col_indices,
1301 const bool elide_zero_values)
1304 for (
size_type i = 0; i < row_indices.size(); ++i)
1305 for (
size_type j = 0; j < col_indices.size(); ++j)
1306 if ((full_matrix(i, j) != 0) || (elide_zero_values ==
false))
1307 add(row_indices[i], col_indices[j], full_matrix(i, j));
1312 template <
typename number>
1313 template <
typename number2>
1316 const std::vector<size_type> &col_indices,
1317 const std::vector<number2> & values,
1318 const bool elide_zero_values)
1321 for (
size_type j = 0; j < col_indices.size(); ++j)
1322 if ((values[j] != 0) || (elide_zero_values ==
false))
1323 add(row, col_indices[j], values[j]);
1328 template <
typename number>
1329 template <
typename number2>
1334 const number2 * values,
1335 const bool elide_zero_values,
1340 if ((std::abs(values[j]) != 0) || (elide_zero_values ==
false))
1341 add(row, col_indices[j], values[j]);
1346 template <
typename number>
1352 return entry->
value;
1358 template <
typename number>
1364 return entry->
value;
1370 template <
typename number>
1378 template <
typename number>
1385 template <
typename number>
1394 template <
typename number>
1403 template <
typename number>
1404 template <
typename MatrixType>
1407 const bool elide_zero_values)
1409 reinit(M.m(), M.n(), this->saved_default_row_length, this->increment);
1414 for (
size_type row = 0; row < M.m(); ++row)
1416 const typename MatrixType::const_iterator end_row = M.end(row);
1417 for (
typename MatrixType::const_iterator entry = M.begin(row);
1420 set(row, entry->column(), entry->value(), elide_zero_values);
1426 template <
typename number>
1427 template <
typename MatrixType>
1440 for (
size_type row = 0; row < M.m(); ++row)
1442 const typename MatrixType::const_iterator end_row = M.end(row);
1443 for (
typename MatrixType::const_iterator entry = M.begin(row);
1446 if (entry->value() != 0)
1447 add(row, entry->column(), factor * entry->value());
1453 template <
typename number>
1454 template <
typename MatrixTypeA,
typename MatrixTypeB>
1457 const MatrixTypeB &B,
1476 typename MatrixTypeB::const_iterator b1 = B.begin();
1477 const typename MatrixTypeB::const_iterator b_final = B.end();
1479 while (b1 != b_final)
1483 typename MatrixTypeB::const_iterator b2 = B.begin();
1484 while (b2 != b_final)
1489 const typename MatrixTypeA::value_type a =
A.el(k,
l);
1492 add(i, j, a * b1->value() * b2->value());
1503 std::vector<size_type> minrow(B.n(), B.m());
1504 std::vector<size_type> maxrow(B.n(), 0);
1505 while (b1 != b_final)
1508 if (r < minrow[b1->column()])
1509 minrow[b1->column()] = r;
1510 if (r > maxrow[b1->column()])
1511 maxrow[b1->column()] = r;
1515 typename MatrixTypeA::const_iterator ai =
A.begin();
1516 const typename MatrixTypeA::const_iterator ae =
A.end();
1520 const typename MatrixTypeA::value_type a = ai->value();
1530 b1 = B.begin(minrow[ai->row()]);
1531 const typename MatrixTypeB::const_iterator be1 =
1532 B.end(maxrow[ai->row()]);
1533 const typename MatrixTypeB::const_iterator be2 =
1534 B.end(maxrow[ai->column()]);
1538 const double b1v = b1->value();
1543 if (b1->column() == ai->row() && (b1v != 0.))
1547 typename MatrixTypeB::const_iterator b2 =
1548 B.begin(minrow[ai->column()]);
1551 if (b2->column() == ai->column())
1554 add(i, j, a * b1v * b2->value());
1567 template <
typename number>
1568 template <
class StreamType>
1575 std::vector<size_type> used_by_line;
1579 out <<
"SparseMatrixEZ:used entries:" << used << std::endl
1580 <<
"SparseMatrixEZ:allocated entries:" << allocated << std::endl
1581 <<
"SparseMatrixEZ:reserved entries:" << reserved << std::endl;
1585 for (
size_type i = 0; i < used_by_line.size(); ++i)
1586 if (used_by_line[i] != 0)
1587 out <<
"SparseMatrixEZ:entries\t" << i <<
"\trows\t"
1588 << used_by_line[i] << std::endl;
size_type n_nonzero_elements() const
@ diagonal
Matrix is diagonal.
static const unsigned short invalid_diagonal
SparseMatrixEZ< number > & operator=(const double d)
Accessor(const SparseMatrixEZ< number > *matrix, const size_type row, const unsigned short index)
Entry * locate(const size_type row, const size_type col)
const SparseMatrixEZ< number > * matrix
void vmult_add(Vector< somenumber > &dst, const Vector< somenumber > &src) const
void set(const size_type i, const size_type j, const number value, const bool elide_zero_values=true)
void Tvmult_add(Vector< somenumber > &dst, const Vector< somenumber > &src) 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
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 block_write(std::ostream &out) const
void add(const size_type i, const size_type j, const number value)
void threaded_vmult(Vector< somenumber > &dst, const Vector< somenumber > &src, const size_type begin_row, const size_type end_row) const
bool operator==(const const_iterator &) const
void block_read(std::istream &in)
unsigned int saved_default_row_length
void add(const std::vector< size_type > &row_indices, const std::vector< size_type > &col_indices, const FullMatrix< number2 > &full_matrix, const bool elide_zero_values=true)
SparseMatrixEZ< number > & copy_from(const MatrixType &source, const bool elide_zero_values=true)
#define AssertIndexRange(index, range)
const Accessor & operator*() const
const_iterator & operator++()
static ::ExceptionBase & ExcInvalidEntry(int arg1, int arg2)
SymmetricTensor< 2, dim, Number > d(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
number operator()(const size_type i, const size_type j) 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 &)
void add(const number factor, const MatrixType &matrix)
RowInfo(const size_type start=Entry::invalid)
void print(std::ostream &out) const
bool operator<(const const_iterator &) const
#define AssertIsFinite(number)
const Entry * locate(const size_type row, const size_type col) const
void vmult(Vector< somenumber > &dst, const Vector< somenumber > &src) const
void add(const size_type row, const std::vector< size_type > &col_indices, const std::vector< number2 > &values, const bool elide_zero_values=true)
unsigned int global_dof_index
#define DEAL_II_NAMESPACE_OPEN
const_iterator end(const size_type r) const
Tensor< 2, dim, Number > l(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
@ matrix
Contents is actually a matrix.
void precondition_SOR(Vector< somenumber > &dst, const Vector< somenumber > &src, const number om=1.) const
unsigned short index() const
void swap(MemorySpaceData< Number, MemorySpace > &, MemorySpaceData< Number, MemorySpace > &)
SparseMatrixEZ< number > & operator=(const SparseMatrixEZ< number > &)
std::size_t memory_consumption() const
SparseMatrixEZ(const size_type n_rows, const size_type n_columns, const size_type default_row_length=0, const unsigned int default_increment=1)
std::vector< Entry > data
void conjugate_add(const MatrixTypeA &A, const MatrixTypeB &B, const bool transpose=false)
static ::ExceptionBase & ExcNoDiagonal()
void add(const std::vector< size_type > &indices, const FullMatrix< number2 > &full_matrix, const bool elide_zero_values=true)
const Accessor * operator->() const
void add(const size_type row, const size_type n_cols, const size_type *col_indices, const number2 *values, const bool elide_zero_values=true, const bool col_indices_are_sorted=false)
size_type get_row_length(const size_type row) const
static const size_type invalid
static ::ExceptionBase & ExcInternalError()
#define Assert(cond, exc)
bool operator!=(const const_iterator &) const
static ::ExceptionBase & ExcEntryAllocationFailure(int arg1, int arg2)
void threaded_matrix_norm_square(const Vector< somenumber > &v, const size_type begin_row, const size_type end_row, somenumber *partial_sum) const
const_iterator(const SparseMatrixEZ< number > *matrix, const size_type row, const unsigned short index)
#define DeclException0(Exception0)
Entry * allocate(const size_type row, const size_type col)
const types::global_dof_index invalid_size_type
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
void precondition_Jacobi(Vector< somenumber > &dst, const Vector< somenumber > &src, const number omega=1.) const
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
~SparseMatrixEZ() override=default
const_iterator begin() const
const_iterator end() const
number el(const size_type i, const size_type j) const
std::vector< RowInfo > row_info
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
#define DEAL_II_NAMESPACE_CLOSE
#define DeclException2(Exception2, type1, type2, outsequence)
const_iterator begin(const size_type r) const
void Tvmult(Vector< somenumber > &dst, const Vector< somenumber > &src) const
void precondition_TSOR(Vector< somenumber > &dst, const Vector< somenumber > &src, const number om=1.) const
static ::ExceptionBase & ExcIteratorPastEnd()
void print_statistics(StreamType &s, bool full=false)