fbgsense
0.1
Generic FBG spectrum analysis tool
include
argmax.h
1
/*
2
* This file is a part of the project "fbgsense", which is released under MIT license.
3
* Copyright (c) 2022 Daniel Múčka, Masaryk University, Faculty of Informatics
4
* See file LICENSE or visit https://opensource.org/licenses/MIT for full license details.
5
*/
6
7
#pragma once
8
9
#include <vector>
13
template
<
typename
T>
14
int
argmax(std::vector<T> vec)
15
{
16
if
(vec.size() == 0)
17
return
-1;
18
19
T localMax = vec[0];
20
int
localMaxIndex = 0;
21
22
// find local argmax
23
for
(
int
z = 0; z < vec.size(); ++z)
24
{
25
if
(vec[z] > localMax)
26
{
27
localMax = vec[z];
28
localMaxIndex = z;
29
}
30
}
31
32
return
localMaxIndex;
33
}
Generated by
1.9.4