def IIR_sos_header(fname_out, SOS_mat):
Ns, Mcol = SOS_mat.shape<EOL>f = open(fname_out, '<STR_LIT>')<EOL>f.write('<STR_LIT>')<EOL>f.write('<STR_LIT>')<EOL>f.write('<STR_LIT>')<EOL>f.write('<STR_LIT>' % Ns)<EOL>f.write('<STR_LIT>')<EOL>f.write('<STR_LIT>');<EOL>f.write('<STR_LIT>');<EOL>f.write('<STR_LIT>' % (<NUM_LIT:5> * Ns))<EOL>for k in range(Ns):<EOL><INDENT>if (k < Ns - <NUM_LIT:1>):<EOL><INDENT>f.write('<STR_LIT>' %(SOS_mat[k, <NUM_LIT:0>], SOS_mat[k, <NUM_LIT:1>], SOS_mat[k, <NUM_LIT:2>]))<EOL>f.write('<STR_LIT>' %(-SOS_mat[k, <NUM_LIT:4>], -SOS_mat[k, <NUM_LIT:5>]))<EOL><DEDENT>else:<EOL><INDENT>f.write('<STR_LIT>' %(SOS_mat[k, <NUM_LIT:0>], SOS_mat[k, <NUM_LIT:1>], SOS_mat[k, <NUM_LIT:2>]))<EOL>f.write('<STR_LIT>' %(-SOS_mat[k, <NUM_LIT:4>], -SOS_mat[k, <NUM_LIT:5>]))<EOL><DEDENT><DEDENT>f.write('<STR_LIT>')<EOL>f.write('<STR_LIT>')<EOL>f.close()<EOL>
Write IIR SOS Header Files
File format is compatible with CMSIS-DSP IIR 
Directform II Filter Functions

Mark Wickert March 2015-October 2016