Hey all,

I'm programming a scientific application, namely, a Finite Element solver in ANSI C. The Finite Element research community is totally addicted to Fortran codes, due to some reasons; for instance its ability and ease when dealing with matrices/vectors and also its flexibility in the indexes of the arrays, since you can use every set of integers as indices.

In this kind of application, one must carry several loops over the elements and nodes of a mesh (basically a triangulation of a domain), and the numbering of these entities starts with one ! So, when programming Finite Element in C, I must every time concern with subtracting 1 to access the positions of my array, when in Fortran I would just use the numbering of the nodes directly as indexes.

The question is: Is there anyway to mask the indexing of vectors in C? I first thought about just providing a function double* AllocateVector(int n) that would actually allocate a (n+1) components vector and set the 0 component to 0 and remain it unused, since only one component more for each vector is not a problem. But this is not valid for matrices, sice an (nxn) matrix would have (2n+1) more entries, and this could represent a great amount of memory more.

Or maybe there is some way to "overload the operator ()" without actually using operator overloading (since the program is C, and not C++) and when I write A(i,j), it converts to A[i-1][j-1].

Is there some way to do this ? I hope you could understand my problem.

Thanks in Advance,

Rafael March.