
On Sun, 13 Jan 2002, Prabhu Ramachandran wrote:
Anyway, my question is u(i,j) as referred to in either Python (u[i,j]) or in blitz or f2py -- do they mean the same thing? Or is it that when I write a loop in fortran that uses a numeric array I must make sure that u(i,j) == u[j,i] ??
I am currently reconsidering the Fortran/C array issues. It is looking promising what I have worked out: u[i,j] in Python and u(i,j) in Fortran will be the same. And one will not need to think about how matrices are stored in memory, as a first instance at least. However, if you are aware about the fact that Fortran and C arrays have different storage orders, then you can be clever by creating arrays with a proper storage order that will be good for performance. The approach will be similar to the one in Pyfort but I think it can be more efficient. Let me say that with this new approach there will be no performance hit compared to the current f2py approach. Just the appearance of Fortran and C multidimensional arrays in Python will be unified and that is a very important step as then matrices in mathematical sense will coincide. However, to code this approach efficiently I need a PyArray_TransposedContiguousFromObject function that does not exists in Numeric. If an Object is PyArray already, then I can easily write that part. However, if an Object is a List or any other Sequence then one needs to repeat lots of code in Numeric. Basically, Array_FromSequence needs to be rewritten to TransposedArray_FromSequence which requires quite good knowledge of Numeric internals which I lack. A good thing is that PyArrayObject needs not to be changed at all. If someone has already coded all that in above or at least parts of it, I would appreciate code examples very much. Pearu