I'm using Python(x,y) / Spyder / Sympy to do some symbolic matrix calculations, which I then want to write into my C program.
Is there a tool (Python or not) that will take this resulting matrix written in Python style and spit it out as one or more lines of (valid) C code ?
E.g. if I define
A = [[a, 0] [b, 0]]
B = [[c, d] [0, 0]]
and then ask Python to compute and print A*B
then I will get
Matrix([[a*c, a*d], [b*c d*c]])
which I then want to be converted to something like :
result[0][0] = a*c;
result[0][1] = a*d;
result[1][0] = b*c;
result[1][1] = d*c;
I can get the core of it done manually in Python, simply because basic arithmetic operators are written the same in Python and in C.
But as soon as we go to powers and trigonometry, things change a little bit ... and there may be other things I can't think off the top of my head right now that will appear down the line as my matrices get more complex and use more advanced standard math functions (and trust me, they will).
So some code or tool that would automate this for me would be great.