ViennaCL - The Vienna Computing Library  1.2.0
fill.hpp
Go to the documentation of this file.
1 #ifndef VIENNACL_TRAITS_FILL_HPP_
2 #define VIENNACL_TRAITS_FILL_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"
29 
30 #ifdef VIENNACL_HAVE_EIGEN
31 #include <Eigen/Core>
32 #include <Eigen/Sparse>
33 #endif
34 
35 #include <vector>
36 #include <map>
37 
38 namespace viennacl
39 {
40 
41  namespace traits
42  {
43  //
44  // Resize: Change the size of vectors and matrices
45  //
46  template <typename MatrixType, typename SCALARTYPE>
47  void fill(MatrixType & matrix, std::size_t row_index, std::size_t col_index, SCALARTYPE value)
48  {
49  matrix(row_index, col_index) = value;
50  }
51 
52  #ifdef VIENNACL_HAVE_EIGEN
53  template <typename T, int options, typename SCALARTYPE>
54  inline void fill(Eigen::SparseMatrix<T, options> & m,
55  std::size_t row_index,
56  std::size_t col_index,
57  SCALARTYPE value
58  )
59  {
60  m.fill(row_index, col_index) = value;
61  }
62  #endif
63 
64 
65  } //namespace traits
66 } //namespace viennacl
67 
68 
69 #endif