33#ifndef GKO_PUBLIC_CORE_MATRIX_SELLP_HPP_
34#define GKO_PUBLIC_CORE_MATRIX_SELLP_HPP_
37#include <ginkgo/core/base/array.hpp>
38#include <ginkgo/core/base/lin_op.hpp>
45constexpr int default_slice_size = 64;
46constexpr int default_stride_factor = 1;
49template <
typename ValueType>
52template <
typename ValueType,
typename IndexType>
70template <
typename ValueType = default_precision,
typename IndexType =
int32>
73 public ConvertibleTo<Sellp<next_precision<ValueType>, IndexType>>,
80 remove_complex<Sellp<ValueType, IndexType>>> {
83 friend class Dense<ValueType>;
84 friend class Csr<ValueType, IndexType>;
99 using value_type = ValueType;
100 using index_type = IndexType;
300 ->get_const_col_idxs()[this->linearize_index(row,
slice_set,
idx)];
340 ceildiv(size[0], default_slice_size) * size[1])
351 Sellp(std::shared_ptr<const Executor> exec,
const dim<2>& size,
353 :
Sellp(std::
move(exec), size, default_slice_size,
367 Sellp(std::shared_ptr<const Executor> exec,
const dim<2>& size,
369 : EnableLinOp<
Sellp>(exec, size),
378 slice_lengths_.
fill(0);
381 void apply_impl(
const LinOp* b, LinOp* x)
const override;
383 void apply_impl(
const LinOp* alpha,
const LinOp* b,
const LinOp* beta,
384 LinOp* x)
const override;
389 return (
slice_set + col) * slice_size_ + row;
393 array<value_type> values_;
394 array<index_type> col_idxs_;
395 array<size_type> slice_lengths_;
396 array<size_type> slice_sets_;
ConvertibleTo interface is used to mark that the implementer can be converted to the object of Result...
Definition polymorphic_object.hpp:499
The EnableAbsoluteComputation mixin provides the default implementations of compute_absolute_linop an...
Definition lin_op.hpp:823
This mixin implements a static create() method on ConcreteType that dynamically allocates the memory,...
Definition polymorphic_object.hpp:776
The EnableLinOp mixin can be used to provide sensible default implementations of the majority of the ...
Definition lin_op.hpp:908
This mixin inherits from (a subclass of) PolymorphicObject and provides a base implementation of a ne...
Definition polymorphic_object.hpp:691
Definition lin_op.hpp:146
A LinOp implementing this interface can read its data from a matrix_data structure.
Definition lin_op.hpp:634
A LinOp implementing this interface can write its data to a matrix_data structure.
Definition lin_op.hpp:689
value_type * get_data() noexcept
Returns a pointer to the block of memory used to store the elements of the array.
Definition array.hpp:646
const value_type * get_const_data() const noexcept
Returns a constant pointer to the block of memory used to store the elements of the array.
Definition array.hpp:655
void fill(const value_type value)
Fill the array with the given value.
size_type get_num_elems() const noexcept
Returns the number of elements in the array.
Definition array.hpp:637
This type is a device-side equivalent to matrix_data.
Definition device_matrix_data.hpp:63
CSR is a matrix format which stores only the nonzero coefficients by compressing each row of the matr...
Definition csr.hpp:146
Dense is a matrix format which explicitly stores all values of the matrix.
Definition dense.hpp:136
SELL-P is a matrix format similar to ELL format.
Definition sellp.hpp:80
size_type get_slice_size() const noexcept
Returns the size of a slice.
Definition sellp.hpp:218
void read(const device_mat_data &data) override
Reads a matrix from a device_matrix_data structure.
value_type & val_at(size_type row, size_type slice_set, size_type idx) noexcept
Returns the idx-th non-zero element of the row-th row with slice_set slice set.
Definition sellp.hpp:259
index_type & col_at(size_type row, size_type slice_set, size_type idx) noexcept
Returns the idx-th column index of the row-th row with slice_set slice set.
Definition sellp.hpp:287
Sellp(const Sellp &)
Copy-assigns a Sellp matrix.
std::unique_ptr< absolute_type > compute_absolute() const override
Gets the AbsoluteLinOp.
void read(const mat_data &data) override
Reads a matrix from a matrix_data structure.
value_type * get_values() noexcept
Returns the values of the matrix.
Definition sellp.hpp:139
void read(device_mat_data &&data) override
Reads a matrix from a device_matrix_data structure.
Sellp & operator=(Sellp &&)
Move-assigns a Sellp matrix.
size_type get_stride_factor() const noexcept
Returns the stride factor(t) of SELL-P.
Definition sellp.hpp:225
const size_type * get_const_slice_sets() const noexcept
Returns the offsets of slices.
Definition sellp.hpp:208
index_type * get_col_idxs() noexcept
Returns the column indexes of the matrix.
Definition sellp.hpp:158
size_type get_total_cols() const noexcept
Returns the total column number.
Definition sellp.hpp:232
index_type col_at(size_type row, size_type slice_set, size_type idx) const noexcept
Returns the idx-th column index of the row-th row with slice_set slice set.
Definition sellp.hpp:296
size_type * get_slice_lengths() noexcept
Returns the lengths(columns) of slices.
Definition sellp.hpp:177
Sellp & operator=(const Sellp &)
Copy-assigns a Sellp matrix.
void compute_absolute_inplace() override
Compute absolute inplace on each element.
size_type * get_slice_sets() noexcept
Returns the offsets of slices.
Definition sellp.hpp:199
size_type get_num_stored_elements() const noexcept
Returns the number of elements explicitly stored in the matrix.
Definition sellp.hpp:242
void write(mat_data &data) const override
Writes a matrix to a matrix_data structure.
value_type val_at(size_type row, size_type slice_set, size_type idx) const noexcept
Returns the idx-th non-zero element of the row-th row with slice_set slice set.
Definition sellp.hpp:268
const index_type * get_const_col_idxs() const noexcept
Returns the column indexes of the matrix.
Definition sellp.hpp:167
Sellp(Sellp &&)
Move-assigns a Sellp matrix.
std::unique_ptr< Diagonal< ValueType > > extract_diagonal() const override
Extracts the diagonal entries of the matrix into a vector.
const size_type * get_const_slice_lengths() const noexcept
Returns the lengths(columns) of slices.
Definition sellp.hpp:189
const value_type * get_const_values() const noexcept
Returns the values of the matrix.
Definition sellp.hpp:148
The Ginkgo namespace.
Definition abstract_factory.hpp:48
constexpr T one()
Returns the multiplicative identity for T.
Definition math.hpp:803
typename detail::remove_complex_s< T >::type remove_complex
Obtain the type which removed the complex of complex/scalar type or the template parameter of class b...
Definition math.hpp:354
typename detail::next_precision_impl< T >::type next_precision
Obtains the next type in the singly-linked precision list.
Definition math.hpp:490
typename detail::to_complex_s< T >::type to_complex
Obtain the type which adds the complex of complex/scalar type or the template parameter of class by a...
Definition math.hpp:373
constexpr int64 ceildiv(int64 num, int64 den)
Performs integer division with rounding up.
Definition math.hpp:641
std::size_t size_type
Integral type used for allocation quantities.
Definition types.hpp:120
A type representing the dimensions of a multidimensional object.
Definition dim.hpp:55
This structure is used as an intermediate data type to store a sparse matrix.
Definition matrix_data.hpp:155