I am a complete newbie of C. I am trying to write a function to multiply two matrices togheter. I will only deal with 2x2's, so I am going to enumerate them. My idea was to have a float 2x2 as a result. Currently I have this,but I don't know how to properly fix it. Any help will be very much appreciated,thank you.
float [][] product2(float A[2][2], float B[2][2]){ //works only on 2x2's!
float C[2][2];
C[0][0]=A[0][0]*B[0][0]+A[0][1]*B[1][0];
C[0][1]=A[0][0]*B[0][1]+A[0][1]*B[1][1];
C[1][0]=A[1][0]*B[0][0]+A[1][1]*B[1][0];
C[1][1]=A[1][0]*B[0][1]+A[1][1]*B[1][1];
return C;
}
EDIT:
I would like to avoid using an input matrix to get the output, if possible. Would this 2nd iteration work?
float* traspose(float A[]){ // Metodo 1
float B[4];
B[1]=A[2];
B[2]=A[1];
return B;
}
I don't get any error from compiler, but is it legit?