FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
max_index_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#ifndef KERNEL_LAFEM_ARCH_MAX_INDEX_GENERIC_HPP
8#define KERNEL_LAFEM_ARCH_MAX_INDEX_GENERIC_HPP 1
9
10#ifndef KERNEL_LAFEM_ARCH_MAX_INDEX_HPP
11#error "Do not include this implementation-only header file directly!"
12#endif
13
14#include <kernel/util/math.hpp>
15
16namespace FEAT
17{
18 namespace LAFEM
19 {
20 namespace Arch
21 {
22 template <typename DT_>
23 Index MaxIndex::value_generic(const DT_ * const x, const Index size)
24 {
25 DT_ max(x[0]);
26 Index max_i(0);
27
28 for (Index i(0) ; i < size ; ++i)
29 {
30 if (x[i] > max)
31 {
32 max = x[i];
33 max_i = i;
34 }
35 }
36
37 return max_i;
38 }
39
40 template <typename ValueType_>
41 ValueType_ MaxIndex::value_blocked_generic(const ValueType_ * const x, const Index size)
42 {
43 ValueType_ max(0);
44
45 if(size > 0)
46 {
47 max = x[0];
48 }
49
50 for (Index i(0) ; i < size ; ++i)
51 {
52 for(int j(0); j < ValueType_::n; ++j)
53 {
54 if(x[i][j] > max[j])
55 {
56 max[j] = x[i][j];
57 }
58 }
59 }
60 return max;
61 }
62
63 } // namespace Arch
64 } // namespace LAFEM
65} // namespace FEAT
66
67#endif // KERNEL_LAFEM_ARCH_MAX_INDEX_GENERIC_HPP
T_ max(T_ a, T_ b)
Returns the maximum of two values.
Definition: math.hpp:137
FEAT namespace.
Definition: adjactor.hpp:12
std::uint64_t Index
Index data type.