コード例 #1
0
        /// <summary>
        /// Forward Weyl-Heisenberg transform.
        /// </summary>
        /// <param name="A">Array</param>
        /// <returns>Array</returns>
        public Complex32[] Forward(Complex32[] A)
        {
            float[]      g0           = WeylHeisenbergTransform.GetPacket(this.window, A.Length);
            ZakTransform zakTransform = new ZakTransform(m);

            return(FastWeylHeisenbergTransform.WHT(A, zakTransform.Forward(g0), m));
        }
コード例 #2
0
        /// <summary>
        /// Backward Weyl-Heisenberg transform.
        /// </summary>
        /// <param name="B">Array</param>
        /// <returns>Array</returns>
        public Complex32[] Backward(Complex32[] B)
        {
            int N = B.Length;

            Complex32[,] U = WeylHeisenbergTransform.Matrix(this.window, N, this.m, true);
            Complex32[] A = Matrice.Dot(B, U);
            return(A);
        }
コード例 #3
0
        /// <summary>
        /// Forward Weyl-Heisenberg transform.
        /// </summary>
        /// <param name="A">Array</param>
        /// <returns>Array</returns>
        public Complex32[] Forward(Complex32[] A)
        {
            int N = A.Length;

            Complex32[,] U = WeylHeisenbergTransform.Matrix(this.window, N, this.m, true);
            Complex32[] B = Matrice.Dot(A, U.Hermitian());
            return(B);
        }
コード例 #4
0
        /// <summary>
        /// Returns the complex Weyl-Heisenberg basis matrix.
        /// <remarks>
        /// Matrix dimension[N, N], where N = M * L.
        /// </remarks>
        /// </summary>
        /// <param name="g0">Function</param>
        /// <param name="M">Number of frequency shifts</param>
        /// <param name="orthogonalize">Orthogonalized matrix or not</param>
        /// <returns>Matrix</returns>
        public static Complex32[,] Matrix(float[] g0, int M, bool orthogonalize = true)
        {
            if (orthogonalize)
            {
                ZakTransform zakTransform = new ZakTransform(M);

                return(WeylHeisenbergTransform.Matrix(zakTransform.Forward(g0), M));
            }

            return(WeylHeisenbergTransform.Matrix(g0, M));
        }
コード例 #5
0
        /// <summary>
        /// Backward Weyl-Heisenberg transform.
        /// </summary>
        /// <param name="B">Matrix</param>
        /// <returns>Matrix</returns>
        public Complex32[,] Backward(Complex32[,] B)
        {
            int N = B.GetLength(0), M = B.GetLength(1);

            Complex32[,] U = WeylHeisenbergTransform.Matrix(this.window, N, this.m, true);
            Complex32[,] V = WeylHeisenbergTransform.Matrix(this.window, M, this.m, true);
            Complex32[,] A;

            if (direction == Direction.Both)
            {
                A = U.Dot(B).Dot(V.Hermitian());
            }
            else if (direction == Direction.Vertical)
            {
                A = U.Dot(B);
            }
            else
            {
                A = B.Dot(V.Hermitian());
            }
            return(A);
        }
コード例 #6
0
        /// <summary>
        /// Forward Weyl-Heisenberg transform.
        /// </summary>
        /// <param name="A">Matrix</param>
        /// <returns>Matrix</returns>
        public Complex32[,] Forward(Complex32[,] A)
        {
            int N = A.GetLength(0), M = A.GetLength(1);

            Complex32[,] U = WeylHeisenbergTransform.Matrix(this.window, N, this.m, true);
            Complex32[,] V = WeylHeisenbergTransform.Matrix(this.window, M, this.m, true);
            Complex32[,] B;

            if (direction == Direction.Both)
            {
                B = U.Hermitian().Dot(A).Dot(V);
            }
            else if (direction == Direction.Vertical)
            {
                B = U.Hermitian().Dot(A);
            }
            else
            {
                B = A.Dot(V);
            }
            return(B);
        }
コード例 #7
0
        /// <summary>
        /// Returns a vector of window function values.
        /// </summary>
        /// <param name="window">Windows function</param>
        /// <param name="length">Number of samples</param>
        /// <returns>Array</returns>
        public static float[] GetPacket(IWindow window, int length)
        {
            // exeption by length
            if (window.FrameSize > length)
            {
                return(WeylHeisenbergTransform.nSymmetry(window, length));
            }

            // params for approximation
            float[] w   = WeylHeisenbergTransform.nSymmetry(window, (int)window.FrameSize);
            int     n   = w.Length;
            float   min = Math.Min(w[0], w[n - 1]);

            float[] g = new float[length];
            int     i, j = (length - n) / 2;
            int     k = Math.Min(length - 2 * j, n);
            int     z = j + k;

            // do job for intervals
            for (i = 0; i < j; i++)
            {
                g[i] = min;
            }

            for (i = j; i < z; i++)
            {
                g[i] = w[i - j];
            }

            for (i = z; i < length; i++)
            {
                g[i] = min;
            }

            return(g);
        }
コード例 #8
0
 /// <summary>
 /// Returns the complex Weyl-Heisenberg basis matrix.
 /// <remarks>
 /// Matrix dimension[N, N], where N = M * L.
 /// </remarks>
 /// </summary>
 /// <param name="window">Windows function</param>
 /// <param name="N">Number of samples</param>
 /// <param name="M">Number of frequency shifts</param>
 /// <param name="orthogonalize">Orthogonalized matrix or not</param>
 /// <returns>Matrix</returns>
 public static Complex32[,] Matrix(IWindow window, int N, int M, bool orthogonalize = true)
 {
     return(WeylHeisenbergTransform.Matrix(WeylHeisenbergTransform.GetPacket(window, N), M, orthogonalize));
 }
コード例 #9
0
        /// <summary>
        /// Backward Weyl-Heisenberg transform.
        /// </summary>
        /// <param name="B">Matrix</param>
        /// <returns>Matrix</returns>
        public Complex32[,] Backward(Complex32[,] B)
        {
            Complex32[,] A = (Complex32[, ])B.Clone();
            int N = B.GetLength(0);
            int M = B.GetLength(1);

            ZakTransform zakTransform = new ZakTransform(m);

            float[] g0 = zakTransform.Forward(WeylHeisenbergTransform.GetPacket(this.window, N));
            float[] g1 = zakTransform.Forward(WeylHeisenbergTransform.GetPacket(this.window, M));

            if (direction == Direction.Both)
            {
                Parallel.For(0, M, j =>
                {
                    Complex32[] col = new Complex32[N];
                    int i;

                    for (i = 0; i < N; i++)
                    {
                        col[i] = A[i, j];
                    }

                    col = IWHT(col, g0, m);

                    for (i = 0; i < N; i++)
                    {
                        A[i, j] = col[i];
                    }
                });

                Parallel.For(0, N, i =>
                {
                    Complex32[] row = new Complex32[M];
                    int j;

                    for (j = 0; j < M; j++)
                    {
                        row[j] = A[i, j];
                    }

                    row = IWHT(row, g1, m);

                    for (j = 0; j < M; j++)
                    {
                        A[i, j] = row[j];
                    }
                });
            }
            else if (direction == Direction.Vertical)
            {
                Parallel.For(0, M, j =>
                {
                    Complex32[] col = new Complex32[N];
                    int i;

                    for (i = 0; i < N; i++)
                    {
                        col[i] = A[i, j];
                    }

                    col = IWHT(col, g0, m);

                    for (i = 0; i < N; i++)
                    {
                        A[i, j] = col[i];
                    }
                });
            }
            else
            {
                Parallel.For(0, N, i =>
                {
                    Complex32[] row = new Complex32[M];
                    int j;

                    for (j = 0; j < M; j++)
                    {
                        row[j] = A[i, j];
                    }

                    row = IWHT(row, g1, m);

                    for (j = 0; j < M; j++)
                    {
                        A[i, j] = row[j];
                    }
                });
            }

            return(A);
        }