Code:

for (i=0; i<2; i++) {
for (j=0; j<2; j++) {
for (k=0; k<2; k++) {
m3[i][j] = (m1[i][j]*m2[j][i])+(m1[i][j+1]*m2[j+1][i])+(m1[i][j+2]*m2[j+2][i]);
}
}

This code is for a 3x3. You only need to change it a bit to support 3x3 mul 2x3

Code:

for (int i=0;i<2;i++)
{
for (int j=0;j<2;j++)
{
m3[i][j]=0.0f;
for (int k=0;k<2;k++)
{
m3[i][j]+=m1[i][k]*m2[k][j];
}
}
}

However the inner loop is not unrolled and is deathly slow. Also I don't recommend using matrices this way.

A better way is to create a set of structs.

Code:

struct M3x2
{
float _00,_01,_02;
float _10,_11,_12;
}
struct M2x3
{
float _00,_01;
float _10,_11;
float _20,_21;
};
struct M3x3
{
float _00,_01,_02;
float _10,_11,_12;
float _20,_21,_22;
}
struct M4x4
{
float _00,_01,_02,_03;
float _10,_11,_12,_13;
float _20,_21,_22,_23;
float _30,_31,_32,_33;
};

Then to multiply you don't need a loop.

Rememeber this:

A*B=C

C(ij)=A(i)*B(j)

Columns of A must equal rows of B to be multiplied together.

The ij entry of C is equal to the dot product of **i**th row of A with the **j**th column of B.

A * B =

[A1 dot B1, A1 dot B2]

[A2 dot B1, A2 dot B2]