/[escript]/branches/diaplayground/cusplibrary/testing/print.cu
ViewVC logotype

Contents of /branches/diaplayground/cusplibrary/testing/print.cu

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4955 - (show annotations)
Tue May 20 04:33:15 2014 UTC (5 years, 4 months ago) by caltinay
File size: 1010 byte(s)
added pristine copy of cusplibrary (apache license) to be used by ripley.

1 #include <unittest/unittest.h>
2
3 #include <cusp/print.h>
4
5 #include <cusp/array1d.h>
6 #include <cusp/array2d.h>
7 #include <cusp/coo_matrix.h>
8 #include <cusp/csr_matrix.h>
9 #include <cusp/dia_matrix.h>
10 #include <cusp/ell_matrix.h>
11 #include <cusp/hyb_matrix.h>
12
13 #include <sstream>
14
15 template <typename Matrix>
16 void TestPrintMatrix(void)
17 {
18 // initialize a 2x3 matrix
19 cusp::array2d<float, cusp::host_memory> A(2,3);
20 A(0,0) = 42; A(0,1) = 0; A(0,2) = 53;
21 A(1,0) = 0; A(1,1) = 71; A(1,2) = 0;
22
23 Matrix M(A);
24
25 std::ostringstream oss;
26
27 cusp::print(M, oss);
28
29 // ensure certain substrings are present in the output
30 ASSERT_EQUAL(oss.str().length() > 0, true);
31 ASSERT_EQUAL(oss.str().find("<2, 3>") != std::string::npos, true);
32 ASSERT_EQUAL(oss.str().find("42") != std::string::npos, true);
33 ASSERT_EQUAL(oss.str().find("53") != std::string::npos, true);
34 ASSERT_EQUAL(oss.str().find("71") != std::string::npos, true);
35 }
36 DECLARE_MATRIX_UNITTEST(TestPrintMatrix);
37

  ViewVC Help
Powered by ViewVC 1.1.26