guest
guest

Reputation: 1746

OpenFOAM, PETSc or other sparse matrix multiplication source code

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

Answers (1)

Jed
Jed

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

Related Questions