ViennaCL - The Vienna Computing Library: tests/src/iterators.cpp Source File

ViennaCL - The Vienna Computing Library 1.7.1 Free open-source GPU-accelerated linear algebra and solver library. |

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
iterators.cpp
Go to the documentation of this file.
1 /* =========================================================================
2 Copyright (c) 2010-2016, Institute for Microelectronics,
3 Institute for Analysis and Scientific Computing,
4 TU Wien.
5 Portions of this software are copyright by UChicago Argonne, LLC.
6
7 -----------------
8 ViennaCL - The Vienna Computing Library
9 -----------------
10
11 Project Head: Karl Rupp rupp@iue.tuwien.ac.at
12
13 (A list of authors and contributors can be found in the PDF manual)
14
15 License: MIT (X11), see file LICENSE in the base directory
16 ============================================================================= */
17
22 //
23 // *** System
24 //
25 #include <iostream>
26 #include <stdlib.h>
27
28 //
29 // *** ViennaCL
30 //
31 //#define VCL_BUILD_INFO
32 //#define VIENNACL_WITH_UBLAS 1
33 #include "viennacl/matrix.hpp"
34 #include "viennacl/vector.hpp"
35
36 //
37 // -------------------------------------------------------------
38 //
39 template< typename NumericT >
40 int test()
41 {
42 int retval = EXIT_SUCCESS;
43 // --------------------------------------------------------------------------
44 typedef viennacl::vector<NumericT> VclVector;
45
46 VclVector vcl_cont(3);
47 vcl_cont[0] = 1;
48 vcl_cont[1] = 2;
49 vcl_cont[2] = 3;
50
51 //typename VclVector::const_iterator const_iter_def_const;
52 //typename VclVector::iterator iter_def_const;
53
54 for (typename VclVector::const_iterator iter = vcl_cont.begin();
55 iter != vcl_cont.end(); iter++)
56 {
57 std::cout << *iter << std::endl;
58 }
59
60 for (typename VclVector::iterator iter = vcl_cont.begin();
61 iter != vcl_cont.end(); iter++)
62 {
63 std::cout << *iter << std::endl;
64 }
65
66 // --------------------------------------------------------------------------
67 return retval;
68 }
69
70 int main()
71 {
72 std::cout << std::endl;
73 std::cout << "----------------------------------------------" << std::endl;
74 std::cout << "----------------------------------------------" << std::endl;
75 std::cout << "## Test :: Iterators" << std::endl;
76 std::cout << "----------------------------------------------" << std::endl;
77 std::cout << "----------------------------------------------" << std::endl;
78 std::cout << std::endl;
79
80 int retval = EXIT_SUCCESS;
81
82 std::cout << std::endl;
83 std::cout << "----------------------------------------------" << std::endl;
84 std::cout << std::endl;
85 {
86 typedef float NumericT;
87 std::cout << "# Testing setup:" << std::endl;
88 std::cout << " numeric: float" << std::endl;
89 retval = test<NumericT>();
90 if ( retval == EXIT_SUCCESS )
91 std::cout << "# Test passed" << std::endl;
92 else
93 return retval;
94 }
95 std::cout << std::endl;
96 std::cout << "----------------------------------------------" << std::endl;
97 std::cout << std::endl;
98
99 #ifdef VIENNACL_WITH_OPENCL
100 if ( viennacl::ocl::current_device().double_support() )
101 #endif
102 {
103 {
104 typedef double NumericT;
105 std::cout << "# Testing setup:" << std::endl;
106 std::cout << " numeric: double" << std::endl;
107 retval = test<NumericT>();
108 if ( retval == EXIT_SUCCESS )
109 std::cout << "# Test passed" << std::endl;
110 else
111 return retval;
112 }
113 std::cout << std::endl;
114 std::cout << "----------------------------------------------" << std::endl;
115 std::cout << std::endl;
116 }
117
118 std::cout << std::endl;
119 std::cout << "------- Test completed --------" << std::endl;
120 std::cout << std::endl;
121
122
123 return retval;
124 }
matrix.hpp
Implementation of the dense matrix class.
viennacl::ocl::current_device
viennacl::ocl::device const & current_device()
Convenience function for returning the active device in the current context.
Definition: backend.hpp:351
NumericT
float NumericT
Definition: bisect.cpp:40
test
int test()
Definition: iterators.cpp:40
viennacl::ocl::device::double_support
bool double_support() const
ViennaCL convenience function: Returns true if the device supports double precision.
Definition: device.hpp:956
viennacl::vector< NumericT >
vector.hpp
The vector type with operator-overloads and proxy classes is defined here. Linear algebra operations ...
main
int main()
Definition: iterators.cpp:70