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_;
72 template<
typename MatrixT,
typename VectorT >
82 std::vector<CPU_ScalarType> s(matrix_size);
85 s[i] = CPU_ScalarType(i % 3) * CPU_ScalarType(0.1234) - CPU_ScalarType(0.5);
89 double epsilon = tag.
factor();
90 CPU_ScalarType norm =
norm_2(eigenvec);
91 CPU_ScalarType norm_prev = 0;
96 if (std::fabs(norm - norm_prev) / std::fabs(norm) < epsilon)
117 template<
typename MatrixT >
121 typedef typename viennacl::result_of::vector_for_matrix<MatrixT>::type VectorT;
123 VectorT eigenvec(A.size1());
124 return eig(A, tag, eigenvec);
T norm_2(std::vector< T, A > const &v1)
std::vector< typename viennacl::result_of::cpu_value_type< typename MatrixT::value_type >::type > eig(MatrixT const &matrix, DenseMatrixT &eigenvectors_A, lanczos_tag const &tag, bool compute_eigenvectors=true)
Implementation of the calculation of eigenvalues using lanczos (with and without reorthogonalization)...
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
void max_iterations(vcl_size_t new_max)
Implementation of the algorithm for finding eigenvalues of a tridiagonal matrix.