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
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-2016, 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 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 #include "viennacl/traits/size.hpp"
31 
32 #include <vector>
33 #include <map>
34 
35 namespace viennacl
36 {
37 namespace traits
38 {
39 
40 //clear:
42 template<typename VectorType>
43 void clear(VectorType & vec)
44 {
45  typedef typename viennacl::result_of::size_type<VectorType>::type size_type;
46 
47  for (size_type i=0; i<viennacl::traits::size(vec); ++i)
48  vec[i] = 0; //TODO: Quantity access can also be wrapped...
49 }
50 
52 template<typename ScalarType, unsigned int AlignmentV>
54 {
55  vec.clear();
56 }
57 
58 } //namespace traits
59 } //namespace viennacl
60 
61 
62 #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:43
This file provides the forward declarations for the main types used within ViennaCL.
vcl_size_t size(VectorType const &vec)
Generic routine for obtaining the size of a vector (ViennaCL, uBLAS, etc.)
Definition: size.hpp:239
void clear()
Resets all entries to zero. Does not change the size of the vector.