Example #1
0
        /// <summary>
        /// Initializes a new plan using the provided input and output buffers.
        /// These buffers may be overwritten during initialization.
        /// </summary>
        public static FftwPlanC2C Create(IPinnedArray <Complex> input, IPinnedArray <Complex> output, DftDirection direction, PlannerFlags plannerFlags = PlannerFlags.Default, int nThreads = 1)
        {
            FftwPlanC2C plan = new FftwPlanC2C(input, output, input.Rank, input.GetSize(), true, direction, plannerFlags, nThreads);

            if (plan.IsZero)
            {
                return(null);
            }
            return(plan);
        }
Example #2
0
        internal static FftwPlanC2C Create(IPinnedArray <Complex> input, IPinnedArray <Complex> output, int rank, int[] n, DftDirection direction, PlannerFlags plannerFlags, int nThreads)
        {
            FftwPlanC2C plan = new FftwPlanC2C(input, output, rank, n, false, direction, plannerFlags, nThreads);

            if (plan.IsZero)
            {
                return(null);
            }
            return(plan);
        }
Example #3
0
        static void Transform(IPinnedArray <Complex> input, IPinnedArray <Complex> output, DftDirection direction, PlannerFlags plannerFlags, int nThreads)
        {
            if ((plannerFlags & PlannerFlags.Estimate) == PlannerFlags.Estimate)
            {
                using (var plan = FftwPlanC2C.Create(input, output, direction, plannerFlags, nThreads))
                {
                    plan.Execute();
                    return;
                }
            }

            using (var plan = FftwPlanC2C.Create(input, output, direction, 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
            if (input != output)
            {
                using (var plan = FftwPlanC2C.Create(output, output, input.Rank, input.GetSize(), direction, plannerFlags, nThreads))
                {
                    input.CopyTo(output);
                    plan.Execute();
                }
            }
            else
            {
                using (var bufferContainer = _bufferPool.RequestBuffer(input.Length * Marshal.SizeOf <Complex>() + MemoryAlignment))
                    using (var buffer = new AlignedArrayComplex(bufferContainer.Buffer, MemoryAlignment, input.GetSize()))
                        using (var plan = FftwPlanC2C.Create(buffer, buffer, input.Rank, input.GetSize(), direction, plannerFlags, nThreads))
                        {
                            input.CopyTo(plan.Input);
                            plan.Execute();
                            plan.Output.CopyTo(output, 0, 0, input.Length);
                        }
            }
        }