![](https://secure.gravatar.com/avatar/1fb17de2e01c86df878d18f517e09210.jpg?s=120&d=mm&r=g)
Stefan van der Walt wrote:
On Sat, Nov 17, 2007 at 04:44:52PM -0600, Alan Jackson wrote:
On Sat, 17 Nov 2007 22:46:59 +0100 Well, with my *real* code, blitz gave me several pages of errors - I tried treating the 2D arrays as a 1D array, doing all the index arithmetic myself, and that seems to work. Which strikes me as odd...
With Blitz, you are allowed M(i,j) indexing. Otherwise, only the memory address of the data is passed and, as you noticed, you must calculate the offset yourself, i.e. M[i*nr_cols + j].
Travis added a few macros to automate this calculation (for non-blitz cases). If you passed in 'a' then A1(i), A2(i, j) A3(i, j, k) and A4(i, j, k, l) are all defined. Here are the macros: #define A1(i) (*((long*)(a_array->data + (i)*Sa[0]))) #define A2(i,j) (*((long*)(a_array->data + (i)*Sa[0] + (j)*Sa[1]))) #define A3(i,j,k) (*((long*)(a_array->data + (i)*Sa[0] + (j)*Sa[1] + (k)*Sa[2]))) #define A4(i,j,k,l) (*((long*)(a_array->data + (i)*Sa[0] + (j)*Sa[1] + (k)*Sa[2] + (l)*Sa[3]))) cheers, prabhu