FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
min_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_MIN_INDEX_GENERIC_HPP
8#define KERNEL_LAFEM_ARCH_MIN_INDEX_GENERIC_HPP 1
9
10#ifndef KERNEL_LAFEM_ARCH_MIN_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 MinIndex::value_generic(const DT_ * const x, const Index size)
24 {
25 DT_ min(x[0]);
26 Index min_i(0);
27
28 for (Index i(0) ; i < size ; ++i)
29 {
30 if (x[i] < min)
31 {
32 min = x[i];
33 min_i = i;
34 }
35 }
36 return min_i;
37 }
38
39 template <typename ValueType_>
40 ValueType_ MinIndex::value_blocked_generic(const ValueType_ * const x, const Index size)
41 {
42 ValueType_ min(0);
43
44 if(size > 0)
45 {
46 min = x[0];
47 }
48
49 for (Index i(0) ; i < size ; ++i)
50 {
51 for(int j(0); j < ValueType_::n; ++j)
52 {
53 if(x[i][j] < min[j])
54 {
55 min[j] = x[i][j];
56 }
57 }
58 }
59 return min;
60 }
61
62 } // namespace Arch
63 } // namespace LAFEM
64} // namespace FEAT
65
66#endif // KERNEL_LAFEM_ARCH_MIN_INDEX_GENERIC_HPP
T_ min(T_ a, T_ b)
Returns the minimum of two values.
Definition: math.hpp:123
FEAT namespace.
Definition: adjactor.hpp:12
std::uint64_t Index
Index data type.