c# - FFTW.NET DFT.FFT(pinIn, pinOut) 在 WEB API 中抛出 System.InvalidOperationException
问题描述
我想在 .NET Core 2.1 WEB API 中使用 FFTW.NET。当我执行下面的一段代码时,我得到System.InvalidOperationException: 'IsAvailable returns false.'
了DFT.FFT(pinIn, pinOut);
Complex[] input = new Complex[1024];
Complex[] output = new Complex[input.Length];
//Initialize input
using (var pinIn = new PinnedArray<Complex>(input))
using (var pinOut = new PinnedArray<Complex>(output))
{
DFT.FFT(pinIn, pinOut);
}
下面是堆栈跟踪。
at FFTW.NET.FftwPlan`2..ctor(IPinnedArray`1 buffer1, IPinnedArray`1 buffer2, Int32 rank, Int32[] n, Boolean verifyRankAndSize, DftDirection direction, PlannerFlags plannerFlags, Int32 nThreads)
at FFTW.NET.FftwPlanC2C.Create(IPinnedArray`1 input, IPinnedArray`1 output, DftDirection direction, PlannerFlags plannerFlags, Int32 nThreads)
at FFTW.NET.DFT.Transform(IPinnedArray`1 input, IPinnedArray`1 output, DftDirection direction, PlannerFlags plannerFlags, Int32 nThreads)
at FFTW.NET.DFT.FFT(IPinnedArray`1 input, IPinnedArray`1 output, PlannerFlags plannerFlags, Int32 nThreads)
at FFTW_WEB_API.Controllers.ValuesController.Get() in D:\FFTW_Test\FFTW_WEB_API\Controllers\ValuesController.cs:line 1059
at lambda_method(Closure , Object , Object[] )
at Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(Object target, Object[] parameters)
at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.SyncObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync()
但是同一段代码在 .NET Core 2.1 控制台应用程序中运行良好。
如果我做错了什么,请提出建议。