From 72972cae51a5012467c9c2ff6b002d663773bc06 Mon Sep 17 00:00:00 2001 From: routersys Date: Thu, 8 Oct 2026 12:24:14 +0900 Subject: [PATCH] =?UTF-8?q?FFT=E3=81=AE=E5=9B=9E=E8=BB=A2=E5=9B=A0?= =?UTF-8?q?=E5=AD=90=E3=81=AE=E8=A1=A8=E3=81=AE=E9=8D=B5=E3=82=92=E6=A7=8B?= =?UTF-8?q?=E9=80=A0=E4=BD=93=E3=81=AB=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SpectralConvolution/FastFourierTransform.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/SpectralConvolution/SpectralConvolution/FastFourierTransform.cs b/SpectralConvolution/SpectralConvolution/FastFourierTransform.cs index bbb91ed..2975cc3 100644 --- a/SpectralConvolution/SpectralConvolution/FastFourierTransform.cs +++ b/SpectralConvolution/SpectralConvolution/FastFourierTransform.cs @@ -8,7 +8,7 @@ namespace SpectralConvolution; internal static class FastFourierTransform { - static readonly ConcurrentDictionary TwiddleCache = new(); + static readonly ConcurrentDictionary TwiddleCache = new(); public static void Forward(Span real, Span imaginary) => Transform(real, imaginary, false); @@ -294,7 +294,9 @@ internal static class FastFourierTransform } static Twiddles GetTwiddles(int count, bool inverse) => - TwiddleCache.GetOrAdd(((long)count << 1) | (inverse ? 1L : 0L), static key => new Twiddles((int)(key >> 1), (key & 1L) != 0)); + TwiddleCache.GetOrAdd(new TwiddleKey(count, inverse), static key => new Twiddles(key.Count, key.Inverse)); + + readonly record struct TwiddleKey(int Count, bool Inverse); sealed class Twiddles {