root/pyx.pyx

Revision 7, 0.9 kB (checked in by steve, 1 year ago)

Faster, hovering text, nicer (refractored code), pyrex enabled now too

Line 
1 #!/usr/bin/env python
2 # encoding: utf-8
3 """
4 pyx.pyx
5
6 Created by Shu Ning Bian on 2007-09-23.
7 Copyright (c) 2007 . All rights reserved.
8 """
9
10 import sys
11 import os
12 def pix_sum(x,y):
13         """Returns a tuple which is the sum of the tuples given"""
14         return ((x[0])+y[0], x[1]+y[1], x[2]+y[2])
15
16 def pix_diff(x,y):
17         """Returns a tuple which is the difference of the tuples given"""
18         return ((x[0])-y[0], x[1]-y[1], x[2]-y[2])
19        
20 def pyx_transform_array(input):
21         """Performs wavelet transform on the input, destorys input"""
22         length = len(input)
23         output = [0]*length
24
25         if length%2:
26                 length=length-1
27
28         while(True):
29                 length=length/2
30                 for i from 0 <= i < length:
31                         s = pix_sum(input[i*2], input[i*2+1])
32                         d = pix_diff(input[i*2], input[i*2+1])
33                         output[i] = s
34                         output[length+i] = d
35                        
36                 if length == 1:
37                         return output
38                 else:
39                         input = output
40         raise Exception
41
42 def main():
43         pass
44
45
46 if __name__ == '__main__':
47         main()
48
Note: See TracBrowser for help on using the browser.