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_EIGEN
60 template<
typename MatrixT,
typename VectorT >
63 prod(MatrixT
const& matrix, VectorT
const& vector)
65 return matrix * vector;
69 #ifdef VIENNACL_WITH_UBLAS
73 template<
typename MatrixT,
typename VectorT >
76 prod(MatrixT
const& matrix, VectorT
const& vector)
89 template<
typename T,
typename A1,
typename A2,
typename VectorT >
93 VectorT result(
matrix.size());
94 for (
typename std::vector<T, A1>::size_type i=0; i<
matrix.size(); ++i)
97 for (
typename std::vector<T, A1>::size_type j=0; j<
matrix[i].size(); ++j)
98 result[i] +=
matrix[i][j] * vector[j];
104 template<
typename KEY,
typename DATA,
typename COMPARE,
typename AMAP,
typename AVEC,
typename VectorT >
106 prod(std::vector< std::map<KEY, DATA, COMPARE, AMAP>, AVEC >
const&
matrix, VectorT
const&
vector)
108 typedef std::vector< std::map<KEY, DATA, COMPARE, AMAP>, AVEC > MatrixType;
110 VectorT result(
matrix.size());
111 for (
typename MatrixType::size_type i=0; i<
matrix.size(); ++i)
114 for (
typename std::map<KEY, DATA, COMPARE, AMAP>::const_iterator row_entries =
matrix[i].begin();
115 row_entries !=
matrix[i].end();
117 result[i] += row_entries->second * vector[row_entries->first];
138 template<
typename NumericT,
typename F1,
typename F2>
143 viennacl::matrix_base<NumericT, F2>
const & B)
147 const viennacl::matrix_base<NumericT, F2>,
152 template<
typename NumericT,
typename F1,
typename F2>
155 const viennacl::matrix_base<NumericT, F2>,
160 const viennacl::matrix_base<NumericT, F2>,
165 const viennacl::matrix_expression<const viennacl::matrix_base<NumericT, F2>,
166 const viennacl::matrix_base<NumericT, F2>,
172 template<
typename NumericT,
typename F1,
typename F2>
176 const viennacl::matrix_base<NumericT, F2>,
179 const viennacl::matrix_base<NumericT, F1>,
181 viennacl::matrix_base<NumericT, F2>
const & B)
185 const viennacl::matrix_base<NumericT, F1>,
187 const viennacl::matrix_base<NumericT, F2>,
193 template<
typename NumericT,
typename F1,
typename F2>
195 const viennacl::matrix_base<NumericT, F1>,
197 const viennacl::matrix_expression<const viennacl::matrix_base<NumericT, F2>,
198 const viennacl::matrix_base<NumericT, F2>,
202 const viennacl::matrix_base<NumericT, F1>,
205 const viennacl::matrix_base<NumericT, F2>,
210 const viennacl::matrix_base<NumericT, F1>,
212 const viennacl::matrix_expression<const viennacl::matrix_base<NumericT, F2>,
213 const viennacl::matrix_base<NumericT, F2>,
221 template<
typename NumericT,
typename F>
226 viennacl::vector_base<NumericT>
const &
vector)
230 const viennacl::vector_base<NumericT>,
235 template<
typename NumericT,
typename F>
239 const viennacl::vector_base<NumericT>,
242 const viennacl::matrix_base<NumericT, F>,
244 viennacl::vector_base<NumericT>
const &
vector)
248 const viennacl::matrix_base<NumericT, F>,
250 const viennacl::vector_base<NumericT>,
255 template<
typename SparseMatrixType,
class SCALARTYPE>
261 prod(
const SparseMatrixType & mat,
262 const vector_base<SCALARTYPE> & vec)
265 const vector_base<SCALARTYPE>,
269 template<
typename SparseMatrixType,
typename SCALARTYPE,
typename F1>
275 prod(
const SparseMatrixType & sp_mat,
284 template<
typename SparseMatrixType,
typename SCALARTYPE,
typename F1 >
292 prod(
const SparseMatrixType & A,
304 template<
typename StructuredMatrixType,
class SCALARTYPE>
307 const vector_base<SCALARTYPE>,
310 prod(
const StructuredMatrixType & mat,
311 const vector_base<SCALARTYPE> & vec)
314 const vector_base<SCALARTYPE>,
Simple enable-if variant that uses the SFINAE pattern.
Definition: enable_if.hpp:29
Dispatch facility for distinguishing between ublas, STL and ViennaCL types.
viennacl::enable_if< viennacl::is_any_dense_structured_matrix< StructuredMatrixType >::value, vector_expression< const StructuredMatrixType, const vector_base< SCALARTYPE >, op_prod > >::type prod(const StructuredMatrixType &mat, const vector_base< SCALARTYPE > &vec)
Definition: prod.hpp:310
A dense matrix class.
Definition: forwards.h:293
Common base class for dense vectors, vector ranges, and vector slices.
Definition: forwards.h:205
This file provides the forward declarations for the main types used within ViennaCL.
A dense matrix class.
Definition: forwards.h:290
Main namespace in ViennaCL. Holds all the basic types such as vector, matrix, etc. and defines operations upon them.
Definition: cpu_ram.hpp:29
VectorT prod(std::vector< std::vector< T, A1 >, A2 > const &matrix, VectorT const &vector)
Definition: prod.hpp:91
An expression template class that represents a binary operation that yields a vector.
Definition: forwards.h:181
A tag class representing matrix-matrix products.
Definition: forwards.h:78
Expression template class for representing a tree of expressions which ultimately result in a matrix...
Definition: forwards.h:283
A vector class representing a linear memory sequence on the GPU. Inspired by boost::numeric::ublas::v...
Definition: forwards.h:208
A tag class representing matrix-vector products and element-wise multiplications. ...
Definition: forwards.h:76
A tag class representing transposed matrices.
Definition: forwards.h:165
Simple enable-if variant that uses the SFINAE pattern.