FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
matmatmult_sparse_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_MATMATMULT_SPARSE_DENSE_HPP
9#error "Do not include this implementation-only header file directly!"
10#endif
11
12#include <kernel/util/math.hpp>
13
14namespace FEAT::LAFEM::Arch
15{
16 template <typename DT_, typename IT_>
17 void MatMatMultSparseDense::exec_generic_impl(DT_ * r, const DT_ alpha, const DT_ * const val, const IT_ * const col_idx, const IT_ * const row_ptr, const Index /*nonzeros*/,
18 const DT_ * const y, const DT_ * const z, const Index rows, const Index cols, const Index /*inner*/)
19 {
20 FEAT_PRAGMA_OMP(parallel for)
21 for (Index i = 0 ; i < rows ; ++i)
22 {
23 for (Index j = 0 ; j < cols ; ++j)
24 {
25 DT_ sum(0.);
26 Index xindex = row_ptr[i];
27 Index yindex(j);
28 for (Index tmp = xindex ; tmp < row_ptr[i+1] ; ++tmp)
29 {
30 sum = sum + val[tmp] * y[yindex + col_idx[tmp] * cols];
31 }
32 if(z)
33 r[i * cols + j] = z[i * cols + j] + alpha * sum;
34 else
35 r[i * cols + j] = alpha * sum;
36 }
37 }
38 }
39} // namespace FEAT::LAFEM::Arch
std::uint64_t Index
Index data type.