Ready for fvm steady case
This commit is contained in:
@@ -38,16 +38,24 @@ namespace numerics{
|
||||
const uint64_t m = A.rows();
|
||||
const uint64_t n = A.cols();
|
||||
|
||||
utils::Vector<T> y(m, T{0});
|
||||
utils::Vector<T> y(m, T{0}); // <-- y has length m (rows)
|
||||
|
||||
|
||||
const T* xptr = x.data();
|
||||
const T* Aptr = A.data(); // row-major: A(i,j) == Aptr[i*n + j]
|
||||
|
||||
// Each row i is an independent dot product: y[i] = dot(A[i,*], x)
|
||||
#pragma omp parallel for schedule(static)
|
||||
for (uint64_t i = 0; i < m; ++i) {
|
||||
T acc = T{0};
|
||||
const T* row = Aptr + i * n; // contiguous row i
|
||||
T acc = T{0};
|
||||
#pragma omp simd reduction(+:acc)
|
||||
for (uint64_t j = 0; j < n; ++j) {
|
||||
acc += A(i, j) * x[j];
|
||||
acc += row[j] * xptr[j];
|
||||
}
|
||||
y[i] = acc;
|
||||
}
|
||||
}
|
||||
|
||||
return y;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user