ViennaCL - The Vienna Computing Library  1.5.2
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-2014, Institute for Microelectronics,
6  Institute for Analysis and Scientific Computing,
7  TU Wien.
8  Portions of this software are copyright by UChicago Argonne, LLC.
9 
10  -----------------
11  ViennaCL - The Vienna Computing Library
12  -----------------
13 
14  Project Head: Karl Rupp rupp@iue.tuwien.ac.at
15 
16  (A list of authors and contributors can be found in the PDF manual)
17 
18  License: MIT (X11), see file LICENSE in the base directory
19 ============================================================================= */
20 
25 #include <string>
26 #include <fstream>
27 #include <sstream>
28 #include "viennacl/forwards.h"
29 
30 #ifdef VIENNACL_WITH_UBLAS
31 #include <boost/numeric/ublas/matrix_sparse.hpp>
32 #include <boost/numeric/ublas/matrix.hpp>
33 #endif
34 
35 #ifdef VIENNACL_WITH_EIGEN
36 #include <Eigen/Core>
37 #include <Eigen/Sparse>
38 #endif
39 
40 #ifdef VIENNACL_WITH_MTL4
41 #include <boost/numeric/mtl/mtl.hpp>
42 #endif
43 
44 #include "viennacl/traits/size.hpp"
45 
46 #include <vector>
47 #include <map>
48 
49 namespace viennacl
50 {
51  namespace traits
52  {
53 
54  //clear:
56  template <typename VectorType>
57  void clear(VectorType & vec)
58  {
59  typedef typename viennacl::result_of::size_type<VectorType>::type size_type;
60 
61  for (size_type i=0; i<viennacl::traits::size(vec); ++i)
62  vec[i] = 0; //TODO: Quantity access can also be wrapped...
63  }
64 
66  template <typename ScalarType, unsigned int ALIGNMENT>
68  {
69  vec.clear();
70  }
71  } //namespace traits
72 } //namespace viennacl
73 
74 
75 #endif
Generic size and resize functionality for different vector and matrix types.
void clear(VectorType &vec)
Generic routine for setting all entries of a vector to zero. This is the version for non-ViennaCL obj...
Definition: clear.hpp:57
This file provides the forward declarations for the main types used within ViennaCL.
Main namespace in ViennaCL. Holds all the basic types such as vector, matrix, etc. and defines operations upon them.
Definition: cpu_ram.hpp:29
vcl_size_t size(VectorType const &vec)
Generic routine for obtaining the size of a vector (ViennaCL, uBLAS, etc.)
Definition: size.hpp:144
A vector class representing a linear memory sequence on the GPU. Inspired by boost::numeric::ublas::v...
Definition: forwards.h:208
T::size_type type
Definition: result_of.hpp:186
void clear()
Resets all entries to zero. Does not change the size of the vector.
Definition: vector.hpp:863