ViennaCL - The Vienna Computing Library  1.5.2
viennacl/traits/clear.hpp
Go to the documentation of this file.
00001 #ifndef VIENNACL_TRAITS_CLEAR_HPP_
00002 #define VIENNACL_TRAITS_CLEAR_HPP_
00003 
00004 /* =========================================================================
00005    Copyright (c) 2010-2014, Institute for Microelectronics,
00006                             Institute for Analysis and Scientific Computing,
00007                             TU Wien.
00008    Portions of this software are copyright by UChicago Argonne, LLC.
00009 
00010                             -----------------
00011                   ViennaCL - The Vienna Computing Library
00012                             -----------------
00013 
00014    Project Head:    Karl Rupp                   rupp@iue.tuwien.ac.at
00015 
00016    (A list of authors and contributors can be found in the PDF manual)
00017 
00018    License:         MIT (X11), see file LICENSE in the base directory
00019 ============================================================================= */
00020 
00025 #include <string>
00026 #include <fstream>
00027 #include <sstream>
00028 #include "viennacl/forwards.h"
00029 
00030 #ifdef VIENNACL_WITH_UBLAS
00031 #include <boost/numeric/ublas/matrix_sparse.hpp>
00032 #include <boost/numeric/ublas/matrix.hpp>
00033 #endif
00034 
00035 #ifdef VIENNACL_WITH_EIGEN
00036 #include <Eigen/Core>
00037 #include <Eigen/Sparse>
00038 #endif
00039 
00040 #ifdef VIENNACL_WITH_MTL4
00041 #include <boost/numeric/mtl/mtl.hpp>
00042 #endif
00043 
00044 #include "viennacl/traits/size.hpp"
00045 
00046 #include <vector>
00047 #include <map>
00048 
00049 namespace viennacl
00050 {
00051   namespace traits
00052   {
00053 
00054     //clear:
00056     template <typename VectorType>
00057     void clear(VectorType & vec)
00058     {
00059       typedef typename viennacl::result_of::size_type<VectorType>::type  size_type;
00060 
00061       for (size_type i=0; i<viennacl::traits::size(vec); ++i)
00062         vec[i] = 0;  //TODO: Quantity access can also be wrapped...
00063     }
00064 
00066     template <typename ScalarType, unsigned int ALIGNMENT>
00067     void clear(viennacl::vector<ScalarType, ALIGNMENT> & vec)
00068     {
00069       vec.clear();
00070     }
00071   } //namespace traits
00072 } //namespace viennacl
00073 
00074 
00075 #endif