30 template<
typename MatrixType, 
typename ScalarType>
 
   33   matrix(row, col) = value;
 
   36 #ifdef VIENNACL_HAVE_EIGEN 
   37 template<
typename ScalarType, 
int option>
 
   38 void insert(Eigen::SparseMatrix<ScalarType, option> & matrix, 
long row, 
long col, 
double value)
 
   40   matrix.fill(row, col) = value;
 
   44 template<
typename MatrixType>
 
   50     void apply(
long row, 
long col, 
double value)
 
   52       insert(mat_, row, col, value);
 
   59 #ifdef VIENNACL_HAVE_MTL4 
   60 #include <boost/numeric/mtl/matrix/inserter.hpp> 
   72 template<
typename ScalarType>
 
   78 template<
typename ScalarType>
 
   81     typedef mtl::compressed2D<ScalarType>    MatrixType;
 
   83     my_inserter(MatrixType & mat) : mat_(mat), ins_(mat) {}
 
   87       typename mtl::Collection<MatrixType>::value_type val(value);
 
   88       ins_(row, col) << val;
 
   93     mtl::matrix::inserter<MatrixType> ins_;
 
   97 template<
typename VectorType>
 
  103 template<
typename VectorType>
 
  109   std::ifstream file(filename.c_str());
 
  111   if (!file) 
return false;
 
  118   for (
unsigned int i = 0; i < 
size; ++i)
 
  129 template<
class MatrixType>
 
  134   std::cout << 
"Reading matrix..." << std::endl;
 
  136   std::ifstream file(filename.c_str());
 
  138   if (!file) 
return false;
 
  142   if (
id != 
"Matrix") 
return false;
 
  145   unsigned int num_rows, num_columns;
 
  146   file >> num_rows >> num_columns;
 
  147   if (num_rows != num_columns) 
return false;
 
  152   for (
unsigned int row = 0; row < num_rows; ++
row)
 
  156     for (
int j = 0; j < num_entries; ++j)
 
  160       file >> column >> element;
 
  162       ins.
apply(row, column, element);
 
Generic size and resize functionality for different vector and matrix types. 
my_inserter(MatrixType &mat)
vcl_size_t size(VectorType const &vec)
Generic routine for obtaining the size of a vector (ViennaCL, uBLAS, etc.) 
void insert(MatrixType &matrix, long row, long col, ScalarType value)
void resize(MatrixType &matrix, vcl_size_t rows, vcl_size_t cols)
Generic resize routine for resizing a matrix (ViennaCL, uBLAS, etc.) to a new size/dimension. 
bool readMatrixFromFile(const std::string &filename, MatrixType &matrix)
bool readVectorFromFile(const std::string &filename, VectorType &vec)
vector_expression< const matrix_base< NumericT, F >, const unsigned int, op_row > row(const matrix_base< NumericT, F > &A, unsigned int i)
void resize_vector(VectorType &vec, unsigned int size)
void apply(long row, long col, double value)
vector_expression< const matrix_base< NumericT, F >, const unsigned int, op_column > column(const matrix_base< NumericT, F > &A, unsigned int j)
A collection of compile time type deductions.