forked from SciSharp/NumSharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNumSharp.cs
More file actions
57 lines (49 loc) · 1.5 KB
/
NumSharp.cs
File metadata and controls
57 lines (49 loc) · 1.5 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
using System;
using System.Collections.Generic;
using System.Text;
namespace NumSharp.Core
{
public class NumSharp
{
public static Type int16 = typeof(short);
public static Type double8 = typeof(double);
public static Type decimal16 = typeof(decimal);
public NDArrayWithDType arange(int stop, Type dtype = null)
{
if(dtype == null)
{
dtype = NumSharp.int16;
}
return arange(0, stop, 1, dtype);
}
public NDArrayWithDType arange(int start, int stop, int step = 1, Type dtype = null)
{
if (start > stop)
{
throw new Exception("parameters invalid");
}
switch (dtype.Name)
{
case "Int32":
{
var n = new NDArrayWithDType(NumSharp.int16);
n.arange(stop, start, step);
return n;
}
case "Double":
{
var n = new NDArrayWithDType(NumSharp.double8);
n.arange(stop, start, step);
return n;
}
default:
throw new NotImplementedException();
}
}
public NDArrayWithDType reshape(NDArrayWithDType nd, params int[] shape)
{
nd.Shape = new Shape(shape);
return nd;
}
}
}