FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
norm2_block_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_NORM2_BLOCK_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 ValueType_>
17 ValueType_ Norm2Block::exec_generic_impl(const ValueType_ * const x, const Index size)
18 {
19 ValueType_ r(0);
20
21 for (Index i(0) ; i < size ; ++i)
22 {
23 for(int j = 0; j < ValueType_::n; ++j)
24 {
25 r[j] += x[i][j] * x[i][j];
26 }
27 }
28
29 for(int j = 0; j < ValueType_::n; ++j)
30 r[j] = Math::sqrt(r[j]);
31
32 return r;
33 }
34} // namespace FEAT::LAFEM::Arch
T_ sqrt(T_ x)
Returns the square-root of a value.
Definition: math.hpp:300
std::uint64_t Index
Index data type.