Demo entry 3548640

matrix mult seq

   

Submitted by anonymous on Jan 14, 2016 at 14:18
Language: C++. Code size: 335 Bytes.

void mat_mul(int N, float *A, float *B, float *C)
{
    int i, j, k;
    for (i = 0; i < N; i++) {
        for (j = 0; j < N; j++) {
            C[i*N+j] = 0.0f;
            for (k = 0; k < N; k++) { 
                C[i*N+j] += A[i*N+k] * B[k*N+j]; // C(i, j) = sum(over k) A(i,k) * B(k,j)
            }
        }
    }
}

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).