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] = CPU_ScalarType(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)
T norm_2(std::vector< T, A > const &v1)
Generic interface for the l^2-norm. See viennacl/linalg/vector_operations.hpp for implementations...
power_iter_tag(double tfac=1e-8, vcl_size_t max_iters=50000)
The constructor.
Generic interface for matrix-vector and matrix-matrix products. See viennacl/linalg/vector_operations...
void factor(double fct)
Sets the factor for termination.
double factor() const
Returns the factor for termination.
A tag for the power iteration algorithm.
vcl_size_t max_iterations() const
VectorT prod(std::vector< std::vector< T, A1 >, A2 > const &matrix, VectorT const &vector)
void copy_vec_to_vec(viennacl::vector< NumericT > const &src, OtherVectorT &dest)
overloaded function for copying vectors
T::ERROR_CANNOT_DEDUCE_CPU_SCALAR_TYPE_FOR_T type
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.
void max_iterations(vcl_size_t new_max)
Implementation of the algorithm for finding eigenvalues of a tridiagonal matrix.