public static void FFT(IPinnedArray <double> input, IPinnedArray <double> output, PlannerFlags plannerFlags = PlannerFlags.Default, int nThreads = 1) { if ((plannerFlags & PlannerFlags.Estimate) == PlannerFlags.Estimate) { using (var plan = FftwPlanR2R.Create(input, output, DftDirection.Forwards, plannerFlags, nThreads)) { plan.Execute(); return; } } using (var plan = FftwPlanR2R.Create(input, output, DftDirection.Forwards, plannerFlags | PlannerFlags.WisdomOnly, nThreads)) { if (plan != null) { plan.Execute(); return; } } /// If with <see cref="PlannerFlags.WisdomOnly"/> no plan can be created /// and <see cref="PlannerFlags.Estimate"/> is not specified, we use /// a different buffer to avoid overwriting the input using (var bufferContainer = _bufferPool.RequestBuffer(input.Length * sizeof(double) + MemoryAlignment)) using (var buffer = new AlignedArrayDouble(bufferContainer.Buffer, MemoryAlignment, input.GetSize())) using (var plan = FftwPlanR2R.Create(buffer, output, DftDirection.Forwards, plannerFlags, nThreads)) { input.CopyTo(plan.Input); plan.Execute(); plan.Output.CopyTo(output, 0, 0, input.Length); } }
internal static FftwPlanR2R Create(IPinnedArray <Double> input, IPinnedArray <Double> output, int rank, int[] n, DftDirection direction, PlannerFlags plannerFlags, int nThreads) { FftwPlanR2R plan = new FftwPlanR2R(input, output, rank, n, false, direction, plannerFlags, nThreads); if (plan.IsZero) { return(null); } return(plan); }
/// <summary> /// Initializes a new plan using the provided input and output buffers. /// These buffers may be overwritten during initialization. /// </summary> public static FftwPlanR2R Create(IPinnedArray <Double> input, IPinnedArray <Double> output, DftDirection direction, PlannerFlags plannerFlags = PlannerFlags.Default, int nThreads = 1) { FftwPlanR2R plan = new FftwPlanR2R(input, output, input.Rank, input.GetSize(), true, direction, plannerFlags, nThreads); if (plan.IsZero) { return(null); } return(plan); }