FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
min_max_value_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_MIN_MAX_VALUE_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_ MinMaxValueBlock::exec_generic_impl(const ValueType_ * const x, const Index size, const bool min_, const bool abs_)
18 {
19 ValueType_ result(x[0]);
20
21 if(abs_)
22 {
23 for(int j(0); j < ValueType_::n; ++j)
24 {
25 result[j] = Math::abs(x[0][j]);
26 }
27 }
28
29 if(min_)
30 {
31 if(abs_)
32 {
33 for (Index i(0) ; i < size ; ++i)
34 {
35 for(int j(0); j < ValueType_::n; ++j)
36 {
37 result[j] = Math::min(result[j], Math::abs(x[i][j]));
38 }
39 }
40 }
41 else
42 {
43 for (Index i(0) ; i < size ; ++i)
44 {
45 for(int j(0); j < ValueType_::n; ++j)
46 {
47 result[j] = Math::min(result[j], x[i][j]);
48 }
49 }
50 }
51 }
52 else // max
53 {
54 if(abs_)
55 {
56 for (Index i(0) ; i < size ; ++i)
57 {
58 for(int j(0); j < ValueType_::n; ++j)
59 {
60 result[j] = Math::max(result[j], Math::abs(x[i][j]));
61 }
62 }
63 }
64 else
65 {
66 for (Index i(0) ; i < size ; ++i)
67 {
68 for(int j(0); j < ValueType_::n; ++j)
69 {
70 result[j] = Math::max(result[j], x[i][j]);
71 }
72 }
73 }
74 }
75
76 return result;
77 }
78} // namespace FEAT::LAFEM::Arch
T_ abs(T_ x)
Returns the absolute value.
Definition: math.hpp:275
T_ min(T_ a, T_ b)
Returns the minimum of two values.
Definition: math.hpp:123
T_ max(T_ a, T_ b)
Returns the maximum of two values.
Definition: math.hpp:137
std::uint64_t Index
Index data type.