Ginkgo: ginkgo/core/matrix/fft.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
fft.hpp
1// SPDX-FileCopyrightText: 2017 - 2025 The Ginkgo authors
2//
3// SPDX-License-Identifier: BSD-3-Clause
4
5#ifndef GKO_PUBLIC_CORE_MATRIX_FFT_HPP_
6#define GKO_PUBLIC_CORE_MATRIX_FFT_HPP_
7
8
9#include <ginkgo/core/base/array.hpp>
10#include <ginkgo/core/base/lin_op.hpp>
11
12
13namespace gko {
14namespace matrix {
15
16
45 class Fft : public EnableLinOp<Fft>,
46 public WritableToMatrixData<std::complex<float>, int32>,
47 public WritableToMatrixData<std::complex<float>, int64>,
48 public WritableToMatrixData<std::complex<double>, int32>,
49 public WritableToMatrixData<std::complex<double>, int64>,
50 public Transposable {
51 friend class EnablePolymorphicObject<Fft, LinOp>;
52
53public:
54 using EnableLinOp<Fft>::convert_to;
55 using EnableLinOp<Fft>::move_to;
56
57 using value_type = std::complex<double>;
58 using index_type = int64;
59 using transposed_type = Fft;
60
61 std::unique_ptr<LinOp> transpose() const override;
62
63 std::unique_ptr<LinOp> conj_transpose() const override;
64
65 void write(matrix_data<std::complex<float>, int32>& data) const override;
66
67 void write(matrix_data<std::complex<float>, int64>& data) const override;
68
69 void write(matrix_data<std::complex<double>, int32>& data) const override;
70
71 void write(matrix_data<std::complex<double>, int64>& data) const override;
72
73 dim<1> get_fft_size() const;
74
75 bool is_inverse() const;
76
84 static std::unique_ptr<Fft> create(std::shared_ptr<const Executor> exec);
85
94 static std::unique_ptr<Fft> create(std::shared_ptr<const Executor> exec,
95 size_type size = 0,
96 bool inverse = false);
97
98protected:
99 Fft(std::shared_ptr<const Executor> exec, size_type size = 0,
100 bool inverse = false);
101
102 void apply_impl(const LinOp* b, LinOp* x) const override;
103
104 void apply_impl(const LinOp* alpha, const LinOp* b, const LinOp* beta,
105 LinOp* x) const override;
106
107private:
108 mutable array<char> buffer_;
109 bool inverse_;
110};
111
112
143 class Fft2 : public EnableLinOp<Fft2>,
144 public WritableToMatrixData<std::complex<float>, int32>,
145 public WritableToMatrixData<std::complex<float>, int64>,
146 public WritableToMatrixData<std::complex<double>, int32>,
147 public WritableToMatrixData<std::complex<double>, int64>,
148 public Transposable {
149 friend class EnablePolymorphicObject<Fft2, LinOp>;
150
151public:
152 using EnableLinOp<Fft2>::convert_to;
153 using EnableLinOp<Fft2>::move_to;
154
155 using value_type = std::complex<double>;
156 using index_type = int64;
157 using transposed_type = Fft2;
158
159 std::unique_ptr<LinOp> transpose() const override;
160
161 std::unique_ptr<LinOp> conj_transpose() const override;
162
163 void write(matrix_data<std::complex<float>, int32>& data) const override;
164
165 void write(matrix_data<std::complex<float>, int64>& data) const override;
166
167 void write(matrix_data<std::complex<double>, int32>& data) const override;
168
169 void write(matrix_data<std::complex<double>, int64>& data) const override;
170
171 dim<2> get_fft_size() const;
172
173 bool is_inverse() const;
174
182 static std::unique_ptr<Fft2> create(std::shared_ptr<const Executor> exec);
183
191 static std::unique_ptr<Fft2> create(std::shared_ptr<const Executor> exec,
192 size_type size);
193
203 static std::unique_ptr<Fft2> create(std::shared_ptr<const Executor> exec,
204 size_type size1, size_type size2,
205 bool inverse = false);
206
207protected:
208 Fft2(std::shared_ptr<const Executor> exec, size_type size1 = 0,
209 size_type size2 = 0, bool inverse = false);
210
211 void apply_impl(const LinOp* b, LinOp* x) const override;
212
213 void apply_impl(const LinOp* alpha, const LinOp* b, const LinOp* beta,
214 LinOp* x) const override;
215
216private:
217 mutable array<char> buffer_;
218 dim<2> fft_size_;
219 bool inverse_;
220};
221
222
255 class Fft3 : public EnableLinOp<Fft3>,
256 public WritableToMatrixData<std::complex<float>, int32>,
257 public WritableToMatrixData<std::complex<float>, int64>,
258 public WritableToMatrixData<std::complex<double>, int32>,
259 public WritableToMatrixData<std::complex<double>, int64>,
260 public Transposable {
261 friend class EnablePolymorphicObject<Fft3, LinOp>;
262
263public:
264 using EnableLinOp<Fft3>::convert_to;
265 using EnableLinOp<Fft3>::move_to;
266
267 using value_type = std::complex<double>;
268 using index_type = int64;
269 using transposed_type = Fft3;
270
271 std::unique_ptr<LinOp> transpose() const override;
272
273 std::unique_ptr<LinOp> conj_transpose() const override;
274
275 void write(matrix_data<std::complex<float>, int32>& data) const override;
276
277 void write(matrix_data<std::complex<float>, int64>& data) const override;
278
279 void write(matrix_data<std::complex<double>, int32>& data) const override;
280
281 void write(matrix_data<std::complex<double>, int64>& data) const override;
282
283 dim<3> get_fft_size() const;
284
285 bool is_inverse() const;
286
294 static std::unique_ptr<Fft3> create(std::shared_ptr<const Executor> exec);
295
303 static std::unique_ptr<Fft3> create(std::shared_ptr<const Executor> exec,
304 size_type size);
305
316 static std::unique_ptr<Fft3> create(std::shared_ptr<const Executor> exec,
317 size_type size1, size_type size2,
318 size_type size3, bool inverse = false);
319
320protected:
321 Fft3(std::shared_ptr<const Executor> exec, size_type size1 = 0,
322 size_type size2 = 0, size_type size3 = 0, bool inverse = false);
323
324 void apply_impl(const LinOp* b, LinOp* x) const override;
325
326 void apply_impl(const LinOp* alpha, const LinOp* b, const LinOp* beta,
327 LinOp* x) const override;
328
329private:
330 mutable array<char> buffer_;
331 dim<3> fft_size_;
332 bool inverse_;
333};
334
335
336} // namespace matrix
337} // namespace gko
338
339
340#endif // GKO_PUBLIC_CORE_MATRIX_FFT_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::Transposable
Linear operators which support transposition should implement the Transposable interface.
Definition lin_op.hpp:433
gko::WritableToMatrixData
A LinOp implementing this interface can write its data to a matrix_data structure.
Definition lin_op.hpp:660
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::Fft2::create
static std::unique_ptr< Fft2 > create(std::shared_ptr< const Executor > exec)
Creates an empty Fourier matrix.
gko::matrix::Fft2::create
static std::unique_ptr< Fft2 > create(std::shared_ptr< const Executor > exec, size_type size1, size_type size2, bool inverse=false)
Creates an Fourier matrix with the given dimensions.
gko::matrix::Fft2::create
static std::unique_ptr< Fft2 > create(std::shared_ptr< const Executor > exec, size_type size)
Creates an Fourier matrix with the given dimensions.
gko::matrix::Fft2::conj_transpose
std::unique_ptr< LinOp > conj_transpose() const override
Returns a LinOp representing the conjugate transpose of the Transposable object.
gko::matrix::Fft2::transpose
std::unique_ptr< LinOp > transpose() const override
Returns a LinOp representing the transpose of the Transposable object.
gko::matrix::Fft3::create
static std::unique_ptr< Fft3 > create(std::shared_ptr< const Executor > exec, size_type size1, size_type size2, size_type size3, bool inverse=false)
Creates an Fourier matrix with the given dimensions.
gko::matrix::Fft3::conj_transpose
std::unique_ptr< LinOp > conj_transpose() const override
Returns a LinOp representing the conjugate transpose of the Transposable object.
gko::matrix::Fft3::create
static std::unique_ptr< Fft3 > create(std::shared_ptr< const Executor > exec, size_type size)
Creates an Fourier matrix with the given dimensions.
gko::matrix::Fft3::transpose
std::unique_ptr< LinOp > transpose() const override
Returns a LinOp representing the transpose of the Transposable object.
gko::matrix::Fft3::create
static std::unique_ptr< Fft3 > create(std::shared_ptr< const Executor > exec)
Creates an empty Fourier matrix.
gko::matrix::Fft::transpose
std::unique_ptr< LinOp > transpose() const override
Returns a LinOp representing the transpose of the Transposable object.
gko::matrix::Fft::conj_transpose
std::unique_ptr< LinOp > conj_transpose() const override
Returns a LinOp representing the conjugate transpose of the Transposable object.
gko::matrix::Fft::create
static std::unique_ptr< Fft > create(std::shared_ptr< const Executor > exec)
Creates an empty Fourier matrix.
gko::matrix::Fft::create
static std::unique_ptr< Fft > create(std::shared_ptr< const Executor > exec, size_type size=0, bool inverse=false)
Creates an Fourier matrix with the given dimensions.
gko::matrix
The matrix namespace.
Definition dense_cache.hpp:24
gko::matrix::permute_mode::inverse
@ inverse
The permutation will be inverted before being applied.
Definition permutation.hpp:55
gko
The Ginkgo namespace.
Definition abstract_factory.hpp:20
gko::int32
std::int32_t int32
32-bit signed integral type.
Definition types.hpp:107
gko::int64
std::int64_t int64
64-bit signed integral type.
Definition types.hpp:113
gko::size_type
std::size_t size_type
Integral type used for allocation quantities.
Definition types.hpp:90
gko::dim
A type representing the dimensions of a multidimensional object.
Definition dim.hpp:26
gko::matrix_data
This structure is used as an intermediate data type to store a sparse matrix.
Definition matrix_data.hpp:126