/// <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)); }
/// <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)); }
/// <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); }