16 #ifndef dealii_lapack_full_matrix_h 17 #define dealii_lapack_full_matrix_h 20 #include <deal.II/base/config.h> 21 #include <deal.II/base/smartpointer.h> 22 #include <deal.II/base/table.h> 23 #include <deal.II/lac/lapack_support.h> 24 #include <deal.II/lac/vector_memory.h> 25 #include <deal.II/base/thread_management.h> 31 DEAL_II_NAMESPACE_OPEN
34 template <
typename number>
class Vector;
52 template <
typename number>
60 typedef std::make_unsigned<types::blas_int>::type
size_type;
104 template <
typename number2>
114 template <
typename number2>
154 void add (
const number a,
178 template <
typename MatrixType>
276 template <
typename MatrixType>
277 void fill (
const MatrixType &src,
282 const number factor = 1.,
313 template <
typename number2>
314 void vmult (Vector<number2> &w,
315 const Vector<number2> &v,
316 const bool adding =
false)
const;
323 const bool adding =
false)
const;
330 template <
typename number2>
332 const Vector<number2> &v)
const;
351 template <
typename number2>
352 void Tvmult (Vector<number2> &w,
353 const Vector<number2> &v,
354 const bool adding=
false)
const;
361 const bool adding=
false)
const;
368 template <
typename number2>
370 const Vector<number2> &v)
const;
395 const bool adding=
false)
const;
403 const bool adding=
false)
const;
421 const bool adding=
false)
const;
429 const bool adding=
false)
const;
448 const bool adding=
false)
const;
466 const bool adding=
false)
const;
474 const bool adding=
false)
const;
493 const bool adding=
false)
const;
501 const bool adding=
false)
const;
575 number
trace()
const;
592 const bool transposed =
false)
const;
599 const bool transposed =
false)
const;
613 const bool transposed)
const;
628 const bool transposed)
const;
649 const bool left_eigenvectors =
false);
669 const number upper_bound,
670 const number abs_accuracy,
699 const number lower_bound,
700 const number upper_bound,
701 const number abs_accuracy,
802 const unsigned int precision = 3,
803 const bool scientific =
true,
804 const unsigned int width = 0,
805 const char *zero_string =
" ",
806 const double denominator = 1.,
807 const double threshold = 0.)
const;
813 number
norm(
const char type)
const;
830 mutable std::vector<number>
work;
835 mutable std::vector<types::blas_int>
iwork;
843 std::vector<types::blas_int>
ipiv;
854 std::vector<number>
wr;
859 std::vector<number>
wi;
864 std::vector<number>
vl;
869 std::vector<number>
vr;
875 std::unique_ptr<LAPACKFullMatrix<number> >
svd_u;
881 std::unique_ptr<LAPACKFullMatrix<number> >
svd_vt;
897 template <
typename number>
919 template <
typename number>
925 (*this)(i,j) = value;
929 template <
typename number>
934 return static_cast<size_type>(this->n_rows ());
937 template <
typename number>
942 return static_cast<size_type>(this->n_cols ());
945 template <
typename number>
946 template <
typename MatrixType>
950 this->reinit (M.m(), M.n());
955 for (
size_type row = 0; row < M.m(); ++row)
957 const typename MatrixType::const_iterator end_row = M.end(row);
958 for (
typename MatrixType::const_iterator entry = M.begin(row);
959 entry != end_row; ++entry)
960 this->el(row, entry->column()) = entry->value();
968 template <
typename number>
969 template <
typename MatrixType>
981 for (
size_type row = src_offset_i; row < M.m(); ++row)
983 const typename MatrixType::const_iterator end_row = M.end(row);
984 for (
typename MatrixType::const_iterator entry = M.begin(row);
985 entry != end_row; ++entry)
990 const size_type dst_i=dst_offset_i+i-src_offset_i;
991 const size_type dst_j=dst_offset_j+j-src_offset_j;
992 if (dst_i<this->n_rows() && dst_j<this->n_cols())
993 (*this)(dst_i, dst_j) = factor * entry->value();
1001 template <
typename number>
1002 template <
typename number2>
1005 const Vector<number2> &,
1009 ExcMessage(
"LAPACKFullMatrix<number>::vmult must be called with a " 1010 "matching Vector<double> vector type."));
1014 template <
typename number>
1015 template <
typename number2>
1018 const Vector<number2> &)
const 1021 ExcMessage(
"LAPACKFullMatrix<number>::vmult_add must be called with a " 1022 "matching Vector<double> vector type."));
1026 template <
typename number>
1027 template <
typename number2>
1030 const Vector<number2> &,
1034 ExcMessage(
"LAPACKFullMatrix<number>::Tvmult must be called with a " 1035 "matching Vector<double> vector type."));
1039 template <
typename number>
1040 template <
typename number2>
1043 const Vector<number2> &)
const 1046 ExcMessage(
"LAPACKFullMatrix<number>::Tvmult_add must be called with a " 1047 "matching Vector<double> vector type."));
1051 template <
typename number>
1052 inline std::complex<number>
1060 return std::complex<number>(wr[i], wi[i]);
1064 template <
typename number>
1076 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
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 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_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
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
TableBase< 2, T >::size_type size_type
#define Assert(cond, exc)
void compute_inverse_svd_with_kernel(const unsigned int kernel_size)
void copy_from(const MatrixType &)
void add(const number a, const LAPACKFullMatrix< number > &B)
std::vector< number > inv_work
Matrix is the inverse of a singular value decomposition.
void compute_lu_factorization()
SymmetricTensor< rank_, dim, Number > transpose(const SymmetricTensor< rank_, dim, Number > &t)
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()
std::make_unsigned< types::blas_int >::type size_type
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
Matrix contains singular value decomposition,.
void set_property(const LAPACKSupport::Property property)
void solve(Vector< number > &v, const bool transposed=false) const
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()