Repository navigation
Expand file tree
/
Copy pathNDArray.argmax.cs
More file actions
59 lines (53 loc) · 1.53 KB
/
Copy pathNDArray.argmax.cs
File metadata and controls
59 lines (53 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NumSharp.Core
{
public partial class NDArray
{
public int argmax()
{
var data = this.Storage.GetData();
int index = -1;
switch (data)
{
case double[] castedData :
{
index = castedData.ToList().IndexOf(castedData.Max());
break;
}
case float[] castedData :
{
index = castedData.ToList().IndexOf(castedData.Max());
break;
}
case int[] castedData :
{
index = castedData.ToList().IndexOf(castedData.Max());
break;
}
case Int64[] castedData :
{
index = castedData.ToList().IndexOf(castedData.Max());
break;
}
case decimal[] castedData :
{
index = castedData.ToList().IndexOf(castedData.Max());
break;
}
default :
{
throw new IncorrectTypeException();
}
}
return index;
}
public int argmax<T>()
{
var max = Storage.GetData<T>().Max();
return Storage.GetData<T>().ToList().IndexOf(max);
}
}
}