16 #ifndef dealii_full_matrix_h 17 #define dealii_full_matrix_h 40 template <
typename number>
42 template <
typename number>
68 template <
typename number>
76 "The FullMatrix class does not support auto-differentiable numbers.");
170 template <
typename number2>
199 template <
typename number2>
209 template <
typename MatrixType>
218 template <
typename MatrixType>
232 const unsigned int src_r_i = 0,
233 const unsigned int src_r_j = dim - 1,
234 const unsigned int src_c_i = 0,
235 const unsigned int src_c_j = dim - 1,
252 const unsigned int dst_r = 0,
253 const unsigned int dst_c = 0)
const;
267 template <
typename MatrixType,
typename index_type>
270 const std::vector<index_type> &row_index_set,
271 const std::vector<index_type> &column_index_set);
285 template <
typename MatrixType,
typename index_type>
288 const std::vector<index_type> &column_index_set,
289 MatrixType &
matrix)
const;
301 template <
typename number2>
313 template <
typename number2>
315 fill(
const number2 *);
328 template <
typename number2>
331 const std::vector<size_type> &p_rows,
332 const std::vector<size_type> &p_cols);
401 template <
typename number2>
414 template <
typename number2>
417 const Vector<number2> &v)
const;
476 template <
class StreamType>
478 print(StreamType & s,
479 const unsigned int width = 5,
480 const unsigned int precision = 2)
const;
506 const unsigned int precision = 3,
507 const bool scientific =
true,
508 const unsigned int width = 0,
509 const char * zero_string =
" ",
510 const double denominator = 1.,
511 const double threshold = 0.)
const;
571 template <
typename number2>
582 template <
typename number2>
597 template <
typename number2>
617 template <
typename number2>
631 template <
typename number2>
646 template <
typename number2>
670 template <
typename number2,
typename index_type>
674 const index_type *col_indices,
676 const bool elide_zero_values =
true,
677 const bool col_indices_are_sorted =
false);
735 template <
typename number2>
742 template <
typename number2>
752 template <
typename number2>
793 template <
typename number2>
805 template <
typename number2>
813 template <
typename number2>
815 outer_product(
const Vector<number2> &
V,
const Vector<number2> &W);
822 template <
typename number2>
831 template <
typename number2>
857 template <
typename number2>
861 const bool adding =
false)
const;
881 template <
typename number2>
885 const bool adding =
false)
const;
905 template <
typename number2>
909 const bool adding =
false)
const;
930 template <
typename number2>
934 const bool adding =
false)
const;
950 const bool transpose_B =
false,
951 const bool transpose_D =
false,
952 const number scaling = number(1.));
966 template <
typename number2>
968 vmult(Vector<number2> &
w,
969 const Vector<number2> &v,
970 const bool adding =
false)
const;
977 template <
typename number2>
979 vmult_add(Vector<number2> &
w,
const Vector<number2> &v)
const;
994 template <
typename number2>
997 const Vector<number2> &v,
998 const bool adding =
false)
const;
1006 template <
typename number2>
1008 Tvmult_add(Vector<number2> &
w,
const Vector<number2> &v)
const;
1015 template <
typename somenumber>
1018 const Vector<somenumber> &src,
1019 const number omega = 1.)
const;
1027 template <
typename number2,
typename number3>
1030 const Vector<number2> &x,
1031 const Vector<number3> &
b)
const;
1043 template <
typename number2>
1045 forward(Vector<number2> &dst,
const Vector<number2> &src)
const;
1054 template <
typename number2>
1056 backward(Vector<number2> &dst,
const Vector<number2> &src)
const;
1076 <<
"The maximal pivot is " << arg1
1077 <<
", which is below the threshold. The matrix may be singular.");
1085 <<
"Target region not in matrix: size in this direction=" 1086 << arg1 <<
", size of new matrix=" << arg2
1087 <<
", offset=" << arg3);
1092 "You are attempting an operation on two matrices that " 1093 "are the same object, but the operation requires that the " 1094 "two objects are in fact different.");
1109 template <
typename number>
1113 return this->n_rows();
1118 template <
typename number>
1122 return this->n_cols();
1127 template <
typename number>
1142 template <
typename number>
1143 template <
typename number2>
1152 template <
typename number>
1153 template <
typename MatrixType>
1157 this->
reinit(M.m(), M.n());
1162 for (
size_type row = 0; row < M.m(); ++row)
1164 const typename MatrixType::const_iterator end_row = M.end(row);
1165 for (
typename MatrixType::const_iterator entry = M.begin(row);
1168 this->
el(row, entry->column()) = entry->value();
1174 template <
typename number>
1175 template <
typename MatrixType>
1179 this->
reinit(M.n(), M.m());
1184 for (
size_type row = 0; row < M.m(); ++row)
1186 const typename MatrixType::const_iterator end_row = M.end(row);
1187 for (
typename MatrixType::const_iterator entry = M.begin(row);
1190 this->
el(entry->column(), row) = entry->value();
1196 template <
typename number>
1197 template <
typename MatrixType,
typename index_type>
1200 const MatrixType &
matrix,
1201 const std::vector<index_type> &row_index_set,
1202 const std::vector<index_type> &column_index_set)
1207 const size_type n_rows_submatrix = row_index_set.size();
1208 const size_type n_cols_submatrix = column_index_set.size();
1210 for (
size_type sub_row = 0; sub_row < n_rows_submatrix; ++sub_row)
1211 for (
size_type sub_col = 0; sub_col < n_cols_submatrix; ++sub_col)
1212 (*
this)(sub_row, sub_col) =
1213 matrix.el(row_index_set[sub_row], column_index_set[sub_col]);
1218 template <
typename number>
1219 template <
typename MatrixType,
typename index_type>
1222 const std::vector<index_type> &row_index_set,
1223 const std::vector<index_type> &column_index_set,
1224 MatrixType & matrix)
const 1229 const size_type n_rows_submatrix = row_index_set.size();
1230 const size_type n_cols_submatrix = column_index_set.size();
1232 for (
size_type sub_row = 0; sub_row < n_rows_submatrix; ++sub_row)
1233 for (
size_type sub_col = 0; sub_col < n_cols_submatrix; ++sub_col)
1234 matrix.set(row_index_set[sub_row],
1235 column_index_set[sub_col],
1236 (*
this)(sub_row, sub_col));
1240 template <
typename number>
1246 (*this)(i, j) = value;
1251 template <
typename number>
1252 template <
typename number2>
1255 const Vector<number2> &v)
const 1261 template <
typename number>
1262 template <
typename number2>
1265 const Vector<number2> &v)
const 1272 template <
typename number>
1282 template <
typename number>
1292 template <
typename number>
1302 template <
typename number>
1312 template <
typename number>
1324 template <
typename number>
1325 template <
typename number2,
typename index_type>
1329 const index_type *col_indices,
1335 for (
size_type col = 0; col < n_cols; ++col)
1338 this->
operator()(row, col_indices[col]) += values[col];
1343 template <
typename number>
1344 template <
class StreamType>
1347 const unsigned int w,
1348 const unsigned int p)
const 1353 const std::streamsize old_precision = s.precision(p);
1354 const std::streamsize old_width = s.width(w);
1362 s << this->
el(i, j);
1368 s.precision(old_precision);
number determinant() const
void diagadd(const number s)
bool operator==(const FullMatrix< number > &) const
typename Table< 2, CoefficientType >::const_iterator const_iterator
static ::ExceptionBase & ExcEmptyMatrix()
#define AssertDimension(dim1, dim2)
void vmult_add(Vector< number2 > &w, const Vector< number2 > &v) const
typename numbers::NumberTraits< CoefficientType >::real_type real_type
number2 matrix_scalar_product(const Vector< number2 > &u, const Vector< number2 > &v) const
Contents is actually a matrix.
FullMatrix(const size_type n=0)
FullMatrix & operator/=(const number factor)
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 double threshold=0.) const
static ::ExceptionBase & ExcNotRegular(number arg1)
static ::ExceptionBase & ExcScalarAssignmentOnlyForZeroValue()
void cholesky(const FullMatrix< number2 > &A)
void add_row(const size_type i, const number s, const size_type j)
void outer_product(const Vector< number2 > &V, const Vector< number2 > &W)
#define AssertIndexRange(index, range)
void right_invert(const FullMatrix< number2 > &M)
void scatter_matrix_to(const std::vector< index_type > &row_index_set, const std::vector< index_type > &column_index_set, MatrixType &matrix) const
void fill_permutation(const FullMatrix< number2 > &src, const std::vector< size_type > &p_rows, const std::vector< size_type > &p_cols)
void invert(const FullMatrix< number2 > &M)
void left_invert(const FullMatrix< number2 > &M)
void Tadd(const number s, const FullMatrix< number2 > &B)
void Tvmult(Vector< number2 > &w, const Vector< number2 > &v, const bool adding=false) const
void copy_transposed(const MatrixType &)
size_type n_elements() const
void mTmult(FullMatrix< number2 > &C, const FullMatrix< number2 > &B, const bool adding=false) const
real_type l1_norm() const
SymmetricTensor< 2, dim, Number > C(const Tensor< 2, dim, Number > &F)
FullMatrix & operator*=(const number factor)
void vmult(Vector< number2 > &w, const Vector< number2 > &v, const bool adding=false) const
void set(const size_type i, const size_type j, const number value)
void triple_product(const FullMatrix< number > &A, const FullMatrix< number > &B, const FullMatrix< number > &D, const bool transpose_B=false, const bool transpose_D=false, const number scaling=number(1.))
real_type frobenius_norm() const
void backward(Vector< number2 > &dst, const Vector< number2 > &src) const
void swap_row(const size_type i, const size_type j)
#define DeclException1(Exception1, type1, outsequence)
real_type linfty_norm() const
void reinit(const TableIndices< N > &new_size, const bool omit_default_initialization=false)
#define Assert(cond, exc)
#define DeclExceptionMsg(Exception, defaulttext)
#define DeclException0(Exception0)
AlignedVector< number >::reference el(const TableIndices< N > &indices)
void mmult(FullMatrix< number2 > &C, const FullMatrix< number2 > &B, const bool adding=false) const
#define DEAL_II_NAMESPACE_CLOSE
void extract_submatrix_from(const MatrixType &matrix, const std::vector< index_type > &row_index_set, const std::vector< index_type > &column_index_set)
void Tvmult_add(Vector< number2 > &w, const Vector< number2 > &v) const
iterator end(const size_type r)
real_type relative_symmetry_norm2() const
number residual(Vector< number2 > &dst, const Vector< number2 > &x, const Vector< number3 > &b) const
SymmetricTensor< 2, dim, Number > d(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
FullMatrix< number > & operator=(const FullMatrix< number2 > &)
number2 matrix_norm_square(const Vector< number2 > &v) const
SymmetricTensor< 2, dim, Number > b(const Tensor< 2, dim, Number > &F)
void add_col(const size_type i, const number s, const size_type j)
Tensor< 2, dim, Number > w(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
void copy_to(Tensor< 2, dim > &T, const size_type src_r_i=0, const size_type src_r_j=dim - 1, const size_type src_c_i=0, const size_type src_c_j=dim - 1, const unsigned int dst_r=0, const unsigned int dst_c=0) const
std::size_t memory_consumption() const
void forward(Vector< number2 > &dst, const Vector< number2 > &src) const
static ::ExceptionBase & ExcSourceEqualsDestination()
void swap_col(const size_type i, const size_type j)
void copy_from(const MatrixType &)
typename AlignedVector< T >::size_type size_type
#define DEAL_II_NAMESPACE_OPEN
void add(const number a, const FullMatrix< number2 > &A)
static ::ExceptionBase & ExcInvalidDestination(size_type arg1, size_type arg2, size_type arg3)
void TmTmult(FullMatrix< number2 > &C, const FullMatrix< number2 > &B, const bool adding=false) const
void precondition_Jacobi(Vector< somenumber > &dst, const Vector< somenumber > &src, const number omega=1.) const
void Tmmult(FullMatrix< number2 > &C, const FullMatrix< number2 > &B, const bool adding=false) const
void print(StreamType &s, const unsigned int width=5, const unsigned int precision=2) const
#define DeclException3(Exception3, type1, type2, type3, outsequence)
static ::ExceptionBase & ExcMatrixNotPositiveDefinite()
iterator begin(const size_type r)
AlignedVector< number >::reference operator()(const TableIndices< N > &indices)
AlignedVector< number > values
void equ(const number a, const FullMatrix< number2 > &A)
void fill(const FullMatrix< number2 > &src, const size_type dst_offset_i=0, const size_type dst_offset_j=0, const size_type src_offset_i=0, const size_type src_offset_j=0)
void fill(InputIterator entries, const bool C_style_indexing=true)
typename Table< 2, CoefficientType >::iterator iterator