diff --git a/.vscode/launch.json b/.vscode/launch.json index 3d7b08dc..89a4a501 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -4,6 +4,14 @@ // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md "version": "0.2.0", "configurations": [ + { + "type": "PowerShell", + "request": "launch", + "name": "PowerShell Launch Current File", + "script": "${file}", + "args": [], + "cwd": "${file}" + }, { "name": "NumSharp Example - Water equation", "type": "coreclr", diff --git a/ExecuteBuild.ps1 b/ExecuteBuild.ps1 new file mode 100644 index 00000000..63432010 --- /dev/null +++ b/ExecuteBuild.ps1 @@ -0,0 +1,10 @@ +Write-Output "--------------------" +Write-Output "Start with building" +Write-Output "--------------------" + +$projectFolders = @{}; + +$projectFolders['projectRoot'] = $PSScriptRoot; +$projectFolders['Projects.Core'] = Join-Path $projectFolders['projectRoot'] src/NumSharp.Core/NumSharp.Core.csproj + +dotnet build $projectFolders['Projects.Core'] \ No newline at end of file diff --git a/src/NumSharp.Core/LAPACK.cs b/src/NumSharp.Core/LinearAlgebra/LAPACK.Provider/LAPACK.NetLib.cs similarity index 94% rename from src/NumSharp.Core/LAPACK.cs rename to src/NumSharp.Core/LinearAlgebra/LAPACK.Provider/LAPACK.NetLib.cs index 0d1f2735..380321a8 100644 --- a/src/NumSharp.Core/LAPACK.cs +++ b/src/NumSharp.Core/LinearAlgebra/LAPACK.Provider/LAPACK.NetLib.cs @@ -1,9 +1,9 @@ -using System; +using System; using System.Runtime.InteropServices; -namespace NumSharp.Core +namespace NumSharp.Core.LAPACKProvider { - public static partial class LAPACK + public static partial class NetLib { [DllImport("lapack")] public static extern void dgesv_(ref int n, ref int nrhs, double[] a, ref int lda, int[] ipiv, double[] b, ref int ldb, ref int info ); diff --git a/src/NumSharp.Core/LinearAlgebra/LAPACK.cs b/src/NumSharp.Core/LinearAlgebra/LAPACK.cs new file mode 100644 index 00000000..6479bf8e --- /dev/null +++ b/src/NumSharp.Core/LinearAlgebra/LAPACK.cs @@ -0,0 +1,66 @@ +using System; +using System.Runtime.InteropServices; +using NumSharp.Core.LAPACKProvider; +using NumSharp.Core; + +namespace NumSharp.Core +{ + public static partial class LAPACK + { + public static void dgesv_(ref int n, ref int nrhs, double[] a, ref int lda, int[] ipiv, double[] b, ref int ldb, ref int info ) + { + switch (np.LAPACKProvider) + { + case LAPACKProvider.LAPACKProvider.NetLib : + { + LAPACKProvider.NetLib.dgesv_(ref n, ref nrhs, a, ref lda, ipiv, b, ref ldb, ref info); + break; + } + } + } + public static void dgeqrf_(ref int m, ref int n, double[] a, ref int lda, double[] tau, double[] work, ref int lwork, ref int info) + { + switch (np.LAPACKProvider) + { + case LAPACKProvider.LAPACKProvider.NetLib : + { + LAPACKProvider.NetLib.dgeqrf_(ref m, ref n, a, ref lda, tau, work, ref lwork, ref info); + break; + } + } + } + public static void dorgqr_(ref int m,ref int n, ref int k, double[] a, ref int lda, double[] tau, double[]work, ref int lwork,ref int info) + { + switch (np.LAPACKProvider) + { + case LAPACKProvider.LAPACKProvider.NetLib : + { + LAPACKProvider.NetLib.dorgqr_(ref m, ref n,ref k, a, ref lda, tau, work, ref lwork, ref info); + break; + } + } + } + public static void dgelss_( ref int m, ref int n, ref int nrhs, double[] a,ref int lda, double[] b, ref int ldb, double[] s,ref double rcond, ref int rank, double[] work,ref int lwork, ref int info ) + { + switch (np.LAPACKProvider) + { + case LAPACKProvider.LAPACKProvider.NetLib : + { + LAPACKProvider.NetLib.dgelss_(ref m, ref n, ref nrhs, a, ref lda, b, ref ldb, s, ref rcond, ref rank, work, ref lwork, ref info); + break; + } + } + } + public static void dgesvd_(char[] JOBU,char[] JOBVT, ref int M, ref int N, double[] A, ref int LDA, double[] S, double[] U, ref int LDU, double[] VT, ref int LDVT, double[] WORK, ref int LWORK, ref int INFO ) + { + switch (np.LAPACKProvider) + { + case LAPACKProvider.LAPACKProvider.NetLib : + { + LAPACKProvider.NetLib.dgesvd_(JOBU, JOBVT, ref M, ref N, A, ref LDA, S, U, ref LDU, VT, ref LDVT, WORK, ref LWORK, ref INFO); + break; + } + } + } + } +} diff --git a/src/NumSharp.Core/LinearAlgebra/np.LAPACK.cs b/src/NumSharp.Core/LinearAlgebra/np.LAPACK.cs new file mode 100644 index 00000000..119197fd --- /dev/null +++ b/src/NumSharp.Core/LinearAlgebra/np.LAPACK.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace NumSharp.Core.LAPACKProvider +{ + public enum LAPACKProvider + { + NetLib + } +} +namespace NumSharp.Core +{ + public static partial class np + { + public static NumSharp.Core.LAPACKProvider.LAPACKProvider LAPACKProvider = NumSharp.Core.LAPACKProvider.LAPACKProvider.NetLib; + } +} diff --git a/src/NumSharp.Core/NDStorage.cs b/src/NumSharp.Core/NDStorage.cs index 612a386f..07b45c94 100644 --- a/src/NumSharp.Core/NDStorage.cs +++ b/src/NumSharp.Core/NDStorage.cs @@ -439,6 +439,10 @@ public void ChangeDataType(Type dtype) _values = this._ChangeTypeOfArray(_values,dtype); _DType = dtype; } + public void SetNewShape(params int[] dimensions) + { + _Shape = new Shape(dimensions); + } public void Reshape(params int[] dimensions) { if (_TensorLayout == 2)