1 #ifndef VIENNACL_LINALG_POWER_ITER_HPP_
2 #define VIENNACL_LINALG_POWER_ITER_HPP_
50 void factor(
double fct){ termination_factor_ = fct; }
53 double factor()
const {
return termination_factor_; }
59 double termination_factor_;
71 template<
typename MatrixT >
78 typedef typename viennacl::result_of::vector_for_matrix<MatrixT>::type VectorT;
80 CPU_ScalarType eigenvalue;
82 VectorT r(matrix_size);
83 VectorT r2(matrix_size);
84 std::vector<CPU_ScalarType> s(matrix_size);
87 s[i] = (i % 3) * CPU_ScalarType(0.1234) - CPU_ScalarType(0.5);
93 double epsilon = tag.
factor();
94 CPU_ScalarType norm =
norm_2(r);
95 CPU_ScalarType norm_prev = 0;
100 if (std::fabs(norm - norm_prev) / std::fabs(norm) < epsilon)
vcl_size_t max_iterations() const
Definition: power_iter.hpp:55
std::size_t vcl_size_t
Definition: forwards.h:58
T norm_2(std::vector< T, A > const &v1)
Definition: norm_2.hpp:86
Generic interface for the l^2-norm. See viennacl/linalg/vector_operations.hpp for implementations...
double factor() const
Returns the factor for termination.
Definition: power_iter.hpp:53
Generic interface for matrix-vector and matrix-matrix products. See viennacl/linalg/vector_operations...
A dense matrix class.
Definition: forwards.h:293
power_iter_tag(double tfac=1e-8, vcl_size_t max_iters=50000)
The constructor.
Definition: power_iter.hpp:47
A tag for the power iteration algorithm.
Definition: power_iter.hpp:38
VectorT prod(std::vector< std::vector< T, A1 >, A2 > const &matrix, VectorT const &vector)
Definition: prod.hpp:91
void factor(double fct)
Sets the factor for termination.
Definition: power_iter.hpp:50
T::value_type type
Definition: result_of.hpp:230
std::vector< typename viennacl::result_of::cpu_value_type< typename MatrixT::value_type >::type > eig(MatrixT const &matrix, lanczos_tag const &tag)
Implementation of the calculation of eigenvalues using lanczos.
Definition: lanczos.hpp:435
T::ERROR_CANNOT_DEDUCE_CPU_SCALAR_TYPE_FOR_T type
Definition: result_of.hpp:276
Implementation of the algorithm for finding eigenvalues of a tridiagonal matrix.
void copy_vec_to_vec(viennacl::vector< T > const &src, OtherVectorType &dest)
overloaded function for copying vectors
Definition: bisect.hpp:44
void max_iterations(vcl_size_t new_max)
Definition: power_iter.hpp:56