Alex, I assume you've looked at NumPy? It has a bunch of math stuff written as a Python module in C. So its fast and proven correct. (Lawrence Livermore Labs wrote it I believe) It should do all the heavy lifting you need, and might even provide a full solution. Just a thought, Alan G.