-
Notifications
You must be signed in to change notification settings - Fork 203
Expand file tree
/
Copy pathNdArray.delete.cs
More file actions
95 lines (78 loc) · 2.67 KB
/
NdArray.delete.cs
File metadata and controls
95 lines (78 loc) · 2.67 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
using System.Collections;
namespace NumSharp
{
public partial class NDArray
{
public NDArray delete(NDArray array, int[] indexToDelete, int axis = 0)
{
int nToDelet = indexToDelete.Length;
int x_shape = array.shape[0];
int y_shape = array.shape[1];
if (axis == 0)
x_shape -= nToDelet;
else
y_shape -= nToDelet;
int[,] newArray = new int[x_shape, y_shape];
if (axis == 0)
{
int newRowIndex = 0;
for (int i = 0; i < array.shape[0]; i++)
{
if (!indexToDelete.Contains(i))
{
for (int j = 0; j < array.shape[1]; j++)
{
newArray[newRowIndex, j] = array[i, j];
}
newRowIndex++;
}
}
}
else
{
int newColumnIndex = 0;
for (int j = 0; j < array.shape[1]; j++)
{
if (!indexToDelete.Contains(j))
{
for (int i = 0; i < array.shape[0]; i++)
{
newArray[i, newColumnIndex] = array[i, j];
}
newColumnIndex++;
}
}
}
return np.array(newArray);
//return null;
//var sysArr = this.Storage.GetData();
//NDArray res = null;
//switch( sysArr)
//{
// case double[] castedSysArr :
// {
// var castedDelete = delete as double[];
// res = np.array(castedSysArr.Where(x => !castedDelete.Contains(x) ).ToArray());
// break;
// }
// case float[] castedSysArr :
// {
// var castedDelete = delete as float[];
// res = np.array(castedSysArr.Where(x => !castedDelete.Contains(x) ).ToArray());
// break;
// }
// case int[] castedSysArr :
// {
// var castedDelete = delete as int[];
// res = np.array(castedSysArr.Where(x => !castedDelete.Contains(x) ).ToArray());
// break;
// }
// default :
// {
// throw new IncorrectTypeException();
// }
//}
//return res;
}
}
}