Ginkgo: ginkgo/core/matrix/row_gatherer.hpp Source File

| Ginkgo Generated from branch based on main. Ginkgo version 1.11.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#include <ginkgo/core/base/array.hpp>
15#include <ginkgo/core/base/exception.hpp>
16#include <ginkgo/core/base/exception_helpers.hpp>
17#include <ginkgo/core/base/executor.hpp>
18#include <ginkgo/core/base/lin_op.hpp>
19#include <ginkgo/core/base/types.hpp>
20#include <ginkgo/core/base/utils.hpp>
21
22
23namespace gko {
24namespace matrix {
25
26
42template <typename IndexType = int32>
43 class RowGatherer : public EnableLinOp<RowGatherer<IndexType>> {
44 friend class EnablePolymorphicObject<RowGatherer, LinOp>;
45
46public:
47 using index_type = IndexType;
48
54 index_type* get_row_idxs() noexcept { return row_idxs_.get_data(); }
55
63 const index_type* get_const_row_idxs() const noexcept
64 {
65 return row_idxs_.get_const_data();
66 }
67
76 static std::unique_ptr<RowGatherer> create(
77 std::shared_ptr<const Executor> exec, const dim<2>& size = {});
78
93 static std::unique_ptr<RowGatherer> create(
94 std::shared_ptr<const Executor> exec, const dim<2>& size,
95 array<index_type> row_idxs);
96
107 static std::unique_ptr<const RowGatherer> create_const(
108 std::shared_ptr<const Executor> exec, const dim<2>& size,
109 gko::detail::const_array_view<IndexType>&& row_idxs);
110
111protected:
112 RowGatherer(std::shared_ptr<const Executor> exec, const dim<2>& size = {});
113
114 RowGatherer(std::shared_ptr<const Executor> exec, const dim<2>& size,
115 array<index_type> row_idxs);
116
117 void apply_impl(const LinOp* in, LinOp* out) const override;
118
119 void apply_impl(const LinOp* alpha, const LinOp* in, const LinOp* beta,
120 LinOp* out) const override;
121
122private:
123 gko::array<index_type> row_idxs_;
124};
125
126
127} // namespace matrix
128} // namespace gko
129
130
131#endif // GKO_PUBLIC_CORE_MATRIX_ROW_GATHERER_HPP_
gko::EnableLinOp
The EnableLinOp mixin can be used to provide sensible default implementations of the majority of the ...
Definition lin_op.hpp:879
gko::EnablePolymorphicObject
This mixin inherits from (a subclass of) PolymorphicObject and provides a base implementation of a ne...
Definition polymorphic_object.hpp:668
gko::LinOp
Definition lin_op.hpp:117
gko::array
An array is a container which encapsulates fixed-sized arrays, stored on the Executor tied to the arr...
Definition array.hpp:166
gko::matrix::RowGatherer
RowGatherer is a matrix "format" which stores the gather indices arrays which can be used to gather r...
Definition row_gatherer.hpp:43
gko::matrix::RowGatherer::create_const
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.
gko::matrix::RowGatherer::get_row_idxs
index_type * get_row_idxs() noexcept
Returns a pointer to the row index array for gathering.
Definition row_gatherer.hpp:54
gko::matrix::RowGatherer::create
static std::unique_ptr< RowGatherer > create(std::shared_ptr< const Executor > exec, const dim< 2 > &size={})
Creates uninitialized RowGatherer arrays of the specified size.
gko::matrix::RowGatherer::get_const_row_idxs
const index_type * get_const_row_idxs() const noexcept
Returns a pointer to the row index array for gathering.
Definition row_gatherer.hpp:63
gko::matrix::RowGatherer::create
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.
gko::matrix
The matrix namespace.
Definition dense_cache.hpp:24
gko
The Ginkgo namespace.
Definition abstract_factory.hpp:20
gko::dim
A type representing the dimensions of a multidimensional object.
Definition dim.hpp:26