forked from SciSharp/NumSharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnp.vstack.cs
More file actions
38 lines (38 loc) · 1.17 KB
/
np.vstack.cs
File metadata and controls
38 lines (38 loc) · 1.17 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
namespace NumSharp
{
public static partial class np
{
/*
/// <summary>
/// Stack arrays in sequence vertically (row wise).
/// </summary>
/// <param name="nps"></param>
/// <returns></returns>
public static NDArray vstack<T>(params NDArray[] nps)
{
if (nps == null || nps.Length == 0)
throw new Exception("Input arrays can not be empty");
List<T> list = new List<T>();
var np = new NDArray(typeof(T));
foreach (NDArray ele in nps)
{
if (nps[0].shape != ele.shape)
throw new Exception("Arrays mush have same shapes");
list.AddRange(ele.Storage.GetData<T>());
}
np.Storage.ReplaceData(list.ToArray());
if (nps[0].ndim == 1)
{
np.Storage.Reshape(new int[] { nps.Length, nps[0].shape[0] });
}
else
{
int[] shapes = nps[0].shape;
shapes[0] *= nps.Length;
np.Storage.Reshape(shapes);
}
return np;
}
*/
}
}