Reputation: 1746
Could someone tell me, where I can find source code for matrix multiplication realized by OpenFOAM, PETSc or something similar? It can't be trivial algorithm. I have found homepages of OpenFOAM and PETSc but in doc I cant find multiply methods and source code.
Upvotes: 0
Views: 956
Reputation: 1701
PETSc implements matrix multiplication for many formats, look at this part of MatMult_SeqAIJ for the most basic implementation. For a sparse matrix stored in compressed sparse row form with row starts ai
, column indices aj
, and entries aa
, multiplication consists of the following simple kernel.
for (i=0; i<m; i++) {
y[i] = 0;
for (j=ai[i]; j<ai[i+1]; j++)
y[i] += aa[j] * x[aj[j]];
}
Upvotes: 1