FEAT
3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
min_max_index_dense_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_INDEX_DENSE_HPP
9
#error "Do not include this implementation-only header file directly!"
10
#endif
11
12
#include <kernel/util/math.hpp>
13
14
namespace
FEAT::LAFEM::Arch
15
{
16
template
<
typename
DT_>
17
Index
MinMaxIndexDense::exec_generic_impl(
const
DT_ *
const
x,
const
Index
size,
const
bool
min_,
const
bool
abs_)
18
{
19
DT_ val(abs_ ?
Math::abs
(x[0]) : x[0]);
20
Index
idx(0);
21
if
(min_)
22
{
23
if
(abs_)
24
{
25
for
(
Index
i(0) ; i < size ; ++i)
26
{
27
DT_ ax(
Math::abs
(x[i]));
28
if
(ax < val)
29
{
30
val = ax;
31
idx = i;
32
}
33
}
34
}
35
else
36
{
37
for
(
Index
i(0) ; i < size ; ++i)
38
{
39
if
(x[i] < val)
40
{
41
val = x[i];
42
idx = i;
43
}
44
}
45
}
46
}
47
else
// max
48
{
49
if
(abs_)
50
{
51
for
(
Index
i(0) ; i < size ; ++i)
52
{
53
DT_ ax(
Math::abs
(x[i]));
54
if
(ax < val)
55
{
56
val = ax;
57
idx = i;
58
}
59
}
60
}
61
else
62
{
63
for
(
Index
i(0) ; i < size ; ++i)
64
{
65
if
(x[i] < val)
66
{
67
val = x[i];
68
idx = i;
69
}
70
}
71
}
72
}
73
74
return
idx;
75
}
76
}
// namespace FEAT::LAFEM::Arch
FEAT::Math::abs
T_ abs(T_ x)
Returns the absolute value.
Definition:
math.hpp:275
FEAT::Index
std::uint64_t Index
Index data type.
Definition:
base_header.hpp:130
kernel
lafem
arch
min_max_index_dense_generic.hpp
Generated by
1.9.5