23 #include <cusp/detail/config.h>
26 #include <cusp/detail/format.h>
27 #include <cusp/detail/matrix_base.h>
28 #include <cusp/detail/type_traits.h>
35 template <
typename IndexType,
typename ValueType,
class MemorySpace>
class ell_matrix;
36 template <
typename IndexType,
typename ValueType,
class MemorySpace>
class coo_matrix;
37 template <
typename MatrixType1,
typename MatrixType2,
typename IndexType,
typename ValueType,
class MemorySpace>
class hyb_matrix_view;
141 template <
typename IndexType,
typename ValueType,
class MemorySpace>
142 class hyb_matrix :
public cusp::detail::matrix_base<IndexType,ValueType,MemorySpace,cusp::hyb_format>
146 typedef cusp::detail::matrix_base<IndexType,ValueType,MemorySpace,cusp::hyb_format> Parent;
159 IndexType, ValueType, MemorySpace> view;
164 IndexType, ValueType, MemorySpace> const_view;
166 typedef typename cusp::detail::coo_view_type<container,cusp::hyb_format>::view coo_view_type;
167 typedef typename cusp::detail::coo_view_type<container const,cusp::hyb_format>::view const_coo_view_type;
169 template<
typename MemorySpace2>
198 IndexType num_ell_entries, IndexType num_coo_entries,
199 IndexType num_entries_per_row, IndexType alignment = 32)
200 : Parent(num_rows, num_cols, num_ell_entries + num_coo_entries),
201 ell(num_rows, num_cols, num_ell_entries, num_entries_per_row, alignment),
202 coo(num_rows, num_cols, num_coo_entries) {}
210 template <
typename MatrixType>
215 void resize(IndexType num_rows, IndexType num_cols,
216 IndexType num_ell_entries, IndexType num_coo_entries,
217 IndexType num_entries_per_row, IndexType alignment = 32)
219 Parent::resize(num_rows, num_cols, num_ell_entries + num_coo_entries);
220 ell.resize(num_rows, num_cols, num_ell_entries, num_entries_per_row, alignment);
221 coo.resize(num_rows, num_cols, num_coo_entries);
230 Parent::swap(matrix);
239 template <
typename MatrixType>
337 template <
typename MatrixType1,
338 typename MatrixType2,
339 typename IndexType =
typename MatrixType1::index_type,
340 typename ValueType =
typename MatrixType1::value_type,
341 typename MemorySpace =
typename cusp::minimum_space<typename MatrixType1::memory_space, typename MatrixType2::memory_space>::type >
342 class hyb_matrix_view :
public cusp::detail::matrix_base<IndexType,ValueType,MemorySpace,cusp::hyb_format>
346 typedef cusp::detail::matrix_base<IndexType,ValueType,MemorySpace,cusp::hyb_format> Parent;
351 typedef MatrixType1 ell_matrix_type;
352 typedef MatrixType2 coo_matrix_type;
358 typedef typename cusp::detail::coo_view_type<view,cusp::hyb_format>::view coo_view_type;
359 typedef typename cusp::detail::coo_view_type<view const,cusp::hyb_format>::view const_coo_view_type;
383 template <
typename OtherMatrixType1,
typename OtherMatrixType2>
385 : Parent(ell.num_rows, ell.num_cols, ell.num_entries + coo.num_entries), ell(ell), coo(coo) {}
396 template <
typename OtherMatrixType1,
typename OtherMatrixType2>
398 : Parent(ell.num_rows, ell.num_cols, ell.num_entries + coo.num_entries), ell(ell), coo(coo) {}
411 hyb_matrix_view(
const hyb_matrix<IndexType,ValueType,MemorySpace>& matrix)
437 void resize(
size_t num_rows,
size_t num_cols,
438 size_t num_ell_entries,
size_t num_coo_entries,
439 size_t num_entries_per_row,
size_t alignment = 32);
446 #include <cusp/detail/hyb_matrix.inl>
void swap(hyb_matrix &matrix)
void resize(IndexType num_rows, IndexType num_cols, IndexType num_ell_entries, IndexType num_coo_entries, IndexType num_entries_per_row, IndexType alignment=32)
Hybrid (HYB) representation a sparse matrix.
hyb_matrix(IndexType num_rows, IndexType num_cols, IndexType num_ell_entries, IndexType num_coo_entries, IndexType num_entries_per_row, IndexType alignment=32)
Coordinate (COO) representation a sparse matrix.
Packed row (ELLPACK/ITPACK) representation of a sparse matrix.
hyb_matrix & operator=(const MatrixType &matrix)
1D array of elements that may reside in "host" or "device" memory space
void resize(size_t num_rows, size_t num_cols, size_t num_ell_entries, size_t num_coo_entries, size_t num_entries_per_row, size_t alignment=32)