I want to implement (what represents abstractly) a two dimensional 4x4 matrix. All the code I write for matrix multiplication et cetera will be entirely "unrolled" as it were -- that is to say, I will not be using loops to access and write data entries in the matrix.
My question is: In C, would it be faster to use a struct as such:
typedef struct { double e0, e1, e2, e3, e4, ..., e15 } My4x4Matrix; Or would this be faster:
typedef double My4x4Matrix[16]; Given that I will be accessing each matrix element individually as such:
My4x4Matrix a,b,c; // (Some initialization of a and b.) ... c.e0=a.e0+b.e0; c.e1=a.e1+b.e1; ... Or
My4x4Matrix a,b,c; // (Some initialization of a and b.) ... c[0]=a[0]+b[0]; c[1]=a[1]+b[1]; ... Or are they exactly the same speed?