URL
https://opencores.org/ocsvn/phr/phr/trunk
Subversion Repositories phr
Compare Revisions
- This comparison shows the changes necessary to convert path
/phr
- from Rev 356 to Rev 357
- ↔ Reverse comparison
Rev 356 → Rev 357
/trunk/codigo/implementaciones/fft/model/py/fft no recursiva/fftv00.py
0,0 → 1,45
#!/usr/bin/env python |
# -*- coding: utf-8 -*- |
|
def omega (k): |
result = ( \ |
+1.000 + 0.000j, \ |
+0.707 - 0.707j, \ |
+0.000 - 1.000j, \ |
-0.707 - 0.707j, \ |
-1.000 + 0.000j, \ |
-0.707 + 0.707j, \ |
+0.000 + 1.000j, \ |
+0.707 + 0.707j) |
|
return result[k] |
|
def butter_upper (a, b, orden): |
return a+b*omega(orden) |
|
def butter_lower (a, b, orden): |
return a-b*omega(orden) |
|
|
seq = (0+0j, 1+0j, 0+0j, -1+0j, 0+0j, 1+0j, 0+0j, -1+0j) |
|
rseq = (0+0j, 0+0j, 0+0j, 0+0j, 1+0j, 1+0j, -1+0j, -1+0j) |
|
orden = 3 |
|
m = [[0 for x in range (8)] for x in range (4)] |
|
for i in range (8): |
m[0][i] = rseq [i] |
|
for nivel in range (1,orden+1): |
for i in range (2**(nivel-1)): |
j = 0 |
while j < 2**orden: |
m[nivel][i+j] = butter_upper(m[nivel-1][i+j],m[nivel-1][i+j+2**(nivel-1)],i*(2**(4-nivel-1))) |
m[nivel][i+j+2**(nivel-1)] = butter_lower(m[nivel-1][i+j],m[nivel-1][i+j+2**(nivel-1)],i*(2**(4-nivel-1))) |
j = j+2**nivel |
|
print m[3] |
|
|
trunk/codigo/implementaciones/fft/model/py/fft no recursiva/fftv00.py
Property changes :
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: trunk/codigo/implementaciones/fft/model/py/fft recursiva/fftv00.py
===================================================================
--- trunk/codigo/implementaciones/fft/model/py/fft recursiva/fftv00.py (nonexistent)
+++ trunk/codigo/implementaciones/fft/model/py/fft recursiva/fftv00.py (revision 357)
@@ -0,0 +1,23 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+import cmath
+
+def omega (p,q):
+ return cmath.exp((2.0 * cmath.pi * 1j * q) / p)
+
+def fft(signal):
+ n = len(signal)
+ if n == 1:
+ return signal
+ else:
+ Feven = fft([signal[i] for i in xrange (0,n,2)])
+ Fodd = fft([signal[i] for i in xrange (1,n,2)])
+
+ combined = [0] * n
+ for m in xrange(n/2):
+ combined[m] = Feven[m] + omega(n,-m) * Fodd[m]
+ combined[m + n/2] = Feven[m] - omega(n,-m) * Fodd[m]
+
+ return combined
+
trunk/codigo/implementaciones/fft/model/py/fft recursiva/fftv00.py
Property changes :
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: trunk/codigo/implementaciones/fft/model/py/fft recursiva/fftv01.py
===================================================================
--- trunk/codigo/implementaciones/fft/model/py/fft recursiva/fftv01.py (nonexistent)
+++ trunk/codigo/implementaciones/fft/model/py/fft recursiva/fftv01.py (revision 357)
@@ -0,0 +1,39 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+import cmath
+
+def omega (N,k):
+ #return cmath.exp(-2.0 * cmath.pi * 1j / N * k)
+ result = ( \
+ +1.000 + 0.000j, \
+ +0.707 - 0.707j, \
+ +0.000 - 1.000j, \
+ -0.707 - 0.707j, \
+ -1.000 + 0.000j, \
+ -0.707 + 0.707j, \
+ +0.000 + 1.000j, \
+ +0.707 + 0.707j)
+
+ return result[k]
+
+def fft(signal):
+ N = len(signal)
+ if N == 1:
+ return signal
+ else:
+ fft_even = fft([signal[i] for i in range (0,N,2)])
+ fft_odd = fft([signal[i] for i in range (1,N,2)])
+
+ # butterfly operation:
+
+ combined = [0] * N
+ for k in range(N/2):
+ omega_x_fftodd = omega(N, k) * fft_odd[k]
+ combined[k] = fft_even[k] + omega_x_fftodd
+ combined[k + N/2] = fft_even[k] - omega_x_fftodd
+
+ return combined
+
+seq = (0, 1, 0, -1, 0, 1, 0, -1)
+print fft (seq)
trunk/codigo/implementaciones/fft/model/py/fft recursiva/fftv01.py
Property changes :
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: trunk/codigo/implementaciones/fft/model/py/fft recursiva/fftv02.py
===================================================================
--- trunk/codigo/implementaciones/fft/model/py/fft recursiva/fftv02.py (nonexistent)
+++ trunk/codigo/implementaciones/fft/model/py/fft recursiva/fftv02.py (revision 357)
@@ -0,0 +1,42 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+#import cmath
+
+def omega (N,k):
+ #return cmath.exp(-2.0 * cmath.pi * 1j / N * k)
+ result = ( \
+ (+1.000, +0.000), \
+ (+0.707, -0.707), \
+ (+0.000, -1.000), \
+ (-0.707, -0.707), \
+ (-1.000, +0.000), \
+ (-0.707, +0.707), \
+ (+0.000, +1.000), \
+ (+0.707, +0.707))
+
+ return result[k]
+
+def fft(signal):
+ N = len(signal)
+ if N == 1:
+ return signal
+ else:
+ fft_even = fft([signal[i] for i in range (0,N,2)])
+ fft_odd = fft([signal[i] for i in range (1,N,2)])
+
+ # butterfly operation:
+
+ combined = [(0,0)]* N
+ for k in range(N/2):
+ # (a+jb).(c+jd) = (a.c-b.d) + j (a.d+b.c)
+ omega_x_fftodd = ((omega(N, k)[0] * fft_odd[k][0] - omega(N, k)[1] * fft_odd[k][1]), \
+ (omega(N, k)[0] * fft_odd[k][1] + omega(N, k)[1] * fft_odd[k][0]))
+
+ combined[k] = ((fft_even[k][0] + omega_x_fftodd[0]),(fft_even[k][1] + omega_x_fftodd[1]))
+ combined[k + N/2] = ((fft_even[k][0] - omega_x_fftodd[0]),(fft_even[k][1] - omega_x_fftodd[1]))
+
+ return combined
+
+seq = ((0,0), (1,0), (0,0), (-1,0), (0,0), (1,0), (0,0), (-1,0))
+print fft (seq)
trunk/codigo/implementaciones/fft/model/py/fft recursiva/fftv02.py
Property changes :
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property