1 #ifndef VIENNACL_LINALG_QR_METHOD_COMMON_HPP
2 #define VIENNACL_LINALG_QR_METHOD_COMMON_HPP
23 #ifdef VIENNACL_WITH_OPENCL
30 #ifdef VIENNACL_WITH_CUDA
61 static const double EPS = 1e-10;
64 template <
typename SCALARTYPE>
65 SCALARTYPE
pythag(SCALARTYPE a, SCALARTYPE b)
67 return std::sqrt(a*a + b*b);
70 template <
typename SCALARTYPE>
71 SCALARTYPE
sign(SCALARTYPE val)
73 return (val >= 0) ? SCALARTYPE(1) : SCALARTYPE(-1);
77 template <
typename VectorType>
80 typename VectorType::value_type x_norm = 0.0;
82 x_norm += std::pow(x[i], 2);
83 return std::sqrt(x_norm);
86 template <
typename VectorType>
89 typename VectorType::value_type x_norm =
norm_lcl(x, size);
96 template <
typename VectorType>
99 typedef typename VectorType::value_type
ScalarType;
100 ScalarType x_norm =
norm_lcl(v, v.size());
101 ScalarType alpha = -
sign(v[start]) * x_norm;
106 template <
typename SCALARTYPE>
110 #ifdef VIENNACL_WITH_OPENCL
141 template <
typename T>
142 void cdiv(T xr, T xi, T yr, T yi, T& cdivr, T& cdivi)
147 if (std::fabs(yr) > std::fabs(yi))
151 cdivr = (xr + r * xi) / d;
152 cdivi = (xi - r * xr) / d;
158 cdivr = (r * xr + xi) / d;
159 cdivi = (r * xi - xr) / d;
164 template<
typename SCALARTYPE>
176 std::vector<SCALARTYPE> tmp(size);
177 copy_vec(A, D, row_start, col_start, is_column);
Represents an OpenCL device within ViennaCL.
viennacl::ocl::kernel & get_kernel(std::string const &prog_name, std::string const &kernel_name)
Convenience function for getting the kernel for a particular program from the current active context...
const std::string SVD_INVERSE_SIGNS_KERNEL
void copy_vec(matrix_base< SCALARTYPE > &A, vector_base< SCALARTYPE > &V, vcl_size_t row_start, vcl_size_t col_start, bool copy_col)
This function copies a row or a column from a matrix to a vector.
Represents an OpenCL kernel within ViennaCL.
Implementation of the dense matrix class.
Manages an OpenCL context and provides the respective convenience functions for creating buffers...
const std::string SVD_UPDATE_QR_COLUMN_KERNEL
const std::string SVD_HOUSEHOLDER_UPDATE_A_RIGHT_KERNEL
void cdiv(T xr, T xi, T yr, T yi, T &cdivr, T &cdivi)
const std::string SVD_HOUSEHOLDER_UPDATE_QR_KERNEL
void transpose(matrix_base< SCALARTYPE > &A)
static void init(viennacl::ocl::context &ctx)
void prepare_householder_vector(matrix_base< SCALARTYPE > &A, vector_base< SCALARTYPE > &D, vcl_size_t size, vcl_size_t row_start, vcl_size_t col_start, vcl_size_t start, bool is_column)
void normalize(VectorType &x, vcl_size_t size)
OpenCL kernel file for singular value decomposition.
vcl_size_t size(VectorType const &vec)
Generic routine for obtaining the size of a vector (ViennaCL, uBLAS, etc.)
Main kernel class for generating OpenCL kernels for singular value decomposition of dense matrices...
iterator begin()
Returns an iterator pointing to the beginning of the vector (STL like)
Implementation of a smart-pointer-like class for handling OpenCL handles.
result_of::size_type< T >::type start(T const &obj)
Common base class for dense vectors, vector ranges, and vector slices.
void householder_vector(VectorType &v, vcl_size_t start)
const std::string SVD_HOUSEHOLDER_UPDATE_A_LEFT_KERNEL
SCALARTYPE pythag(SCALARTYPE a, SCALARTYPE b)
Implementations of dense matrix related operations, including matrix-vector products, using CUDA.
void enqueue(KernelType &k, viennacl::ocl::command_queue const &queue)
Enqueues a kernel in the provided queue.
Representation of an OpenCL kernel in ViennaCL.
The vector type with operator-overloads and proxy classes is defined here. Linear algebra operations ...
const std::string SVD_HOUSEHOLDER_UPDATE_QL_KERNEL
const std::string SVD_FINAL_ITER_UPDATE_KERNEL
const std::string SVD_MATRIX_TRANSPOSE_KERNEL
size_type internal_size2() const
Returns the internal number of columns. Usually required for launching OpenCL kernels only...
size_type internal_size1() const
Returns the internal number of rows. Usually required for launching OpenCL kernels only...
VectorType::value_type norm_lcl(VectorType const &x, vcl_size_t size)
A collection of compile time type deductions.
const std::string SVD_GIVENS_PREV_KERNEL
std::ptrdiff_t vcl_ptrdiff_t
SCALARTYPE sign(SCALARTYPE val)
void fast_copy(const const_vector_iterator< SCALARTYPE, ALIGNMENT > &gpu_begin, const const_vector_iterator< SCALARTYPE, ALIGNMENT > &gpu_end, CPU_ITERATOR cpu_begin)