Skip to content

Commit cbc4aec

Browse files
committed
wip: use row-scatterer type
1 parent 4ad1dfe commit cbc4aec

File tree

4 files changed

+84
-0
lines changed

4 files changed

+84
-0
lines changed

core/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ target_sources(${ginkgo_core}
8282
matrix/identity.cpp
8383
matrix/permutation.cpp
8484
matrix/row_gatherer.cpp
85+
matrix/row_scatterer.cpp
8586
matrix/scaled_permutation.cpp
8687
matrix/sellp.cpp
8788
matrix/sparsity_csr.cpp

core/matrix/row_scatterer.cpp

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// SPDX-FileCopyrightText: 2024 The Ginkgo authors
2+
//
3+
// SPDX-License-Identifier: BSD-3-Clause
4+
5+
#include "ginkgo/core/matrix/row_scatterer.hpp"
6+
7+
namespace gko {
8+
namespace matrix {
9+
10+
11+
template <typename IndexType>
12+
RowScatterer<IndexType>::RowScatterer(std::shared_ptr<const Executor> exec)
13+
: EnableLinOp<RowScatterer>(std::move(exec))
14+
{}
15+
16+
17+
template <typename IndexType>
18+
RowScatterer<IndexType>::RowScatterer(std::shared_ptr<const Executor> exec,
19+
array<IndexType> idxs, size_type to_size)
20+
: EnableLinOp<RowScatterer>(exec, {to_size, idxs.get_size()}),
21+
idxs_(exec, std::move(idxs))
22+
{}
23+
24+
25+
template <typename IndexType>
26+
void RowScatterer<IndexType>::apply_impl(const LinOp* b, LinOp* x) const
27+
{}
28+
29+
30+
template <typename IndexType>
31+
void RowScatterer<IndexType>::apply_impl(const LinOp* alpha, const LinOp* b,
32+
const LinOp* beta, LinOp* x) const
33+
{}
34+
35+
36+
} // namespace matrix
37+
} // namespace gko
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// SPDX-FileCopyrightText: 2024 The Ginkgo authors
2+
//
3+
// SPDX-License-Identifier: BSD-3-Clause
4+
5+
#pragma once
6+
7+
#include <ginkgo/core/base/lin_op.hpp>
8+
9+
namespace gko {
10+
11+
namespace matrix {
12+
13+
14+
template <typename IndexType = int32>
15+
class RowScatterer : public EnableLinOp<RowScatterer<IndexType>> {
16+
friend class EnablePolymorphicObject<RowScatterer>;
17+
18+
public:
19+
static std::unique_ptr<RowScatterer> create(
20+
std::shared_ptr<const Executor> exec, array<IndexType> idxs,
21+
size_type to_size)
22+
{
23+
return std::unique_ptr<RowScatterer>(
24+
new RowScatterer(std::move(exec), std::move(idxs), to_size));
25+
}
26+
27+
protected:
28+
void apply_impl(const LinOp* b, LinOp* x) const override;
29+
30+
void apply_impl(const LinOp* alpha, const LinOp* b, const LinOp* beta,
31+
LinOp* x) const override;
32+
33+
private:
34+
explicit RowScatterer(std::shared_ptr<const Executor> exec);
35+
36+
explicit RowScatterer(std::shared_ptr<const Executor> exec,
37+
array<IndexType> idxs, size_type to_size);
38+
39+
array<IndexType> idxs_;
40+
};
41+
42+
43+
} // namespace matrix
44+
45+
} // namespace gko

include/ginkgo/ginkgo.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105
#include <ginkgo/core/matrix/identity.hpp>
106106
#include <ginkgo/core/matrix/permutation.hpp>
107107
#include <ginkgo/core/matrix/row_gatherer.hpp>
108+
#include <ginkgo/core/matrix/row_scatterer.hpp>
108109
#include <ginkgo/core/matrix/scaled_permutation.hpp>
109110
#include <ginkgo/core/matrix/sellp.hpp>
110111
#include <ginkgo/core/matrix/sparsity_csr.hpp>

0 commit comments

Comments
 (0)