16 #ifndef dealii_lapack_full_matrix_h 17 #define dealii_lapack_full_matrix_h 20 #include <deal.II/base/config.h> 22 #include <deal.II/base/smartpointer.h> 23 #include <deal.II/base/table.h> 24 #include <deal.II/base/thread_management.h> 26 #include <deal.II/lac/lapack_support.h> 27 #include <deal.II/lac/vector_memory.h> 33 DEAL_II_NAMESPACE_OPEN
36 template <
typename number>
38 template <
typename number>
40 template <
typename number>
42 template <
typename number>
58 template <
typename number>
65 using size_type = std::make_unsigned<types::blas_int>::type;
109 template <
typename number2>
119 template <
typename number2>
196 const bool left =
true);
204 template <
typename MatrixType>
306 template <
typename MatrixType>
308 fill(
const MatrixType &src,
313 const number factor = 1.,
344 template <
typename number2>
346 vmult(Vector<number2> & w,
347 const Vector<number2> &v,
348 const bool adding =
false)
const;
356 const bool adding =
false)
const;
364 template <
typename number2>
366 vmult_add(Vector<number2> &w,
const Vector<number2> &v)
const;
385 template <
typename number2>
387 Tvmult(Vector<number2> & w,
388 const Vector<number2> &v,
389 const bool adding =
false)
const;
397 const bool adding =
false)
const;
405 template <
typename number2>
407 Tvmult_add(Vector<number2> &w,
const Vector<number2> &v)
const;
433 const bool adding =
false)
const;
442 const bool adding =
false)
const;
461 const bool adding =
false)
const;
470 const bool adding =
false)
const;
491 const bool adding =
false)
const;
510 const bool adding =
false)
const;
519 const bool adding =
false)
const;
539 const bool adding =
false)
const;
548 const bool adding =
false)
const;
704 const bool transposed)
const;
726 const bool left_eigenvectors =
false);
749 const number upper_bound,
750 const number abs_accuracy,
783 const number lower_bound,
784 const number upper_bound,
785 const number abs_accuracy,
894 const unsigned int precision = 3,
895 const bool scientific =
true,
896 const unsigned int width = 0,
897 const char * zero_string =
" ",
898 const double denominator = 1.,
899 const double threshold = 0.)
const;
906 norm(
const char type)
const;
923 mutable std::vector<number>
work;
928 mutable std::vector<types::blas_int>
iwork;
936 std::vector<types::blas_int>
ipiv;
947 std::vector<typename numbers::NumberTraits<number>::real_type>
wr;
953 std::vector<number>
wi;
958 std::vector<number>
vl;
963 std::vector<number>
vr;
969 std::unique_ptr<LAPACKFullMatrix<number>>
svd_u;
975 std::unique_ptr<LAPACKFullMatrix<number>>
svd_vt;
991 template <
typename number>
1015 template <
typename number>
1021 (*this)(i, j) = value;
1025 template <
typename number>
1029 return static_cast<size_type>(this->n_rows());
1032 template <
typename number>
1036 return static_cast<size_type>(this->n_cols());
1039 template <
typename number>
1040 template <
typename MatrixType>
1044 this->reinit(M.m(), M.n());
1049 for (
size_type row = 0; row < M.m(); ++row)
1051 const typename MatrixType::const_iterator end_row = M.end(row);
1052 for (
typename MatrixType::const_iterator entry = M.begin(row);
1055 this->el(row, entry->column()) = entry->value();
1063 template <
typename number>
1064 template <
typename MatrixType>
1071 const number factor,
1076 for (
size_type row = src_offset_i; row < M.m(); ++row)
1078 const typename MatrixType::const_iterator end_row = M.end(row);
1079 for (
typename MatrixType::const_iterator entry = M.begin(row);
1086 const size_type dst_i = dst_offset_i + i - src_offset_i;
1087 const size_type dst_j = dst_offset_j + j - src_offset_j;
1088 if (dst_i < this->n_rows() && dst_j < this->n_cols())
1089 (*this)(dst_i, dst_j) = factor * entry->value();
1097 template <
typename number>
1098 template <
typename number2>
1101 const Vector<number2> &,
1105 ExcMessage(
"LAPACKFullMatrix<number>::vmult must be called with a " 1106 "matching Vector<double> vector type."));
1110 template <
typename number>
1111 template <
typename number2>
1114 const Vector<number2> &)
const 1117 ExcMessage(
"LAPACKFullMatrix<number>::vmult_add must be called with a " 1118 "matching Vector<double> vector type."));
1122 template <
typename number>
1123 template <
typename number2>
1126 const Vector<number2> &,
1130 ExcMessage(
"LAPACKFullMatrix<number>::Tvmult must be called with a " 1131 "matching Vector<double> vector type."));
1135 template <
typename number>
1136 template <
typename number2>
1139 const Vector<number2> &)
const 1143 "LAPACKFullMatrix<number>::Tvmult_add must be called with a " 1144 "matching Vector<double> vector type."));
1148 template <
typename number>
1149 inline std::complex<number>
1158 return std::complex<number>(wi[i]);
1160 return std::complex<number>(wr[i], wi[i]);
1164 template <
typename number>
1177 DEAL_II_NAMESPACE_CLOSE
LAPACKFullMatrix(const size_type size=0)
std::vector< number > work
void rank1_update(const number a, const Vector< number > &v)
void TmTmult(LAPACKFullMatrix< number > &C, const LAPACKFullMatrix< number > &B, const bool adding=false) const
std::unique_ptr< LAPACKFullMatrix< number > > svd_vt
LAPACKFullMatrix< number > & operator/=(const number factor)
Contents is actually a matrix.
std::array< std::pair< Number, Tensor< 1, dim, Number > >, std::integral_constant< int, dim >::value > eigenvectors(const SymmetricTensor< 2, dim, Number > &T, const SymmetricTensorEigenvectorMethod method=SymmetricTensorEigenvectorMethod::ql_implicit_shifts)
void Tvmult(Vector< number2 > &w, const Vector< number2 > &v, const bool adding=false) const
std::array< Number, 1 > eigenvalues(const SymmetricTensor< 2, 1, Number > &T)
LAPACKSupport::State state
typename TableBase< 2, T >::size_type size_type
void remove_row_and_column(const size_type row, const size_type col)
std::vector< types::blas_int > ipiv
const TableIndices< N > & size() const
std::complex< number > eigenvalue(const size_type i) const
#define AssertIndexRange(index, range)
void apply_givens_rotation(const std::array< number, 3 > &csr, const size_type i, const size_type k, const bool left=true)
void compute_eigenvalues_symmetric(const number lower_bound, const number upper_bound, const number abs_accuracy, Vector< number > &eigenvalues, FullMatrix< number > &eigenvectors)
void reinit(const size_type size)
number norm(const char type) const
void Tmmult(LAPACKFullMatrix< number > &C, const LAPACKFullMatrix< number > &B, const bool adding=false) const
LinearAlgebra::distributed::Vector< Number > Vector
std::vector< types::blas_int > iwork
static ::ExceptionBase & ExcState(State arg1)
void set(const size_type i, const size_type j, const number value)
static ::ExceptionBase & ExcInvalidState()
static ::ExceptionBase & ExcMessage(std::string arg1)
void mTmult(LAPACKFullMatrix< number > &C, const LAPACKFullMatrix< number > &B, const bool adding=false) const
#define Assert(cond, exc)
void compute_inverse_svd_with_kernel(const unsigned int kernel_size)
void copy_from(const MatrixType &)
std::make_unsigned< types::blas_int >::type size_type
void add(const number a, const LAPACKFullMatrix< number > &B)
std::vector< number > inv_work
void transpose(LAPACKFullMatrix< number > &B) const
Matrix is the inverse of a singular value decomposition.
void compute_lu_factorization()
void vmult(Vector< number2 > &w, const Vector< number2 > &v, const bool adding=false) const
std::unique_ptr< LAPACKFullMatrix< number > > svd_u
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
void grow_or_shrink(const size_type size)
void scale_rows(const Vector< number > &V)
number singular_value(const size_type i) const
LAPACKFullMatrix< number > & operator*=(const number factor)
void compute_inverse_svd(const double threshold=0.)
void compute_cholesky_factorization()
number linfty_norm() const
LAPACKFullMatrix< number > & operator=(const LAPACKFullMatrix< number > &)
void fill(const MatrixType &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, const number factor=1., const bool transpose=false)
number determinant() const
number frobenius_norm() const
void Tvmult_add(Vector< number2 > &w, const Vector< number2 > &v) const
std::vector< typename numbers::NumberTraits< number >::real_type > wr
Matrix contains singular value decomposition,.
void set_property(const LAPACKSupport::Property property)
void solve(Vector< number > &v, const bool transposed=false) const
void compute_generalized_eigenvalues_symmetric(LAPACKFullMatrix< number > &B, const number lower_bound, const number upper_bound, const number abs_accuracy, Vector< number > &eigenvalues, std::vector< Vector< number >> &eigenvectors, const types::blas_int itype=1)
void compute_eigenvalues(const bool right_eigenvectors=false, const bool left_eigenvectors=false)
void apply_lu_factorization(Vector< number > &v, const bool transposed) const
number reciprocal_condition_number() const
Eigenvalue vector is filled.
LAPACKSupport::Property property
void vmult_add(Vector< number2 > &w, const Vector< number2 > &v) const
void mmult(LAPACKFullMatrix< number > &C, const LAPACKFullMatrix< number > &B, const bool adding=false) const
static ::ExceptionBase & ExcInternalError()