FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
row_norm2_csr_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_ROW_NORM2_CSR_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 RowNorm2CSR::exec_generic_impl(DT_* row_norms, const DT_* const a, const IT_* const /*col_idx*/, const IT_* const row_ptr, const Index rows, const bool squared)
18 {
19 FEAT_PRAGMA_OMP(parallel for)
20 for (Index row = 0; row < rows; row++)
21 {
22 Index end = row_ptr[row + 1];
23 DT_ norm(0);
24
25 for (Index j = row_ptr[row]; j < end; j++)
26 {
27 norm += Math::sqr(a[j]);
28 }
29
30 row_norms[row] = (squared ? norm : Math::sqrt(norm));
31 }
32 }
33} // namespace FEAT::LAFEM::Arch
T_ sqrt(T_ x)
Returns the square-root of a value.
Definition: math.hpp:300
T_ sqr(T_ x)
Returns the square of a value.
Definition: math.hpp:95
std::uint64_t Index
Index data type.