Source Code of Matrix Multiplication

Source Code of Matrix Multiplication

If three matrices are given as

double A[N * N];
double B[N * N];
double C[N * N];

and the values of A[...] and B[...] are initialized,  the matrix multiplication of A x B can be calculated as:

for (int i = 0; i < N; ++i)
    for (int j = 0; j < N; ++j)
        for (int k = 0; k < N; ++k)
            C[N * i + k] += A[N * i + j] * B[N * j + k];

In another way, if the matrices are given as two dimensional matrix form such that

double A[N][N];
double B[N][N];
double C[N][N];

the matrix multiplication of A x B can be calculated as:

for (int i = 0; i < N; ++i)
    for (int j = 0; j < N; ++j)
        for (int k = 0; k < N; ++k)
            C[i][k] += A[i][j] * B[j][k];


added 11 years ago

- What is x-ray?
- The Wink home automation
- Skype works, shows I have internet, but browser wont go online
- If LED lights are so efficient then why do they get almost as hot as incandescents?
- How to correctly optimize your SSD for windows 10
- WAMP Mysqli: Your password has expired
- MySQL Dump/Restore, Dumping MySQL Database and Tables using MysqlDump command
- Source Code of Matrix Multiplication
- How to create your own PHP caching system? A simple example
- Domain Life Cycle
- Comparison of Random Functions According to their Exploration Performance (STL, .NET, Java)
- How to draw double buffered in C# or Java using GDI+
- How to recover Ubuntu after installing Windows using Ubuntu live cd
2
1