ViennaCL - The Vienna Computing Library  1.2.0
clear.hpp
Go to the documentation of this file.
1 #ifndef VIENNACL_TRAITS_CLEAR_HPP_
2 #define VIENNACL_TRAITS_CLEAR_HPP_
3 
4 /* =========================================================================
5  Copyright (c) 2010-2011, Institute for Microelectronics,
6  Institute for Analysis and Scientific Computing,
7  TU Wien.
8 
9  -----------------
10  ViennaCL - The Vienna Computing Library
11  -----------------
12 
13  Project Head: Karl Rupp rupp@iue.tuwien.ac.at
14 
15  (A list of authors and contributors can be found in the PDF manual)
16 
17  License: MIT (X11), see file LICENSE in the base directory
18 ============================================================================= */
19 
24 #include <string>
25 #include <fstream>
26 #include <sstream>
27 #include "viennacl/forwards.h"
28 
29 #ifdef VIENNACL_HAVE_UBLAS
30 #include <boost/numeric/ublas/matrix_sparse.hpp>
31 #include <boost/numeric/ublas/matrix.hpp>
32 #endif
33 
34 #ifdef VIENNACL_HAVE_EIGEN
35 #include <Eigen/Core>
36 #include <Eigen/Sparse>
37 #endif
38 
39 #ifdef VIENNACL_HAVE_MTL4
40 #include <boost/numeric/mtl/mtl.hpp>
41 #endif
42 
43 #include "viennacl/traits/size.hpp"
44 
45 #include <vector>
46 #include <map>
47 
48 namespace viennacl
49 {
50  namespace traits
51  {
52 
53  //clear:
54  template <typename VectorType>
55  void clear(VectorType & vec)
56  {
57  typedef typename viennacl::result_of::size_type<VectorType>::type size_type;
58 
59  for (size_type i=0; i<viennacl::traits::size(vec); ++i)
60  vec[i] = 0; //TODO: Quantity access can also be wrapped...
61  }
62 
63  template <typename ScalarType, unsigned int ALIGNMENT>
65  {
66  vec.clear();
67  }
68  } //namespace traits
69 } //namespace viennacl
70 
71 
72 #endif