1 #ifndef VIENNACL_LINALG_BISECT_HPP_
2 #define VIENNACL_LINALG_BISECT_HPP_
43 template <
typename T,
typename OtherVectorType>
49 template <
typename OtherVectorType,
typename T>
55 template <
typename VectorType1,
typename VectorType2>
70 template<
typename VectorT >
74 bisect(VectorT
const & alphas, VectorT
const & betas)
80 std::vector<CPU_ScalarType> x_temp(size);
83 std::vector<CPU_ScalarType> beta_bisect;
84 std::vector<CPU_ScalarType> wu;
86 double rel_error = std::numeric_limits<CPU_ScalarType>::epsilon();
87 beta_bisect.push_back(0);
90 beta_bisect.push_back(betas[i] * betas[i]);
93 double xmin = alphas[size - 1] - std::fabs(betas[size - 1]);
94 double xmax = alphas[size - 1] + std::fabs(betas[size - 1]);
98 double h = std::fabs(betas[i]) + std::fabs(betas[i + 1]);
99 if (alphas[i] + h > xmax)
100 xmax = alphas[i] + h;
101 if (alphas[i] - h < xmin)
102 xmin = alphas[i] - h;
121 for(
long k = static_cast<long>(size) - 1; k >= 0; --k)
124 for(
long i = k; i >= 0; --i)
136 double x1 = (xu + x0) / 2.0;
137 while (x0 - xu > 2.0 * rel_error * (std::fabs(xu) + std::fabs(x0)) + eps1)
144 q = alphas[i] - x1 - beta_bisect[i] / q;
146 q = alphas[i] - x1 - std::fabs(betas[i] / rel_error);
152 if (a <= static_cast<vcl_size_t>(k))
160 if(x_temp[a - 1] > x1)
167 x1 = (xu + x0) / 2.0;
std::size_t vcl_size_t
Definition: forwards.h:58
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...
Definition: bisect.hpp:74
vcl_size_t size(VectorType const &vec)
Generic routine for obtaining the size of a vector (ViennaCL, uBLAS, etc.)
Definition: size.hpp:144
void copy(std::vector< SCALARTYPE > &cpu_vec, circulant_matrix< SCALARTYPE, ALIGNMENT > &gpu_mat)
Copies a circulant matrix from the std::vector to the OpenCL device (either GPU or multi-core CPU) ...
Definition: circulant_matrix.hpp:150
T::value_type type
Definition: result_of.hpp:230
A vector class representing a linear memory sequence on the GPU. Inspired by boost::numeric::ublas::v...
Definition: forwards.h:208
T::ERROR_CANNOT_DEDUCE_CPU_SCALAR_TYPE_FOR_T type
Definition: result_of.hpp:276
void copy_vec_to_vec(viennacl::vector< T > const &src, OtherVectorType &dest)
overloaded function for copying vectors
Definition: bisect.hpp:44
A collection of compile time type deductions.