I would like to write a program that describes a mathematical (optimization) problem, analyzes it and generates a compact, efficient C-code that solves it. I have a hacked solution to a much smaller, more specific problem in python, but it is ugly and just relies on templating C code, so I have a whole mess of lines that look like
for (k = 0; k <= %s; k += %s) a[k] = v[k]/%s * a[i];
And then there is a mess of complex conditional logic, and at some point the above line is written to solve_problem.c after filling in the correct% s values.
In fact, it becomes much more complicated, because, as a rule, the problem is parameterized by matrices with a certain structure, etc., and the above approach, being efficient, starts to fall apart under its own weight.
So, I believe what I'm looking for is high-level tips on how to represent these problems in code, or rather, just examples of other projects where this has been resolved. Someone told me to use OCaml or F # and look at FFTW, but something simpler would be appreciated.
I am sorry that I am so slurred, but it’s hard for me to even express what I’m looking for myself, which, I think, is the root of the problem.
source share