17 #include <deal.II/lac/tridiagonal_matrix.h> 18 #include <deal.II/lac/vector.h> 19 #include <deal.II/lac/lapack_templates.h> 21 DEAL_II_NAMESPACE_OPEN
25 template <
typename number>
39 template <
typename number>
54 template <
typename number>
60 typename std::vector<number>::const_iterator i;
61 typename std::vector<number>::const_iterator e;
64 for (i=
diagonal.begin() ; i != e ; ++i)
65 if (*i != 0.)
return false;
68 for (i=left.begin() ; i != e ; ++i)
69 if (*i != 0.)
return false;
72 for (i=right.begin() ; i != e ; ++i)
73 if (*i != 0.)
return false;
79 template <
typename number>
84 const bool adding)
const 98 typename std::vector<number>::const_iterator d =
diagonal.begin();
99 typename std::vector<number>::const_iterator r = right.begin();
103 typename std::vector<number>::const_iterator l = left.begin();
112 w(0) += (*d) * v(0) + (*r) * v(1);
116 for (
size_type i=1; i<e; ++i,++d,++r,++l)
117 w(i) += (*l) * v(i-1) + (*d) * v(i) + (*r) * v(i+1);
119 w(e) += (*l) * v(e-1) + (*d) * v(e);
123 w(0) = (*d) * v(0) + (*r) * v(1);
126 for (
size_type i=1; i<e; ++i,++d,++r,++l)
127 w(i) = (*l) * v(i-1) + (*d) * v(i) + (*r) * v(i+1);
128 w(e) = (*l) * v(e-1) + (*d) * v(e);
133 template <
typename number>
144 template <
typename number>
149 const bool adding)
const 159 typename std::vector<number>::const_iterator d =
diagonal.begin();
160 typename std::vector<number>::const_iterator r = right.begin();
161 typename std::vector<number>::const_iterator l = left.begin();
169 w(0) += (*d) * v(0) + (*l) * v(1);
172 for (
size_type i=1; i<e; ++i,++d,++r,++l)
173 w(i) += (*l) * v(i+1) + (*d) * v(i) + (*r) * v(i-1);
174 w(e) += (*d) * v(e) + (*r) * v(e-1);
178 w(0) = (*d) * v(0) + (*l) * v(1);
181 for (
size_type i=1; i<e; ++i,++d,++r,++l)
182 w(i) = (*l) * v(i+1) + (*d) * v(i) + (*r) * v(i-1);
183 w(e) = (*d) * v(e) + (*r) * v(e-1);
189 template <
typename number>
200 template <
typename number>
209 typename std::vector<number>::const_iterator d =
diagonal.begin();
210 typename std::vector<number>::const_iterator r = right.begin();
211 typename std::vector<number>::const_iterator l = left.begin();
217 number result = w(0) * ((*d) * v(0) + (*r) * v(1));
220 for (
size_type i=1; i<e; ++i,++d,++r,++l)
221 result += w(i) * ((*l) * v(i-1)+ (*d) * v(i)+ (*r) * v(i+1));
222 result += w(e) * ((*l) * v(e-1) + (*d) * v(e));
228 template <
typename number>
233 return matrix_scalar_product(v,v);
238 template <
typename number>
242 #ifdef DEAL_II_WITH_LAPACK 248 stev (&N, &nn,
diagonal.data(), right.data(),
nullptr, &one,
nullptr, &info);
259 template <
typename number>
281 DEAL_II_NAMESPACE_CLOSE
void compute_eigenvalues()
Contents is actually a matrix.
void vmult(Vector< number > &w, const Vector< number > &v, const bool adding=false) const
static ::ExceptionBase & ExcIndexRange(int arg1, int arg2, int arg3)
void Tvmult_add(Vector< number > &w, const Vector< number > &v) const
static ::ExceptionBase & ExcNeedsLAPACK()
static ::ExceptionBase & ExcState(State arg1)
#define Assert(cond, exc)
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
number matrix_scalar_product(const Vector< number > &u, const Vector< number > &v) const
TridiagonalMatrix(size_type n=0, bool symmetric=false)
types::global_dof_index size_type
number matrix_norm_square(const Vector< number > &v) const
number eigenvalue(const size_type i) const
void Tvmult(Vector< number > &w, const Vector< number > &v, const bool adding=false) const
static ::ExceptionBase & ExcNotImplemented()
void reinit(size_type n, bool symmetric=false)
Eigenvalue vector is filled.
void vmult_add(Vector< number > &w, const Vector< number > &v) const
static ::ExceptionBase & ExcInternalError()