|
Ginkgo
Generated from pipelines/1330831941 branch based on master. Ginkgo version 1.8.0
A numerical linear algebra library targeting many-core architectures
|
5 #ifndef GKO_PUBLIC_CORE_MATRIX_SELLP_HPP_
6 #define GKO_PUBLIC_CORE_MATRIX_SELLP_HPP_
9 #include <ginkgo/core/base/array.hpp>
10 #include <ginkgo/core/base/lin_op.hpp>
17 constexpr
int default_slice_size = 64;
18 constexpr
int default_stride_factor = 1;
21 template <
typename ValueType>
24 template <
typename ValueType,
typename IndexType>
42 template <
typename ValueType = default_precision,
typename IndexType =
int32>
43 class Sellp :
public EnableLinOp<Sellp<ValueType, IndexType>>,
44 public ConvertibleTo<Sellp<next_precision<ValueType>, IndexType>>,
45 public ConvertibleTo<Dense<ValueType>>,
46 public ConvertibleTo<Csr<ValueType, IndexType>>,
47 public DiagonalExtractable<ValueType>,
48 public ReadableFromMatrixData<ValueType, IndexType>,
49 public WritableToMatrixData<ValueType, IndexType>,
50 public EnableAbsoluteComputation<
51 remove_complex<Sellp<ValueType, IndexType>>> {
52 friend class EnablePolymorphicObject<
Sellp,
LinOp>;
53 friend class Dense<ValueType>;
54 friend class Csr<ValueType, IndexType>;
61 Sellp<next_precision<ValueType>, IndexType>>::convert_to;
62 using ConvertibleTo<Sellp<next_precision<ValueType>, IndexType>>::move_to;
63 using ConvertibleTo<Dense<ValueType>>::convert_to;
64 using ConvertibleTo<Dense<ValueType>>::move_to;
65 using ConvertibleTo<Csr<ValueType, IndexType>>::convert_to;
66 using ConvertibleTo<Csr<ValueType, IndexType>>::move_to;
69 using value_type = ValueType;
70 using index_type = IndexType;
71 using mat_data = matrix_data<ValueType, IndexType>;
72 using device_mat_data = device_matrix_data<ValueType, IndexType>;
73 using absolute_type = remove_complex<Sellp>;
78 Sellp<next_precision<ValueType>, IndexType>* result)
const override;
80 void move_to(
Sellp<next_precision<ValueType>, IndexType>* result)
override;
82 void convert_to(Dense<ValueType>* other)
const override;
84 void move_to(Dense<ValueType>* other)
override;
86 void convert_to(Csr<ValueType, IndexType>* other)
const override;
88 void move_to(Csr<ValueType, IndexType>* other)
override;
90 void read(
const mat_data& data)
override;
92 void read(
const device_mat_data& data)
override;
94 void read(device_mat_data&& data)
override;
96 void write(mat_data& data)
const override;
204 return values_.
get_size() / slice_size_;
232 return values_.
get_data()[this->linearize_index(row, slice_set, idx)];
260 return this->
get_col_idxs()[this->linearize_index(row, slice_set, idx)];
270 ->get_const_col_idxs()[this->linearize_index(row, slice_set, idx)];
283 static std::unique_ptr<Sellp>
create(std::shared_ptr<const Executor> exec,
299 static std::unique_ptr<Sellp>
create(std::shared_ptr<const Executor> exec,
332 Sellp(std::shared_ptr<const Executor> exec,
const dim<2>& size = {},
335 Sellp(std::shared_ptr<const Executor> exec,
const dim<2>& size,
338 void apply_impl(
const LinOp* b,
LinOp* x)
const override;
341 LinOp* x)
const override;
346 return (slice_set + col) * slice_size_ + row;
350 array<value_type> values_;
351 array<index_type> col_idxs_;
352 array<size_type> slice_lengths_;
353 array<size_type> slice_sets_;
363 #endif // GKO_PUBLIC_CORE_MATRIX_SELLP_HPP_
const size_type * get_const_slice_sets() const noexcept
Returns the offsets of slices.
Definition: sellp.hpp:178
size_type get_stride_factor() const noexcept
Returns the stride factor(t) of SELL-P.
Definition: sellp.hpp:195
void move_to(result_type *result) override
Definition: polymorphic_object.hpp:732
void convert_to(result_type *result) const override
Definition: polymorphic_object.hpp:730
Sellp(const Sellp &)
Copy-assigns a Sellp matrix.
virtual void read(const matrix_data< ValueType, IndexType > &data)=0
Reads a matrix from a matrix_data structure.
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:257
value_type * get_values() noexcept
Returns the values of the matrix.
Definition: sellp.hpp:109
Sellp & operator=(const Sellp &)
Copy-assigns a Sellp matrix.
size_type get_num_stored_elements() const noexcept
Returns the number of elements explicitly stored in the matrix.
Definition: sellp.hpp:212
std::size_t size_type
Integral type used for allocation quantities.
Definition: types.hpp:108
static std::unique_ptr< Sellp > create(std::shared_ptr< const Executor > exec, const dim< 2 > &size={}, size_type total_cols=0)
Creates an uninitialized Sellp matrix of the specified size.
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:229
void write(mat_data &data) const override
Writes a matrix to a matrix_data structure.
const index_type * get_const_col_idxs() const noexcept
Returns the column indexes of the matrix.
Definition: sellp.hpp:137
void read(const mat_data &data) override
Reads a matrix from a matrix_data structure.
index_type * get_col_idxs() noexcept
Returns the column indexes of the matrix.
Definition: sellp.hpp:128
size_type * get_slice_lengths() noexcept
Returns the lengths(columns) of slices.
Definition: sellp.hpp:147
size_type * get_slice_sets() noexcept
Returns the offsets of slices.
Definition: sellp.hpp:169
The Ginkgo namespace.
Definition: abstract_factory.hpp:20
std::unique_ptr< absolute_type > compute_absolute() const override
Gets the AbsoluteLinOp.
const size_type * get_const_slice_lengths() const noexcept
Returns the lengths(columns) of slices.
Definition: sellp.hpp:159
typename detail::next_precision_impl< T >::type next_precision
Obtains the next type in the singly-linked precision list.
Definition: math.hpp:462
value_type * get_data() noexcept
Returns a pointer to the block of memory used to store the elements of the array.
Definition: array.hpp:674
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:238
size_type get_total_cols() const noexcept
Returns the total column number.
Definition: sellp.hpp:202
size_type get_slice_size() const noexcept
Returns the size of a slice.
Definition: sellp.hpp:188
void compute_absolute_inplace() override
Compute absolute inplace on each element.
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:683
std::unique_ptr< Diagonal< ValueType > > extract_diagonal() const override
Extracts the diagonal entries of the matrix into a vector.
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:266
size_type get_size() const noexcept
Returns the number of elements in the array.
Definition: array.hpp:657
const value_type * get_const_values() const noexcept
Returns the values of the matrix.
Definition: sellp.hpp:118
LinOp(const LinOp &)=default
Copy-constructs a LinOp.
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:345