public double[] Spectrum(double[] input, bool scale) { int length = input.Length; using (var data1 = new RealArray(length)) using (var data2 = new ComplexArray(length / 2 + 1)) using (var plan1 = Plan.Create1(length, data1, data2, Options.Estimate)) using (var plan2 = Plan.Create1(length, data2, data1, Options.Estimate)) { data1.Set(input); plan1.Execute(); var temp = data2.ToArray(); var spectrum = Helper.ComputeSpectrum(temp); plan2.Execute(); data1.CopyTo(input); if (scale) { for (int i = 0; i < length; i++) { input[i] /= length; } } return(spectrum); } }
public double[] Spectrum(double[] input, bool scale) { int length = input.Length; var zinput = Helper.ToComplex(input); using (var data1 = new ComplexArray(zinput)) using (var data2 = new ComplexArray(length)) using (var plan1 = Plan.Create1(length, data1, data2, Direction.Forward, Options.Estimate)) using (var plan2 = Plan.Create1(length, data2, data1, Direction.Backward, Options.Estimate)) { plan1.Execute(); var temp = data2.ToArray(); var spectrum = Helper.ComputeSpectrum(temp); plan2.Execute(); data1.CopyTo(input, true); if (scale) { for (int i = 0; i < length; i++) { input[i] /= length; } } return(spectrum); } }