-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
52 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
| ||
namespace fftbench.Benchmark { | ||
using Cavern.Utilities; | ||
|
||
public class TestCavern : ITest { | ||
public string Name => ToString(); | ||
|
||
public int Size => data.Length; | ||
|
||
public bool Enabled { get; set; } | ||
|
||
Complex[] data; | ||
|
||
FFTCache cache; | ||
|
||
public void Initialize(double[] data) { | ||
this.data = new Complex[data.Length]; | ||
cache = new FFTCache(data.Length); | ||
for (int i = 0; i < data.Length; i++) { | ||
this.data[i].Real = (float)data[i]; | ||
} | ||
} | ||
|
||
public void FFT(bool forward) { | ||
Complex[] workingSet = (Complex[])data.Clone(); | ||
Measurements.InPlaceFFT(workingSet, cache); | ||
} | ||
|
||
public double[] Spectrum(double[] input, bool scale) { | ||
Complex[] workingSet = (Complex[])data.Clone(); | ||
Measurements.InPlaceFFT(workingSet, cache); | ||
|
||
float[] spectrumSource = Measurements.GetSpectrum(workingSet); | ||
double[] spectrum = new double[spectrumSource.Length]; | ||
Helper.CopyToDouble(spectrumSource, spectrum); | ||
|
||
Measurements.InPlaceIFFT(workingSet, cache); | ||
float[] ifftResult = Measurements.GetRealPart(workingSet); | ||
Helper.CopyToDouble(ifftResult, input); | ||
|
||
return spectrum; | ||
} | ||
|
||
public override string ToString() { | ||
return "Cavern"; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters