本文整理汇总了C#中FourierOptions类的典型用法代码示例。如果您正苦于以下问题:C# FourierOptions类的具体用法?C# FourierOptions怎么用?C# FourierOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FourierOptions类属于命名空间,在下文中一共展示了FourierOptions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FourierRadix2MatchesNaive_RealSine
public void FourierRadix2MatchesNaive_RealSine(FourierOptions options)
{
var samples = Generate.PeriodicMap(16, w => new Complex(Math.Sin(w), 0), 16, 1.0, Constants.Pi2);
Verify(samples, 12, options, Fourier.NaiveForward, Fourier.Radix2Forward);
Verify(samples, 12, options, Fourier.NaiveInverse, Fourier.Radix2Inverse);
}
示例2: FourierRadix2IsReversible
public void FourierRadix2IsReversible(FourierOptions options)
{
var samples = Generate.RandomComplex(0x8000, GetUniform(1));
var work = new Complex[samples.Length];
samples.CopyTo(work, 0);
Fourier.Radix2Forward(work, options);
Assert.IsFalse(work.ListAlmostEqual(samples, 6));
Fourier.Radix2Inverse(work, options);
AssertHelpers.AlmostEqual(samples, work, 12);
}
示例3: FourierBluesteinIsReversible
public void FourierBluesteinIsReversible(FourierOptions options)
{
var dft = new DiscreteFourierTransform();
var samples = Generate.RandomComplex(0x7FFF, GetUniform(1));
var work = new Complex[samples.Length];
samples.CopyTo(work, 0);
dft.BluesteinForward(work, options);
Assert.IsFalse(work.ListAlmostEqual(samples, 6));
dft.BluesteinInverse(work, options);
AssertHelpers.ListAlmostEqual(samples, work, 10);
}
示例4: ForwardScaleByOptions
/// <summary>
/// Rescale FFT-the resulting vector according to the provided convention options.
/// </summary>
/// <param name="options">Fourier Transform Convention Options.</param>
/// <param name="samples">Sample Vector.</param>
private static void ForwardScaleByOptions(FourierOptions options, Complex[] samples)
{
if ((options & FourierOptions.NoScaling) == FourierOptions.NoScaling ||
(options & FourierOptions.AsymmetricScaling) == FourierOptions.AsymmetricScaling)
{
return;
}
var scalingFactor = Math.Sqrt(1.0 / samples.Length);
for (int i = 0; i < samples.Length; i++)
{
samples[i] *= scalingFactor;
}
}
示例5: FourierRadix2IsReversible
public void FourierRadix2IsReversible(FourierOptions options)
{
var dft = new DiscreteFourierTransform();
var samples = SignalGenerator.Random((u, v) => new Complex(u, v), GetUniform(1), 0x8000);
var work = new Complex[samples.Length];
samples.CopyTo(work, 0);
dft.Radix2Forward(work, options);
Assert.IsFalse(work.ListAlmostEqual(samples, 6));
dft.Radix2Inverse(work, options);
AssertHelpers.ListAlmostEqual(samples, work, 12);
}
示例6: Verify
static void Verify(
Complex[] samples,
int maximumErrorDecimalPlaces,
FourierOptions options,
Func<Complex[], FourierOptions, Complex[]> naive,
Action<Complex[], FourierOptions> fast)
{
var spectrumNaive = naive(samples, options);
var spectrumFast = new Complex[samples.Length];
samples.CopyTo(spectrumFast, 0);
fast(spectrumFast, options);
AssertHelpers.AlmostEqual(spectrumNaive, spectrumFast, maximumErrorDecimalPlaces);
}
示例7: FourierBluesteinMatchesNaiveOnRandomNonPowerOfTwo
public void FourierBluesteinMatchesNaiveOnRandomNonPowerOfTwo(FourierOptions options)
{
var dft = new DiscreteFourierTransform();
var samples = Generate.RandomComplex(0x7F, GetUniform(1));
VerifyMatchesNaiveComplex(
samples,
10,
s => dft.NaiveForward(s, options),
s => dft.BluesteinForward(s, options));
VerifyMatchesNaiveComplex(
samples,
10,
s => dft.NaiveInverse(s, options),
s => dft.BluesteinInverse(s, options));
}
示例8: FourierBluesteinMatchesNaiveOnRandomNonPowerOfTwo
public void FourierBluesteinMatchesNaiveOnRandomNonPowerOfTwo(FourierOptions options)
{
var dft = new DiscreteFourierTransform();
var samples = SignalGenerator.Random((u, v) => new Complex(u, v), GetUniform(1), 0x7F);
VerifyMatchesNaiveComplex(
samples,
1e-12,
s => dft.NaiveForward(s, options),
s => dft.BluesteinForward(s, options));
VerifyMatchesNaiveComplex(
samples,
1e-12,
s => dft.NaiveInverse(s, options),
s => dft.BluesteinInverse(s, options));
}
示例9: NaiveMatchesDft
public void NaiveMatchesDft(HartleyOptions hartleyOptions, FourierOptions fourierOptions)
{
var samples = Generate.Random(0x80, GetUniform(1));
VerifyMatchesDft(
samples,
5,
false,
s => Fourier.Forward(s, fourierOptions),
s => Hartley.NaiveForward(s, hartleyOptions));
VerifyMatchesDft(
samples,
5,
true,
s => Fourier.Inverse(s, fourierOptions),
s => Hartley.NaiveInverse(s, hartleyOptions));
}
示例10: FourierBluesteinMatchesNaiveOnRandomPowerOfTwo
public void FourierBluesteinMatchesNaiveOnRandomPowerOfTwo(FourierOptions options)
{
var dft = new DiscreteFourierTransform();
var samples = Sample.Random((u, v) => new Complex(u, v), _uniform, 0x80);
VerifyMatchesNaiveComplex(
samples,
1e-12,
s => dft.NaiveForward(s, options),
s => dft.BluesteinForward(s, options));
VerifyMatchesNaiveComplex(
samples,
1e-12,
s => dft.NaiveInverse(s, options),
s => dft.BluesteinInverse(s, options));
}
示例11: FourierRadix2MatchesNaiveOnRealSine
public void FourierRadix2MatchesNaiveOnRealSine(FourierOptions options)
{
var dft = new DiscreteFourierTransform();
var samples = SignalGenerator.EquidistantPeriodic(w => new Complex(Math.Sin(w), 0), Constants.Pi2, 0, 16);
VerifyMatchesNaiveComplex(
samples,
1e-12,
s => dft.NaiveForward(s, options),
s => dft.Radix2Forward(s, options));
VerifyMatchesNaiveComplex(
samples,
1e-12,
s => dft.NaiveInverse(s, options),
s => dft.Radix2Inverse(s, options));
}
示例12: FourierBluesteinIsReversible
public void FourierBluesteinIsReversible(FourierOptions options)
{
var dft = new DiscreteFourierTransform();
VerifyIsReversibleComplex(
0x7FFF,
1e-12,
s =>
{
dft.BluesteinForward(s, options);
return s;
},
s =>
{
dft.BluesteinInverse(s, options);
return s;
});
}
示例13: InverseScaleByOptions
/// <summary>
/// Rescale the iFFT-resulting vector according to the provided convention options.
/// </summary>
/// <param name="options">Fourier Transform Convention Options.</param>
/// <param name="samples">Sample Vector.</param>
private static void InverseScaleByOptions(FourierOptions options, Complex[] samples)
{
if ((options & FourierOptions.NoScaling) == FourierOptions.NoScaling)
{
return;
}
var scalingFactor = 1.0 / samples.Length;
if ((options & FourierOptions.AsymmetricScaling) != FourierOptions.AsymmetricScaling)
{
scalingFactor = Math.Sqrt(scalingFactor);
}
for (int i = 0; i < samples.Length; i++)
{
samples[i] *= scalingFactor;
}
}
示例14: NaiveMatchesDft
public void NaiveMatchesDft(HartleyOptions hartleyOptions, FourierOptions fourierOptions)
{
var dht = new DiscreteHartleyTransform();
var samples = SignalGenerator.Random(x => x, GetUniform(1), 0x80);
VerifyMatchesDft(
samples,
1e-5,
false,
s => Transform.FourierForward(s, fourierOptions),
s => dht.NaiveForward(s, hartleyOptions));
VerifyMatchesDft(
samples,
1e-5,
true,
s => Transform.FourierInverse(s, fourierOptions),
s => dht.NaiveInverse(s, hartleyOptions));
}
示例15: NaiveMatchesDFT
public void NaiveMatchesDFT(HartleyOptions hartleyOptions, FourierOptions fourierOptions)
{
var dht = new DiscreteHartleyTransform();
var samples = Sample.Random(x => x, _uniform, 0x80);
VerifyMatchesDFT(
samples,
1e-10,
false,
s => Transform.FourierForward(s, fourierOptions),
s => dht.NaiveForward(s, hartleyOptions));
VerifyMatchesDFT(
samples,
1e-10,
true,
s => Transform.FourierInverse(s, fourierOptions),
s => dht.NaiveInverse(s, hartleyOptions));
}