FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
matvecmult_dense_dense_generic.hpp
1// FEAT3: Finite Element Analysis Toolbox, Version 3
2// Copyright (C) 2010 by Stefan Turek & the FEAT group
3// FEAT3 is released under the GNU General Public License version 3,
4// see the file 'copyright.txt' in the top level directory for details.
5
6#pragma once
7
8#ifndef KERNEL_LAFEM_ARCH_MATVECMULT_DENSE_DENSE_HPP
9#error "Do not include this implementation-only header file directly!"
10#endif
11
12namespace FEAT::LAFEM::Arch
13{
14 template <typename DT_>
15 void MatVecMultDenseDense::exec_generic_impl(DT_ * r, const DT_ alpha, const DT_ * const y, const DT_ * const val, const DT_ * const x, const Index rows, const Index cols, bool transposed)
16 {
17 if (transposed)
18 {
19 if(y == nullptr)
20 {
21 FEAT_PRAGMA_OMP(parallel for)
22 for (Index col = 0 ; col < cols ; ++col)
23 {
24 DT_ sum(0);
25 for (Index row(0); row < rows; ++row)
26 {
27 sum += val[row * cols + col] * x[row];
28 }
29 r[col] = alpha * sum;
30 }
31 }
32 else
33 {
34 FEAT_PRAGMA_OMP(parallel for)
35 for (Index col = 0 ; col < cols ; ++col)
36 {
37 DT_ sum(0);
38 for (Index row(0); row < rows; ++row)
39 {
40 sum += val[row * cols + col] * x[row];
41 }
42 r[col] = y[col] + alpha * sum;
43 }
44 }
45 }
46 else
47 {
48 if(y == nullptr)
49 {
50 FEAT_PRAGMA_OMP(parallel for)
51 for (Index row = 0 ; row < rows ; ++row)
52 {
53 DT_ sum(0);
54 for (Index col(0); col < cols; ++col)
55 {
56 sum += val[row * cols + col] * x[col];
57 }
58 r[row] = alpha * sum;
59 }
60 }
61 else
62 {
63 FEAT_PRAGMA_OMP(parallel for)
64 for (Index row = 0 ; row < rows ; ++row)
65 {
66 DT_ sum(0);
67 for (Index col(0); col < cols; ++col)
68 {
69 sum += val[row * cols + col] * x[col];
70 }
71 r[row] = y[row] + alpha * sum;
72 }
73 }
74 }
75 }
76} // namespace FEAT::LAFEM::Arch
std::uint64_t Index
Index data type.