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> 26 #include <deal.II/base/std_cxx11/shared_ptr.h> 30 DEAL_II_NAMESPACE_OPEN
33 template<
typename number>
class Vector;
51 template <
typename number>
77 const size_type cols);
103 template <
typename number2>
113 template <
typename number2>
130 template <
typename MatrixType>
145 void reinit (
const size_type rows,
146 const size_type cols);
153 unsigned int m ()
const;
160 unsigned int n ()
const;
175 template<
typename MatrixType>
176 void fill (
const MatrixType &src,
177 const size_type dst_offset_i = 0,
178 const size_type dst_offset_j = 0,
179 const size_type src_offset_i = 0,
180 const size_type src_offset_j = 0,
181 const number factor = 1.,
182 const bool transpose =
false);
213 template <
typename number2>
216 const bool adding =
false)
const;
223 const bool adding =
false)
const;
230 template <
typename number2>
252 template <
typename number2>
255 const bool adding=
false)
const;
262 const bool adding=
false)
const;
270 template <
typename number2>
298 const bool adding=
false)
const;
306 const bool adding=
false)
const;
325 const bool adding=
false)
const;
333 const bool adding=
false)
const;
352 const bool adding=
false)
const;
360 const bool adding=
false)
const;
380 const bool adding=
false)
const;
388 const bool adding=
false)
const;
410 const bool transposed)
const;
422 const bool transposed)
const;
443 const bool left_eigenvectors =
false);
464 const number upper_bound,
465 const number abs_accuracy,
491 const number lower_bound,
492 const number upper_bound,
493 const number abs_accuracy,
496 const int itype = 1);
516 const int itype = 1);
585 const unsigned int precision = 3,
586 const bool scientific =
true,
587 const unsigned int width = 0,
588 const char *zero_string =
" ",
589 const double denominator = 1.,
590 const double threshold = 0.)
const;
609 mutable std::vector<number>
work;
628 std::vector<number>
wr;
633 std::vector<number>
wi;
638 std::vector<number>
vl;
643 std::vector<number>
vr;
649 std_cxx11::shared_ptr<LAPACKFullMatrix<number> >
svd_u;
655 std_cxx11::shared_ptr<LAPACKFullMatrix<number> >
svd_vt;
666 template <
typename number>
688 template <
typename number>
696 template <
typename number>
704 template <
typename number>
705 template <
typename MatrixType>
709 this->
reinit (M.m(), M.n());
714 for (
size_type row = 0; row < M.m(); ++row)
716 const typename MatrixType::const_iterator end_row = M.end(row);
717 for (
typename MatrixType::const_iterator entry = M.begin(row);
718 entry != end_row; ++entry)
719 this->
el(row, entry->column()) = entry->value();
722 state = LAPACKSupport::matrix;
727 template <
typename number>
728 template <
typename MatrixType>
736 const bool transpose)
740 for (
size_type row = src_offset_i; row < M.m(); ++row)
742 const typename MatrixType::const_iterator end_row = M.end(row);
743 for (
typename MatrixType::const_iterator entry = M.begin(row);
744 entry != end_row; ++entry)
746 const size_type i = transpose ? entry->column() : row;
747 const size_type j = transpose ? row : entry->column();
749 const size_type dst_i=dst_offset_i+i-src_offset_i;
750 const size_type dst_j=dst_offset_j+j-src_offset_j;
752 (*this)(dst_i, dst_j) = factor * entry->value();
756 state = LAPACKSupport::matrix;
760 template <
typename number>
761 template <
typename number2>
768 ExcMessage(
"LAPACKFullMatrix<number>::vmult must be called with a " 769 "matching Vector<double> vector type."));
773 template <
typename number>
774 template <
typename number2>
780 ExcMessage(
"LAPACKFullMatrix<number>::vmult_add must be called with a " 781 "matching Vector<double> vector type."));
785 template <
typename number>
786 template <
typename number2>
793 ExcMessage(
"LAPACKFullMatrix<number>::Tvmult must be called with a " 794 "matching Vector<double> vector type."));
798 template <
typename number>
799 template <
typename number2>
805 ExcMessage(
"LAPACKFullMatrix<number>::Tvmult_add must be called with a " 806 "matching Vector<double> vector type."));
810 template <
typename number>
811 inline std::complex<number>
814 Assert (
state & LAPACKSupport::eigenvalues, ExcInvalidState());
819 return std::complex<number>(
wr[i],
wi[i]);
823 template <
typename number>
827 Assert (
state == LAPACKSupport::svd ||
state == LAPACKSupport::inverse_svd, LAPACKSupport::ExcState(
state));
835 DEAL_II_NAMESPACE_CLOSE
LAPACKFullMatrix(const size_type size=0)
std_cxx11::shared_ptr< LAPACKFullMatrix< number > > svd_u
std::vector< number > work
void TmTmult(LAPACKFullMatrix< number > &C, const LAPACKFullMatrix< number > &B, const bool adding=false) const
void Tvmult(Vector< number2 > &w, const Vector< number2 > &v, const bool adding=false) const
LAPACKSupport::State state
const TableIndices< N > & size() const
AlignedVector< number >::reference el(const unsigned int i, const unsigned int j)
::ExceptionBase & ExcMessage(std::string arg1)
std::complex< number > eigenvalue(const size_type i) const
#define AssertIndexRange(index, range)
LAPACKSupport::Properties properties
void compute_eigenvalues_symmetric(const number lower_bound, const number upper_bound, const number abs_accuracy, Vector< number > &eigenvalues, FullMatrix< number > &eigenvectors)
unsigned int n_cols() const
void reinit(const size_type size)
void Tmmult(LAPACKFullMatrix< number > &C, const LAPACKFullMatrix< number > &B, const bool adding=false) const
types::global_dof_index size_type
void mTmult(LAPACKFullMatrix< number > &C, const LAPACKFullMatrix< number > &B, const bool adding=false) const
TableBase< 2, T >::size_type size_type
unsigned int global_dof_index
std_cxx11::shared_ptr< LAPACKFullMatrix< number > > svd_vt
#define Assert(cond, exc)
void copy_from(const MatrixType &)
std::vector< number > inv_work
unsigned int n_rows() const
void compute_lu_factorization()
void vmult(Vector< number2 > &w, const Vector< number2 > &v, const bool adding=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 int itype=1)
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
number singular_value(const size_type i) const
void compute_inverse_svd(const double threshold=0.)
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)
void Tvmult_add(Vector< number2 > &w, const Vector< number2 > &v) 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
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