All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
clear.hpp
Go to the documentation of this file.
#ifndef VIENNACL_TRAITS_CLEAR_HPP_
#define VIENNACL_TRAITS_CLEAR_HPP_
/* =========================================================================
Copyright (c) 2010-2016, Institute for Microelectronics,
Institute for Analysis and Scientific Computing,
TU Wien.
Portions of this software are copyright by UChicago Argonne, LLC.
-----------------
ViennaCL - The Vienna Computing Library
-----------------
Project Head: Karl Rupp rupp@iue.tuwien.ac.at
(A list of authors and contributors can be found in the manual)
License: MIT (X11), see file LICENSE in the base directory
============================================================================= */
#include <string>
#include <fstream>
#include <sstream>
#include "viennacl/forwards.h"
#include "viennacl/traits/size.hpp"
#include <vector>
#include <map>
namespace viennacl
{
namespace traits
{
//clear:
template<typename VectorType>
void clear(VectorType & vec)
{
typedef typename viennacl::result_of::size_type<VectorType>::type size_type;
for (size_type i=0; i<viennacl::traits::size(vec); ++i)
vec[i] = 0; //TODO: Quantity access can also be wrapped...
}
template<typename ScalarType, unsigned int AlignmentV>
void clear(viennacl::vector<ScalarType, AlignmentV> & vec)
{
vec.clear();
}
} //namespace traits
} //namespace viennacl
#endif
viennacl::result_of::size_type::type
T::size_type type
Definition: result_of.hpp:141
size.hpp
Generic size and resize functionality for different vector and matrix types.
viennacl::traits::clear
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
forwards.h
This file provides the forward declarations for the main types used within ViennaCL.
viennacl::traits::size
vcl_size_t size(VectorType const &vec)
Generic routine for obtaining the size of a vector (ViennaCL, uBLAS, etc.)
Definition: size.hpp:239
viennacl::vector
Definition: forwards.h:266
viennacl::vector_base< NumericT >::clear
void clear()
Resets all entries to zero. Does not change the size of the vector.