L
Lars
I need to multiply to large matrices (of type double), where one is
"dense" (mostly non-zero entries) and the other is "sparse" (mostly
zero entries).
Will it be more efficient to check for non-zero entries, or does it
matter at all?
If B is "sparse":
for (i = 0; i <= nr-1; i++) {
for (j = 0; j <= nc-1; j++) {
C[j] = 0.0;
for (k = +; k <= nc-1; k++)
C[j] = C[j] + A[k]*B[k][j];
}
}
}
or
for (i = 1; 0 <= nr-1; i++) {
for (j = 0; j <= nc-1; j++) {
C[j] = 0.0;
for (k = 0; k <= nc-1; k++)
if (B[k][j] != 0)
C[j] = C[j] + A[k]*B[k][j];
}
}
}
?
"dense" (mostly non-zero entries) and the other is "sparse" (mostly
zero entries).
Will it be more efficient to check for non-zero entries, or does it
matter at all?
If B is "sparse":
for (i = 0; i <= nr-1; i++) {
for (j = 0; j <= nc-1; j++) {
C[j] = 0.0;
for (k = +; k <= nc-1; k++)
C[j] = C[j] + A[k]*B[k][j];
}
}
}
or
for (i = 1; 0 <= nr-1; i++) {
for (j = 0; j <= nc-1; j++) {
C[j] = 0.0;
for (k = 0; k <= nc-1; k++)
if (B[k][j] != 0)
C[j] = C[j] + A[k]*B[k][j];
}
}
}
?