74 std::cout <<
"Copying a few scalars..." << std::endl;
84 std::cout <<
"Manipulating a few scalars..." << std::endl;
85 std::cout <<
"operator +=" << std::endl;
89 std::cout <<
"operator *=" << std::endl;
93 std::cout <<
"operator -=" << std::endl;
97 std::cout <<
"operator /=" << std::endl;
101 std::cout <<
"operator +" << std::endl;
103 vcl_s1 = vcl_s2 + vcl_s3;
105 std::cout <<
"multiple operators" << std::endl;
106 s1 = s2 + s3 * s2 - s3 /
s1;
107 vcl_s1 = vcl_s2 + vcl_s3 * vcl_s2 - vcl_s3 / vcl_s1;
113 std::cout <<
"mixed operations" << std::endl;
114 vcl_s1 = s1 * vcl_s2 + s3 - vcl_s3;
121 std::cout <<
"CPU scalar s3: " << s3 << std::endl;
122 std::cout <<
"GPU scalar vcl_s3: " << vcl_s3 << std::endl;
130 std::vector<ScalarType> std_vec1(10);
131 std::vector<ScalarType> std_vec2(10);
132 ScalarType plain_vec3[10];
142 for (
unsigned int i = 0; i < 10; ++i)
144 std_vec1[i] = randomNumber();
145 vcl_vec2(i) = randomNumber();
146 plain_vec3[i] = randomNumber();
152 viennacl::copy(std_vec1.begin(), std_vec1.end(), vcl_vec1.begin());
153 viennacl::copy(vcl_vec2.begin(), vcl_vec2.end(), std_vec2.begin());
160 viennacl::copy(std_vec1.begin() + 4, std_vec1.begin() + 8, vcl_vec1.begin() + 4);
161 viennacl::copy(vcl_vec1.begin() + 4, vcl_vec1.begin() + 8, vcl_vec2.begin() + 1);
162 viennacl::copy(vcl_vec1.begin() + 4, vcl_vec1.begin() + 8, std_vec1.begin() + 1);
189 vcl_vec1 = vcl_s1 * vcl_vec2 / vcl_s3;
192 vcl_vec1 = vcl_vec2 / vcl_s3 + vcl_s2 * (vcl_vec1 - vcl_s2 * vcl_vec2);
210 std::cout <<
"!!!! TUTORIAL COMPLETED SUCCESSFULLY !!!!" << std::endl;
T norm_2(std::vector< T, A > const &v1)
This class represents a single scalar value on the GPU and behaves mostly like a built-in scalar type...
Generic interface for the l^2-norm. See viennacl/linalg/vector_operations.hpp for implementations...
vector< NumericT, AlignmentV > & fast_swap(vector< NumericT, AlignmentV > &v1, vector< NumericT, AlignmentV > &v2)
Swaps the content of two vectors by swapping OpenCL handles only, NO data is copied.
void plane_rotation(vector_base< T > &vec1, vector_base< T > &vec2, T alpha, T beta)
Computes a plane rotation of two vectors.
viennacl::enable_if< viennacl::is_stl< typename viennacl::traits::tag_of< VectorT1 >::type >::value, typename VectorT1::value_type >::type inner_prod(VectorT1 const &v1, VectorT2 const &v2)
viennacl::scalar< int > s2
viennacl::scalar< float > s1
Generic interface for the computation of inner products. See viennacl/linalg/vector_operations.hpp for implementations.
Generic interface for the l^1-norm. See viennacl/linalg/vector_operations.hpp for implementations...
void swap(vector_base< T > &vec1, vector_base< T > &vec2)
Swaps the contents of two vectors, data is copied.
The vector type with operator-overloads and proxy classes is defined here. Linear algebra operations ...
T norm_inf(std::vector< T, A > const &v1)
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 small collection of sequential random number generators.
T norm_1(std::vector< T, A > const &v1)
Implementation of the ViennaCL scalar class.
Generic interface for the l^infty-norm. See viennacl/linalg/vector_operations.hpp for implementations...