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 Inv(this NDArray np) { double[][] matrix = np.ToDotNetArray(); double[][] matrixInv = MatrixInv.InverseMatrix(matrix); NDArray npInv = new NDArray().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; } } }