FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
unit_filter_block_bcsr_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_UNIT_FILTER_BLOCK_BCSR_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 UnitFilterBlockBCSR::exec_generic_impl(DT_* mat, const IT_* const row_ptr, const IT_* const col_idx, const DT_ * const f_val, const IT_ * const f_idx, const Index f_nzes, const bool unit, const bool ign_nans, const int block_height, const int block_width)
18 {
19 FEAT_PRAGMA_OMP(parallel for)
20 for(Index i = 0; i < f_nzes; ++i)
21 {
22 const IT_ ix(f_idx[i]);
23 const DT_* const vx(&f_val[i*Index(block_height)]);
24
25 // replace by unit row
26 for(IT_ j(row_ptr[ix]); j < row_ptr[ix + 1]; ++j)
27 {
28 // loop over rows in the block
29 for(int k(0); k < block_height; ++k)
30 {
31 // possibly skip row if filter value is NaN
32 if(ign_nans && Math::isnan(vx[k]))
33 continue;
34
35 // format block row to zero
36 for(int l(0); l < block_width; ++l)
37 mat[j*IT_(block_height*block_width) + IT_(k*block_width) + IT_(l)] = DT_(0);
38
39 // replace diagonal entry by 1 if requested
40 if(unit && (col_idx[j] == ix) && (k < block_width))
41 mat[j*IT_(block_height*block_width) + IT_(k*block_width) + IT_(k)] = DT_(1);
42 }
43 }
44 }
45 }
46} // namespace FEAT::LAFEM::Arch
bool isnan(T_ x)
Checks whether a value is Not-A-Number.
std::uint64_t Index
Index data type.