refactor
Sync public mirror / sync (push) Failing after 29s

almost complete. Need to doublecheck names for functions in *_serial.h
This commit is contained in:
2026-01-18 17:51:05 +01:00
parent 9709949a5b
commit 6b8a7ab582
15 changed files with 383 additions and 523 deletions
+35
View File
@@ -0,0 +1,35 @@
#pragma once
#include <cstdint> //uint64_t
#include <stdexcept> // std::runtime_error
#include "../utils/vector.h"
#include "../utils/matrix.h"
namespace numerics::detail{
// ---------------- Matrix * Matrix ----------------
template <typename T>
inline utils::Matrix<T> matmul_serial(const utils::Matrix<T>& A, const utils::Matrix<T>& B){
const uint64_t m = A.rows();
const uint64_t n = A.cols(); // also B.rows()
const uint64_t p = B.cols();
if(n != B.rows()){
throw std::runtime_error("matmul: dimension mismatch");
}
T tmp;
utils::Matrix<T> C(m, p, T{0});
for (uint64_t i = 0; i < m; ++i){
for (uint64_t j = 0; j < n; ++j){
tmp = A(i,j);
for (uint64_t k = 0; k < p; ++k){
C(i,k) += tmp * B(j,k);
}
}
}
return C;
}
} // namespace numerics