1 #ifndef VIENNACL_LINALG_PROD_HPP_
2 #define VIENNACL_LINALG_PROD_HPP_
43 #ifdef VIENNACL_WITH_MTL4
47 template<
typename MatrixT,
typename VectorT >
50 prod(MatrixT
const& matrix, VectorT
const& vector)
52 return VectorT(matrix * vector);
56 #ifdef VIENNACL_WITH_ARMADILLO
60 template<
typename NumericT,
typename VectorT>
61 VectorT
prod(arma::SpMat<NumericT>
const& A, VectorT
const& vector)
67 #ifdef VIENNACL_WITH_EIGEN
71 template<
typename MatrixT,
typename VectorT >
74 prod(MatrixT
const& matrix, VectorT
const& vector)
76 return matrix * vector;
80 #ifdef VIENNACL_WITH_UBLAS
84 template<
typename MatrixT,
typename VectorT >
87 prod(MatrixT
const& matrix, VectorT
const& vector)
100 template<
typename T,
typename A1,
typename A2,
typename VectorT >
104 VectorT result(
matrix.size());
105 for (
typename std::vector<T, A1>::size_type i=0; i<
matrix.size(); ++i)
108 for (
typename std::vector<T, A1>::size_type j=0; j<
matrix[i].size(); ++j)
109 result[i] +=
matrix[i][j] * vector[j];
115 template<
typename KEY,
typename DATA,
typename COMPARE,
typename AMAP,
typename AVEC,
typename VectorT >
117 prod(std::vector< std::map<KEY, DATA, COMPARE, AMAP>, AVEC >
const&
matrix, VectorT
const&
vector)
119 typedef std::vector< std::map<KEY, DATA, COMPARE, AMAP>, AVEC > MatrixType;
121 VectorT result(
matrix.size());
122 for (
typename MatrixType::size_type i=0; i<
matrix.size(); ++i)
125 for (
typename std::map<KEY, DATA, COMPARE, AMAP>::const_iterator row_entries =
matrix[i].begin();
126 row_entries !=
matrix[i].end();
128 result[i] += row_entries->second * vector[row_entries->first];
149 template<
typename NumericT>
153 prod(viennacl::matrix_base<NumericT>
const & A,
154 viennacl::matrix_base<NumericT>
const & B)
157 const viennacl::matrix_base<NumericT>,
162 template<
typename NumericT,
typename LhsT,
typename RhsT,
typename OpT>
166 prod(viennacl::matrix_base<NumericT>
const & A,
167 viennacl::matrix_expression<const LhsT, const RhsT, OpT>
const & B)
170 const viennacl::matrix_expression<const LhsT, const RhsT, OpT>,
175 template<
typename LhsT,
typename RhsT,
typename OpT,
typename NumericT>
177 const viennacl::matrix_base<NumericT>,
179 prod(viennacl::matrix_expression<const LhsT, const RhsT, OpT>
const & A,
180 viennacl::matrix_base<NumericT>
const & B)
183 const viennacl::matrix_base<NumericT>,
189 template<
typename LhsT1,
typename RhsT1,
typename OpT1,
190 typename LhsT2,
typename RhsT2,
typename OpT2>
195 viennacl::matrix_expression<const LhsT2, const RhsT2, OpT2>
const & B)
197 return viennacl::matrix_expression< const viennacl::matrix_expression<const LhsT1, const RhsT1, OpT1>,
198 const viennacl::matrix_expression<const LhsT2, const RhsT2, OpT2>,
205 template<
typename NumericT>
209 prod(viennacl::matrix_base<NumericT>
const & A,
210 viennacl::vector_base<NumericT>
const & x)
213 const viennacl::vector_base<NumericT>,
218 template<
typename NumericT,
typename F>
220 const viennacl::vector_base<NumericT>,
223 viennacl::vector_base<NumericT>
const & x)
226 const viennacl::vector_base<NumericT>,
231 template<
typename MatrixT,
typename NumericT>
233 const viennacl::vector_base<NumericT>,
236 viennacl::vector_base<NumericT>
const & x)
239 const viennacl::vector_base<NumericT>,
244 template<
typename MatrixT,
typename NumericT>
246 const viennacl::vector_base<NumericT>,
249 viennacl::vector_base<NumericT>
const & x)
252 const viennacl::vector_base<NumericT>,
257 template<
typename NumericT,
typename LhsT,
typename RhsT,
typename OpT>
259 const viennacl::vector_base<NumericT>,
261 prod(viennacl::matrix_expression<const LhsT, const RhsT, OpT>
const & A,
262 viennacl::vector_base<NumericT>
const & x)
265 const viennacl::vector_base<NumericT>,
271 template<
typename NumericT,
typename LhsT,
typename RhsT,
typename OpT>
275 prod(viennacl::matrix_base<NumericT>
const & A,
276 viennacl::vector_expression<const LhsT, const RhsT, OpT>
const & x)
279 const viennacl::vector_expression<const LhsT, const RhsT, OpT>,
285 template<
typename LhsT1,
typename RhsT1,
typename OpT1,
286 typename LhsT2,
typename RhsT2,
typename OpT2>
291 viennacl::vector_expression<const LhsT2, const RhsT2, OpT2>
const & x)
293 return viennacl::vector_expression< const viennacl::matrix_expression<const LhsT1, const RhsT1, OpT1>,
294 const viennacl::vector_expression<const LhsT2, const RhsT2, OpT2>,
301 template<
typename SparseMatrixType,
typename SCALARTYPE>
307 prod(
const SparseMatrixType & sp_mat,
316 template<
typename SparseMatrixType,
typename SCALARTYPE>
324 prod(
const SparseMatrixType & A,
326 const viennacl::matrix_base<SCALARTYPE>,
330 const viennacl::matrix_expression<const viennacl::matrix_base<SCALARTYPE>,
331 const viennacl::matrix_base<SCALARTYPE>,
338 template<
typename NumericT>
342 prod(compressed_matrix<NumericT>
const & A,
343 compressed_matrix<NumericT>
const & B)
346 const compressed_matrix<NumericT>,
351 template<
typename SparseMatrixType,
typename NumericT>
355 prod(
const SparseMatrixType & A,
356 const vector_base<NumericT> & x)
359 const vector_base<NumericT>,
Simple enable-if variant that uses the SFINAE pattern.
Dispatch facility for distinguishing between ublas, STL and ViennaCL types.
Class for representing strided submatrices of a bigger matrix A.
Expression template class for representing a tree of expressions which ultimately result in a matrix...
This file provides the forward declarations for the main types used within ViennaCL.
An expression template class that represents a binary operation that yields a vector.
Main namespace in ViennaCL. Holds all the basic types such as vector, matrix, etc. and defines operations upon them.
VectorT prod(std::vector< std::vector< T, A1 >, A2 > const &matrix, VectorT const &vector)
A tag class representing matrix-matrix products.
A tag class representing matrix-vector products and element-wise multiplications. ...
void prod(std::vector< std::map< IndexT, NumericT > > const &stl_A, std::vector< std::map< IndexT, NumericT > > const &stl_B, std::vector< std::map< IndexT, NumericT > > &stl_C)
A tag class representing transposed matrices.
Class for representing non-strided submatrices of a bigger matrix A.
Simple enable-if variant that uses the SFINAE pattern.