33 #include <boost/numeric/ublas/io.hpp>
34 #include <boost/numeric/ublas/vector.hpp>
35 #include <boost/numeric/ublas/vector_proxy.hpp>
41 #define VIENNACL_WITH_UBLAS 1
58 template<
typename ScalarType>
67 template<
typename ScalarType>
76 template<
typename ScalarType>
85 template<
typename ScalarType,
typename VCLVectorType>
88 ublas::vector<ScalarType> v2_cpu(v2.size());
92 for (
unsigned int i=0;i<v1.size(); ++i)
94 if (v2_cpu[i] != v1[i])
102 template<
typename T1,
typename T2>
103 int check(T1
const & t1, T2
const & t2)
105 int retval = EXIT_SUCCESS;
107 if (
diff(t1, t2) != 0)
109 std::cout <<
"# Error! Difference: " <<
diff(t1, t2) << std::endl;
110 retval = EXIT_FAILURE;
119 template<
typename NumericT,
typename UblasVectorType,
typename ViennaCLVectorType1,
typename ViennaCLVectorType2 >
120 int test(UblasVectorType & ublas_v1, UblasVectorType & ublas_v2,
121 ViennaCLVectorType1 & vcl_v1, ViennaCLVectorType2 & vcl_v2)
123 int retval = EXIT_SUCCESS;
125 NumericT cpu_result = 42;
131 std::cout <<
"Checking for zero_vector initializer..." << std::endl;
133 for (std::size_t i=0; i<ublas_v1.size(); ++i)
136 if (
check(ublas_v1, vcl_v1) != EXIT_SUCCESS)
139 std::cout <<
"Checking for scalar_vector initializer..." << std::endl;
141 for (std::size_t i=0; i<ublas_v1.size(); ++i)
142 ublas_v1[i] = cpu_result;
144 if (
check(ublas_v1, vcl_v1) != EXIT_SUCCESS)
148 for (std::size_t i=0; i<ublas_v1.size(); ++i)
149 ublas_v1[i] = cpu_result + 1;
151 if (
check(ublas_v1, vcl_v1) != EXIT_SUCCESS)
154 std::cout <<
"Checking for unit_vector initializer..." << std::endl;
156 for (std::size_t i=0; i<ublas_v1.size(); ++i)
157 ublas_v1[i] = (i == 5) ? 1 : 0;
159 if (
check(ublas_v1, vcl_v1) != EXIT_SUCCESS)
162 for (std::size_t i=0; i<ublas_v1.size(); ++i)
164 ublas_v1[i] = NumericT(i);
165 ublas_v2[i] = NumericT(i+42);
171 std::cout <<
"Checking for successful copy..." << std::endl;
172 if (
check(ublas_v1, vcl_v1) != EXIT_SUCCESS)
174 if (
check(ublas_v2, vcl_v2) != EXIT_SUCCESS)
182 std::cout <<
"Testing inner_prod..." << std::endl;
187 if (
check(cpu_result, cpu_result2) != EXIT_SUCCESS)
189 if (
check(cpu_result, gpu_result) != EXIT_SUCCESS)
192 cpu_result =
inner_prod(ublas_v1 + ublas_v2, 2*ublas_v2);
196 if (
check(cpu_result, cpu_result3) != EXIT_SUCCESS)
198 if (
check(cpu_result, gpu_result) != EXIT_SUCCESS)
202 std::cout <<
"Testing norm_1..." << std::endl;
204 for (std::size_t i=0; i<ublas_v1.size(); ++i)
205 cpu_result += ublas_v1[i];
208 if (
check(cpu_result, gpu_result) != EXIT_SUCCESS)
212 for (std::size_t i=0; i<ublas_v1.size(); ++i)
213 cpu_result2 += ublas_v1[i];
216 if (
check(cpu_result, cpu_result2) != EXIT_SUCCESS)
220 for (std::size_t i=0; i<ublas_v1.size(); ++i)
221 cpu_result2 += ublas_v1[i] + ublas_v2[i];
224 if (
check(cpu_result, cpu_result2) != EXIT_SUCCESS)
228 std::cout <<
"Testing norm_inf..." << std::endl;
230 for (std::size_t i=0; i<ublas_v1.size(); ++i)
231 if (ublas_v1[i] > cpu_result)
232 cpu_result = ublas_v1[i];
235 if (
check(cpu_result, gpu_result) != EXIT_SUCCESS)
239 for (std::size_t i=0; i<ublas_v1.size(); ++i)
240 if (ublas_v1[i] > cpu_result2)
241 cpu_result2 = ublas_v1[i];
244 if (
check(cpu_result, cpu_result2) != EXIT_SUCCESS)
248 for (std::size_t i=0; i<ublas_v1.size(); ++i)
249 if (ublas_v1[i] + ublas_v2[i] > cpu_result2)
250 cpu_result2 = ublas_v1[i] + ublas_v2[i];
253 if (
check(cpu_result, cpu_result2) != EXIT_SUCCESS)
257 std::cout <<
"Testing index_norm_inf..." << std::endl;
259 std::size_t cpu_index = 0;
261 for (std::size_t i=0; i<ublas_v1.size(); ++i)
262 if (ublas_v1[i] > cpu_result)
264 cpu_result = ublas_v1[i];
269 if (
check(static_cast<NumericT>(cpu_index), static_cast<NumericT>(gpu_index)) != EXIT_SUCCESS)
274 if (
check(cpu_result, gpu_result) != EXIT_SUCCESS)
279 for (std::size_t i=0; i<ublas_v1.size(); ++i)
280 if (ublas_v1[i] + ublas_v2[i] > cpu_result)
282 cpu_result = ublas_v1[i];
287 if (
check(cpu_result, gpu_result) != EXIT_SUCCESS)
291 std::cout <<
"Testing max..." << std::endl;
292 cpu_result = ublas_v1[0];
293 for (std::size_t i=0; i<ublas_v1.size(); ++i)
294 cpu_result = std::max<NumericT>(cpu_result, ublas_v1[i]);
297 if (
check(cpu_result, gpu_result) != EXIT_SUCCESS)
300 cpu_result = ublas_v1[0];
301 for (std::size_t i=0; i<ublas_v1.size(); ++i)
302 cpu_result = std::max<NumericT>(cpu_result, ublas_v1[i]);
303 gpu_result = cpu_result;
307 if (
check(cpu_result, gpu_result) != EXIT_SUCCESS)
310 cpu_result = ublas_v1[0] + ublas_v2[0];
311 for (std::size_t i=0; i<ublas_v1.size(); ++i)
312 cpu_result = std::max<NumericT>(cpu_result, ublas_v1[i] + ublas_v2[i]);
313 gpu_result = cpu_result;
317 if (
check(cpu_result, gpu_result) != EXIT_SUCCESS)
322 std::cout <<
"Testing min..." << std::endl;
323 cpu_result = ublas_v1[0];
324 for (std::size_t i=0; i<ublas_v1.size(); ++i)
325 cpu_result = std::min<NumericT>(cpu_result, ublas_v1[i]);
328 if (
check(cpu_result, gpu_result) != EXIT_SUCCESS)
331 cpu_result = ublas_v1[0];
332 for (std::size_t i=0; i<ublas_v1.size(); ++i)
333 cpu_result = std::min<NumericT>(cpu_result, ublas_v1[i]);
334 gpu_result = cpu_result;
338 if (
check(cpu_result, gpu_result) != EXIT_SUCCESS)
341 cpu_result = ublas_v1[0] + ublas_v2[0];
342 for (std::size_t i=0; i<ublas_v1.size(); ++i)
343 cpu_result = std::min<NumericT>(cpu_result, ublas_v1[i] + ublas_v2[i]);
344 gpu_result = cpu_result;
348 if (
check(cpu_result, gpu_result) != EXIT_SUCCESS)
355 std::cout <<
"Testing assignments..." << std::endl;
356 NumericT val =
static_cast<NumericT
>(1);
357 for (
size_t i=0; i < ublas_v1.size(); ++i)
360 for (
size_t i=0; i < vcl_v1.size(); ++i)
363 if (
check(ublas_v1, vcl_v1) != EXIT_SUCCESS)
370 std::cout <<
"Testing scaling with CPU scalar..." << std::endl;
371 NumericT alpha =
static_cast<NumericT
>(3);
377 if (
check(ublas_v1, vcl_v1) != EXIT_SUCCESS)
380 std::cout <<
"Testing scaling with GPU scalar..." << std::endl;
384 if (
check(ublas_v1, vcl_v1) != EXIT_SUCCESS)
387 NumericT beta =
static_cast<NumericT
>(2);
390 std::cout <<
"Testing shrinking with CPU scalar..." << std::endl;
394 if (
check(ublas_v1, vcl_v1) != EXIT_SUCCESS)
397 std::cout <<
"Testing shrinking with GPU scalar..." << std::endl;
401 if (
check(ublas_v1, vcl_v1) != EXIT_SUCCESS)
408 for (
size_t i=0; i < ublas_v1.size(); ++i)
409 ublas_v1(i) = NumericT(i);
410 ublas_v2 = 3 * ublas_v1;
414 std::cout <<
"Testing add on vector..." << std::endl;
416 std::cout <<
"Checking for successful copy..." << std::endl;
417 if (
check(ublas_v1, vcl_v1) != EXIT_SUCCESS)
419 if (
check(ublas_v2, vcl_v2) != EXIT_SUCCESS)
422 ublas_v1 = ublas_v1 + ublas_v2;
423 vcl_v1 = vcl_v1 + vcl_v2;
425 if (
check(ublas_v1, vcl_v1) != EXIT_SUCCESS)
428 std::cout <<
"Testing inplace-add on vector..." << std::endl;
429 ublas_v1 += ublas_v2;
432 if (
check(ublas_v1, vcl_v1) != EXIT_SUCCESS)
439 std::cout <<
"Testing multiply-add on vector with CPU scalar (right)..." << std::endl;
440 for (
size_t i=0; i < ublas_v1.size(); ++i)
441 ublas_v1(i) = NumericT(i);
442 ublas_v2 = 3 * ublas_v1;
446 ublas_v1 = ublas_v1 + alpha * ublas_v2;
447 vcl_v1 = vcl_v1 + alpha * vcl_v2;
449 if (
check(ublas_v1, vcl_v1) != EXIT_SUCCESS)
452 std::cout <<
"Testing multiply-add on vector with CPU scalar (left)..." << std::endl;
453 ublas_v2 = 3 * ublas_v1;
457 ublas_v1 = alpha * ublas_v1 + ublas_v2;
458 vcl_v1 = alpha * vcl_v1 + vcl_v2;
460 if (
check(ublas_v1, vcl_v1) != EXIT_SUCCESS)
463 std::cout <<
"Testing multiply-add on vector with CPU scalar (both)..." << std::endl;
464 ublas_v2 = 3 * ublas_v1;
468 ublas_v1 = alpha * ublas_v1 + beta * ublas_v2;
469 vcl_v1 = alpha * vcl_v1 + beta * vcl_v2;
471 if (
check(ublas_v1, vcl_v1) != EXIT_SUCCESS)
475 std::cout <<
"Testing inplace multiply-add on vector with CPU scalar..." << std::endl;
476 ublas_v2 = 3 * ublas_v1;
480 ublas_v1 += alpha * ublas_v2;
481 vcl_v1 += alpha * vcl_v2;
483 if (
check(ublas_v1, vcl_v1) != EXIT_SUCCESS)
487 std::cout <<
"Testing multiply-add on vector with GPU scalar (right)..." << std::endl;
488 ublas_v2 = 3 * ublas_v1;
492 ublas_v1 = ublas_v1 + alpha * ublas_v2;
493 vcl_v1 = vcl_v1 + gpu_alpha * vcl_v2;
495 if (
check(ublas_v1, vcl_v1) != EXIT_SUCCESS)
498 std::cout <<
"Testing multiply-add on vector with GPU scalar (left)..." << std::endl;
499 ublas_v2 = 3 * ublas_v1;
503 ublas_v1 = ublas_v1 + alpha * ublas_v2;
504 vcl_v1 = vcl_v1 + gpu_alpha * vcl_v2;
506 if (
check(ublas_v1, vcl_v1) != EXIT_SUCCESS)
509 std::cout <<
"Testing multiply-add on vector with GPU scalar (both)..." << std::endl;
510 ublas_v2 = 3 * ublas_v1;
514 ublas_v1 = alpha * ublas_v1 + beta * ublas_v2;
515 vcl_v1 = gpu_alpha * vcl_v1 + gpu_beta * vcl_v2;
517 if (
check(ublas_v1, vcl_v1) != EXIT_SUCCESS)
521 std::cout <<
"Testing inplace multiply-add on vector with GPU scalar (both, adding)..." << std::endl;
522 ublas_v2 = 3 * ublas_v1;
526 ublas_v1 += alpha * ublas_v1 + beta * ublas_v2;
527 vcl_v1 += gpu_alpha * vcl_v1 + gpu_beta * vcl_v2;
529 if (
check(ublas_v1, vcl_v1) != EXIT_SUCCESS)
533 std::cout <<
"Testing inplace multiply-add on vector with GPU scalar..." << std::endl;
534 ublas_v2 = 3 * ublas_v1;
538 ublas_v1 += alpha * ublas_v2;
539 vcl_v1 += gpu_alpha * vcl_v2;
541 if (
check(ublas_v1, vcl_v1) != EXIT_SUCCESS)
548 std::cout <<
"Testing division-add on vector with CPU scalar (right)..." << std::endl;
549 for (
size_t i=0; i < ublas_v1.size(); ++i)
550 ublas_v1(i) = NumericT(i);
551 ublas_v2 = 3 * ublas_v1;
555 ublas_v1 = ublas_v1 + ublas_v2 / alpha;
556 vcl_v1 = vcl_v1 + vcl_v2 / alpha;
558 if (
check(ublas_v1, vcl_v1) != EXIT_SUCCESS)
562 std::cout <<
"Testing division-add on vector with CPU scalar (left)..." << std::endl;
563 ublas_v2 = 3 * ublas_v1;
567 ublas_v1 = ublas_v1 / alpha + ublas_v2;
568 vcl_v1 = vcl_v1 / alpha + vcl_v2;
570 if (
check(ublas_v1, vcl_v1) != EXIT_SUCCESS)
573 std::cout <<
"Testing division-add on vector with CPU scalar (both)..." << std::endl;
574 ublas_v2 = 3 * ublas_v1;
578 ublas_v1 = ublas_v1 / alpha + ublas_v2 / beta;
579 vcl_v1 = vcl_v1 / alpha + vcl_v2 / beta;
581 if (
check(ublas_v1, vcl_v1) != EXIT_SUCCESS)
584 std::cout <<
"Testing division-multiply-add on vector with CPU scalar..." << std::endl;
585 ublas_v2 = 3 * ublas_v1;
589 ublas_v1 = ublas_v1 / alpha + ublas_v2 * beta;
590 vcl_v1 = vcl_v1 / alpha + vcl_v2 * beta;
592 if (
check(ublas_v1, vcl_v1) != EXIT_SUCCESS)
596 std::cout <<
"Testing multiply-division-add on vector with CPU scalar..." << std::endl;
597 ublas_v2 = 3 * ublas_v1;
601 ublas_v1 = ublas_v1 * alpha + ublas_v2 / beta;
602 vcl_v1 = vcl_v1 * alpha + vcl_v2 / beta;
604 if (
check(ublas_v1, vcl_v1) != EXIT_SUCCESS)
609 std::cout <<
"Testing inplace division-add on vector with CPU scalar..." << std::endl;
610 ublas_v2 = 3 * ublas_v1;
614 ublas_v1 += ublas_v2 / alpha;
615 vcl_v1 += vcl_v2 / alpha;
617 if (
check(ublas_v1, vcl_v1) != EXIT_SUCCESS)
621 std::cout <<
"Testing division-add on vector with GPU scalar (right)..." << std::endl;
622 ublas_v2 = 3 * ublas_v1;
626 ublas_v1 = ublas_v1 + ublas_v2 / alpha;
627 vcl_v1 = vcl_v1 + vcl_v2 / gpu_alpha;
629 if (
check(ublas_v1, vcl_v1) != EXIT_SUCCESS)
632 std::cout <<
"Testing division-add on vector with GPU scalar (left)..." << std::endl;
633 ublas_v2 = 3 * ublas_v1;
637 ublas_v1 = ublas_v1 + ublas_v2 / alpha;
638 vcl_v1 = vcl_v1 + vcl_v2 / gpu_alpha;
640 if (
check(ublas_v1, vcl_v1) != EXIT_SUCCESS)
643 std::cout <<
"Testing division-add on vector with GPU scalar (both)..." << std::endl;
644 ublas_v2 = 3 * ublas_v1;
648 ublas_v1 = ublas_v1 / alpha + ublas_v2 / beta;
649 vcl_v1 = vcl_v1 / gpu_alpha + vcl_v2 / gpu_beta;
651 if (
check(ublas_v1, vcl_v1) != EXIT_SUCCESS)
655 std::cout <<
"Testing inplace division-add on vector with GPU scalar (both, adding)..." << std::endl;
656 ublas_v2 = 3 * ublas_v1;
660 ublas_v1 += ublas_v1 / alpha + ublas_v2 / beta;
661 vcl_v1 += vcl_v1 / gpu_alpha + vcl_v2 / gpu_beta;
663 if (
check(ublas_v1, vcl_v1) != EXIT_SUCCESS)
666 std::cout <<
"Testing inplace division-multiply-add on vector with GPU scalar (adding)..." << std::endl;
667 ublas_v2 = 3 * ublas_v1;
671 ublas_v1 += ublas_v1 / alpha + ublas_v2 * beta;
672 vcl_v1 += vcl_v1 / gpu_alpha + vcl_v2 * gpu_beta;
674 if (
check(ublas_v1, vcl_v1) != EXIT_SUCCESS)
678 std::cout <<
"Testing inplace division-add on vector with GPU scalar..." << std::endl;
679 ublas_v2 = 3 * ublas_v1;
683 ublas_v1 += ublas_v2 * alpha;
684 vcl_v1 += vcl_v2 * gpu_alpha;
686 if (
check(ublas_v1, vcl_v1) != EXIT_SUCCESS)
692 for (
size_t i=0; i < ublas_v1.size(); ++i)
693 ublas_v1(i) = NumericT(i);
694 ublas_v2 = 3 * ublas_v1;
698 std::cout <<
"Testing three vector additions..." << std::endl;
699 ublas_v1 = ublas_v2 + ublas_v1 + ublas_v2;
700 vcl_v1 = vcl_v2 + vcl_v1 + vcl_v2;
702 if (
check(ublas_v1, vcl_v1) != EXIT_SUCCESS)
706 ublas_v2 = 3 * ublas_v1;
710 std::cout <<
"Testing swap..." << std::endl;
711 swap(ublas_v1, ublas_v2);
712 swap(vcl_v1, vcl_v2);
714 if (
check(ublas_v1, vcl_v1) != EXIT_SUCCESS)
717 std::cout <<
"Testing elementwise multiplication..." << std::endl;
718 std::cout <<
" v1 = element_prod(v1, v2);" << std::endl;
722 if (
check(ublas_v1, vcl_v1) != EXIT_SUCCESS)
725 std::cout <<
" v1 += element_prod(v1, v2);" << std::endl;
729 if (
check(ublas_v1, vcl_v1) != EXIT_SUCCESS)
733 std::cout <<
" v1 = element_prod(v1 + v2, v2);" << std::endl;
737 if (
check(ublas_v1, vcl_v1) != EXIT_SUCCESS)
740 std::cout <<
" v1 += element_prod(v1 + v2, v2);" << std::endl;
744 if (
check(ublas_v1, vcl_v1) != EXIT_SUCCESS)
748 std::cout <<
" v1 = element_prod(v1, v2 + v1);" << std::endl;
752 if (
check(ublas_v1, vcl_v1) != EXIT_SUCCESS)
755 std::cout <<
" v1 += element_prod(v1, v2 + v1);" << std::endl;
759 if (
check(ublas_v1, vcl_v1) != EXIT_SUCCESS)
763 std::cout <<
" v1 = element_prod(v1 + v2, v2 + v1);" << std::endl;
767 if (
check(ublas_v1, vcl_v1) != EXIT_SUCCESS)
770 std::cout <<
" v1 += element_prod(v1 + v2, v2 + v1);" << std::endl;
774 if (
check(ublas_v1, vcl_v1) != EXIT_SUCCESS)
778 std::cout <<
"Testing elementwise division..." << std::endl;
779 for (std::size_t i=0; i<ublas_v1.size(); ++i)
781 ublas_v1[i] = NumericT(1 + i);
782 ublas_v2[i] = NumericT(5 + i);
791 if (
check(ublas_v1, vcl_v1) != EXIT_SUCCESS)
797 if (
check(ublas_v1, vcl_v1) != EXIT_SUCCESS)
804 if (
check(ublas_v1, vcl_v1) != EXIT_SUCCESS)
810 if (
check(ublas_v1, vcl_v1) != EXIT_SUCCESS)
817 if (
check(ublas_v1, vcl_v1) != EXIT_SUCCESS)
823 if (
check(ublas_v1, vcl_v1) != EXIT_SUCCESS)
830 if (
check(ublas_v1, vcl_v1) != EXIT_SUCCESS)
836 if (
check(ublas_v1, vcl_v1) != EXIT_SUCCESS)
844 template<
typename NumericT >
847 int retval = EXIT_SUCCESS;
848 std::size_t
size = 12345;
850 std::cout <<
"Running tests for vector of size " << size << std::endl;
855 ublas::vector<NumericT> ublas_full_vec(size);
856 ublas::vector<NumericT> ublas_full_vec2(ublas_full_vec.size());
858 for (std::size_t i=0; i<ublas_full_vec.size(); ++i)
860 ublas_full_vec[i] = NumericT(1.0) + NumericT(i);
861 ublas_full_vec2[i] = NumericT(2.0) + NumericT(i) / NumericT(2);
864 ublas::range r1( ublas_full_vec.size() / 4, 2 * ublas_full_vec.size() / 4);
865 ublas::range r2(2 * ublas_full_vec2.size() / 4, 3 * ublas_full_vec2.size() / 4);
866 ublas::vector_range< ublas::vector<NumericT> > ublas_range_vec(ublas_full_vec, r1);
867 ublas::vector_range< ublas::vector<NumericT> > ublas_range_vec2(ublas_full_vec2, r2);
869 ublas::slice s1( ublas_full_vec.size() / 4, 3, ublas_full_vec.size() / 4);
870 ublas::slice s2(2 * ublas_full_vec2.size() / 4, 2, ublas_full_vec2.size() / 4);
871 ublas::vector_slice< ublas::vector<NumericT> > ublas_slice_vec(ublas_full_vec,
s1);
872 ublas::vector_slice< ublas::vector<NumericT> > ublas_slice_vec2(ublas_full_vec2,
s2);
881 viennacl::copy(ublas_full_vec2.begin(), ublas_full_vec2.end(), vcl_full_vec2.begin());
883 viennacl::range vcl_r1( vcl_full_vec.size() / 4, 2 * vcl_full_vec.size() / 4);
884 viennacl::range vcl_r2(2 * vcl_full_vec2.size() / 4, 3 * vcl_full_vec2.size() / 4);
892 ublas::vector<NumericT> ublas_short_vec(ublas_range_vec);
893 ublas::vector<NumericT> ublas_short_vec2(ublas_range_vec2);
895 std::cout <<
"Testing creation of vectors from range..." << std::endl;
896 if (
check(ublas_short_vec, vcl_short_vec) != EXIT_SUCCESS)
898 if (
check(ublas_short_vec2, vcl_short_vec2) != EXIT_SUCCESS)
902 viennacl::slice vcl_s1( vcl_full_vec.size() / 4, 3, vcl_full_vec.size() / 4);
903 viennacl::slice vcl_s2(2 * vcl_full_vec2.size() / 4, 2, vcl_full_vec2.size() / 4);
910 ublas::vector<NumericT> ublas_short_vec(ublas_slice_vec);
911 ublas::vector<NumericT> ublas_short_vec2(ublas_slice_vec2);
913 std::cout <<
"Testing creation of vectors from slice..." << std::endl;
914 if (
check(ublas_short_vec, vcl_short_vec) != EXIT_SUCCESS)
916 if (
check(ublas_short_vec2, vcl_short_vec2) != EXIT_SUCCESS)
924 std::cout <<
" ** vcl_v1 = vector, vcl_v2 = vector **" << std::endl;
925 retval = test<NumericT>(ublas_short_vec, ublas_short_vec2,
926 vcl_short_vec, vcl_short_vec2);
927 if (retval != EXIT_SUCCESS)
930 std::cout <<
" ** vcl_v1 = vector, vcl_v2 = range **" << std::endl;
931 retval = test<NumericT>(ublas_short_vec, ublas_short_vec2,
932 vcl_short_vec, vcl_range_vec2);
933 if (retval != EXIT_SUCCESS)
936 std::cout <<
" ** vcl_v1 = vector, vcl_v2 = slice **" << std::endl;
937 retval = test<NumericT>(ublas_short_vec, ublas_short_vec2,
938 vcl_short_vec, vcl_slice_vec2);
939 if (retval != EXIT_SUCCESS)
944 std::cout <<
" ** vcl_v1 = range, vcl_v2 = vector **" << std::endl;
945 retval = test<NumericT>(ublas_short_vec, ublas_short_vec2,
946 vcl_range_vec, vcl_short_vec2);
947 if (retval != EXIT_SUCCESS)
950 std::cout <<
" ** vcl_v1 = range, vcl_v2 = range **" << std::endl;
951 retval = test<NumericT>(ublas_short_vec, ublas_short_vec2,
952 vcl_range_vec, vcl_range_vec2);
953 if (retval != EXIT_SUCCESS)
956 std::cout <<
" ** vcl_v1 = range, vcl_v2 = slice **" << std::endl;
957 retval = test<NumericT>(ublas_short_vec, ublas_short_vec2,
958 vcl_range_vec, vcl_slice_vec2);
959 if (retval != EXIT_SUCCESS)
964 std::cout <<
" ** vcl_v1 = slice, vcl_v2 = vector **" << std::endl;
965 retval = test<NumericT>(ublas_short_vec, ublas_short_vec2,
966 vcl_slice_vec, vcl_short_vec2);
967 if (retval != EXIT_SUCCESS)
970 std::cout <<
" ** vcl_v1 = slice, vcl_v2 = range **" << std::endl;
971 retval = test<NumericT>(ublas_short_vec, ublas_short_vec2,
972 vcl_slice_vec, vcl_range_vec2);
973 if (retval != EXIT_SUCCESS)
976 std::cout <<
" ** vcl_v1 = slice, vcl_v2 = slice **" << std::endl;
977 retval = test<NumericT>(ublas_short_vec, ublas_short_vec2,
978 vcl_slice_vec, vcl_slice_vec2);
979 if (retval != EXIT_SUCCESS)
992 std::cout << std::endl;
993 std::cout <<
"----------------------------------------------" << std::endl;
994 std::cout <<
"----------------------------------------------" << std::endl;
995 std::cout <<
"## Test :: Vector with Integer types" << std::endl;
996 std::cout <<
"----------------------------------------------" << std::endl;
997 std::cout <<
"----------------------------------------------" << std::endl;
998 std::cout << std::endl;
1000 int retval = EXIT_SUCCESS;
1002 std::cout << std::endl;
1003 std::cout <<
"----------------------------------------------" << std::endl;
1004 std::cout << std::endl;
1006 std::cout <<
"# Testing setup:" << std::endl;
1007 std::cout <<
" numeric: unsigned int" << std::endl;
1008 retval = test<unsigned int>();
1009 if ( retval == EXIT_SUCCESS )
1010 std::cout <<
"# Test passed" << std::endl;
1014 std::cout << std::endl;
1015 std::cout <<
"----------------------------------------------" << std::endl;
1016 std::cout << std::endl;
1018 std::cout <<
"# Testing setup:" << std::endl;
1019 std::cout <<
" numeric: long" << std::endl;
1020 retval = test<unsigned long>();
1021 if ( retval == EXIT_SUCCESS )
1022 std::cout <<
"# Test passed" << std::endl;
1026 std::cout << std::endl;
1027 std::cout <<
"----------------------------------------------" << std::endl;
1028 std::cout << std::endl;
1030 std::cout << std::endl;
1031 std::cout <<
"------- Test completed --------" << std::endl;
1032 std::cout << std::endl;
int test(UblasVectorType &ublas_v1, UblasVectorType &ublas_v2, ViennaCLVectorType1 &vcl_v1, ViennaCLVectorType2 &vcl_v2)
viennacl::vector_expression< const vector_base< T >, const vector_base< T >, op_element_binary< op_div > > element_div(vector_base< T > const &v1, vector_base< T > const &v2)
vcl_size_t index_norm_inf(vector_base< T > const &vec)
Computes the index of the first entry that is equal to the supremum-norm in modulus.
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...
int check(T1 const &t1, T2 const &t2)
void finish()
Synchronizes the execution. finish() will only return after all compute kernels (CUDA, OpenCL) have completed.
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...
viennacl::vector< float > v1
vcl_size_t size(VectorType const &vec)
Generic routine for obtaining the size of a vector (ViennaCL, uBLAS, etc.)
Class for representing non-strided subvectors of a bigger vector x.
Class for representing strided subvectors of a bigger vector x.
Proxy classes for vectors.
viennacl::enable_if< viennacl::is_scalar< ScalarT1 >::value &&viennacl::is_scalar< ScalarT2 >::value >::type swap(ScalarT1 &s1, ScalarT2 &s2)
Swaps the contents of two scalars, data is copied.
ScalarType diff(ScalarType const &s1, ScalarType const &s2)
Represents a vector consisting of 1 at a given index and zeros otherwise.
viennacl::vector< int > v2
The vector type with operator-overloads and proxy classes is defined here. Linear algebra operations ...
Represents a vector consisting of scalars 's' only, i.e. v[i] = s for all i. To be used as an initial...
NumericT max(std::vector< NumericT > const &v1)
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) ...
T norm_1(std::vector< T, A > const &v1)
A range class that refers to an interval [start, stop), where 'start' is included, and 'stop' is excluded.
viennacl::vector_expression< const vector_base< T >, const vector_base< T >, op_element_binary< op_prod > > element_prod(vector_base< T > const &v1, vector_base< T > const &v2)
A slice class that refers to an interval [start, stop), where 'start' is included, and 'stop' is excluded.
A proxy class for a single element of a vector or matrix. This proxy should not be noticed by end-use...
Generic interface for the l^infty-norm. See viennacl/linalg/vector_operations.hpp for implementations...
NumericT min(std::vector< NumericT > const &v1)
void fast_copy(const const_vector_iterator< SCALARTYPE, ALIGNMENT > &gpu_begin, const const_vector_iterator< SCALARTYPE, ALIGNMENT > &gpu_end, CPU_ITERATOR cpu_begin)