Skip to content

Commit 58bcdeb

Browse files
authored
Merge pull request #183 from dotChris90/master
Add LAPACK Provider Strategy (MKL not!!! implemented yet)
2 parents 4353804 + f4e6e1c commit 58bcdeb

File tree

6 files changed

+109
-3
lines changed

6 files changed

+109
-3
lines changed

.vscode/launch.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@
44
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
55
"version": "0.2.0",
66
"configurations": [
7+
{
8+
"type": "PowerShell",
9+
"request": "launch",
10+
"name": "PowerShell Launch Current File",
11+
"script": "${file}",
12+
"args": [],
13+
"cwd": "${file}"
14+
},
715
{
816
"name": "NumSharp Example - Water equation",
917
"type": "coreclr",

ExecuteBuild.ps1

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Write-Output "--------------------"
2+
Write-Output "Start with building"
3+
Write-Output "--------------------"
4+
5+
$projectFolders = @{};
6+
7+
$projectFolders['projectRoot'] = $PSScriptRoot;
8+
$projectFolders['Projects.Core'] = Join-Path $projectFolders['projectRoot'] src/NumSharp.Core/NumSharp.Core.csproj
9+
10+
dotnet build $projectFolders['Projects.Core']

src/NumSharp.Core/LAPACK.cs renamed to src/NumSharp.Core/LinearAlgebra/LAPACK.Provider/LAPACK.NetLib.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
using System;
1+
using System;
22
using System.Runtime.InteropServices;
33

4-
namespace NumSharp.Core
4+
namespace NumSharp.Core.LAPACKProvider
55
{
6-
public static partial class LAPACK
6+
public static partial class NetLib
77
{
88
[DllImport("lapack")]
99
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 );
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
using System;
2+
using System.Runtime.InteropServices;
3+
using NumSharp.Core.LAPACKProvider;
4+
using NumSharp.Core;
5+
6+
namespace NumSharp.Core
7+
{
8+
public static partial class LAPACK
9+
{
10+
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 )
11+
{
12+
switch (np.LAPACKProvider)
13+
{
14+
case LAPACKProvider.LAPACKProvider.NetLib :
15+
{
16+
LAPACKProvider.NetLib.dgesv_(ref n, ref nrhs, a, ref lda, ipiv, b, ref ldb, ref info);
17+
break;
18+
}
19+
}
20+
}
21+
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)
22+
{
23+
switch (np.LAPACKProvider)
24+
{
25+
case LAPACKProvider.LAPACKProvider.NetLib :
26+
{
27+
LAPACKProvider.NetLib.dgeqrf_(ref m, ref n, a, ref lda, tau, work, ref lwork, ref info);
28+
break;
29+
}
30+
}
31+
}
32+
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)
33+
{
34+
switch (np.LAPACKProvider)
35+
{
36+
case LAPACKProvider.LAPACKProvider.NetLib :
37+
{
38+
LAPACKProvider.NetLib.dorgqr_(ref m, ref n,ref k, a, ref lda, tau, work, ref lwork, ref info);
39+
break;
40+
}
41+
}
42+
}
43+
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 )
44+
{
45+
switch (np.LAPACKProvider)
46+
{
47+
case LAPACKProvider.LAPACKProvider.NetLib :
48+
{
49+
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);
50+
break;
51+
}
52+
}
53+
}
54+
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 )
55+
{
56+
switch (np.LAPACKProvider)
57+
{
58+
case LAPACKProvider.LAPACKProvider.NetLib :
59+
{
60+
LAPACKProvider.NetLib.dgesvd_(JOBU, JOBVT, ref M, ref N, A, ref LDA, S, U, ref LDU, VT, ref LDVT, WORK, ref LWORK, ref INFO);
61+
break;
62+
}
63+
}
64+
}
65+
}
66+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
namespace NumSharp.Core.LAPACKProvider
6+
{
7+
public enum LAPACKProvider
8+
{
9+
NetLib
10+
}
11+
}
12+
namespace NumSharp.Core
13+
{
14+
public static partial class np
15+
{
16+
public static NumSharp.Core.LAPACKProvider.LAPACKProvider LAPACKProvider = NumSharp.Core.LAPACKProvider.LAPACKProvider.NetLib;
17+
}
18+
}

src/NumSharp.Core/NDStorage.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,10 @@ public void ChangeDataType(Type dtype)
439439
_values = this._ChangeTypeOfArray(_values,dtype);
440440
_DType = dtype;
441441
}
442+
public void SetNewShape(params int[] dimensions)
443+
{
444+
_Shape = new Shape(dimensions);
445+
}
442446
public void Reshape(params int[] dimensions)
443447
{
444448
if (_TensorLayout == 2)

0 commit comments

Comments
 (0)