forked from SciSharp/NumSharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNdArray.Inv.cs
More file actions
27 lines (22 loc) · 787 Bytes
/
NdArray.Inv.cs
File metadata and controls
27 lines (22 loc) · 787 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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using NumSharp.Shared;
namespace NumSharp.Extensions
{
public static partial class NDArrayExtensions
{
public static NDArray<double> Inv(this NDArray<double> np)
{
double[][] matrix = np.ToDotNetArray<double[][]>();
double[][] matrixInv = MatrixInv.InverseMatrix(matrix);
NDArray<double> npInv = new NDArray<double>().Zeros(np.Shape.Shapes[0], np.Shape.Shapes[1]);
for (int idx = 0; idx < npInv.Shape.Shapes[0]; idx++)
for (int jdx = 0; jdx < npInv.Shape.Shapes[1]; jdx++)
npInv[idx, jdx] = matrixInv[idx][jdx];
return npInv;
}
}
}