Beispiel #1
0
        public void TestLinSeries()
        {
            double[] target = { 1, 2, 3, 4, 5 };
            var      result = Dsp.LinSeries(1, 5, 5).ToReadOnlyList();

            FilterAssert.ListsAreReasonablyClose(target, result);
            Assert.Catch <ArgumentOutOfRangeException>(() => Dsp.LinSeries(1, 5, 1));
        }
Beispiel #2
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="UniformSeries" /> class.
 /// </summary>
 /// <param name="from">The first value of the series.</param>
 /// <param name="to">The last value of the series.</param>
 /// <param name="length">Determines how many values (including first and last) the series should contain.</param>
 /// <param name="logarithmic">Determines whether the series should be on a linear or a logarithmic scale.</param>
 public UniformSeries(double from, double to, int length, bool logarithmic = false) :
     base(logarithmic
         ? Dsp.LogSeries(from, to, length)
         : Dsp.LinSeries(from, to, length),
          logarithmic)
 {
     this.From   = from;
     this.To     = to;
     this.Length = length;
 }
Beispiel #3
0
 /// <summary>
 ///     Calculates the even-spaced frequency points from 0 Hz (DC) to Nyquist frequency (SampleRate/2) representing the
 ///     positive part of the
 ///     frequency axis of a signal of length N with SampleRate in time domain.
 /// </summary>
 /// <param name="samplerate">The Samplerate of the signal in time domain</param>
 /// <param name="n">The Length of the signal in time domain</param>
 /// <returns>Array of frequencies</returns>
 public static IEnumerable <double> GetFrequencies(double samplerate, int n)
 {
     return(Dsp.LinSeries(0, samplerate * 0.5, (n >> 1) + 1));
 }