34 template<
typename NumericT,
typename VCLMatrixType>
35 bool check_for_equality(std::vector<std::vector<NumericT> >
const & std_A, VCLMatrixType
const & vcl_A)
37 std::vector<std::vector<NumericT> > vcl_A_cpu(vcl_A.size1(), std::vector<NumericT>(vcl_A.size2()));
41 for (std::size_t i=0; i<std_A.size(); ++i)
43 for (std::size_t j=0; j<std_A[i].size(); ++j)
45 if (std_A[i][j] != vcl_A_cpu[i][j])
47 std::cout <<
"Error at index (" << i <<
", " << j <<
"): " << std_A[i][j] <<
" vs " << vcl_A_cpu[i][j] << std::endl;
48 std::cout << std::endl <<
"TEST failed!" << std::endl;
54 std::cout <<
"PASSED!" << std::endl;
61 template<
typename STLMatrixType,
62 typename ViennaCLMatrixType1,
typename ViennaCLMatrixType2,
typename ViennaCLMatrixType3>
63 int run_test(STLMatrixType & std_A, STLMatrixType & std_B, STLMatrixType & std_C,
64 ViennaCLMatrixType1 & vcl_A, ViennaCLMatrixType2 & vcl_B, ViennaCLMatrixType3 vcl_C)
69 cpu_value_type alpha = 3;
72 cpu_value_type beta = 2;
79 std::cout <<
"Checking for zero_matrix initializer..." << std::endl;
80 std_A = std::vector<std::vector<cpu_value_type> >(std_A.size(), std::vector<cpu_value_type>(std_A[0].size()));
85 std::cout <<
"Checking for scalar_matrix initializer..." << std::endl;
86 std_A = std::vector<std::vector<cpu_value_type> >(std_A.size(), std::vector<cpu_value_type>(std_A[0].size(), alpha));
91 std_A = std::vector<std::vector<cpu_value_type> >(std_A.size(), std::vector<cpu_value_type>(std_A[0].size(), gpu_beta));
104 std::cout << std::endl;
112 std::cout <<
"Testing matrix assignment... ";
128 std::cout <<
"Testing upper left copy to GPU... ";
135 std::cout <<
"Testing lower right copy to GPU... ";
145 std::cout <<
"Testing upper left copy to A... ";
149 std::cout <<
"Testing lower right copy to C... ";
160 std::cout <<
"Inplace add: ";
161 for (std::size_t i=0; i<std_C.size(); ++i)
162 for (std::size_t j=0; j<std_C[i].size(); ++j)
163 std_C[i][j] += std_C[i][j];
169 std::cout <<
"Scaled inplace add: ";
170 for (std::size_t i=0; i<std_C.size(); ++i)
171 for (std::size_t j=0; j<std_C[i].size(); ++j)
172 std_C[i][j] += beta * std_A[i][j];
173 vcl_C += gpu_beta * vcl_A;
178 std::cout <<
"Add: ";
179 for (std::size_t i=0; i<std_C.size(); ++i)
180 for (std::size_t j=0; j<std_C[i].size(); ++j)
181 std_C[i][j] = std_A[i][j] + std_B[i][j];
182 vcl_C = vcl_A + vcl_B;
187 std::cout <<
"Add with flipsign: ";
188 for (std::size_t i=0; i<std_C.size(); ++i)
189 for (std::size_t j=0; j<std_C[i].size(); ++j)
190 std_C[i][j] = -std_A[i][j] + std_B[i][j];
191 vcl_C = - vcl_A + vcl_B;
197 std::cout <<
"Scaled add (left): ";
198 for (std::size_t i=0; i<std_C.size(); ++i)
199 for (std::size_t j=0; j<std_C[i].size(); ++j)
200 std_C[i][j] = alpha * std_A[i][j] + std_B[i][j];
201 vcl_C = alpha * vcl_A + vcl_B;
206 std::cout <<
"Scaled add (left): ";
207 vcl_C = gpu_alpha * vcl_A + vcl_B;
212 std::cout <<
"Scaled add (right): ";
213 for (std::size_t i=0; i<std_C.size(); ++i)
214 for (std::size_t j=0; j<std_C[i].size(); ++j)
215 std_C[i][j] = std_A[i][j] + beta * std_B[i][j];
216 vcl_C = vcl_A + beta * vcl_B;
221 std::cout <<
"Scaled add (right): ";
222 vcl_C = vcl_A + gpu_beta * vcl_B;
228 std::cout <<
"Scaled add (both): ";
229 for (std::size_t i=0; i<std_C.size(); ++i)
230 for (std::size_t j=0; j<std_C[i].size(); ++j)
231 std_C[i][j] = alpha * std_A[i][j] + beta * std_B[i][j];
232 vcl_C = alpha * vcl_A + beta * vcl_B;
237 std::cout <<
"Scaled add (both): ";
238 vcl_C = gpu_alpha * vcl_A + gpu_beta * vcl_B;
247 std::cout <<
"Inplace sub: ";
248 for (std::size_t i=0; i<std_C.size(); ++i)
249 for (std::size_t j=0; j<std_C[i].size(); ++j)
250 std_C[i][j] -= std_B[i][j];
256 std::cout <<
"Scaled Inplace sub: ";
257 for (std::size_t i=0; i<std_C.size(); ++i)
258 for (std::size_t j=0; j<std_C[i].size(); ++j)
259 std_C[i][j] -= alpha * std_B[i][j];
260 vcl_C -= alpha * vcl_B;
268 std::cout <<
"Sub: ";
269 for (std::size_t i=0; i<std_C.size(); ++i)
270 for (std::size_t j=0; j<std_C[i].size(); ++j)
271 std_C[i][j] = std_A[i][j] - std_B[i][j];
272 vcl_C = vcl_A - vcl_B;
277 std::cout <<
"Scaled sub (left): ";
278 for (std::size_t i=0; i<std_C.size(); ++i)
279 for (std::size_t j=0; j<std_C[i].size(); ++j)
280 std_B[i][j] = alpha * std_A[i][j] - std_C[i][j];
281 vcl_B = alpha * vcl_A - vcl_C;
286 std::cout <<
"Scaled sub (left): ";
287 vcl_B = gpu_alpha * vcl_A - vcl_C;
292 std::cout <<
"Scaled sub (right): ";
293 for (std::size_t i=0; i<std_C.size(); ++i)
294 for (std::size_t j=0; j<std_C[i].size(); ++j)
295 std_B[i][j] = std_A[i][j] - beta * std_C[i][j];
296 vcl_B = vcl_A - vcl_C * beta;
301 std::cout <<
"Scaled sub (right): ";
302 vcl_B = vcl_A - vcl_C * gpu_beta;
307 std::cout <<
"Scaled sub (both): ";
308 for (std::size_t i=0; i<std_C.size(); ++i)
309 for (std::size_t j=0; j<std_C[i].size(); ++j)
310 std_B[i][j] = alpha * std_A[i][j] - beta * std_C[i][j];
311 vcl_B = alpha * vcl_A - vcl_C * beta;
316 std::cout <<
"Scaled sub (both): ";
317 vcl_B = gpu_alpha * vcl_A - vcl_C * gpu_beta;
322 std::cout <<
"Unary operator-: ";
323 for (std::size_t i=0; i<std_C.size(); ++i)
324 for (std::size_t j=0; j<std_C[i].size(); ++j)
325 std_C[i][j] = - std_A[i][j];
338 std::cout <<
"Multiplication with CPU scalar: ";
339 for (std::size_t i=0; i<std_C.size(); ++i)
340 for (std::size_t j=0; j<std_C[i].size(); ++j)
341 std_A[i][j] *= alpha;
347 std::cout <<
"Multiplication with GPU scalar: ";
348 for (std::size_t i=0; i<std_C.size(); ++i)
349 for (std::size_t j=0; j<std_C[i].size(); ++j)
357 std::cout <<
"Division with CPU scalar: ";
358 for (std::size_t i=0; i<std_C.size(); ++i)
359 for (std::size_t j=0; j<std_C[i].size(); ++j)
360 std_A[i][j] /= alpha;
366 std::cout <<
"Division with GPU scalar: ";
367 for (std::size_t i=0; i<std_C.size(); ++i)
368 for (std::size_t j=0; j<std_C[i].size(); ++j)
377 std::cout <<
"Testing elementwise multiplication..." << std::endl;
378 std_B = std::vector<std::vector<cpu_value_type> >(std_B.size(), std::vector<cpu_value_type>(std_B[0].size(), 2));
379 for (std::size_t i=0; i<std_C.size(); ++i)
380 for (std::size_t j=0; j<std_C[i].size(); ++j)
381 std_A[i][j] = 3 * std_B[i][j];
385 for (std::size_t i=0; i<std_A.size(); ++i)
386 for (std::size_t j=0; j<std_A[i].size(); ++j)
387 std_A[i][j] = std_A[i][j] * std_B[i][j];
393 for (std::size_t i=0; i<std_A.size(); ++i)
394 for (std::size_t j=0; j<std_A[i].size(); ++j)
395 std_A[i][j] += std_A[i][j] * std_B[i][j];
401 for (std::size_t i=0; i<std_A.size(); ++i)
402 for (std::size_t j=0; j<std_A[i].size(); ++j)
403 std_A[i][j] -= std_A[i][j] * std_B[i][j];
410 for (std::size_t i=0; i<std_A.size(); ++i)
411 for (std::size_t j=0; j<std_A[i].size(); ++j)
412 std_A[i][j] = (std_A[i][j] + std_B[i][j]) * std_B[i][j];
418 for (std::size_t i=0; i<std_A.size(); ++i)
419 for (std::size_t j=0; j<std_A[i].size(); ++j)
420 std_A[i][j] += (std_A[i][j] + std_B[i][j]) * std_B[i][j];
426 for (std::size_t i=0; i<std_A.size(); ++i)
427 for (std::size_t j=0; j<std_A[i].size(); ++j)
428 std_A[i][j] -= (std_A[i][j] + std_B[i][j]) * std_B[i][j];
435 for (std::size_t i=0; i<std_A.size(); ++i)
436 for (std::size_t j=0; j<std_A[i].size(); ++j)
437 std_A[i][j] = std_A[i][j] * (std_B[i][j] + std_A[i][j]);
443 for (std::size_t i=0; i<std_A.size(); ++i)
444 for (std::size_t j=0; j<std_A[i].size(); ++j)
445 std_A[i][j] += std_A[i][j] * (std_B[i][j] + std_A[i][j]);
451 for (std::size_t i=0; i<std_A.size(); ++i)
452 for (std::size_t j=0; j<std_A[i].size(); ++j)
453 std_A[i][j] -= std_A[i][j] * (std_B[i][j] + std_A[i][j]);
460 for (std::size_t i=0; i<std_A.size(); ++i)
461 for (std::size_t j=0; j<std_A[i].size(); ++j)
462 std_A[i][j] = (std_A[i][j] + std_B[i][j]) * (std_B[i][j] + std_A[i][j]);
468 for (std::size_t i=0; i<std_A.size(); ++i)
469 for (std::size_t j=0; j<std_A[i].size(); ++j)
470 std_A[i][j] += (std_A[i][j] + std_B[i][j]) * (std_B[i][j] + std_A[i][j]);
476 for (std::size_t i=0; i<std_A.size(); ++i)
477 for (std::size_t j=0; j<std_A[i].size(); ++j)
478 std_A[i][j] -= (std_A[i][j] + std_B[i][j]) * (std_B[i][j] + std_A[i][j]);
485 std_B = std::vector<std::vector<cpu_value_type> >(std_B.size(), std::vector<cpu_value_type>(std_B[0].size(), 2));
486 for (std::size_t i=0; i<std_A.size(); ++i)
487 for (std::size_t j=0; j<std_A[i].size(); ++j)
488 std_A[i][j] = 3 * std_B[i][j];
493 for (std::size_t i=0; i<std_A.size(); ++i)
494 for (std::size_t j=0; j<std_A[i].size(); ++j)
495 std_A[i][j] = std_A[i][j] / std_B[i][j];
501 for (std::size_t i=0; i<std_A.size(); ++i)
502 for (std::size_t j=0; j<std_A[i].size(); ++j)
503 std_A[i][j] += std_A[i][j] / std_B[i][j];
509 for (std::size_t i=0; i<std_A.size(); ++i)
510 for (std::size_t j=0; j<std_A[i].size(); ++j)
511 std_A[i][j] -= std_A[i][j] / std_B[i][j];
518 for (std::size_t i=0; i<std_A.size(); ++i)
519 for (std::size_t j=0; j<std_A[i].size(); ++j)
520 std_A[i][j] = (std_A[i][j] + std_B[i][j]) / std_B[i][j];
526 for (std::size_t i=0; i<std_A.size(); ++i)
527 for (std::size_t j=0; j<std_A[i].size(); ++j)
528 std_A[i][j] += (std_A[i][j] + std_B[i][j]) / std_B[i][j];
534 for (std::size_t i=0; i<std_A.size(); ++i)
535 for (std::size_t j=0; j<std_A[i].size(); ++j)
536 std_A[i][j] -= (std_A[i][j] + std_B[i][j]) / std_B[i][j];
543 for (std::size_t i=0; i<std_A.size(); ++i)
544 for (std::size_t j=0; j<std_A[i].size(); ++j)
545 std_A[i][j] = std_A[i][j] / (std_B[i][j] + std_A[i][j]);
551 for (std::size_t i=0; i<std_A.size(); ++i)
552 for (std::size_t j=0; j<std_A[i].size(); ++j)
553 std_A[i][j] += std_A[i][j] / (std_B[i][j] + std_A[i][j]);
559 for (std::size_t i=0; i<std_A.size(); ++i)
560 for (std::size_t j=0; j<std_A[i].size(); ++j)
561 std_A[i][j] -= std_A[i][j] / (std_B[i][j] + std_A[i][j]);
568 for (std::size_t i=0; i<std_A.size(); ++i)
569 for (std::size_t j=0; j<std_A[i].size(); ++j)
570 std_A[i][j] = (std_A[i][j] + std_B[i][j]) / (std_B[i][j] + std_A[i][j]);
576 for (std::size_t i=0; i<std_A.size(); ++i)
577 for (std::size_t j=0; j<std_A[i].size(); ++j)
578 std_A[i][j] += (std_A[i][j] + std_B[i][j]) / (std_B[i][j] + std_A[i][j]);
584 for (std::size_t i=0; i<std_A.size(); ++i)
585 for (std::size_t j=0; j<std_A[i].size(); ++j)
586 std_A[i][j] -= (std_A[i][j] + std_B[i][j]) / (std_B[i][j] + std_A[i][j]);
592 std::cout <<
"Testing unary elementwise operations..." << std::endl;
594 #define GENERATE_UNARY_OP_TEST(FUNCNAME) \
595 std_B = std::vector<std::vector<cpu_value_type> >(std_B.size(), std::vector<cpu_value_type>(std_B[0].size(), 1)); \
596 for (std::size_t i=0; i<std_A.size(); ++i) \
597 for (std::size_t j=0; j<std_A[i].size(); ++j) {\
598 std_A[i][j] = 3 * std_B[i][j]; \
599 std_C[i][j] = 2 * std_A[i][j]; \
601 viennacl::copy(std_A, vcl_A); \
602 viennacl::copy(std_B, vcl_B); \
603 viennacl::copy(std_C, vcl_C); \
604 viennacl::copy(std_B, vcl_B); \
606 for (std::size_t i=0; i<std_C.size(); ++i) \
607 for (std::size_t j=0; j<std_C[i].size(); ++j) \
608 std_C[i][j] = std::FUNCNAME(std_A[i][j]); \
609 vcl_C = viennacl::linalg::element_##FUNCNAME(vcl_A); \
611 if (!check_for_equality(std_C, vcl_C)) \
613 std::cout << "Failure at C = " << #FUNCNAME << "(A)" << std::endl; \
614 return EXIT_FAILURE; \
617 for (std::size_t i=0; i<std_C.size(); ++i) \
618 for (std::size_t j=0; j<std_C[i].size(); ++j) \
619 std_C[i][j] = std::FUNCNAME(std_A[i][j] + std_B[i][j]); \
620 vcl_C = viennacl::linalg::element_##FUNCNAME(vcl_A + vcl_B); \
622 if (!check_for_equality(std_C, vcl_C)) \
624 std::cout << "Failure at C = " << #FUNCNAME << "(A + B)" << std::endl; \
625 return EXIT_FAILURE; \
628 for (std::size_t i=0; i<std_C.size(); ++i) \
629 for (std::size_t j=0; j<std_C[i].size(); ++j) \
630 std_C[i][j] += std::FUNCNAME(std_A[i][j]); \
631 vcl_C += viennacl::linalg::element_##FUNCNAME(vcl_A); \
633 if (!check_for_equality(std_C, vcl_C)) \
635 std::cout << "Failure at C += " << #FUNCNAME << "(A)" << std::endl; \
636 return EXIT_FAILURE; \
639 for (std::size_t i=0; i<std_C.size(); ++i) \
640 for (std::size_t j=0; j<std_C[i].size(); ++j) \
641 std_C[i][j] += std::FUNCNAME(std_A[i][j] + std_B[i][j]); \
642 vcl_C += viennacl::linalg::element_##FUNCNAME(vcl_A + vcl_B); \
644 if (!check_for_equality(std_C, vcl_C)) \
646 std::cout << "Failure at C += " << #FUNCNAME << "(A + B)" << std::endl; \
647 return EXIT_FAILURE; \
650 for (std::size_t i=0; i<std_C.size(); ++i) \
651 for (std::size_t j=0; j<std_C[i].size(); ++j) \
652 std_C[i][j] -= std::FUNCNAME(std_A[i][j]); \
653 vcl_C -= viennacl::linalg::element_##FUNCNAME(vcl_A); \
655 if (!check_for_equality(std_C, vcl_C)) \
657 std::cout << "Failure at C -= " << #FUNCNAME << "(A)" << std::endl; \
658 return EXIT_FAILURE; \
661 for (std::size_t i=0; i<std_C.size(); ++i) \
662 for (std::size_t j=0; j<std_C[i].size(); ++j) \
663 std_C[i][j] -= std::FUNCNAME(std_A[i][j] + std_B[i][j]); \
664 vcl_C -= viennacl::linalg::element_##FUNCNAME(vcl_A + vcl_B); \
666 if (!check_for_equality(std_C, vcl_C)) \
668 std::cout << "Failure at C -= " << #FUNCNAME << "(A + B)" << std::endl; \
669 return EXIT_FAILURE; \
675 std::cout <<
"Complicated expressions: ";
679 for (std::size_t i=0; i<std_A.size(); ++i)
680 for (std::size_t j=0; j<std_A[i].size(); ++j)
681 std_B[i][j] += alpha * (- std_A[i][j] - beta * std_C[i][j] + std_A[i][j]);
682 vcl_B += gpu_alpha * (- vcl_A - vcl_C * beta + vcl_A);
687 for (std::size_t i=0; i<std_A.size(); ++i)
688 for (std::size_t j=0; j<std_A[i].size(); ++j)
689 std_B[i][j] += (- std_A[i][j] - beta * std_C[i][j] + std_A[i][j] * beta) / gpu_alpha;
690 vcl_B += (- vcl_A - vcl_C * beta + gpu_beta * vcl_A) / gpu_alpha;
696 for (std::size_t i=0; i<std_A.size(); ++i)
697 for (std::size_t j=0; j<std_A[i].size(); ++j)
698 std_B[i][j] -= alpha * (- std_A[i][j] - beta * std_C[i][j] - std_A[i][j]);
699 vcl_B -= gpu_alpha * (- vcl_A - vcl_C * beta - vcl_A);
704 for (std::size_t i=0; i<std_A.size(); ++i)
705 for (std::size_t j=0; j<std_A[i].size(); ++j)
706 std_B[i][j] -= (- std_A[i][j] - beta * std_C[i][j] - std_A[i][j] * beta) / alpha;
707 vcl_B -= (- vcl_A - vcl_C * beta - gpu_beta * vcl_A) / gpu_alpha;
712 std::cout << std::endl;
713 std::cout <<
"----------------------------------------------" << std::endl;
714 std::cout << std::endl;
723 template<
typename T,
typename ScalarType>
728 std::size_t dim_rows = 131;
729 std::size_t dim_cols = 33;
734 std::vector<std::vector<ScalarType> > std_A(dim_rows, std::vector<ScalarType>(dim_cols));
735 std::vector<std::vector<ScalarType> > std_B(dim_rows, std::vector<ScalarType>(dim_cols));
736 std::vector<std::vector<ScalarType> > std_C(dim_rows, std::vector<ScalarType>(dim_cols));
738 for (std::size_t i=0; i<std_A.size(); ++i)
739 for (std::size_t j=0; j<std_A[i].size(); ++j)
741 std_A[i][j] =
ScalarType((i+2) + (j+1)*(i+2));
742 std_B[i][j] =
ScalarType((j+2) + (j+1)*(j+2));
743 std_C[i][j] =
ScalarType((i+1) + (i+1)*(i+2));
746 std::vector<std::vector<ScalarType> > std_A_large(4 * dim_rows, std::vector<ScalarType>(4 * dim_cols));
747 for (std::size_t i=0; i<std_A_large.size(); ++i)
748 for (std::size_t j=0; j<std_A_large[i].size(); ++j)
752 VCLMatrixType vcl_A_full(4 * dim_rows, 4 * dim_cols);
753 VCLMatrixType vcl_B_full(4 * dim_rows, 4 * dim_cols);
754 VCLMatrixType vcl_C_full(4 * dim_rows, 4 * dim_cols);
763 VCLMatrixType vcl_A(dim_rows, dim_cols);
777 VCLMatrixType vcl_B(dim_rows, dim_cols);
791 VCLMatrixType vcl_C(dim_rows, dim_cols);
814 std::cout << std::endl;
815 std::cout <<
"//" << std::endl;
816 std::cout <<
"////////// Test: Copy CTOR //////////" << std::endl;
817 std::cout <<
"//" << std::endl;
820 std::cout <<
"Testing matrix created from range... ";
821 VCLMatrixType vcl_temp = vcl_range_A;
823 std::cout <<
"PASSED!" << std::endl;
826 std::cout <<
"vcl_temp: " << vcl_temp << std::endl;
827 std::cout <<
"vcl_range_A: " << vcl_range_A << std::endl;
828 std::cout <<
"vcl_A: " << vcl_A << std::endl;
829 std::cout << std::endl <<
"TEST failed!" << std::endl;
833 std::cout <<
"Testing matrix created from slice... ";
834 VCLMatrixType vcl_temp2 = vcl_range_B;
836 std::cout <<
"PASSED!" << std::endl;
839 std::cout << std::endl <<
"TEST failed!" << std::endl;
844 std::cout <<
"//" << std::endl;
845 std::cout <<
"////////// Test: Initializer for matrix type //////////" << std::endl;
846 std::cout <<
"//" << std::endl;
849 std::vector<std::vector<ScalarType> > std_dummy1(std_A.size(), std::vector<ScalarType>(std_A.size()));
850 for (std::size_t i=0; i<std_A.size(); ++i) std_dummy1[i][i] =
ScalarType(1);
851 std::vector<std::vector<ScalarType> > std_dummy2(std_A.size(), std::vector<ScalarType>(std_A.size(), 3));
852 std::vector<std::vector<ScalarType> > std_dummy3(std_A.size(), std::vector<ScalarType>(std_A.size()));
858 std::cout <<
"Testing initializer CTOR... ";
863 std::cout <<
"PASSED!" << std::endl;
866 std::cout << std::endl <<
"TEST failed!" << std::endl;
870 std_dummy1 = std::vector<std::vector<ScalarType> >(std_A.size(), std::vector<ScalarType>(std_A.size()));
871 std_dummy2 = std::vector<std::vector<ScalarType> >(std_A.size(), std::vector<ScalarType>(std_A.size()));
872 for (std::size_t i=0; i<std_A.size(); ++i) std_dummy2[i][i] =
ScalarType(1);
873 std_dummy3 = std::vector<std::vector<ScalarType> >(std_A.size(), std::vector<ScalarType>(std_A.size(), 3));
879 std::cout <<
"Testing initializer assignment... ";
884 std::cout <<
"PASSED!" << std::endl;
887 std::cout << std::endl <<
"TEST failed!" << std::endl;
898 std::cout <<
"Testing A=matrix, B=matrix, C=matrix ..." << std::endl;
903 vcl_A, vcl_B, vcl_C) != EXIT_SUCCESS)
908 std::cout <<
"Testing A=matrix, B=matrix, C=range ..." << std::endl;
913 vcl_A, vcl_B, vcl_range_C) != EXIT_SUCCESS)
918 std::cout <<
"Testing A=matrix, B=matrix, C=slice ..." << std::endl;
923 vcl_A, vcl_B, vcl_slice_C) != EXIT_SUCCESS)
928 std::cout <<
"Testing A=matrix, B=range, C=matrix ..." << std::endl;
933 vcl_A, vcl_range_B, vcl_C) != EXIT_SUCCESS)
938 std::cout <<
"Testing A=matrix, B=range, C=range ..." << std::endl;
943 vcl_A, vcl_range_B, vcl_range_C) != EXIT_SUCCESS)
948 std::cout <<
"Testing A=matrix, B=range, C=slice ..." << std::endl;
953 vcl_A, vcl_range_B, vcl_slice_C) != EXIT_SUCCESS)
959 std::cout <<
"Testing A=matrix, B=slice, C=matrix ..." << std::endl;
964 vcl_A, vcl_slice_B, vcl_C) != EXIT_SUCCESS)
969 std::cout <<
"Testing A=matrix, B=slice, C=range ..." << std::endl;
974 vcl_A, vcl_slice_B, vcl_range_C) != EXIT_SUCCESS)
979 std::cout <<
"Testing A=matrix, B=slice, C=slice ..." << std::endl;
984 vcl_A, vcl_slice_B, vcl_slice_C) != EXIT_SUCCESS)
992 std::cout <<
"Testing A=range, B=matrix, C=matrix ..." << std::endl;
997 vcl_range_A, vcl_B, vcl_C) != EXIT_SUCCESS)
1002 std::cout <<
"Testing A=range, B=matrix, C=range ..." << std::endl;
1007 vcl_range_A, vcl_B, vcl_range_C) != EXIT_SUCCESS)
1009 return EXIT_FAILURE;
1012 std::cout <<
"Testing A=range, B=matrix, C=slice ..." << std::endl;
1017 vcl_range_A, vcl_B, vcl_slice_C) != EXIT_SUCCESS)
1019 return EXIT_FAILURE;
1024 std::cout <<
"Testing A=range, B=range, C=matrix ..." << std::endl;
1029 vcl_range_A, vcl_range_B, vcl_C) != EXIT_SUCCESS)
1031 return EXIT_FAILURE;
1034 std::cout <<
"Testing A=range, B=range, C=range ..." << std::endl;
1039 vcl_range_A, vcl_range_B, vcl_range_C) != EXIT_SUCCESS)
1041 return EXIT_FAILURE;
1044 std::cout <<
"Testing A=range, B=range, C=slice ..." << std::endl;
1049 vcl_range_A, vcl_range_B, vcl_slice_C) != EXIT_SUCCESS)
1051 return EXIT_FAILURE;
1056 std::cout <<
"Testing A=range, B=slice, C=matrix ..." << std::endl;
1061 vcl_range_A, vcl_slice_B, vcl_C) != EXIT_SUCCESS)
1063 return EXIT_FAILURE;
1066 std::cout <<
"Testing A=range, B=slice, C=range ..." << std::endl;
1071 vcl_range_A, vcl_slice_B, vcl_range_C) != EXIT_SUCCESS)
1073 return EXIT_FAILURE;
1076 std::cout <<
"Testing A=range, B=slice, C=slice ..." << std::endl;
1081 vcl_range_A, vcl_slice_B, vcl_slice_C) != EXIT_SUCCESS)
1083 return EXIT_FAILURE;
1088 std::cout <<
"Testing A=slice, B=matrix, C=matrix ..." << std::endl;
1093 vcl_slice_A, vcl_B, vcl_C) != EXIT_SUCCESS)
1095 return EXIT_FAILURE;
1098 std::cout <<
"Testing A=slice, B=matrix, C=range ..." << std::endl;
1103 vcl_slice_A, vcl_B, vcl_range_C) != EXIT_SUCCESS)
1105 return EXIT_FAILURE;
1108 std::cout <<
"Testing A=slice, B=matrix, C=slice ..." << std::endl;
1113 vcl_slice_A, vcl_B, vcl_slice_C) != EXIT_SUCCESS)
1115 return EXIT_FAILURE;
1120 std::cout <<
"Testing A=slice, B=range, C=matrix ..." << std::endl;
1125 vcl_slice_A, vcl_range_B, vcl_C) != EXIT_SUCCESS)
1127 return EXIT_FAILURE;
1130 std::cout <<
"Testing A=slice, B=range, C=range ..." << std::endl;
1135 vcl_slice_A, vcl_range_B, vcl_range_C) != EXIT_SUCCESS)
1137 return EXIT_FAILURE;
1140 std::cout <<
"Testing A=slice, B=range, C=slice ..." << std::endl;
1145 vcl_slice_A, vcl_range_B, vcl_slice_C) != EXIT_SUCCESS)
1147 return EXIT_FAILURE;
1152 std::cout <<
"Testing A=slice, B=slice, C=matrix ..." << std::endl;
1157 vcl_slice_A, vcl_slice_B, vcl_C) != EXIT_SUCCESS)
1159 return EXIT_FAILURE;
1162 std::cout <<
"Testing A=slice, B=slice, C=range ..." << std::endl;
1167 vcl_slice_A, vcl_slice_B, vcl_range_C) != EXIT_SUCCESS)
1169 return EXIT_FAILURE;
1172 std::cout <<
"Testing A=slice, B=slice, C=slice ..." << std::endl;
1177 vcl_slice_A, vcl_slice_B, vcl_slice_C) != EXIT_SUCCESS)
1179 return EXIT_FAILURE;
1183 return EXIT_SUCCESS;
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)
This class represents a single scalar value on the GPU and behaves mostly like a built-in scalar type...
bool check_for_equality(std::vector< std::vector< NumericT > > const &std_A, VCLMatrixType const &vcl_A)
Class for representing strided submatrices of a bigger matrix A.
Generic interface for matrix-vector and matrix-matrix products. See viennacl/linalg/vector_operations...
Implementation of the dense matrix class.
void finish()
Synchronizes the execution. finish() will only return after all compute kernels (CUDA, OpenCL) have completed.
Represents a vector consisting of 1 at a given index and zeros otherwise. To be used as an initialize...
int run_test(STLMatrixType &std_A, STLMatrixType &std_B, STLMatrixType &std_C, ViennaCLMatrixType1 &vcl_A, ViennaCLMatrixType2 &vcl_B, ViennaCLMatrixType3 vcl_C)
vcl_size_t size(VectorType const &vec)
Generic routine for obtaining the size of a vector (ViennaCL, uBLAS, etc.)
Represents a vector consisting of scalars 's' only, i.e. v[i] = s for all i. To be used as an initial...
#define GENERATE_UNARY_OP_TEST(FUNCNAME)
Represents a vector consisting of zeros only. To be used as an initializer for viennacl::vector, vector_range, or vector_slize only.
T::ERROR_CANNOT_DEDUCE_CPU_SCALAR_TYPE_FOR_T type
Proxy classes for vectors.
Proxy classes for matrices.
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 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)
Class for representing non-strided submatrices of a bigger matrix A.
A slice class that refers to an interval [start, stop), where 'start' is included, and 'stop' is excluded.
Implementation of the ViennaCL scalar class.