- Timestamp:
- 07/22/10 00:44:01 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.ALGLIB/2.5.0/ALGLIB-2.5.0/fht.cs
r3839 r4068 19 19 *************************************************************************/ 20 20 21 using System;22 21 23 namespace alglib 24 { 25 public class fht 26 { 27 /************************************************************************* 28 1-dimensional Fast Hartley Transform. 22 namespace alglib { 23 public class fht { 24 /************************************************************************* 25 1-dimensional Fast Hartley Transform. 29 26 30 27 Algorithm has O(N*logN) complexity for any N (composite or prime). 31 28 32 33 34 29 INPUT PARAMETERS 30 A - array[0..N-1] - real function to be transformed 31 N - problem size 35 32 36 37 38 33 OUTPUT PARAMETERS 34 A - FHT of a input array, array[0..N-1], 35 A_out[k] = sum(A_in[j]*(cos(2*pi*j*k/N)+sin(2*pi*j*k/N)), j=0..N-1) 39 36 40 37 41 -- ALGLIB -- 42 Copyright 04.06.2009 by Bochkanov Sergey 43 *************************************************************************/ 44 public static void fhtr1d(ref double[] a, 45 int n) 46 { 47 ftbase.ftplan plan = new ftbase.ftplan(); 48 int i = 0; 49 AP.Complex[] fa = new AP.Complex[0]; 38 -- ALGLIB -- 39 Copyright 04.06.2009 by Bochkanov Sergey 40 *************************************************************************/ 41 public static void fhtr1d(ref double[] a, 42 int n) { 43 ftbase.ftplan plan = new ftbase.ftplan(); 44 int i = 0; 45 AP.Complex[] fa = new AP.Complex[0]; 50 46 51 System.Diagnostics.Debug.Assert(n>0, "FHTR1D: incorrect N!"); 52 53 // 54 // Special case: N=1, FHT is just identity transform. 55 // After this block we assume that N is strictly greater than 1. 56 // 57 if( n==1 ) 58 { 59 return; 60 } 61 62 // 63 // Reduce FHt to real FFT 64 // 65 fft.fftr1d(ref a, n, ref fa); 66 for(i=0; i<=n-1; i++) 67 { 68 a[i] = fa[i].x-fa[i].y; 69 } 70 } 47 System.Diagnostics.Debug.Assert(n > 0, "FHTR1D: incorrect N!"); 48 49 // 50 // Special case: N=1, FHT is just identity transform. 51 // After this block we assume that N is strictly greater than 1. 52 // 53 if (n == 1) { 54 return; 55 } 56 57 // 58 // Reduce FHt to real FFT 59 // 60 fft.fftr1d(ref a, n, ref fa); 61 for (i = 0; i <= n - 1; i++) { 62 a[i] = fa[i].x - fa[i].y; 63 } 64 } 71 65 72 66 73 74 67 /************************************************************************* 68 1-dimensional inverse FHT. 75 69 76 70 Algorithm has O(N*logN) complexity for any N (composite or prime). 77 71 78 79 80 72 INPUT PARAMETERS 73 A - array[0..N-1] - complex array to be transformed 74 N - problem size 81 75 82 83 76 OUTPUT PARAMETERS 77 A - inverse FHT of a input array, array[0..N-1] 84 78 85 79 86 -- ALGLIB -- 87 Copyright 29.05.2009 by Bochkanov Sergey 88 *************************************************************************/ 89 public static void fhtr1dinv(ref double[] a, 90 int n) 91 { 92 int i = 0; 80 -- ALGLIB -- 81 Copyright 29.05.2009 by Bochkanov Sergey 82 *************************************************************************/ 83 public static void fhtr1dinv(ref double[] a, 84 int n) { 85 int i = 0; 93 86 94 System.Diagnostics.Debug.Assert(n>0, "FHTR1DInv: incorrect N!"); 95 96 // 97 // Special case: N=1, iFHT is just identity transform. 98 // After this block we assume that N is strictly greater than 1. 99 // 100 if( n==1 ) 101 { 102 return; 103 } 104 105 // 106 // Inverse FHT can be expressed in terms of the FHT as 107 // 108 // invfht(x) = fht(x)/N 109 // 110 fhtr1d(ref a, n); 111 for(i=0; i<=n-1; i++) 112 { 113 a[i] = a[i]/n; 114 } 115 } 87 System.Diagnostics.Debug.Assert(n > 0, "FHTR1DInv: incorrect N!"); 88 89 // 90 // Special case: N=1, iFHT is just identity transform. 91 // After this block we assume that N is strictly greater than 1. 92 // 93 if (n == 1) { 94 return; 95 } 96 97 // 98 // Inverse FHT can be expressed in terms of the FHT as 99 // 100 // invfht(x) = fht(x)/N 101 // 102 fhtr1d(ref a, n); 103 for (i = 0; i <= n - 1; i++) { 104 a[i] = a[i] / n; 105 } 116 106 } 107 } 117 108 }
Note: See TracChangeset
for help on using the changeset viewer.