Skip to content

Commit

Permalink
FFT: fix RFFT_WithoutChecks() overload
Browse files Browse the repository at this point in the history
resolves #73
  • Loading branch information
swharden committed Aug 21, 2023
1 parent e3a6281 commit 18a4680
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/FftSharp/FftOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,21 @@ public static void RFFT_WithoutChecks(Span<System.Numerics.Complex> destination,
{
System.Numerics.Complex[] temp = ArrayPool<System.Numerics.Complex>.Shared.Rent(input.Length);

Span<System.Numerics.Complex> buffer = temp.AsSpan(0, input.Length);

FFT_WithoutChecks(buffer);
buffer.Slice(0, destination.Length).CopyTo(destination);

ArrayPool<System.Numerics.Complex>.Shared.Return(temp);
try
{
Span<System.Numerics.Complex> buffer = temp.AsSpan(0, input.Length);
input.CopyTo(buffer);
FFT.Forward(buffer);
buffer.Slice(0, destination.Length).CopyTo(destination);
}
catch (Exception ex)
{
throw new Exception("Could not calculate RFFT", ex);
}
finally
{
ArrayPool<System.Numerics.Complex>.Shared.Return(temp);
}
}

/// <summary>
Expand Down

0 comments on commit 18a4680

Please sign in to comment.