forked from SciSharp/NumSharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNumPy.sin.cs
More file actions
62 lines (54 loc) · 1.78 KB
/
NumPy.sin.cs
File metadata and controls
62 lines (54 loc) · 1.78 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;
using NumSharp.Core.Extensions;
namespace NumSharp.Core
{
public static partial class NumPyExtensions
{
public static NDArray<T> sin<T>(this NumPy<T> np, NDArray<T> nd)
{
NDArray<T> sinArray = new NDArray<T>();
sinArray.Data = new T[nd.Size];
sinArray.Shape = new Shape(nd.Shape.Shapes);
for (int idx = 0; idx < nd.Size; idx++)
{
switch (nd[idx])
{
case double d:
sinArray[idx] = (T)(object)Math.Sin(d);
break;
case float d:
sinArray[idx] = (T)(object)Math.Sin(d);
break;
case Complex d:
sinArray[idx] = (T)(object)Complex.Sin(d);
break;
}
}
return sinArray;
}
public static NDArray<NDArray<T>> sin<T>(this NumPy<T> np, NDArray<NDArray<T>> nd)
{
var sinArray = new NDArray<NDArray<T>>();
sinArray.Data = new NDArray<T>[nd.Size];
sinArray.Shape = new Shape(nd.Shape.Shapes);
for (int idx = 0; idx < nd.Size; idx++)
{
switch (default(T))
{
case double d:
sinArray[idx] = new NDArray<T>
{
Data = new T[] { (T)(object)Math.Sin(d) },
Shape = new Shape(1)
};
break;
}
}
return sinArray;
}
}
}