Skip to content

Commit ff6205c

Browse files
committed
FFT: throw for inputs with fewer than 16 values
1 parent 1124b02 commit ff6205c

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

src/FftSharp/Transform.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ public static void FFT(Complex[] buffer)
2323
/// <param name="buffer">Data to transform in-place. Length must be a power of 2.</param>
2424
public static void FFT(Span<Complex> buffer)
2525
{
26-
if (buffer.Length == 0)
27-
throw new ArgumentException("Buffer must not be empty");
26+
if (buffer.Length < 16)
27+
throw new ArgumentException("Buffer must contain at least 16 values");
2828

2929
if (!IsPowerOfTwo(buffer.Length))
3030
throw new ArgumentException("Buffer length must be a power of 2");
@@ -74,8 +74,8 @@ public static void IFFT(Complex[] buffer)
7474
if (buffer is null)
7575
throw new ArgumentNullException(nameof(buffer));
7676

77-
if (buffer.Length == 0)
78-
throw new ArgumentException("Buffer must not be empty");
77+
if (buffer.Length < 16)
78+
throw new ArgumentException("Buffer must contain at least 16 values");
7979

8080
if (!IsPowerOfTwo(buffer.Length))
8181
throw new ArgumentException("Buffer length must be a power of 2");
@@ -213,8 +213,8 @@ public static Complex[] FFT(double[] input)
213213
if (input is null)
214214
throw new ArgumentNullException(nameof(input));
215215

216-
if (input.Length == 0)
217-
throw new ArgumentException("Input must not be empty");
216+
if (input.Length < 16)
217+
throw new ArgumentException("Input must have at least 16 values");
218218

219219
if (!IsPowerOfTwo(input.Length))
220220
throw new ArgumentException("Input length must be an even power of 2");
@@ -234,8 +234,8 @@ public static Complex[] RFFT(double[] input)
234234
if (input is null)
235235
throw new ArgumentNullException(nameof(input));
236236

237-
if (input.Length == 0)
238-
throw new ArgumentException("Input must not be empty");
237+
if (input.Length < 16)
238+
throw new ArgumentException("Input must have at least 16 values");
239239

240240
if (!IsPowerOfTwo(input.Length))
241241
throw new ArgumentException("Input length must be an even power of 2");

0 commit comments

Comments
 (0)