1 #ifndef VIENNACL_LINALG_SPARSE_MATRIX_OPERATIONS_HPP_
2 #define VIENNACL_LINALG_SPARSE_MATRIX_OPERATIONS_HPP_
32 #ifdef VIENNACL_WITH_OPENCL
36 #ifdef VIENNACL_WITH_CUDA
48 template<
typename SparseMatrixType,
typename SCALARTYPE,
unsigned int VEC_ALIGNMENT>
59 #ifdef VIENNACL_WITH_OPENCL
64 #ifdef VIENNACL_WITH_CUDA
90 template<
typename SparseMatrixType,
class ScalarType>
96 assert( (mat.size1() == result.
size()) &&
bool(
"Size check failed for compressed matrix-vector product: size1(mat) != size(result)"));
97 assert( (mat.size2() == vec.
size()) &&
bool(
"Size check failed for compressed matrix-vector product: size2(mat) != size(x)"));
104 #ifdef VIENNACL_WITH_OPENCL
109 #ifdef VIENNACL_WITH_CUDA
131 template<
typename SparseMatrixType,
class ScalarType,
typename F1,
typename F2>
137 assert( (sp_mat.size1() == result.
size1()) &&
bool(
"Size check failed for compressed matrix - dense matrix product: size1(sp_mat) != size1(result)"));
138 assert( (sp_mat.size2() == d_mat.
size1()) &&
bool(
"Size check failed for compressed matrix - dense matrix product: size2(sp_mat) != size1(d_mat)"));
145 #ifdef VIENNACL_WITH_OPENCL
150 #ifdef VIENNACL_WITH_CUDA
171 template<
typename SparseMatrixType,
class ScalarType,
typename F1,
typename F2>
179 assert( (sp_mat.size1() == result.
size1()) &&
bool(
"Size check failed for compressed matrix - dense matrix product: size1(sp_mat) != size1(result)"));
180 assert( (sp_mat.size2() == d_mat.size1()) &&
bool(
"Size check failed for compressed matrix - dense matrix product: size2(sp_mat) != size1(d_mat)"));
187 #ifdef VIENNACL_WITH_OPENCL
192 #ifdef VIENNACL_WITH_CUDA
210 template<
typename SparseMatrixType,
class ScalarType,
typename SOLVERTAG>
216 assert( (mat.size1() == mat.size2()) &&
bool(
"Size check failed for triangular solve on compressed matrix: size1(mat) != size2(mat)"));
217 assert( (mat.size2() == vec.
size()) &&
bool(
"Size check failed for compressed matrix-vector product: size2(mat) != size(x)"));
224 #ifdef VIENNACL_WITH_OPENCL
229 #ifdef VIENNACL_WITH_CUDA
248 template<
typename SparseMatrixType,
class ScalarType,
typename SOLVERTAG>
254 assert( (mat.
size1() == mat.
size2()) &&
bool(
"Size check failed for triangular solve on transposed compressed matrix: size1(mat) != size2(mat)"));
255 assert( (mat.
size1() == vec.
size()) &&
bool(
"Size check failed for transposed compressed matrix triangular solve: size1(mat) != size(x)"));
262 #ifdef VIENNACL_WITH_OPENCL
267 #ifdef VIENNACL_WITH_CUDA
284 template<
typename SparseMatrixType,
class ScalarType,
typename SOLVERTAG>
292 assert( (mat.
size1() == mat.
size2()) &&
bool(
"Size check failed for triangular solve on transposed compressed matrix: size1(mat) != size2(mat)"));
293 assert( (mat.
size1() == vec.
size()) &&
bool(
"Size check failed for transposed compressed matrix triangular solve: size1(mat) != size(x)"));
300 #ifdef VIENNACL_WITH_OPENCL
305 #ifdef VIENNACL_WITH_CUDA
326 template<
typename M1>
328 matrix_expression< const M1, const M1, op_trans>
341 template <
typename SCALARTYPE,
typename SparseMatrixType>
347 assert(proxy.lhs().size1() == result.
size() && bool(
"Dimensions for addition of sparse matrix-vector product to vector don't match!"));
359 template <
typename SCALARTYPE,
typename SparseMatrixType>
365 assert(proxy.lhs().size1() == result.
size() && bool(
"Dimensions for addition of sparse matrix-vector product to vector don't match!"));
Simple enable-if variant that uses the SFINAE pattern.
Definition: enable_if.hpp:29
size_type size1() const
Returns the number of rows.
Definition: matrix.hpp:625
std::size_t vcl_size_t
Definition: forwards.h:58
size_type size() const
Returns the length of the vector (cf. std::vector)
Definition: vector.hpp:859
Definition: forwards.h:478
viennacl::enable_if< viennacl::is_any_sparse_matrix< M1 >::value, matrix_expression< const M1, const M1, op_trans > >::type trans(const M1 &mat)
Returns an expression template class representing a transposed matrix.
Definition: sparse_matrix_operations.hpp:330
Exception class in case of memory errors.
Definition: forwards.h:485
void inplace_solve(const matrix_base< NumericT, F1 > &A, matrix_base< NumericT, F2 > &B, SOLVERTAG)
Direct inplace solver for dense triangular systems. Matlab notation: A \ B.
Definition: direct_solve.hpp:54
Implementation of the dense matrix class.
Implementations of operations using sparse matrices on the CPU using a single thread or OpenMP...
A dense matrix class.
Definition: forwards.h:290
void row_info(compressed_matrix< ScalarType, MAT_ALIGNMENT > const &mat, vector_base< ScalarType > &vec, viennacl::linalg::detail::row_info_types info_selector)
Definition: sparse_matrix_operations.hpp:100
Expression template class for representing a tree of expressions which ultimately result in a matrix...
Definition: forwards.h:283
void inplace_solve(const matrix_base< NumericT, F1 > &A, matrix_base< NumericT, F2 > &B, SOLVERTAG tag)
Direct inplace solver for triangular systems with multiple right hand sides, i.e. A \ B (MATLAB notat...
Definition: direct_solve.hpp:297
This file provides the forward declarations for the main types used within ViennaCL.
void prod_impl(const matrix_base< NumericT, F > &mat, const vector_base< NumericT > &vec, vector_base< NumericT > &result)
Carries out matrix-vector multiplication.
Definition: matrix_operations.hpp:737
An expression template class that represents a binary operation that yields a vector.
Definition: forwards.h:181
Definition: forwards.h:481
void inplace_solve(const matrix_base< NumericT, F1 > &A, matrix_base< NumericT, F2 > &B, SOLVERTAG)
Direct inplace solver for triangular systems with multiple right hand sides, i.e. A \ B (MATLAB notat...
Definition: direct_solve.hpp:130
memory_types get_active_handle_id() const
Returns an ID for the currently active memory buffer. Other memory buffers might contain old or no da...
Definition: mem_handle.hpp:91
Definition: forwards.h:480
Implementations of operations using sparse matrices using CUDA.
vcl_size_t size1() const
Returns the size of the result vector.
Definition: matrix.hpp:180
vcl_size_t size2() const
Definition: matrix.hpp:181
A vector class representing a linear memory sequence on the GPU. Inspired by boost::numeric::ublas::v...
Definition: forwards.h:208
void block_inplace_solve(const matrix_expression< const compressed_matrix< ScalarType, MAT_ALIGNMENT >, const compressed_matrix< ScalarType, MAT_ALIGNMENT >, op_trans > &L, viennacl::backend::mem_handle const &block_indices, vcl_size_t num_blocks, vector_base< ScalarType > const &, vector_base< ScalarType > &vec, viennacl::linalg::unit_lower_tag)
Definition: sparse_matrix_operations.hpp:613
viennacl::vector< NumericT > operator-(const vector_base< NumericT > &v1, const vector_expression< const matrix_base< NumericT, F >, const vector_base< NumericT >, op_prod > &proxy)
Implementation of the operation 'result = v1 - A * v2', where A is a matrix.
Definition: matrix_operations.hpp:858
void block_inplace_solve(const matrix_expression< const compressed_matrix< ScalarType, MAT_ALIGNMENT >, const compressed_matrix< ScalarType, MAT_ALIGNMENT >, op_trans > &L, viennacl::backend::mem_handle const &block_indices, vcl_size_t num_blocks, vector_base< ScalarType > const &, vector_base< ScalarType > &vec, viennacl::linalg::unit_lower_tag)
Definition: sparse_matrix_operations.hpp:289
Implementations of operations using sparse matrices and OpenCL.
void inplace_solve(const matrix_base< NumericT, F1 > &A, matrix_base< NumericT, F2 > &B, SOLVERTAG)
Direct inplace solver for dense triangular systems. Matlab notation: A \ B.
Definition: direct_solve.hpp:75
void block_inplace_solve(const matrix_expression< const compressed_matrix< ScalarType, MAT_ALIGNMENT >, const compressed_matrix< ScalarType, MAT_ALIGNMENT >, op_trans > &L, viennacl::backend::mem_handle const &, vcl_size_t, vector_base< ScalarType > const &, vector_base< ScalarType > &vec, viennacl::linalg::unit_lower_tag)
Definition: sparse_matrix_operations.hpp:620
A tag class representing matrix-vector products and element-wise multiplications. ...
Definition: forwards.h:76
row_info_types
Definition: forwards.h:691
The vector type with operator-overloads and proxy classes is defined here. Linear algebra operations ...
Definition: forwards.h:479
Main abstraction class for multiple memory domains. Represents a buffer in either main RAM...
Definition: mem_handle.hpp:62
A tag class representing transposed matrices.
Definition: forwards.h:165
void prod_impl(const matrix_base< NumericT, F > &mat, const vector_base< NumericT > &vec, vector_base< NumericT > &result)
Carries out matrix-vector multiplication.
Definition: matrix_operations.hpp:547
void prod_impl(const matrix_base< NumericT, F > &mat, const vector_base< NumericT > &vec, vector_base< NumericT > &result)
Carries out matrix-vector multiplication.
Definition: matrix_operations.hpp:350
viennacl::backend::mem_handle & handle(T &obj)
Returns the generic memory handle of an object. Non-const version.
Definition: handle.hpp:41
LHS & lhs() const
Get left hand side operand.
Definition: matrix.hpp:174
viennacl::enable_if< viennacl::is_any_sparse_matrix< SparseMatrixType >::value >::type row_info(SparseMatrixType const &mat, vector< SCALARTYPE, VEC_ALIGNMENT > &vec, row_info_types info_selector)
Definition: sparse_matrix_operations.hpp:50
void row_info(compressed_matrix< SCALARTYPE, MAT_ALIGNMENT > const &mat, vector_base< SCALARTYPE > &vec, viennacl::linalg::detail::row_info_types info_selector)
Definition: sparse_matrix_operations.hpp:53
Implementation of the ViennaCL scalar class.
viennacl::vector< NumericT > operator+(const vector_base< NumericT > &v1, const vector_expression< const matrix_base< NumericT, F >, const vector_base< NumericT >, op_prod > &proxy)
Implementation of the operation 'result = v1 + A * v2', where A is a matrix.
Definition: matrix_operations.hpp:840
void row_info(compressed_matrix< ScalarType, MAT_ALIGNMENT > const &mat, vector_base< ScalarType > &vec, viennacl::linalg::detail::row_info_types info_selector)
Definition: sparse_matrix_operations.hpp:47
void prod_impl(const matrix_base< NumericT, F > &mat, const vector_base< NumericT > &vec, vector_base< NumericT > &result)
Carries out matrix-vector multiplication.
Definition: matrix_operations.hpp:1364
viennacl::enable_if< viennacl::is_any_sparse_matrix< SparseMatrixType >::value >::type block_inplace_solve(const matrix_expression< const SparseMatrixType, const SparseMatrixType, op_trans > &mat, viennacl::backend::mem_handle const &block_index_array, vcl_size_t num_blocks, viennacl::vector_base< ScalarType > const &mat_diagonal, viennacl::vector_base< ScalarType > &vec, SOLVERTAG tag)
Definition: sparse_matrix_operations.hpp:286