Skip to content

Fix dlang#10798 — Reimplement FFT solver to support @nogc nothrow pure @safe #10799

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 32 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
c0a3ea1
Fix dlang#10796 - FFT doesn’t work with user-defined complex types
Ogi-kun Jun 5, 2025
c1789b7
Style
Ogi-kun Jun 6, 2025
663dd61
Branch by `isNumeric` instead of `isComplexLike`
Ogi-kun Jun 6, 2025
17d605c
Merge branch 'master' of https://github.com/Ogi-kun/phobos
Ogi-kun Jun 7, 2025
cef0b7c
Reimplement FFT solver as a struct
Ogi-kun Jun 7, 2025
9bf6dbb
FFTImpl(size_t size) : throw error on Out of Memory
Ogi-kun Jun 7, 2025
bb48954
Convenience functions use `FFTImpl` instead of `Fft`
Ogi-kun Jun 7, 2025
e0e18b3
Make `FFTImpl` `@nogc nothrow`
Ogi-kun Jun 7, 2025
7d85642
`FFTImpl`: rename `fft`/`inverseFft` to `compute`/`computeInverse`
Ogi-kun Jun 7, 2025
434c2e0
Add `std.numeric.FFT`
Ogi-kun Jun 7, 2025
61ba6c5
Make `lookup_t` public
Ogi-kun Jun 7, 2025
134e998
FFT.lookupTableSize
Ogi-kun Jun 7, 2025
c5265c6
Fix dlang#10798 — make FFT fully compatible with `@nogc`
Ogi-kun Jun 7, 2025
e5546ac
Style
Ogi-kun Jun 7, 2025
2e17de6
Style
Ogi-kun Jun 7, 2025
86a7c59
Works on my machine but CI reports missing import
Ogi-kun Jun 7, 2025
56574a3
Style
Ogi-kun Jun 7, 2025
53f1170
Removed `FFT`. `FFT` is now an alias to `FFTImpl`
Ogi-kun Jun 7, 2025
3f13129
Rename `FFTImpl` to `FFT`
Ogi-kun Jun 7, 2025
e267223
Make `FFT` `pure`
Ogi-kun Jun 9, 2025
13441e6
Mark unittests `pure`
Ogi-kun Jun 9, 2025
e382092
Move lookup generation to a function
Ogi-kun Jun 9, 2025
107e115
Unsafe constructor should take `void[]`, not `lookup_t[]`
Ogi-kun Jun 9, 2025
3bddd34
Make `lookup_t` private, as it used to be
Ogi-kun Jun 9, 2025
7dc1d0b
Make `FFT.this(size_t)` `@safe`
Ogi-kun Jun 9, 2025
290b907
`requiredBufferSize` : check for overflow
Ogi-kun Jun 9, 2025
69fa611
Fix documentation
Ogi-kun Jun 14, 2025
08edea9
Fix missing identation
Ogi-kun Jun 14, 2025
ed3ed85
Make a pointer to immutable data also `immutable`
Ogi-kun Jun 14, 2025
cf48c8c
Sunset `Fft`
Ogi-kun Jun 14, 2025
8edebe5
Mark old unittests `@safe`
Ogi-kun Jun 14, 2025
f941d3d
Add changelog entry
Ogi-kun Jun 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions changelog/add_nogc_fft.dd
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
Add `FFT` that doesn’t use GC.

`FFT` is an FFT solver compatible with `@nogc`, `nothrow`, `@safe`, and `pure`.
```D
@nogc nothrow pure @safe void fun()
{
import std.complex;

enum size = 8;
float[size] arr = [1,2,3,4,5,6,7,8];
Complex!float[size] fft;

immutable fftSolver = FFT(size);

fftSolver.compute(arr[], fft[]);
}
```

Convenience functions now use `FFT`. In effect, `fft(R, Ret)` and
`inverseFft(R, Ret)` also can be used in `@nogc`, `nothrow`, `pure`,
and `@safe` code.

`FFT` can also avoid dynamic memory allocation by using a preallocated buffer.
However, this is not `@safe`. The buffer must not be modified or freed within
the lifetime of the `FFT` instance.

```D
@nogc nothrow pure @system void unsafeFun()
{
import std.complex;

enum size = 8;
float[size] arr = [1,2,3,4,5,6,7,8];
Complex!float[size] fft;

enum bufferSize = FFT.requiredBufferSize(size);
ubyte[bufferSize] buff;
immutable fftSolver = FFT(size, buff);

fftSolver.compute(arr[], fft[]);
}
```

`Fft` class is still available for backwards compatibility. It is not recommended
for new code.
Loading
Loading