36 #include <boost/numeric/ublas/io.hpp>
37 #include <boost/numeric/ublas/triangular.hpp>
38 #include <boost/numeric/ublas/matrix_sparse.hpp>
39 #include <boost/numeric/ublas/matrix.hpp>
40 #include <boost/numeric/ublas/matrix_proxy.hpp>
41 #include <boost/numeric/ublas/lu.hpp>
42 #include <boost/numeric/ublas/io.hpp>
43 #include <boost/numeric/ublas/operation_sparse.hpp>
44 #include <boost/numeric/ublas/vector_proxy.hpp>
50 #define VIENNACL_WITH_UBLAS 1
75 template<
typename ScalarType>
79 return (s1 - s2) /
std::max(fabs(s1), std::fabs(s2));
83 template<
typename ScalarType>
86 ublas::vector<ScalarType> v2_cpu(v2.
size());
90 for (
unsigned int i=0;i<v1.size(); ++i)
92 if (
std::max( std::fabs(v2_cpu[i]), std::fabs(v1[i]) ) > 0 )
97 v2_cpu[i] = std::fabs(v2_cpu[i] - v1[i]) /
std::max( std::fabs(v2_cpu[i]), std::fabs(v1[i]) );
102 if (v2_cpu[i] > 0.0001)
105 std::cout <<
"Error at entry " << i <<
": Should: " << v1[i] <<
" vs. Is: " << v2[i] << std::endl;
115 template<
typename ScalarType,
typename VCL_MATRIX>
116 ScalarType diff(ublas::compressed_matrix<ScalarType> & cpu_matrix, VCL_MATRIX & gpu_matrix)
118 typedef ublas::compressed_matrix<ScalarType> CPU_MATRIX;
119 CPU_MATRIX from_gpu(gpu_matrix.size1(), gpu_matrix.size2());
128 for (
typename CPU_MATRIX::const_iterator1 row_it = cpu_matrix.begin1();
129 row_it != cpu_matrix.end1();
133 for (
typename CPU_MATRIX::const_iterator2 col_it = row_it.begin();
134 col_it != row_it.end();
140 if (
std::max( std::fabs(cpu_matrix(col_it.index1(), col_it.index2())),
141 std::fabs(from_gpu(col_it.index1(), col_it.index2())) ) > 0 )
142 current_error = std::fabs(cpu_matrix(col_it.index1(), col_it.index2()) - from_gpu(col_it.index1(), col_it.index2()))
143 /
std::max( std::fabs(cpu_matrix(col_it.index1(), col_it.index2())),
144 std::fabs(from_gpu(col_it.index1(), col_it.index2())) );
145 if (current_error > error)
146 error = current_error;
152 for (
typename CPU_MATRIX::const_iterator1 row_it = from_gpu.begin1();
153 row_it != from_gpu.end1();
157 for (
typename CPU_MATRIX::const_iterator2 col_it = row_it.begin();
158 col_it != row_it.end();
164 if (
std::max( std::fabs(cpu_matrix(col_it.index1(), col_it.index2())),
165 std::fabs(from_gpu(col_it.index1(), col_it.index2())) ) > 0 )
166 current_error = std::fabs(cpu_matrix(col_it.index1(), col_it.index2()) - from_gpu(col_it.index1(), col_it.index2()))
167 /
std::max( std::fabs(cpu_matrix(col_it.index1(), col_it.index2())),
168 std::fabs(from_gpu(col_it.index1(), col_it.index2())) );
169 if (current_error > error)
170 error = current_error;
178 template<
typename NumericT,
typename VCL_MatrixT,
typename Epsilon,
typename UblasVectorT,
typename VCLVectorT>
180 UblasVectorT & result, UblasVectorT
const & rhs,
181 VCLVectorT & vcl_result, VCLVectorT & vcl_rhs)
183 int retval = EXIT_SUCCESS;
185 ublas::compressed_matrix<NumericT> ublas_matrix2(5, 4);
193 VCL_MatrixT vcl_sparse_matrix2;
202 if ( std::fabs(
diff(result, vcl_result)) > epsilon )
204 std::cout <<
"# Error at operation: matrix-vector product with stided vectors, part 1" << std::endl;
205 std::cout <<
" diff: " << std::fabs(
diff(result, vcl_result)) << std::endl;
206 retval = EXIT_FAILURE;
216 if ( std::fabs(
diff(result, vcl_result)) > epsilon )
218 std::cout <<
"# Error at operation: matrix-vector product with strided vectors, part 2" << std::endl;
219 std::cout <<
" diff: " << std::fabs(
diff(result, vcl_result)) << std::endl;
220 retval = EXIT_FAILURE;
227 template<
typename NumericT,
typename VCL_MATRIX,
typename Epsilon >
230 int retval = EXIT_SUCCESS;
232 ublas::compressed_matrix<NumericT> ublas_matrix(5,5);
233 VCL_MATRIX vcl_matrix;
242 ublas::compressed_matrix<NumericT> other_matrix(ublas_matrix.size1(), ublas_matrix.size2());
245 std::cout <<
"Checking for equality after copy..." << std::endl;
246 if ( std::fabs(
diff(ublas_matrix, vcl_matrix)) > epsilon )
248 std::cout <<
"# Error at operation: equality after copy with sparse matrix" << std::endl;
249 std::cout <<
" diff: " << std::fabs(
diff(ublas_matrix, vcl_matrix)) << std::endl;
253 std::cout <<
"Testing resize to larger..." << std::endl;
254 ublas_matrix.resize(10, 10,
false);
262 vcl_matrix.resize(10, 10,
true);
264 if ( std::fabs(
diff(ublas_matrix, vcl_matrix)) > epsilon )
266 std::cout <<
"# Error at operation: resize (to larger) with sparse matrix" << std::endl;
267 std::cout <<
" diff: " << std::fabs(
diff(ublas_matrix, vcl_matrix)) << std::endl;
278 std::cout <<
"Testing resize to smaller..." << std::endl;
279 ublas_matrix.resize(7, 7,
false);
288 vcl_matrix.resize(7, 7);
291 if ( std::fabs(
diff(ublas_matrix, vcl_matrix)) > epsilon )
293 std::cout <<
"# Error at operation: resize (to smaller) with sparse matrix" << std::endl;
294 std::cout <<
" diff: " << std::fabs(
diff(ublas_matrix, vcl_matrix)) << std::endl;
295 retval = EXIT_FAILURE;
298 ublas::vector<NumericT> ublas_vec = ublas::scalar_vector<NumericT>(ublas_matrix.size1(),
NumericT(3.1415));
302 std::cout <<
"Testing transposed unit lower triangular solve: compressed_matrix" << std::endl;
304 std::cout <<
"matrix: " << ublas_matrix << std::endl;
305 std::cout <<
"vector: " << ublas_vec << std::endl;
306 std::cout <<
"ViennaCL matrix size: " << vcl_matrix.size1() <<
" x " << vcl_matrix.size2() << std::endl;
308 std::cout <<
"ublas..." << std::endl;
310 std::cout <<
"ViennaCL..." << std::endl;
365 for (std::size_t i=0; i<ublas_vec.size(); ++i)
367 std::cout << ublas_vec[i] <<
" vs. " << vcl_vec[i] << std::endl;
393 template<
typename NumericT,
typename Epsilon >
394 int test(Epsilon
const& epsilon)
398 std::cout <<
"Testing resizing of compressed_matrix..." << std::endl;
399 int retval = resize_test<NumericT, viennacl::compressed_matrix<NumericT> >(epsilon);
400 if (retval != EXIT_SUCCESS)
402 std::cout <<
"Testing resizing of coordinate_matrix..." << std::endl;
409 ublas::vector<NumericT> rhs;
410 ublas::vector<NumericT> result;
411 ublas::compressed_matrix<NumericT> ublas_matrix;
415 std::cout <<
"Error reading Matrix file" << std::endl;
420 std::cout <<
"done reading matrix" << std::endl;
423 rhs.resize(ublas_matrix.size2());
424 for (std::size_t i=0; i<rhs.size(); ++i)
427 rhs[i] =
NumericT(1) + randomNumber();
431 ublas::compressed_matrix<NumericT> ublas_cc_matrix(ublas_matrix.size1(), ublas_matrix.size2());
432 ublas_cc_matrix(42,199) =
NumericT(3.1415);
433 ublas_cc_matrix(31, 69) =
NumericT(2.71);
434 ublas_cc_matrix(23, 32) =
NumericT(6);
435 ublas_cc_matrix(177,57) =
NumericT(4);
436 ublas_cc_matrix(21, 97) =
NumericT(-4);
437 ublas_cc_matrix(92, 25) =
NumericT(2);
438 ublas_cc_matrix(89, 62) =
NumericT(11);
439 ublas_cc_matrix(1, 7) =
NumericT(8);
440 ublas_cc_matrix(85, 41) =
NumericT(13);
441 ublas_cc_matrix(66, 28) =
NumericT(8);
442 ublas_cc_matrix(21, 74) =
NumericT(-2);
460 viennacl::copy(ublas_cc_matrix, vcl_compressed_compressed_matrix);
464 std::cout <<
"Testing products: ublas" << std::endl;
467 std::cout <<
"Testing products: compressed_matrix" << std::endl;
470 if ( std::fabs(
diff(result, vcl_result)) > epsilon )
472 std::cout <<
"# Error at operation: matrix-vector product with compressed_matrix" << std::endl;
473 std::cout <<
" diff: " << std::fabs(
diff(result, vcl_result)) << std::endl;
474 retval = EXIT_FAILURE;
477 std::cout <<
"Testing products: compressed_matrix, strided vectors" << std::endl;
478 retval = strided_matrix_vector_product_test<NumericT, viennacl::compressed_matrix<NumericT> >(epsilon, result, rhs, vcl_result, vcl_rhs);
479 if (retval != EXIT_SUCCESS)
485 ublas::compressed_matrix<NumericT> ublas_matrix_trans(ublas_matrix.size2(), ublas_matrix.size1(), ublas_matrix.nnz());
488 for (
typename ublas::compressed_matrix<NumericT>::iterator1 row_it = ublas_matrix.begin1();
489 row_it != ublas_matrix.end1();
492 for (
typename ublas::compressed_matrix<NumericT>::iterator2 col_it = row_it.begin();
493 col_it != row_it.end();
496 ublas_matrix_trans(col_it.index1(), col_it.index2()) = *col_it;
501 std::cout <<
"Testing unit upper triangular solve: compressed_matrix" << std::endl;
507 if ( std::fabs(
diff(result, vcl_result)) > epsilon )
509 std::cout <<
"# Error at operation: unit upper triangular solve with compressed_matrix" << std::endl;
510 std::cout <<
" diff: " << std::fabs(
diff(result, vcl_result)) << std::endl;
511 retval = EXIT_FAILURE;
514 std::cout <<
"Testing upper triangular solve: compressed_matrix" << std::endl;
520 if ( std::fabs(
diff(result, vcl_result)) > epsilon )
522 std::cout <<
"# Error at operation: upper triangular solve with compressed_matrix" << std::endl;
523 std::cout <<
" diff: " << std::fabs(
diff(result, vcl_result)) << std::endl;
524 retval = EXIT_FAILURE;
527 std::cout <<
"Testing unit lower triangular solve: compressed_matrix" << std::endl;
561 if ( std::fabs(
diff(result, vcl_result)) > epsilon )
563 std::cout <<
"# Error at operation: unit lower triangular solve with compressed_matrix" << std::endl;
564 std::cout <<
" diff: " << std::fabs(
diff(result, vcl_result)) << std::endl;
565 retval = EXIT_FAILURE;
569 std::cout <<
"Testing lower triangular solve: compressed_matrix" << std::endl;
600 if ( std::fabs(
diff(result, vcl_result)) > epsilon )
602 std::cout <<
"# Error at operation: lower triangular solve with compressed_matrix" << std::endl;
603 std::cout <<
" diff: " << std::fabs(
diff(result, vcl_result)) << std::endl;
604 retval = EXIT_FAILURE;
625 std::cout <<
"Testing transposed unit upper triangular solve: compressed_matrix" << std::endl;
631 if ( std::fabs(
diff(result, vcl_result)) > epsilon )
633 std::cout <<
"# Error at operation: unit upper triangular solve with compressed_matrix" << std::endl;
634 std::cout <<
" diff: " << std::fabs(
diff(result, vcl_result)) << std::endl;
635 retval = EXIT_FAILURE;
638 std::cout <<
"Testing transposed upper triangular solve: compressed_matrix" << std::endl;
644 if ( std::fabs(
diff(result, vcl_result)) > epsilon )
646 std::cout <<
"# Error at operation: upper triangular solve with compressed_matrix" << std::endl;
647 std::cout <<
" diff: " << std::fabs(
diff(result, vcl_result)) << std::endl;
648 retval = EXIT_FAILURE;
652 std::cout <<
"Testing transposed unit lower triangular solve: compressed_matrix" << std::endl;
658 if ( std::fabs(
diff(result, vcl_result)) > epsilon )
660 std::cout <<
"# Error at operation: unit lower triangular solve with compressed_matrix" << std::endl;
661 std::cout <<
" diff: " << std::fabs(
diff(result, vcl_result)) << std::endl;
662 retval = EXIT_FAILURE;
665 std::cout <<
"Testing transposed lower triangular solve: compressed_matrix" << std::endl;
671 if ( std::fabs(
diff(result, vcl_result)) > epsilon )
673 std::cout <<
"# Error at operation: lower triangular solve with compressed_matrix" << std::endl;
674 std::cout <<
" diff: " << std::fabs(
diff(result, vcl_result)) << std::endl;
675 retval = EXIT_FAILURE;
678 std::cout <<
"Testing products: compressed_compressed_matrix" << std::endl;
682 if ( std::fabs(
diff(result, vcl_result)) > epsilon )
684 std::cout <<
"# Error at operation: matrix-vector product with compressed_compressed_matrix" << std::endl;
685 std::cout <<
" diff: " << std::fabs(
diff(result, vcl_result)) << std::endl;
686 retval = EXIT_FAILURE;
690 ublas::compressed_matrix<NumericT> temp(vcl_compressed_compressed_matrix.size1(), vcl_compressed_compressed_matrix.size2());
696 if ( std::fabs(
diff(result, vcl_result)) > epsilon )
698 std::cout <<
"# Error at operation: matrix-vector product with compressed_compressed_matrix (after copy back)" << std::endl;
699 std::cout <<
" diff: " << std::fabs(
diff(result, vcl_result)) << std::endl;
700 retval = EXIT_FAILURE;
708 std::cout <<
"Testing products: coordinate_matrix" << std::endl;
712 if ( std::fabs(
diff(result, vcl_result)) > epsilon )
714 std::cout <<
"# Error at operation: matrix-vector product with coordinate_matrix" << std::endl;
715 std::cout <<
" diff: " << std::fabs(
diff(result, vcl_result)) << std::endl;
716 retval = EXIT_FAILURE;
719 std::cout <<
"Testing products: coordinate_matrix, strided vectors" << std::endl;
721 retval = strided_matrix_vector_product_test<NumericT, viennacl::coordinate_matrix<NumericT> >(epsilon, result, rhs, vcl_result, vcl_rhs);
722 if (retval != EXIT_SUCCESS)
728 ublas_matrix.clear();
732 std::cout <<
"Testing products: ell_matrix" << std::endl;
741 if ( std::fabs(
diff(result, vcl_result)) > epsilon )
743 std::cout <<
"# Error at operation: matrix-vector product with ell_matrix" << std::endl;
744 std::cout <<
" diff: " << std::fabs(
diff(result, vcl_result)) << std::endl;
745 retval = EXIT_FAILURE;
748 std::cout <<
"Testing products: ell_matrix, strided vectors" << std::endl;
749 retval = strided_matrix_vector_product_test<NumericT, viennacl::ell_matrix<NumericT> >(epsilon, result, rhs, vcl_result, vcl_rhs);
750 if (retval != EXIT_SUCCESS)
759 std::cout <<
"Testing products: sliced_ell_matrix" << std::endl;
764 if ( std::fabs(
diff(result, vcl_result)) > epsilon )
766 std::cout <<
"# Error at operation: matrix-vector product with sliced_ell_matrix" << std::endl;
767 std::cout <<
" diff: " << std::fabs(
diff(result, vcl_result)) << std::endl;
768 retval = EXIT_FAILURE;
771 std::cout <<
"Testing products: sliced_ell_matrix, strided vectors" << std::endl;
772 retval = strided_matrix_vector_product_test<NumericT, viennacl::sliced_ell_matrix<NumericT> >(epsilon, result, rhs, vcl_result, vcl_rhs);
773 if (retval != EXIT_SUCCESS)
779 ublas_matrix.clear();
783 std::cout <<
"Testing products: hyb_matrix" << std::endl;
792 if ( std::fabs(
diff(result, vcl_result)) > epsilon )
794 std::cout <<
"# Error at operation: matrix-vector product with hyb_matrix" << std::endl;
795 std::cout <<
" diff: " << std::fabs(
diff(result, vcl_result)) << std::endl;
796 retval = EXIT_FAILURE;
799 std::cout <<
"Testing products: hyb_matrix, strided vectors" << std::endl;
800 retval = strided_matrix_vector_product_test<NumericT, viennacl::hyb_matrix<NumericT> >(epsilon, result, rhs, vcl_result, vcl_rhs);
801 if (retval != EXIT_SUCCESS)
809 copy(rhs.begin(), rhs.end(), vcl_rhs.begin());
810 copy(result.begin(), result.end(), vcl_result.begin());
811 copy(result.begin(), result.end(), vcl_result2.begin());
813 std::cout <<
"Testing scaled additions of products and vectors" << std::endl;
817 if ( std::fabs(
diff(result, vcl_result2)) > epsilon )
819 std::cout <<
"# Error at operation: matrix-vector product (compressed_matrix) with scaled additions" << std::endl;
820 std::cout <<
" diff: " << std::fabs(
diff(result, vcl_result2)) << std::endl;
821 retval = EXIT_FAILURE;
828 if ( std::fabs(
diff(result, vcl_result2)) > epsilon )
830 std::cout <<
"# Error at operation: matrix-vector product (coordinate_matrix) with scaled additions" << std::endl;
831 std::cout <<
" diff: " << std::fabs(
diff(result, vcl_result2)) << std::endl;
832 retval = EXIT_FAILURE;
838 if ( std::fabs(
diff(result, vcl_result2)) > epsilon )
840 std::cout <<
"# Error at operation: matrix-vector product (ell_matrix) with scaled additions" << std::endl;
841 std::cout <<
" diff: " << std::fabs(
diff(result, vcl_result2)) << std::endl;
842 retval = EXIT_FAILURE;
848 if ( std::fabs(
diff(result, vcl_result2)) > epsilon )
850 std::cout <<
"# Error at operation: matrix-vector product (hyb_matrix) with scaled additions" << std::endl;
851 std::cout <<
" diff: " << std::fabs(
diff(result, vcl_result2)) << std::endl;
852 retval = EXIT_FAILURE;
856 ublas_matrix.clear();
858 std::cout <<
"Testing products after clear(): compressed_matrix" << std::endl;
859 vcl_compressed_matrix.clear();
860 result = ublas::scalar_vector<NumericT>(result.size(),
NumericT(1));
864 if ( std::fabs(
diff(result, vcl_result)) > epsilon )
866 std::cout <<
"# Error at operation: matrix-vector product with compressed_matrix" << std::endl;
867 std::cout <<
" diff: " << std::fabs(
diff(result, vcl_result)) << std::endl;
868 retval = EXIT_FAILURE;
871 std::cout <<
"Testing products after clear(): compressed_compressed_matrix" << std::endl;
872 vcl_compressed_compressed_matrix.clear();
873 result = ublas::scalar_vector<NumericT>(result.size(),
NumericT(1));
877 if ( std::fabs(
diff(result, vcl_result)) > epsilon )
879 std::cout <<
"# Error at operation: matrix-vector product with compressed_compressed_matrix" << std::endl;
880 std::cout <<
" diff: " << std::fabs(
diff(result, vcl_result)) << std::endl;
881 retval = EXIT_FAILURE;
884 std::cout <<
"Testing products after clear(): coordinate_matrix" << std::endl;
885 vcl_coordinate_matrix.clear();
886 result = ublas::scalar_vector<NumericT>(result.size(),
NumericT(1));
890 if ( std::fabs(
diff(result, vcl_result)) > epsilon )
892 std::cout <<
"# Error at operation: matrix-vector product with coordinate_matrix" << std::endl;
893 std::cout <<
" diff: " << std::fabs(
diff(result, vcl_result)) << std::endl;
894 retval = EXIT_FAILURE;
897 std::cout <<
"Testing products after clear(): ell_matrix" << std::endl;
898 vcl_ell_matrix.
clear();
899 result = ublas::scalar_vector<NumericT>(result.size(),
NumericT(1));
903 if ( std::fabs(
diff(result, vcl_result)) > epsilon )
905 std::cout <<
"# Error at operation: matrix-vector product with ell_matrix" << std::endl;
906 std::cout <<
" diff: " << std::fabs(
diff(result, vcl_result)) << std::endl;
907 retval = EXIT_FAILURE;
910 std::cout <<
"Testing products after clear(): hyb_matrix" << std::endl;
911 vcl_hyb_matrix.
clear();
912 result = ublas::scalar_vector<NumericT>(result.size(),
NumericT(1));
916 if ( std::fabs(
diff(result, vcl_result)) > epsilon )
918 std::cout <<
"# Error at operation: matrix-vector product with hyb_matrix" << std::endl;
919 std::cout <<
" diff: " << std::fabs(
diff(result, vcl_result)) << std::endl;
920 retval = EXIT_FAILURE;
923 std::cout <<
"Testing products after clear(): sliced_ell_matrix" << std::endl;
924 vcl_sliced_ell_matrix.
clear();
925 result = ublas::scalar_vector<NumericT>(result.size(),
NumericT(1));
929 if ( std::fabs(
diff(result, vcl_result)) > epsilon )
931 std::cout <<
"# Error at operation: matrix-vector product with sliced_ell_matrix" << std::endl;
932 std::cout <<
" diff: " << std::fabs(
diff(result, vcl_result)) << std::endl;
933 retval = EXIT_FAILURE;
945 std::cout << std::endl;
946 std::cout <<
"----------------------------------------------" << std::endl;
947 std::cout <<
"----------------------------------------------" << std::endl;
948 std::cout <<
"## Test :: Sparse Matrices" << std::endl;
949 std::cout <<
"----------------------------------------------" << std::endl;
950 std::cout <<
"----------------------------------------------" << std::endl;
951 std::cout << std::endl;
953 int retval = EXIT_SUCCESS;
955 std::cout << std::endl;
956 std::cout <<
"----------------------------------------------" << std::endl;
957 std::cout << std::endl;
960 NumericT epsilon =
static_cast<NumericT
>(1E-4);
961 std::cout <<
"# Testing setup:" << std::endl;
962 std::cout <<
" eps: " << epsilon << std::endl;
963 std::cout <<
" numeric: float" << std::endl;
964 retval = test<NumericT>(epsilon);
965 if ( retval == EXIT_SUCCESS )
966 std::cout <<
"# Test passed" << std::endl;
970 std::cout << std::endl;
971 std::cout <<
"----------------------------------------------" << std::endl;
972 std::cout << std::endl;
974 #ifdef VIENNACL_WITH_OPENCL
980 NumericT epsilon = 1.0E-12;
981 std::cout <<
"# Testing setup:" << std::endl;
982 std::cout <<
" eps: " << epsilon << std::endl;
983 std::cout <<
" numeric: double" << std::endl;
984 retval = test<NumericT>(epsilon);
985 if ( retval == EXIT_SUCCESS )
986 std::cout <<
"# Test passed" << std::endl;
990 std::cout << std::endl;
991 std::cout <<
"----------------------------------------------" << std::endl;
992 std::cout << std::endl;
994 #ifdef VIENNACL_WITH_OPENCL
996 std::cout <<
"No double precision support, skipping test..." << std::endl;
1000 std::cout << std::endl;
1001 std::cout <<
"------- Test completed --------" << std::endl;
1002 std::cout << std::endl;
Sparse matrix class using a hybrid format composed of the ELL and CSR format for storing the nonzeros...
void clear()
Resets all entries in the matrix back to zero without changing the matrix size. Resets the sparsity p...
void inplace_solve(matrix_base< NumericT > const &A, matrix_base< NumericT > &B, SolverTagT tag)
Direct inplace solver for triangular systems with multiple right hand sides, i.e. A \ B (MATLAB notat...
void inplace_solve(const matrix_base< NumericT > &A, matrix_base< NumericT > &B, SolverTagT)
Direct inplace solver for triangular systems with multiple right hand sides, i.e. A \ B (MATLAB notat...
A reader and writer for the matrix market format is implemented here.
ScalarType diff(ScalarType &s1, viennacl::scalar< ScalarType > &s2)
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 test(Epsilon const &epsilon)
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...
A tag class representing a lower triangular matrix.
void clear()
Resets all entries in the matrix back to zero without changing the matrix size. Resets the sparsity p...
void finish()
Synchronizes the execution. finish() will only return after all compute kernels (CUDA, OpenCL) have completed.
viennacl::scalar< int > s2
viennacl::scalar< float > s1
T max(const T &lhs, const T &rhs)
Maximum.
viennacl::ocl::device const & current_device()
Convenience function for returning the active device in the current context.
Implementation of the coordinate_matrix class.
viennacl::vector< float > v1
Implementation of the hyb_matrix class.
VectorT prod(std::vector< std::vector< T, A1 >, A2 > const &matrix, VectorT const &vector)
Sparse matrix class using the ELLPACK format for storing the nonzeros.
iterator begin()
Returns an iterator pointing to the beginning of the vector (STL like)
Implementations of incomplete factorization preconditioners. Convenience header file.
A tag class representing an upper triangular matrix.
Sparse matrix class using the sliced ELLPACK with parameters C, .
Implementation of the compressed_matrix class.
A sparse square matrix in compressed sparse rows format optimized for the case that only a few rows c...
Implementation of the sliced_ell_matrix class.
bool double_support() const
ViennaCL convenience function: Returns true if the device supports double precision.
matrix_range< MatrixType > project(MatrixType const &A, viennacl::range const &r1, viennacl::range const &r2)
Implementation of the ell_matrix class.
Proxy classes for vectors.
Implementation of the compressed_compressed_matrix class (CSR format with a relatively small number o...
void clear()
Resets all entries to zero. Does not change the size of the vector.
viennacl::vector< int > v2
void prod(std::vector< std::map< IndexT, NumericT > > const &stl_A, std::vector< std::map< IndexT, NumericT > > const &stl_B, std::vector< std::map< IndexT, NumericT > > &stl_C)
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.
int strided_matrix_vector_product_test(Epsilon epsilon, UblasVectorT &result, UblasVectorT const &rhs, VCLVectorT &vcl_result, VCLVectorT &vcl_rhs)
size_type size() const
Returns the length of the vector (cf. std::vector)
A tag class representing a lower triangular matrix with unit diagonal.
long read_matrix_market_file(MatrixT &mat, const char *file, long index_base=1)
Reads a sparse matrix from a file (MatrixMarket format)
iterator end()
Returns an iterator pointing to the end of the vector (STL like)
Common routines used within ILU-type preconditioners.
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 resize_test(Epsilon const &epsilon)
A tag class representing an upper triangular matrix with unit diagonal.
A sparse square matrix, where entries are stored as triplets (i,j, val), where i and j are the row an...