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>
31 left((symmetric ? 0 : size), 0.),
33 is_symmetric(symmetric),
38 template<
typename number>
44 is_symmetric = symmetric;
45 diagonal.resize(size);
47 left.resize(symmetric ? 0 : size);
52 template<
typename number>
58 typename std::vector<number>::const_iterator i;
59 typename std::vector<number>::const_iterator e;
62 for (i=diagonal.begin() ; i != e ; ++i)
63 if (*i != 0.)
return false;
66 for (i=left.begin() ; i != e ; ++i)
67 if (*i != 0.)
return false;
70 for (i=right.begin() ; i != e ; ++i)
71 if (*i != 0.)
return false;
76 template<
typename number>
81 const bool adding)
const 95 typename std::vector<number>::const_iterator d = diagonal.begin();
96 typename std::vector<number>::const_iterator r = right.begin();
100 typename std::vector<number>::const_iterator l = left.begin();
109 w(0) += (*d) * v(0) + (*r) * v(1);
113 for (
size_type i=1; i<e; ++i,++d,++r,++l)
114 w(i) += (*l) * v(i-1) + (*d) * v(i) + (*r) * v(i+1);
116 w(e) += (*l) * v(e-1) + (*d) * v(e);
120 w(0) = (*d) * v(0) + (*r) * v(1);
123 for (
size_type i=1; i<e; ++i,++d,++r,++l)
124 w(i) = (*l) * v(i-1) + (*d) * v(i) + (*r) * v(i+1);
125 w(e) = (*l) * v(e-1) + (*d) * v(e);
130 template<
typename number>
140 template<
typename number>
145 const bool adding)
const 155 typename std::vector<number>::const_iterator d = diagonal.begin();
156 typename std::vector<number>::const_iterator r = right.begin();
157 typename std::vector<number>::const_iterator l = left.begin();
165 w(0) += (*d) * v(0) + (*l) * v(1);
168 for (
size_type i=1; i<e; ++i,++d,++r,++l)
169 w(i) += (*l) * v(i+1) + (*d) * v(i) + (*r) * v(i-1);
170 w(e) += (*d) * v(e) + (*r) * v(e-1);
174 w(0) = (*d) * v(0) + (*l) * v(1);
177 for (
size_type i=1; i<e; ++i,++d,++r,++l)
178 w(i) = (*l) * v(i+1) + (*d) * v(i) + (*r) * v(i-1);
179 w(e) = (*d) * v(e) + (*r) * v(e-1);
184 template<
typename number>
194 template<
typename number>
203 typename std::vector<number>::const_iterator d = diagonal.begin();
204 typename std::vector<number>::const_iterator r = right.begin();
205 typename std::vector<number>::const_iterator l = left.begin();
211 number result = w(0) * ((*d) * v(0) + (*r) * v(1));
214 for (
size_type i=1; i<e; ++i,++d,++r,++l)
215 result += w(i) * ((*l) * v(i-1)+ (*d) * v(i)+ (*r) * v(i+1));
216 result += w(e) * ((*l) * v(e-1) + (*d) * v(e));
221 template<
typename number>
226 return matrix_scalar_product(v,v);
234 #ifdef DEAL_II_WITH_LAPACK 240 stev (&N, &nn, &*diagonal.begin(), &*right.begin(), 0, &one, 0, &info);
250 template<
typename number>
272 DEAL_II_NAMESPACE_CLOSE
void compute_eigenvalues()
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)
void vmult_add(Vector< number > &w, const Vector< number > &v) const
static ::ExceptionBase & ExcInternalError()