Ginkgo Generated from branch based on master. Ginkgo version 1.8.0
A numerical linear algebra library targeting many-core architectures
Loading...
Searching...
No Matches
row_gatherer.hpp
1// SPDX-FileCopyrightText: 2017 - 2024 The Ginkgo authors
2//
3// SPDX-License-Identifier: BSD-3-Clause
4
5#ifndef GKO_PUBLIC_CORE_MATRIX_ROW_GATHERER_HPP_
6#define GKO_PUBLIC_CORE_MATRIX_ROW_GATHERER_HPP_
7
8
9#include <algorithm>
10#include <memory>
11#include <numeric>
12#include <vector>
13
14
15#include <ginkgo/core/base/array.hpp>
16#include <ginkgo/core/base/exception.hpp>
17#include <ginkgo/core/base/exception_helpers.hpp>
18#include <ginkgo/core/base/executor.hpp>
19#include <ginkgo/core/base/lin_op.hpp>
20#include <ginkgo/core/base/types.hpp>
21#include <ginkgo/core/base/utils.hpp>
22
23
24namespace gko {
25namespace matrix {
26
27
43template <typename IndexType = int32>
44class RowGatherer : public EnableLinOp<RowGatherer<IndexType>> {
46
47public:
48 using index_type = IndexType;
49
55 index_type* get_row_idxs() noexcept { return row_idxs_.get_data(); }
56
64 const index_type* get_const_row_idxs() const noexcept
65 {
66 return row_idxs_.get_const_data();
67 }
68
77 static std::unique_ptr<RowGatherer> create(
78 std::shared_ptr<const Executor> exec, const dim<2>& size = {});
79
94 static std::unique_ptr<RowGatherer> create(
95 std::shared_ptr<const Executor> exec, const dim<2>& size,
96 array<index_type> row_idxs);
97
108 static std::unique_ptr<const RowGatherer> create_const(
109 std::shared_ptr<const Executor> exec, const dim<2>& size,
110 gko::detail::const_array_view<IndexType>&& row_idxs);
111
112protected:
113 RowGatherer(std::shared_ptr<const Executor> exec, const dim<2>& size = {});
114
115 RowGatherer(std::shared_ptr<const Executor> exec, const dim<2>& size,
116 array<index_type> row_idxs);
117
118 void apply_impl(const LinOp* in, LinOp* out) const override;
119
120 void apply_impl(const LinOp* alpha, const LinOp* in, const LinOp* beta,
121 LinOp* out) const override;
122
123private:
124 gko::array<index_type> row_idxs_;
125};
126
127
128} // namespace matrix
129} // namespace gko
130
131
132#endif // GKO_PUBLIC_CORE_MATRIX_ROW_GATHERER_HPP_
The EnableLinOp mixin can be used to provide sensible default implementations of the majority of the ...
Definition lin_op.hpp:880
This mixin inherits from (a subclass of) PolymorphicObject and provides a base implementation of a ne...
Definition polymorphic_object.hpp:663
Definition lin_op.hpp:118
An array is a container which encapsulates fixed-sized arrays, stored on the Executor tied to the arr...
Definition logger.hpp:25
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
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
RowGatherer is a matrix "format" which stores the gather indices arrays which can be used to gather r...
Definition row_gatherer.hpp:44
static std::unique_ptr< const RowGatherer > create_const(std::shared_ptr< const Executor > exec, const dim< 2 > &size, gko::detail::const_array_view< IndexType > &&row_idxs)
Creates a constant (immutable) RowGatherer matrix from a constant array.
index_type * get_row_idxs() noexcept
Returns a pointer to the row index array for gathering.
Definition row_gatherer.hpp:55
static std::unique_ptr< RowGatherer > create(std::shared_ptr< const Executor > exec, const dim< 2 > &size={})
Creates uninitialized RowGatherer arrays of the specified size.
const index_type * get_const_row_idxs() const noexcept
Returns a pointer to the row index array for gathering.
Definition row_gatherer.hpp:64
static std::unique_ptr< RowGatherer > create(std::shared_ptr< const Executor > exec, const dim< 2 > &size, array< index_type > row_idxs)
Creates a RowGatherer matrix from an already allocated (and initialized) row gathering array.
The Ginkgo namespace.
Definition abstract_factory.hpp:20
A type representing the dimensions of a multidimensional object.
Definition dim.hpp:27