Example #1
0
        public void zcopy_ExtendedTestCaseData_SequenceEqualArray(int n, int startIndexX, int startIndexY, int incX, int incY, params Complex[] x)
        {
            Complex[] y = new Complex[startIndexY + incY * n];

            m_Level1BLAS.zcopy(n, x, y, incX, incY, startIndexX, startIndexY);

            var sparseY = y.Where((z, i) => { return((i >= startIndexY) && (((i - startIndexY) % incY) == 0)); });
            var sparseX = x.Where((z, i) => { return((i >= startIndexX) && (((i - startIndexX) % incX) == 0)); });

            Assert.That(sparseY.SequenceEqual(sparseX));
        }
Example #2
0
 // TODO: Way to define Signal as Complex collection?
 private static Complex[] FFT(Complex[] v)
 {
     int N = v.Length;
     if (N == 1) return v;
     Complex[] E = FFT(v.Where((element, i) => i % 2 == 0).ToArray());
     Complex[] O = FFT(v.Where((element, i) => i % 2 != 0).ToArray());
     Complex[] T = E.Where((element, i) => i == i % N / 2).ToArray();
     Complex[] U = O.Select((element, i) =>
         {
             float a = Mathf.Cos(-i * 2f * Mathf.PI / N);
             float b = Mathf.Sin(-i * 2f * Mathf.PI / N);
             return (i == i % N / 2) ? element * new Complex(a, b) : element;
         }).Where((element, i) => i == i % N / 2).ToArray();
     Complex[] R = new Complex[Math.Min(U.Length, T.Length)];
     for (int k = 0; k < R.Length; ++k)
     {
         R[k] = T[k] + U[k];
     }
     return R;
 }