tags : Math
Matrix Multiplication
Ordered n-tuples are often indicated by a variable with an arrow on top. For example, eg.
// C(m, n) = A(m, k) * B(k, n)
// m = no. row of A
// k = no. col of A & no. row of B
// n = no. col of B
// This actually has pretty bad spatial locality
// as B is being accessed column-wise. (stride-n access!)
for (int i = 0; i < m; i++) { // row of C
for (int j = 0; j < n; j++) { // col of C
for (int p = 0; p < k; p++) { // k x k for the multiplication
C(i, j) += A(i, p) * B(p, j);
}
}
}