##// END OF EJS Templates
Fusion
Fusion

File last commit:

r10:1a975ebae8ac default
r11:c08a29e29fbf merge tip default
Show More
cic_impulse_response.py
41 lines | 1002 B | text/x-python | PythonLexer
/ SRC / cic_impulse_response.py
class GenericInterator(object):
"""docstring for GenericInterator"""
def __init__(self):
super(GenericInterator, self).__init__()
self.y = 0
def integrator(self, x):
self.y = self.y + x
return self.y
class GenericDerivator(object):
"""docstring for GenericInterator"""
def __init__(self):
super(GenericDerivator, self).__init__()
self.y = 0
self.x_tmp1 = 0
self.x_tmp2 = 0
def derivator(self, x):
self.y = x - self.x_tmp2
self.x_tmp2 = self.x_tmp1
self.x_tmp1 = x
return self.y
if __name__ == "__main__":
i0 = GenericInterator()
i1 = GenericInterator()
i2 = GenericInterator()
c0 = GenericDerivator()
c1 = GenericDerivator()
c2 = GenericDerivator()
for i in range(10):
for j in range(32):
i2.integrator(i1.y)
i1.integrator(i0.y)
i0.integrator(127)
if j == 0:
c0.derivator(i2.y)
c1.derivator(c0.y)
c2.derivator(c1.y)
print i, j, i0.y, i1.y, " *** ", i2.y, c0.y, c1.y, c2.y, c2.y / 2**16