18 #define VIENNACL_WITH_UBLAS
23 #define BOOST_UBLAS_NDEBUG
47 #include "boost/numeric/ublas/vector.hpp"
48 #include "boost/numeric/ublas/matrix.hpp"
49 #include "boost/numeric/ublas/matrix_proxy.hpp"
50 #include "boost/numeric/ublas/vector_proxy.hpp"
51 #include "boost/numeric/ublas/io.hpp"
53 template<
typename MatrixType,
typename VCLMatrixType>
56 typedef typename MatrixType::value_type value_type;
58 boost::numeric::ublas::matrix<value_type> vcl_A_cpu(vcl_A.size1(), vcl_A.size2());
62 for (std::size_t i=0; i<ublas_A.size1(); ++i)
64 for (std::size_t j=0; j<ublas_A.size2(); ++j)
66 if (std::fabs(ublas_A(i,j) - vcl_A_cpu(i,j)) > 0)
68 if ( (std::abs(ublas_A(i,j) - vcl_A_cpu(i,j)) /
std::max(std::fabs(ublas_A(i,j)), std::fabs(vcl_A_cpu(i,j))) > epsilon) || std::fabs(vcl_A_cpu(i,j) - vcl_A_cpu(i,j)) > 0 )
70 std::cout <<
"Error at index (" << i <<
", " << j <<
"): " << ublas_A(i,j) <<
" vs " << vcl_A_cpu(i,j) << std::endl;
71 std::cout << std::endl <<
"TEST failed!" << std::endl;
78 std::cout <<
"PASSED!" << std::endl;
85 template<
typename UBLASMatrixType,
86 typename ViennaCLMatrixType1,
typename ViennaCLMatrixType2,
typename ViennaCLMatrixType3>
88 UBLASMatrixType & ublas_A, UBLASMatrixType & ublas_B, UBLASMatrixType & ublas_C,
89 ViennaCLMatrixType1 & vcl_A, ViennaCLMatrixType2 & vcl_B, ViennaCLMatrixType3 vcl_C)
94 cpu_value_type alpha = cpu_value_type(3.1415);
97 cpu_value_type beta = cpu_value_type(2.7182);
104 std::cout <<
"Checking for zero_matrix initializer..." << std::endl;
105 ublas_A = boost::numeric::ublas::zero_matrix<cpu_value_type>(ublas_A.size1(), ublas_A.size2());
110 std::cout <<
"Checking for scalar_matrix initializer..." << std::endl;
111 ublas_A = boost::numeric::ublas::scalar_matrix<cpu_value_type>(ublas_A.size1(), ublas_A.size2(), alpha);
116 ublas_A = boost::numeric::ublas::scalar_matrix<cpu_value_type>(ublas_A.size1(), ublas_A.size2(), gpu_beta);
128 std::cout << std::endl;
136 std::cout <<
"Testing matrix assignment... ";
143 if (ublas_A.size1() == ublas_A.size2())
145 std::cout <<
"Testing matrix assignment (transposed)... ";
146 ublas_A =
trans(ublas_B);
162 std::cout <<
"Testing upper left copy to GPU... ";
169 std::cout <<
"Testing lower right copy to GPU... ";
179 std::cout <<
"Testing upper left copy to A... ";
183 std::cout <<
"Testing lower right copy to C... ";
194 std::cout <<
"Inplace add: ";
201 if (ublas_C.size1() == ublas_C.size2())
203 std::cout <<
"Inplace add (transposed): ";
204 ublas_C +=
trans(ublas_C);
211 std::cout <<
"Scaled inplace add: ";
212 ublas_C += beta * ublas_A;
213 vcl_C += gpu_beta * vcl_A;
218 std::cout <<
"Add: ";
219 ublas_C = ublas_A + ublas_B;
220 vcl_C = vcl_A + vcl_B;
225 std::cout <<
"Add with flipsign: ";
226 ublas_C = - ublas_A + ublas_B;
227 vcl_C = - vcl_A + vcl_B;
233 std::cout <<
"Scaled add (left): ";
234 ublas_C = long(alpha) * ublas_A + ublas_B;
235 vcl_C = long(alpha) * vcl_A + vcl_B;
240 ublas_C = float(alpha) * ublas_A + ublas_B;
241 vcl_C = float(alpha) * vcl_A + vcl_B;
246 ublas_C = double(alpha) * ublas_A + ublas_B;
247 vcl_C = double(alpha) * vcl_A + vcl_B;
252 std::cout <<
"Scaled add (left): ";
253 vcl_C = gpu_alpha * vcl_A + vcl_B;
258 std::cout <<
"Scaled add (right): ";
259 ublas_C = ublas_A + ublas_B * long(beta);
260 vcl_C = vcl_A + vcl_B * long(beta);
265 ublas_C = ublas_A + ublas_B * float(beta);
266 vcl_C = vcl_A + vcl_B * float(beta);
271 ublas_C = ublas_A + ublas_B * double(beta);
272 vcl_C = vcl_A + vcl_B * double(beta);
277 std::cout <<
"Scaled add (right): ";
278 vcl_C = vcl_A + gpu_beta * vcl_B;
282 std::cout <<
"Scaled add (right, with division): ";
283 ublas_C = ublas_A + ublas_B / long(beta);
284 vcl_C = vcl_A + vcl_B / long(beta);
289 ublas_C = ublas_A + ublas_B / float(beta);
290 vcl_C = vcl_A + vcl_B / float(beta);
295 ublas_C = ublas_A + ublas_B / double(beta);
296 vcl_C = vcl_A + vcl_B / double(beta);
302 std::cout <<
"Scaled add (both): ";
303 ublas_C = alpha * ublas_A + beta * ublas_B;
304 vcl_C = alpha * vcl_A + beta * vcl_B;
309 std::cout <<
"Scaled add (both): ";
310 vcl_C = gpu_alpha * vcl_A + gpu_beta * vcl_B;
319 std::cout <<
"Inplace sub: ";
326 if (ublas_C.size1() == ublas_C.size2())
328 std::cout <<
"Inplace add (transposed): ";
329 ublas_C -=
trans(ublas_C);
336 std::cout <<
"Scaled Inplace sub: ";
337 ublas_C -= alpha * ublas_B;
338 vcl_C -= alpha * vcl_B;
346 std::cout <<
"Sub: ";
347 ublas_C = ublas_A - ublas_B;
348 vcl_C = vcl_A - vcl_B;
353 std::cout <<
"Scaled sub (left): ";
354 ublas_B = alpha * ublas_A - ublas_C;
355 vcl_B = alpha * vcl_A - vcl_C;
360 std::cout <<
"Scaled sub (left): ";
361 vcl_B = gpu_alpha * vcl_A - vcl_C;
366 std::cout <<
"Scaled sub (right): ";
367 ublas_B = ublas_A - beta * ublas_C;
368 vcl_B = vcl_A - vcl_C * beta;
373 std::cout <<
"Scaled sub (right): ";
374 vcl_B = vcl_A - vcl_C * gpu_beta;
379 std::cout <<
"Scaled sub (both): ";
380 ublas_B = alpha * ublas_A - beta * ublas_C;
381 vcl_B = alpha * vcl_A - vcl_C * beta;
386 std::cout <<
"Scaled sub (both): ";
387 vcl_B = gpu_alpha * vcl_A - vcl_C * gpu_beta;
392 std::cout <<
"Unary operator-: ";
406 std::cout <<
"Multiplication with CPU scalar: ";
407 ublas_A *= long(alpha);
408 vcl_A *= long(alpha);
413 ublas_A *= float(alpha);
414 vcl_A *= float(alpha);
419 ublas_A *= double(alpha);
420 vcl_A *= double(alpha);
425 std::cout <<
"Multiplication with GPU scalar: ";
433 std::cout <<
"Division with CPU scalar: ";
434 ublas_A /= long(alpha);
435 vcl_A /= long(alpha);
440 ublas_A /= float(alpha);
441 vcl_A /= float(alpha);
446 ublas_A /= double(alpha);
447 vcl_A /= double(alpha);
452 std::cout <<
"Division with GPU scalar: ";
461 std::cout <<
"Testing elementwise multiplication..." << std::endl;
462 ublas_B = boost::numeric::ublas::scalar_matrix<cpu_value_type>(ublas_B.size1(), ublas_B.size2(), cpu_value_type(1.4142));
463 ublas_A = cpu_value_type(3.1415) * ublas_B;
543 ublas_B = boost::numeric::ublas::scalar_matrix<cpu_value_type>(ublas_B.size1(), ublas_B.size2(), cpu_value_type(1.4142));
544 ublas_A = cpu_value_type(3.1415) * ublas_B;
624 std::cout <<
"Testing unary element_pow()..." << std::endl;
626 ublas_B = boost::numeric::ublas::scalar_matrix<cpu_value_type>(ublas_B.size1(), ublas_B.size2(), cpu_value_type(1.4142));
627 ublas_A = cpu_value_type(3.1415) * ublas_B;
631 for (std::size_t i=0; i<ublas_C.size1(); i++)
632 for (std::size_t j=0; j<ublas_C.size2(); ++j)
633 ublas_C(i,j) = std::pow(ublas_A(i,j), ublas_B(i,j));
634 vcl_C = viennacl::linalg::element_pow(vcl_A, vcl_B);
639 for (std::size_t i=0; i<ublas_C.size1(); i++)
640 for (std::size_t j=0; j<ublas_C.size2(); ++j)
641 ublas_C(i,j) += std::pow(ublas_A(i,j), ublas_B(i,j));
642 vcl_C += viennacl::linalg::element_pow(vcl_A, vcl_B);
647 for (std::size_t i=0; i<ublas_C.size1(); i++)
648 for (std::size_t j=0; j<ublas_C.size2(); ++j)
649 ublas_C(i,j) -= std::pow(ublas_A(i,j), ublas_B(i,j));
650 vcl_C -= viennacl::linalg::element_pow(vcl_A, vcl_B);
656 for (std::size_t i=0; i<ublas_C.size1(); i++)
657 for (std::size_t j=0; j<ublas_C.size2(); ++j)
658 ublas_C(i,j) = std::pow(ublas_A(i,j) + ublas_B(i,j), ublas_B(i,j));
659 vcl_C = viennacl::linalg::element_pow(vcl_A + vcl_B, vcl_B);
664 for (std::size_t i=0; i<ublas_C.size1(); i++)
665 for (std::size_t j=0; j<ublas_C.size2(); ++j)
666 ublas_C(i,j) += std::pow(ublas_A(i,j) + ublas_B(i,j), ublas_B(i,j));
667 vcl_C += viennacl::linalg::element_pow(vcl_A + vcl_B, vcl_B);
672 for (std::size_t i=0; i<ublas_C.size1(); i++)
673 for (std::size_t j=0; j<ublas_C.size2(); ++j)
674 ublas_C(i,j) -= std::pow(ublas_A(i,j) + ublas_B(i,j), ublas_B(i,j));
675 vcl_C -= viennacl::linalg::element_pow(vcl_A + vcl_B, vcl_B);
681 for (std::size_t i=0; i<ublas_C.size1(); i++)
682 for (std::size_t j=0; j<ublas_C.size2(); ++j)
683 ublas_C(i,j) = std::pow(ublas_A(i,j), ublas_B(i,j) + ublas_A(i,j));
684 vcl_C = viennacl::linalg::element_pow(vcl_A, vcl_B + vcl_A);
689 for (std::size_t i=0; i<ublas_C.size1(); i++)
690 for (std::size_t j=0; j<ublas_C.size2(); ++j)
691 ublas_C(i,j) += std::pow(ublas_A(i,j), ublas_B(i,j) + ublas_A(i,j));
692 vcl_C += viennacl::linalg::element_pow(vcl_A, vcl_B + vcl_A);
697 for (std::size_t i=0; i<ublas_C.size1(); i++)
698 for (std::size_t j=0; j<ublas_C.size2(); ++j)
699 ublas_C(i,j) -= std::pow(ublas_A(i,j), ublas_B(i,j) + ublas_A(i,j));
700 vcl_C -= viennacl::linalg::element_pow(vcl_A, vcl_B + vcl_A);
706 for (std::size_t i=0; i<ublas_C.size1(); i++)
707 for (std::size_t j=0; j<ublas_C.size2(); ++j)
708 ublas_C(i,j) = std::pow(ublas_A(i,j) + ublas_B(i,j), ublas_B(i,j) + ublas_A(i,j));
709 vcl_C = viennacl::linalg::element_pow(vcl_A + vcl_B, vcl_B + vcl_A);
714 for (std::size_t i=0; i<ublas_C.size1(); i++)
715 for (std::size_t j=0; j<ublas_C.size2(); ++j)
716 ublas_C(i,j) += std::pow(ublas_A(i,j) + ublas_B(i,j), ublas_B(i,j) + ublas_A(i,j));
717 vcl_C += viennacl::linalg::element_pow(vcl_A + vcl_B, vcl_B + vcl_A);
722 for (std::size_t i=0; i<ublas_C.size1(); i++)
723 for (std::size_t j=0; j<ublas_C.size2(); ++j)
724 ublas_C(i,j) -= std::pow(ublas_A(i,j) + ublas_B(i,j), ublas_B(i,j) + ublas_A(i,j));
725 vcl_C -= viennacl::linalg::element_pow(vcl_A + vcl_B, vcl_B + vcl_A);
731 std::cout <<
"Testing unary elementwise operations..." << std::endl;
733 #define GENERATE_UNARY_OP_TEST(FUNCNAME) \
734 ublas_B = boost::numeric::ublas::scalar_matrix<cpu_value_type>(ublas_B.size1(), ublas_B.size2(), cpu_value_type(1.4142)); \
735 ublas_A = cpu_value_type(3.1415) * ublas_B; \
736 ublas_C = cpu_value_type(2.7172) * ublas_A; \
737 viennacl::copy(ublas_A, vcl_A); \
738 viennacl::copy(ublas_B, vcl_B); \
739 viennacl::copy(ublas_C, vcl_C); \
740 viennacl::copy(ublas_B, vcl_B); \
742 for (std::size_t i=0; i<ublas_C.size1(); ++i) \
743 for (std::size_t j=0; j<ublas_C.size2(); ++j) \
744 ublas_C(i,j) = std::FUNCNAME(ublas_A(i,j)); \
745 vcl_C = viennacl::linalg::element_##FUNCNAME(vcl_A); \
747 if (!check_for_equality(ublas_C, vcl_C, epsilon)) \
749 std::cout << "Failure at C = " << #FUNCNAME << "(A)" << std::endl; \
750 return EXIT_FAILURE; \
753 for (std::size_t i=0; i<ublas_C.size1(); ++i) \
754 for (std::size_t j=0; j<ublas_C.size2(); ++j) \
755 ublas_C(i,j) = std::FUNCNAME(ublas_A(i,j) + ublas_B(i,j)); \
756 vcl_C = viennacl::linalg::element_##FUNCNAME(vcl_A + vcl_B); \
758 if (!check_for_equality(ublas_C, vcl_C, epsilon)) \
760 std::cout << "Failure at C = " << #FUNCNAME << "(A + B)" << std::endl; \
761 return EXIT_FAILURE; \
764 for (std::size_t i=0; i<ublas_C.size1(); ++i) \
765 for (std::size_t j=0; j<ublas_C.size2(); ++j) \
766 ublas_C(i,j) += std::FUNCNAME(ublas_A(i,j)); \
767 vcl_C += viennacl::linalg::element_##FUNCNAME(vcl_A); \
769 if (!check_for_equality(ublas_C, vcl_C, epsilon)) \
771 std::cout << "Failure at C += " << #FUNCNAME << "(A)" << std::endl; \
772 return EXIT_FAILURE; \
775 for (std::size_t i=0; i<ublas_C.size1(); ++i) \
776 for (std::size_t j=0; j<ublas_C.size2(); ++j) \
777 ublas_C(i,j) += std::FUNCNAME(ublas_A(i,j) + ublas_B(i,j)); \
778 vcl_C += viennacl::linalg::element_##FUNCNAME(vcl_A + vcl_B); \
780 if (!check_for_equality(ublas_C, vcl_C, epsilon)) \
782 std::cout << "Failure at C += " << #FUNCNAME << "(A + B)" << std::endl; \
783 return EXIT_FAILURE; \
786 for (std::size_t i=0; i<ublas_C.size1(); ++i) \
787 for (std::size_t j=0; j<ublas_C.size2(); ++j) \
788 ublas_C(i,j) -= std::FUNCNAME(ublas_A(i,j)); \
789 vcl_C -= viennacl::linalg::element_##FUNCNAME(vcl_A); \
791 if (!check_for_equality(ublas_C, vcl_C, epsilon)) \
793 std::cout << "Failure at C -= " << #FUNCNAME << "(A)" << std::endl; \
794 return EXIT_FAILURE; \
797 for (std::size_t i=0; i<ublas_C.size1(); ++i) \
798 for (std::size_t j=0; j<ublas_C.size2(); ++j) \
799 ublas_C(i,j) -= std::FUNCNAME(ublas_A(i,j) + ublas_B(i,j)); \
800 vcl_C -= viennacl::linalg::element_##FUNCNAME(vcl_A + vcl_B); \
802 if (!check_for_equality(ublas_C, vcl_C, epsilon)) \
804 std::cout << "Failure at C -= " << #FUNCNAME << "(A + B)" << std::endl; \
805 return EXIT_FAILURE; \
823 std::cout <<
"Complicated expressions: ";
827 ublas_B += alpha * (- ublas_A - beta * ublas_C + ublas_A);
828 vcl_B += gpu_alpha * (- vcl_A - vcl_C * beta + vcl_A);
833 ublas_B += (- ublas_A - beta * ublas_C + ublas_A * beta) / gpu_alpha;
834 vcl_B += (- vcl_A - vcl_C * beta + gpu_beta * vcl_A) / gpu_alpha;
840 ublas_B -= alpha * (- ublas_A - beta * ublas_C - ublas_A);
841 vcl_B -= gpu_alpha * (- vcl_A - vcl_C * beta - vcl_A);
846 ublas_B -= (- ublas_A - beta * ublas_C - ublas_A * beta) / alpha;
847 vcl_B -= (- vcl_A - vcl_C * beta - gpu_beta * vcl_A) / gpu_alpha;
852 std::cout << std::endl;
853 std::cout <<
"----------------------------------------------" << std::endl;
854 std::cout << std::endl;
863 template<
typename T,
typename ScalarType>
867 typedef boost::numeric::ublas::matrix<ScalarType> MatrixType;
871 std::size_t dim_rows = 131;
872 std::size_t dim_cols = 33;
877 MatrixType ublas_A(dim_rows, dim_cols);
878 MatrixType ublas_B(dim_rows, dim_cols);
879 MatrixType ublas_C(dim_rows, dim_cols);
881 for (std::size_t i=0; i<ublas_A.size1(); ++i)
882 for (std::size_t j=0; j<ublas_A.size2(); ++j)
884 ublas_A(i,j) =
ScalarType((i+2) + (j+1)*(i+2));
885 ublas_B(i,j) =
ScalarType((j+2) + (j+1)*(j+2));
886 ublas_C(i,j) =
ScalarType((i+1) + (i+1)*(i+2));
889 MatrixType ublas_A_large(4 * dim_rows, 4 * dim_cols);
890 for (std::size_t i=0; i<ublas_A_large.size1(); ++i)
891 for (std::size_t j=0; j<ublas_A_large.size2(); ++j)
892 ublas_A_large(i,j) =
ScalarType(i * ublas_A_large.size2() + j);
895 VCLMatrixType vcl_A_full(4 * dim_rows, 4 * dim_cols);
896 VCLMatrixType vcl_B_full(4 * dim_rows, 4 * dim_cols);
897 VCLMatrixType vcl_C_full(4 * dim_rows, 4 * dim_cols);
906 VCLMatrixType vcl_A(dim_rows, dim_cols);
920 VCLMatrixType vcl_B(dim_rows, dim_cols);
934 VCLMatrixType vcl_C(dim_rows, dim_cols);
957 std::cout << std::endl;
958 std::cout <<
"//" << std::endl;
959 std::cout <<
"////////// Test: Copy CTOR //////////" << std::endl;
960 std::cout <<
"//" << std::endl;
963 std::cout <<
"Testing matrix created from range... ";
964 VCLMatrixType vcl_temp = vcl_range_A;
966 std::cout <<
"PASSED!" << std::endl;
969 std::cout <<
"ublas_A: " << ublas_A << std::endl;
970 std::cout <<
"vcl_temp: " << vcl_temp << std::endl;
971 std::cout <<
"vcl_range_A: " << vcl_range_A << std::endl;
972 std::cout <<
"vcl_A: " << vcl_A << std::endl;
973 std::cout << std::endl <<
"TEST failed!" << std::endl;
977 std::cout <<
"Testing matrix created from slice... ";
978 VCLMatrixType vcl_temp2 = vcl_range_B;
980 std::cout <<
"PASSED!" << std::endl;
983 std::cout << std::endl <<
"TEST failed!" << std::endl;
988 std::cout <<
"//" << std::endl;
989 std::cout <<
"////////// Test: Initializer for matrix type //////////" << std::endl;
990 std::cout <<
"//" << std::endl;
993 boost::numeric::ublas::matrix<ScalarType> ublas_dummy1 = boost::numeric::ublas::identity_matrix<ScalarType>(ublas_A.size1());
994 boost::numeric::ublas::matrix<ScalarType> ublas_dummy2 = boost::numeric::ublas::scalar_matrix<ScalarType>(ublas_A.size1(), ublas_A.size1(), 3.0);
995 boost::numeric::ublas::matrix<ScalarType> ublas_dummy3 = boost::numeric::ublas::zero_matrix<ScalarType>(ublas_A.size1(), ublas_A.size1());
1001 std::cout <<
"Testing initializer CTOR... ";
1006 std::cout <<
"PASSED!" << std::endl;
1009 std::cout << std::endl <<
"TEST failed!" << std::endl;
1010 return EXIT_FAILURE;
1013 ublas_dummy1 = boost::numeric::ublas::zero_matrix<ScalarType>(ublas_A.size1(), ublas_A.size1());
1014 ublas_dummy2 = boost::numeric::ublas::identity_matrix<ScalarType>(ublas_A.size1());
1015 ublas_dummy3 = boost::numeric::ublas::scalar_matrix<ScalarType>(ublas_A.size1(), ublas_A.size1(), 3.0);
1021 std::cout <<
"Testing initializer assignment... ";
1026 std::cout <<
"PASSED!" << std::endl;
1029 std::cout << std::endl <<
"TEST failed!" << std::endl;
1030 return EXIT_FAILURE;
1034 std::cout <<
"//" << std::endl;
1035 std::cout <<
"////////// Test: Norms //////////" << std::endl;
1036 std::cout <<
"//" << std::endl;
1056 if ( std::fabs(ublas_norm_frobenius - vcl_norm_frobenius) / ublas_norm_frobenius > epsilon)
1058 std::cerr <<
"Failure at norm_frobenius()" << std::endl;
1059 return EXIT_FAILURE;
1064 if ( std::fabs(device_ublas_norm_frobenius - device_vcl_norm_frobenius) / device_ublas_norm_frobenius > epsilon)
1066 std::cerr <<
"Failure at norm_frobenius()" << std::endl;
1067 return EXIT_FAILURE;
1071 if ( std::fabs(ublas_norm_frobenius - vcl_norm_frobenius) / ublas_norm_frobenius > epsilon)
1073 std::cerr <<
"Failure at norm_frobenius() with range" << std::endl;
1074 return EXIT_FAILURE;
1078 if ( std::fabs(device_ublas_norm_frobenius - device_vcl_norm_frobenius) / device_ublas_norm_frobenius > epsilon)
1080 std::cerr <<
"Failure at norm_frobenius() with range" << std::endl;
1081 return EXIT_FAILURE;
1085 if ( std::fabs(ublas_norm_frobenius - vcl_norm_frobenius) / ublas_norm_frobenius > epsilon)
1087 std::cerr <<
"Failure at norm_frobenius() with slice" << std::endl;
1088 return EXIT_FAILURE;
1092 if ( std::fabs(device_ublas_norm_frobenius - device_vcl_norm_frobenius) / device_ublas_norm_frobenius > epsilon)
1094 std::cerr <<
"Failure at norm_frobenius() with slice" << std::endl;
1095 return EXIT_FAILURE;
1098 std::cout <<
"PASSED!" << std::endl;
1105 std::cout <<
"//" << std::endl;
1106 std::cout <<
"////////// Test: Operations //////////" << std::endl;
1107 std::cout <<
"//" << std::endl;
1111 std::cout <<
"Testing A=matrix, B=matrix, C=matrix ..." << std::endl;
1116 ublas_A, ublas_B, ublas_C,
1117 vcl_A, vcl_B, vcl_C) != EXIT_SUCCESS)
1119 return EXIT_FAILURE;
1122 std::cout <<
"Testing A=matrix, B=matrix, C=range ..." << std::endl;
1127 ublas_A, ublas_B, ublas_C,
1128 vcl_A, vcl_B, vcl_range_C) != EXIT_SUCCESS)
1130 return EXIT_FAILURE;
1133 std::cout <<
"Testing A=matrix, B=matrix, C=slice ..." << std::endl;
1138 ublas_A, ublas_B, ublas_C,
1139 vcl_A, vcl_B, vcl_slice_C) != EXIT_SUCCESS)
1141 return EXIT_FAILURE;
1144 std::cout <<
"Testing A=matrix, B=range, C=matrix ..." << std::endl;
1149 ublas_A, ublas_B, ublas_C,
1150 vcl_A, vcl_range_B, vcl_C) != EXIT_SUCCESS)
1152 return EXIT_FAILURE;
1155 std::cout <<
"Testing A=matrix, B=range, C=range ..." << std::endl;
1160 ublas_A, ublas_B, ublas_C,
1161 vcl_A, vcl_range_B, vcl_range_C) != EXIT_SUCCESS)
1163 return EXIT_FAILURE;
1166 std::cout <<
"Testing A=matrix, B=range, C=slice ..." << std::endl;
1171 ublas_A, ublas_B, ublas_C,
1172 vcl_A, vcl_range_B, vcl_slice_C) != EXIT_SUCCESS)
1174 return EXIT_FAILURE;
1178 std::cout <<
"Testing A=matrix, B=slice, C=matrix ..." << std::endl;
1183 ublas_A, ublas_B, ublas_C,
1184 vcl_A, vcl_slice_B, vcl_C) != EXIT_SUCCESS)
1186 return EXIT_FAILURE;
1189 std::cout <<
"Testing A=matrix, B=slice, C=range ..." << std::endl;
1194 ublas_A, ublas_B, ublas_C,
1195 vcl_A, vcl_slice_B, vcl_range_C) != EXIT_SUCCESS)
1197 return EXIT_FAILURE;
1200 std::cout <<
"Testing A=matrix, B=slice, C=slice ..." << std::endl;
1205 ublas_A, ublas_B, ublas_C,
1206 vcl_A, vcl_slice_B, vcl_slice_C) != EXIT_SUCCESS)
1208 return EXIT_FAILURE;
1214 std::cout <<
"Testing A=range, B=matrix, C=matrix ..." << std::endl;
1219 ublas_A, ublas_B, ublas_C,
1220 vcl_range_A, vcl_B, vcl_C) != EXIT_SUCCESS)
1222 return EXIT_FAILURE;
1225 std::cout <<
"Testing A=range, B=matrix, C=range ..." << std::endl;
1230 ublas_A, ublas_B, ublas_C,
1231 vcl_range_A, vcl_B, vcl_range_C) != EXIT_SUCCESS)
1233 return EXIT_FAILURE;
1236 std::cout <<
"Testing A=range, B=matrix, C=slice ..." << std::endl;
1241 ublas_A, ublas_B, ublas_C,
1242 vcl_range_A, vcl_B, vcl_slice_C) != EXIT_SUCCESS)
1244 return EXIT_FAILURE;
1249 std::cout <<
"Testing A=range, B=range, C=matrix ..." << std::endl;
1254 ublas_A, ublas_B, ublas_C,
1255 vcl_range_A, vcl_range_B, vcl_C) != EXIT_SUCCESS)
1257 return EXIT_FAILURE;
1260 std::cout <<
"Testing A=range, B=range, C=range ..." << std::endl;
1265 ublas_A, ublas_B, ublas_C,
1266 vcl_range_A, vcl_range_B, vcl_range_C) != EXIT_SUCCESS)
1268 return EXIT_FAILURE;
1271 std::cout <<
"Testing A=range, B=range, C=slice ..." << std::endl;
1276 ublas_A, ublas_B, ublas_C,
1277 vcl_range_A, vcl_range_B, vcl_slice_C) != EXIT_SUCCESS)
1279 return EXIT_FAILURE;
1284 std::cout <<
"Testing A=range, B=slice, C=matrix ..." << std::endl;
1289 ublas_A, ublas_B, ublas_C,
1290 vcl_range_A, vcl_slice_B, vcl_C) != EXIT_SUCCESS)
1292 return EXIT_FAILURE;
1295 std::cout <<
"Testing A=range, B=slice, C=range ..." << std::endl;
1300 ublas_A, ublas_B, ublas_C,
1301 vcl_range_A, vcl_slice_B, vcl_range_C) != EXIT_SUCCESS)
1303 return EXIT_FAILURE;
1306 std::cout <<
"Testing A=range, B=slice, C=slice ..." << std::endl;
1311 ublas_A, ublas_B, ublas_C,
1312 vcl_range_A, vcl_slice_B, vcl_slice_C) != EXIT_SUCCESS)
1314 return EXIT_FAILURE;
1319 std::cout <<
"Testing A=slice, B=matrix, C=matrix ..." << std::endl;
1324 ublas_A, ublas_B, ublas_C,
1325 vcl_slice_A, vcl_B, vcl_C) != EXIT_SUCCESS)
1327 return EXIT_FAILURE;
1330 std::cout <<
"Testing A=slice, B=matrix, C=range ..." << std::endl;
1335 ublas_A, ublas_B, ublas_C,
1336 vcl_slice_A, vcl_B, vcl_range_C) != EXIT_SUCCESS)
1338 return EXIT_FAILURE;
1341 std::cout <<
"Testing A=slice, B=matrix, C=slice ..." << std::endl;
1346 ublas_A, ublas_B, ublas_C,
1347 vcl_slice_A, vcl_B, vcl_slice_C) != EXIT_SUCCESS)
1349 return EXIT_FAILURE;
1354 std::cout <<
"Testing A=slice, B=range, C=matrix ..." << std::endl;
1359 ublas_A, ublas_B, ublas_C,
1360 vcl_slice_A, vcl_range_B, vcl_C) != EXIT_SUCCESS)
1362 return EXIT_FAILURE;
1365 std::cout <<
"Testing A=slice, B=range, C=range ..." << std::endl;
1370 ublas_A, ublas_B, ublas_C,
1371 vcl_slice_A, vcl_range_B, vcl_range_C) != EXIT_SUCCESS)
1373 return EXIT_FAILURE;
1376 std::cout <<
"Testing A=slice, B=range, C=slice ..." << std::endl;
1381 ublas_A, ublas_B, ublas_C,
1382 vcl_slice_A, vcl_range_B, vcl_slice_C) != EXIT_SUCCESS)
1384 return EXIT_FAILURE;
1389 std::cout <<
"Testing A=slice, B=slice, C=matrix ..." << std::endl;
1394 ublas_A, ublas_B, ublas_C,
1395 vcl_slice_A, vcl_slice_B, vcl_C) != EXIT_SUCCESS)
1397 return EXIT_FAILURE;
1400 std::cout <<
"Testing A=slice, B=slice, C=range ..." << std::endl;
1405 ublas_A, ublas_B, ublas_C,
1406 vcl_slice_A, vcl_slice_B, vcl_range_C) != EXIT_SUCCESS)
1408 return EXIT_FAILURE;
1411 std::cout <<
"Testing A=slice, B=slice, C=slice ..." << std::endl;
1416 ublas_A, ublas_B, ublas_C,
1417 vcl_slice_A, vcl_slice_B, vcl_slice_C) != EXIT_SUCCESS)
1419 return EXIT_FAILURE;
1423 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...
Generic interface for the l^2-norm. See viennacl/linalg/vector_operations.hpp for implementations...
viennacl::enable_if< viennacl::is_any_sparse_matrix< M1 >::value, matrix_expression< const M1, const M1, op_trans > >::type trans(const M1 &mat)
Returns an expression template class representing a transposed matrix.
Class for representing strided submatrices of a bigger matrix A.
void trans(matrix_expression< const matrix_base< NumericT, SizeT, DistanceT >, const matrix_base< NumericT, SizeT, DistanceT >, op_trans > const &proxy, matrix_base< NumericT > &temp_trans)
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...
T max(const T &lhs, const T &rhs)
Maximum.
Generic interface for the l^1-norm. See viennacl/linalg/vector_operations.hpp for implementations...
Generic interface for the Frobenius norm.
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.
bool check_for_equality(MatrixType const &ublas_A, VCLMatrixType const &vcl_A, double epsilon)
Proxy classes for matrices.
scalar_expression< const matrix_base< NumericT >, const matrix_base< NumericT >, op_norm_frobenius > norm_frobenius(const matrix_base< NumericT > &A)
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.
int run_test(double epsilon, UBLASMatrixType &ublas_A, UBLASMatrixType &ublas_B, UBLASMatrixType &ublas_C, ViennaCLMatrixType1 &vcl_A, ViennaCLMatrixType2 &vcl_B, ViennaCLMatrixType3 vcl_C)
Generic interface for the l^infty-norm. See viennacl/linalg/vector_operations.hpp for implementations...