1import cmsisdsp as dsp 2import numpy as np 3 4recipQ15=np.array([0x7F03, 0x7D13, 0x7B31, 0x795E, 0x7798, 0x75E0, 5 0x7434, 0x7294, 0x70FF, 0x6F76, 0x6DF6, 0x6C82, 6 0x6B16, 0x69B5, 0x685C, 0x670C, 0x65C4, 0x6484, 7 0x634C, 0x621C, 0x60F3, 0x5FD0, 0x5EB5, 0x5DA0, 8 0x5C91, 0x5B88, 0x5A85, 0x5988, 0x5890, 0x579E, 9 0x56B0, 0x55C8, 0x54E4, 0x5405, 0x532B, 0x5255, 10 0x5183, 0x50B6, 0x4FEC, 0x4F26, 0x4E64, 0x4DA6, 11 0x4CEC, 0x4C34, 0x4B81, 0x4AD0, 0x4A23, 0x4978, 12 0x48D1, 0x482D, 0x478C, 0x46ED, 0x4651, 0x45B8, 13 0x4521, 0x448D, 0x43FC, 0x436C, 0x42DF, 0x4255, 14 0x41CC, 0x4146, 0x40C2, 0x4040]) 15 16s,v=dsp.arm_recip_q15(int(0x2000),recipQ15) 17print("1 / 0.25") 18print(s) 19print("%04X -> %f" % (v,((v<<s)/(1<<15)))) 20print("----\n") 21 22s,v=dsp.arm_recip_q15(1,recipQ15) 23print("1 / (1 << 15)") 24print(s) 25print("%04X -> %f" % (v,((v<<s)/(1<<15)))) 26print(1<<15) 27print("----\n") 28 29