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>
98 assert( (mat.size1() == result.
size()) &&
bool(
"Size check failed for compressed matrix-vector product: size1(mat) != size(result)"));
99 assert( (mat.size2() == vec.
size()) &&
bool(
"Size check failed for compressed matrix-vector product: size2(mat) != size(x)"));
106 #ifdef VIENNACL_WITH_OPENCL
111 #ifdef VIENNACL_WITH_CUDA
133 template<
typename SparseMatrixType,
class ScalarType>
139 assert( (sp_mat.size1() == result.
size1()) &&
bool(
"Size check failed for compressed matrix - dense matrix product: size1(sp_mat) != size1(result)"));
140 assert( (sp_mat.size2() == d_mat.
size1()) &&
bool(
"Size check failed for compressed matrix - dense matrix product: size2(sp_mat) != size1(d_mat)"));
147 #ifdef VIENNACL_WITH_OPENCL
152 #ifdef VIENNACL_WITH_CUDA
173 template<
typename SparseMatrixType,
class ScalarType>
181 assert( (sp_mat.size1() == result.
size1()) &&
bool(
"Size check failed for compressed matrix - dense matrix product: size1(sp_mat) != size1(result)"));
182 assert( (sp_mat.size2() == d_mat.size1()) &&
bool(
"Size check failed for compressed matrix - dense matrix product: size2(sp_mat) != size1(d_mat)"));
189 #ifdef VIENNACL_WITH_OPENCL
194 #ifdef VIENNACL_WITH_CUDA
217 template<
typename NumericT>
223 assert( (A.
size2() == B.
size1()) &&
bool(
"Size check failed for sparse matrix-matrix product: size2(A) != size1(B)"));
224 assert( (C.
size1() == 0 || C.
size1() == A.
size1()) &&
bool(
"Size check failed for sparse matrix-matrix product: size1(A) != size1(C)"));
225 assert( (C.
size2() == 0 || C.
size2() == B.
size2()) &&
bool(
"Size check failed for sparse matrix-matrix product: size2(B) != size2(B)"));
232 #ifdef VIENNACL_WITH_OPENCL
237 #ifdef VIENNACL_WITH_CUDA
256 template<
typename SparseMatrixType,
class ScalarType,
typename SOLVERTAG>
262 assert( (mat.size1() == mat.size2()) &&
bool(
"Size check failed for triangular solve on compressed matrix: size1(mat) != size2(mat)"));
263 assert( (mat.size2() == vec.
size()) &&
bool(
"Size check failed for compressed matrix-vector product: size2(mat) != size(x)"));
270 #ifdef VIENNACL_WITH_OPENCL
275 #ifdef VIENNACL_WITH_CUDA
294 template<
typename SparseMatrixType,
class ScalarType,
typename SOLVERTAG>
300 assert( (mat.
size1() == mat.
size2()) &&
bool(
"Size check failed for triangular solve on transposed compressed matrix: size1(mat) != size2(mat)"));
301 assert( (mat.
size1() == vec.
size()) &&
bool(
"Size check failed for transposed compressed matrix triangular solve: size1(mat) != size(x)"));
308 #ifdef VIENNACL_WITH_OPENCL
313 #ifdef VIENNACL_WITH_CUDA
330 template<
typename SparseMatrixType,
class ScalarType,
typename SOLVERTAG>
338 assert( (mat.
size1() == mat.
size2()) &&
bool(
"Size check failed for triangular solve on transposed compressed matrix: size1(mat) != size2(mat)"));
339 assert( (mat.
size1() == vec.
size()) &&
bool(
"Size check failed for transposed compressed matrix triangular solve: size1(mat) != size(x)"));
346 #ifdef VIENNACL_WITH_OPENCL
351 #ifdef VIENNACL_WITH_CUDA
372 template<
typename M1>
374 matrix_expression< const M1, const M1, op_trans>
387 template<
typename SCALARTYPE,
typename SparseMatrixType>
393 assert(proxy.lhs().size1() == result.
size() && bool(
"Dimensions for addition of sparse matrix-vector product to vector don't match!"));
405 template<
typename SCALARTYPE,
typename SparseMatrixType>
411 assert(proxy.lhs().size1() == result.
size() && bool(
"Dimensions for addition of sparse matrix-vector product to vector don't match!"));
const vcl_size_t & size2() const
Returns the number of columns.
Simple enable-if variant that uses the SFINAE pattern.
void inplace_solve(matrix_base< NumericT > const &A, matrix_base< NumericT > &B, SolverTagT tag)
Direct inplace solver for triangular systems with multiple right hand sides, i.e. A \ B (MATLAB notat...
void inplace_solve(const matrix_base< NumericT > &A, matrix_base< NumericT > &B, SolverTagT)
Direct inplace solver for triangular systems with multiple right hand sides, i.e. A \ B (MATLAB notat...
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.
void prod_impl(const matrix_base< NumericT > &mat, bool trans_A, const vector_base< NumericT > &vec, vector_base< NumericT > &result)
Carries out matrix-vector multiplication.
Exception class in case of memory errors.
const vcl_size_t & size1() const
Returns the number of rows.
Implementation of the dense matrix class.
Implementations of operations using sparse matrices on the CPU using a single thread or OpenMP...
void inplace_solve(matrix_base< NumericT > const &A, matrix_base< NumericT > &B, SolverTagT)
Direct inplace solver for triangular systems with multiple right hand sides, i.e. A \ B (MATLAB notat...
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.
void row_info(compressed_matrix< NumericT, AligmentV > const &mat, vector_base< NumericT > &vec, viennacl::linalg::detail::row_info_types info_selector)
void prod_impl(const matrix_base< NumericT > &mat, bool mat_transpose, const vector_base< NumericT > &vec, vector_base< NumericT > &result)
Carries out matrix-vector multiplication.
An expression template class that represents a binary operation that yields a vector.
vcl_size_t size1() const
Returns the size of the result vector.
viennacl::vector< NumericT > operator-(const vector_base< NumericT > &v1, const vector_expression< const matrix_base< NumericT >, const vector_base< NumericT >, op_prod > &proxy)
Implementation of the operation 'result = v1 - A * v2', where A is a matrix.
void prod_impl(const matrix_base< NumericT > &mat, bool trans, const vector_base< NumericT > &vec, vector_base< NumericT > &result)
Carries out matrix-vector multiplication.
Implementations of operations using sparse matrices using CUDA.
Common base class for dense vectors, vector ranges, and vector slices.
void block_inplace_solve(const matrix_expression< const compressed_matrix< NumericT, AlignmentV >, const compressed_matrix< NumericT, AlignmentV >, op_trans > &L, viennacl::backend::mem_handle const &, vcl_size_t, vector_base< NumericT > const &, vector_base< NumericT > &vec, viennacl::linalg::unit_lower_tag)
void block_inplace_solve(const matrix_expression< const compressed_matrix< NumericT, AlignmentV >, const compressed_matrix< NumericT, AlignmentV >, op_trans > &L, viennacl::backend::mem_handle const &block_indices, vcl_size_t num_blocks, vector_base< NumericT > const &, vector_base< NumericT > &vec, viennacl::linalg::unit_lower_tag)
size_type size1() const
Returns the number of rows.
Implementations of operations using sparse matrices and OpenCL.
void inplace_solve(matrix_base< NumericT > const &A, matrix_base< NumericT > &B, SolverTagT)
Direct inplace solver for dense triangular systems. Matlab notation: A \ B.
viennacl::vector< NumericT > operator+(const vector_base< NumericT > &v1, const vector_expression< const matrix_base< NumericT >, const vector_base< NumericT >, op_prod > &proxy)
Implementation of the operation 'result = v1 + A * v2', where A is a matrix.
A tag class representing matrix-vector products and element-wise multiplications. ...
The vector type with operator-overloads and proxy classes is defined here. Linear algebra operations ...
size_type size() const
Returns the length of the vector (cf. std::vector)
Main abstraction class for multiple memory domains. Represents a buffer in either main RAM...
A tag class representing transposed matrices.
void row_info(compressed_matrix< NumericT, AlignmentV > const &mat, vector_base< NumericT > &vec, viennacl::linalg::detail::row_info_types info_selector)
void prod_impl(const matrix_base< NumericT > &mat, const vector_base< NumericT > &vec, vector_base< NumericT > &result)
Carries out matrix-vector multiplication.
viennacl::backend::mem_handle & handle(T &obj)
Returns the generic memory handle of an object. Non-const version.
void block_inplace_solve(const matrix_expression< const compressed_matrix< NumericT, AlignmentV >, const compressed_matrix< NumericT, AlignmentV >, op_trans > &L, viennacl::backend::mem_handle const &block_indices, vcl_size_t num_blocks, vector_base< NumericT > const &, vector_base< NumericT > &x, viennacl::linalg::unit_lower_tag)
LHS & lhs() const
Get left hand side operand.
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)
Implementation of the ViennaCL scalar class.
void row_info(compressed_matrix< NumericT, AlignmentV > const &A, vector_base< NumericT > &x, viennacl::linalg::detail::row_info_types info_selector)
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...
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)