ViennaCL - The Vienna Computing Library  1.5.1
viennacl/traits/fill.hpp
Go to the documentation of this file.
00001 #ifndef VIENNACL_TRAITS_FILL_HPP_
00002 #define VIENNACL_TRAITS_FILL_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 #include "viennacl/meta/result_of.hpp"
00030 
00031 #ifdef VIENNACL_WITH_EIGEN
00032 #include <Eigen/Core>
00033 #include <Eigen/Sparse>
00034 #endif
00035 
00036 #include <vector>
00037 #include <map>
00038 
00039 namespace viennacl
00040 {
00041 
00042   namespace traits
00043   {
00044 
00046     template <typename MatrixType, typename SCALARTYPE>
00047     void fill(MatrixType & matrix, vcl_size_t row_index, vcl_size_t col_index, SCALARTYPE value)
00048     {
00049       matrix(row_index, col_index) = value;
00050     }
00051 
00052     #ifdef VIENNACL_WITH_EIGEN
00053 
00054     template <typename T, int options, typename SCALARTYPE>
00055     inline void fill(Eigen::SparseMatrix<T, options> & m,
00056                      vcl_size_t row_index,
00057                      vcl_size_t col_index,
00058                      SCALARTYPE value
00059                     )
00060     {
00061       m.insert(row_index, col_index) = value;
00062     }
00063     #endif
00064 
00065 
00066   } //namespace traits
00067 } //namespace viennacl
00068 
00069 
00070 #endif