Click here to Skip to main content
16,016,605 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I find what I need from Stack Overflow and now I have a question,what is the benefit of this function
   static void transpose_matrix()
{
  int i, j;
   for(i = 0; i<SIZE; i++)
     for(j = 0; j<SIZE;j++)
        b[i][j] = b_to_trans[j][i];
 }

and why useing this conditions ? can anyone explain to me? please.

if(i >= SIZE/2) a[i][j] = 2.0;
     b_to_trans[i][j] = 1.0;        //this array in specific
     if(j >= SIZE/2) b[i][j] = 2.0;


What I have tried:

I find what I need from this link c - Matrix Multiplication in MPI - Stack Overflow[^]
Posted
Updated 27-Nov-17 21:57pm
v3

1 solution

In the header, you ask about matrix multiplication, while in the question you ask about transposing a matrix. Transposing a matrix is just to switch the rows and columns:
C++
TransposeA[i][j]=A[j][i]
Matrix multiplication is a bit more cumbersome as you need to make sure that the columns in the first matrix have an equal number of rows in the second matrix. That it is just to perform a dot product of the column in the first matrix and the row in the second matix.
$ Result[i][j] = \sum_{k}{A(i,k) \cdot B(k,j)} $

However, If the speed of calculation is of importance it would certainly be better to implement a math library like:
Intel® Math Kernel Library (Intel® MKL) | Intel® Software[^]
or use your GPU:
performance - Why is MATLAB so fast in matrix multiplication? - Stack Overflow[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900