Skip to content

Commit

Permalink
Vectorize the multiplication
Browse files Browse the repository at this point in the history
  • Loading branch information
beomki-yeo committed Apr 11, 2024
1 parent cd3fea5 commit 36183bf
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions math/cmath/include/algebra/math/impl/cmath_operators.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,16 +205,17 @@ ALGEBRA_HOST_DEVICE inline array_t<array_t<scalar_t, M>, O> operator*(

array_t<array_t<scalar_t, M>, O> C;

for (size_type i = 0; i < M; ++i) {
for (size_type i = 0; i < N; ++i) {
for (size_type j = 0; j < O; ++j) {

scalar_t val = 0;
const scalar_t B_ij = B[j][i];

for (size_type k = 0; k < N; ++k) {
val += A[k][i] * B[j][k];
for (size_type k = 0; k < M; ++k) {
val += A[i][k] * B_ij;
}

C[j][i] = val;
C[j][k] = val;
}
}

Expand Down

0 comments on commit 36183bf

Please sign in to comment.