Advertisement
LeonardCHoo

Simplified Matrix Multiplication

Jul 26th, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.41 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <unistd.h>
  3. #define DIM 4
  4.  
  5. double A[DIM][DIM];
  6. double B[DIM][DIM];
  7. double C[DIM][DIM]; #result of multiplication goes into this matrix
  8.  
  9. int main(void)
  10. {      
  11.     int i, j, k;
  12.     for ( i = 0 ; i < DIM ; i++ ){
  13.         for ( j = 0 ; j < DIM ; j++ ){
  14.             for ( k = 0 ; k < DIM ; k++ ){
  15.                 C[i][j] += A[i][k]*B[k][j];
  16.             }  
  17.         }
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement