forked from SciSharp/NumSharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNDArray.power.cs
More file actions
37 lines (34 loc) · 1011 Bytes
/
NDArray.power.cs
File metadata and controls
37 lines (34 loc) · 1011 Bytes
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;
using NumSharp.Core.Extensions;
namespace NumSharp.Core
{
public partial class NDArray<T>
{
public NDArray<T> power(T exponent)
{
NDArray<T> sinArray = new NDArray<T>();
sinArray.Data = new T[this.Size];
sinArray.Shape = new Shape(this.Shape.Shapes);
switch (Data)
{
case double[] sinData :
{
for (int idx = 0; idx < sinData.Length;idx++)
{
sinArray[idx] = (T)(object)Math.Pow(sinData[idx], (double)(object)exponent);
}
break;
}
default :
{
throw new Exception("The operation is not implemented for the");
}
}
return sinArray;
}
}
}