forked from SciSharp/NumSharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnumpy.array.cs
More file actions
56 lines (52 loc) · 1.51 KB
/
numpy.array.cs
File metadata and controls
56 lines (52 loc) · 1.51 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
using System;
using NumSharp;
using System.Linq;
using System.Collections.Generic;
using NumSharp.Core;
public static partial class numpy
{
public static dynamic array(IList<object> list, string dataType)
{
Console.WriteLine(list);
Console.WriteLine(dataType);
dynamic returnArray = null;
switch (dataType)
{
case "Double" :
{
double[] array = list.Select(x => (double)x).ToArray();
returnArray = np.array(array);
break;
}
case "Float" :
{
float[] array = list.Select(x => (float)x ).ToArray();
returnArray = np.array(array);
break;
}
case "Int32" :
{
System.Int32[] array = list.Select(x => (System.Int32)x ).ToArray();
returnArray = np.array(array);
break;
}
case "Int64" :
{
System.Int64[] array = list.Select(x => (System.Int64)x ).ToArray();
returnArray = np.array(array);
break;
}
case "Complex" :
{
System.Numerics.Complex[] array = list.Select(x => (System.Numerics.Complex)x ).ToArray();
returnArray = np.array(array);
break;
}
default :
{
break;
}
}
return returnArray;
}
}