33 #ifndef GKO_CORE_MATRIX_COO_HPP_ 34 #define GKO_CORE_MATRIX_COO_HPP_ 37 #include <ginkgo/core/base/array.hpp> 38 #include <ginkgo/core/base/lin_op.hpp> 50 template <
typename ValueType,
typename IndexType>
54 template <
typename ValueType>
72 template <
typename ValueType = default_precision,
typename IndexType =
int32>
81 friend class Csr<ValueType, IndexType>;
82 friend class Dense<ValueType>;
88 using value_type = ValueType;
89 using index_type = IndexType;
183 this->validate_application_parameters(b, x);
193 const LinOp *
apply2(
const LinOp *b, LinOp *x)
const 195 this->validate_application_parameters(b, x);
211 LinOp *
apply2(
const LinOp *alpha,
const LinOp *b, LinOp *x)
213 this->validate_application_parameters(b, x);
214 GKO_ASSERT_EQUAL_DIMENSIONS(alpha,
dim<2>(1, 1));
225 const LinOp *
apply2(
const LinOp *alpha,
const LinOp *b, LinOp *x)
const 227 this->validate_application_parameters(b, x);
228 GKO_ASSERT_EQUAL_DIMENSIONS(alpha,
dim<2>(1, 1));
244 Coo(std::shared_ptr<const Executor> exec,
const dim<2> &size =
dim<2>{},
247 values_(exec, num_nonzeros),
248 col_idxs_(exec, num_nonzeros),
249 row_idxs_(exec, num_nonzeros)
272 template <
typename ValuesArray,
typename ColIdxsArray,
273 typename RowIdxsArray>
274 Coo(std::shared_ptr<const Executor> exec,
const dim<2> &size,
275 ValuesArray &&values, ColIdxsArray &&col_idxs, RowIdxsArray &&row_idxs)
277 values_{exec, std::forward<ValuesArray>(values)},
278 col_idxs_{exec, std::forward<ColIdxsArray>(col_idxs)},
279 row_idxs_{exec, std::forward<RowIdxsArray>(row_idxs)}
287 void apply_impl(
const LinOp *b, LinOp *x)
const override;
289 void apply_impl(
const LinOp *alpha,
const LinOp *b,
const LinOp *beta,
290 LinOp *x)
const override;
292 void apply2_impl(
const LinOp *b, LinOp *x)
const;
294 void apply2_impl(
const LinOp *alpha,
const LinOp *b, LinOp *x)
const;
307 #endif // GKO_CORE_MATRIX_COO_HPP_
This mixin implements a static create() method on ConcreteType that dynamically allocates the memory...
Definition: polymorphic_object.hpp:576
size_type get_num_elems() const noexcept
Returns the number of elements in the Array.
Definition: array.hpp:388
const LinOp * apply2(const LinOp *b, LinOp *x) const
Definition: coo.hpp:193
ConvertibleTo interface is used to mark that the implementer can be converted to the object of Result...
Definition: polymorphic_object.hpp:380
void read(const mat_data &data) override
Reads a matrix from a matrix_data structure.
const index_type * get_const_row_idxs() const noexcept
Definition: coo.hpp:156
This mixin inherits from (a subclass of) PolymorphicObject and provides a base implementation of a ne...
Definition: polymorphic_object.hpp:505
index_type * get_col_idxs() noexcept
Returns the column indexes of the matrix.
Definition: coo.hpp:128
LinOp * apply2(const LinOp *alpha, const LinOp *b, LinOp *x)
Performs the operation x = alpha * Coo * b + x.
Definition: coo.hpp:211
const value_type * get_const_values() const noexcept
Returns the values of the matrix.
Definition: coo.hpp:118
std::size_t size_type
Integral type used for allocation quantities.
Definition: types.hpp:94
void write(mat_data &data) const override
Writes a matrix to a matrix_data structure.
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:406
The Ginkgo namespace.
Definition: abstract_factory.hpp:45
CSR is a matrix format which stores only the nonzero coefficients by compressing each row of the matr...
Definition: coo.hpp:51
const LinOp * apply2(const LinOp *alpha, const LinOp *b, LinOp *x) const
Performs the operation x = alpha * Coo * b + x.
Definition: coo.hpp:225
index_type * get_row_idxs() noexcept
Returns the row indexes of the matrix.
Definition: coo.hpp:147
value_type * get_values() noexcept
Returns the values of the matrix.
Definition: coo.hpp:109
Dense is a matrix format which explicitly stores all values of the matrix.
Definition: coo.hpp:55
The EnableLinOp mixin can be used to provide sensible default implementations of the majority of the ...
Definition: lin_op.hpp:509
COO stores a matrix in the coordinate matrix format.
Definition: coo.hpp:73
const index_type * get_const_col_idxs() const noexcept
Returns the column indexes of the matrix.
Definition: coo.hpp:137
std::shared_ptr< const Executor > get_executor() const noexcept
Returns the Executor of the object.
Definition: polymorphic_object.hpp:201
LinOp * apply2(const LinOp *b, LinOp *x)
Applies Coo matrix axpy to a vector (or a sequence of vectors).
Definition: coo.hpp:181
A LinOp implementing this interface can write its data to a matrix_data structure.
Definition: lin_op.hpp:446
value_type * get_data() noexcept
Returns a pointer to the block of memory used to store the elements of the Array. ...
Definition: array.hpp:397
size_type get_num_stored_elements() const noexcept
Returns the number of elements explicitly stored in the matrix.
Definition: coo.hpp:166
This structure is used as an intermediate data type to store a sparse matrix.
Definition: matrix_data.hpp:102
A LinOp implementing this interface can read its data from a matrix_data structure.
Definition: lin_op.hpp:426
temporary_clone< T > make_temporary_clone(std::shared_ptr< const Executor > exec, T *ptr)
Creates a temporary_clone.
Definition: utils.hpp:474