1 #ifndef VIENNACL_LINALG_BISECT_HPP_
2 #define VIENNACL_LINALG_BISECT_HPP_
43 template<
typename NumericT,
typename OtherVectorT>
49 template<
typename OtherVectorT,
typename NumericT>
55 template<
typename VectorT1,
typename VectorT2>
74 template<
typename VectorT>
78 bisect(VectorT
const & alphas, VectorT
const & betas)
84 std::vector<CPU_NumericType> x_temp(size);
87 std::vector<CPU_NumericType> beta_bisect;
88 std::vector<CPU_NumericType> wu;
90 double rel_error = std::numeric_limits<CPU_NumericType>::epsilon();
91 beta_bisect.push_back(0);
94 beta_bisect.push_back(betas[i] * betas[i]);
96 double xmin = alphas[size - 1] - std::fabs(betas[size - 1]);
97 double xmax = alphas[size - 1] + std::fabs(betas[size - 1]);
101 double h = std::fabs(betas[i]) + std::fabs(betas[i + 1]);
102 if (alphas[i] + h > xmax)
103 xmax = alphas[i] + h;
104 if (alphas[i] - h < xmin)
105 xmin = alphas[i] - h;
124 for (
long k = static_cast<long>(size) - 1; k >= 0; --k)
127 for (
long i = k; i >= 0; --i)
139 double x1 = (xu + x0) / 2.0;
140 while (x0 - xu > 2.0 * rel_error * (std::fabs(xu) + std::fabs(x0)) + eps1)
147 q = alphas[i] - x1 - beta_bisect[i] / q;
149 q = alphas[i] - x1 - std::fabs(betas[i] / rel_error);
155 if (a <= static_cast<vcl_size_t>(k))
163 if (x_temp[a - 1] > x1)
170 x1 = (xu + x0) / 2.0;
std::vector< typename viennacl::result_of::cpu_value_type< typename VectorT::value_type >::type > bisect(VectorT const &alphas, VectorT const &betas)
Implementation of the bisect-algorithm for the calculation of the eigenvalues of a tridiagonal matrix...
Main namespace in ViennaCL. Holds all the basic types such as vector, matrix, etc. and defines operations upon them.
vcl_size_t size(VectorType const &vec)
Generic routine for obtaining the size of a vector (ViennaCL, uBLAS, etc.)
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 copy(std::vector< NumericT > &cpu_vec, circulant_matrix< NumericT, AlignmentV > &gpu_mat)
Copies a circulant matrix from the std::vector to the OpenCL device (either GPU or multi-core CPU) ...
A collection of compile time type deductions.