Hi everyone,

I got problem with coding of matrix-matrix multi plication; Please help me to figure out this
my problem is:
Having a matrix, U2[k][j], with dimension of 9081x84 and other matrix, U[m][j], with dimension of 9081x4
i now want to multiply transpose of A with B,
following is my code, but i can not get correct results

for(j=0; j<=d+8; j++) {
			for(i=0; i<=l+8; i++) {
				for(k=1; k<=21*(TSpcs+3); k++) {
					for (m=1; m<TSpcs+3; m++)
						U2T[i][j][k] = U2[k][i][j]*U2[i][j][m];
			}
		}
}

Thank you very much

NGUYEN VAN BO

Member Avatar for iamthwee

Assuming the matrices are 2 dimensional and the rows/columns are valid (matrix multiplication can only work given a set rule for rows and columns) then you could try:

for ( int i = 0; i < rows; i++ )
{
  for ( int j = 0; j < cols; j++ )
  {
    int val = 0;
    for ( int k = 0; k < cols; k++ )
    {
      val += m1[i][k] * m2[k][j];
    }
    m3[i][j] = val;
  }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.