diff --git a/MathNet.Numerics.sln b/MathNet.Numerics.sln
index 5d2251ec..7d00a422 100644
--- a/MathNet.Numerics.sln
+++ b/MathNet.Numerics.sln
@@ -32,6 +32,15 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{B54A0B40
paket.dependencies = paket.dependencies
paket.lock = paket.lock
Directory.Build.props = Directory.Build.props
+ build\MathNet.Numerics.CUDA.Win.nuspec = build\MathNet.Numerics.CUDA.Win.nuspec
+ build\MathNet.Numerics.MKL.Linux.nuspec = build\MathNet.Numerics.MKL.Linux.nuspec
+ build\MathNet.Numerics.MKL.Linux-x64.nuspec = build\MathNet.Numerics.MKL.Linux-x64.nuspec
+ build\MathNet.Numerics.MKL.Linux-x86.nuspec = build\MathNet.Numerics.MKL.Linux-x86.nuspec
+ build\MathNet.Numerics.MKL.Win.nuspec = build\MathNet.Numerics.MKL.Win.nuspec
+ build\MathNet.Numerics.MKL.Win-x64.nuspec = build\MathNet.Numerics.MKL.Win-x64.nuspec
+ build\MathNet.Numerics.MKL.Win-x86.nuspec = build\MathNet.Numerics.MKL.Win-x86.nuspec
+ build\MathNet.Numerics.OpenBLAS.Win.nuspec = build\MathNet.Numerics.OpenBLAS.Win.nuspec
+ build\NativeProvider.targets = build\NativeProvider.targets
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestData", "src\TestData\TestData.csproj", "{AF3253C9-4DB5-45A0-98CF-C105FDA9DA47}"
diff --git a/build/MathNet.Numerics.CUDA.Win.nuspec b/build/MathNet.Numerics.CUDA.Win.nuspec
index 2b1ee69a..731ea155 100644
--- a/build/MathNet.Numerics.CUDA.Win.nuspec
+++ b/build/MathNet.Numerics.CUDA.Win.nuspec
@@ -20,8 +20,11 @@
-
-
+
+
+
+
+
diff --git a/build/MathNet.Numerics.MKL.Linux-x64.nuspec b/build/MathNet.Numerics.MKL.Linux-x64.nuspec
index cc53a21d..c7c2ada0 100644
--- a/build/MathNet.Numerics.MKL.Linux-x64.nuspec
+++ b/build/MathNet.Numerics.MKL.Linux-x64.nuspec
@@ -19,8 +19,11 @@
-
-
+
+
+
+
+
diff --git a/build/MathNet.Numerics.MKL.Linux-x86.nuspec b/build/MathNet.Numerics.MKL.Linux-x86.nuspec
index c2daf5e2..be0079af 100644
--- a/build/MathNet.Numerics.MKL.Linux-x86.nuspec
+++ b/build/MathNet.Numerics.MKL.Linux-x86.nuspec
@@ -19,8 +19,11 @@
-
-
+
+
+
+
+
diff --git a/build/MathNet.Numerics.MKL.Linux.nuspec b/build/MathNet.Numerics.MKL.Linux.nuspec
index 70209f35..d1105a14 100644
--- a/build/MathNet.Numerics.MKL.Linux.nuspec
+++ b/build/MathNet.Numerics.MKL.Linux.nuspec
@@ -19,10 +19,13 @@
-
+
-
-
+
+
+
+
+
diff --git a/build/MathNet.Numerics.MKL.Win-x64.nuspec b/build/MathNet.Numerics.MKL.Win-x64.nuspec
index 491670f6..a97ce5c2 100644
--- a/build/MathNet.Numerics.MKL.Win-x64.nuspec
+++ b/build/MathNet.Numerics.MKL.Win-x64.nuspec
@@ -19,8 +19,11 @@
-
-
+
+
+
+
+
diff --git a/build/MathNet.Numerics.MKL.Win-x86.nuspec b/build/MathNet.Numerics.MKL.Win-x86.nuspec
index 029bae91..88ed139b 100644
--- a/build/MathNet.Numerics.MKL.Win-x86.nuspec
+++ b/build/MathNet.Numerics.MKL.Win-x86.nuspec
@@ -19,8 +19,11 @@
-
-
+
+
+
+
+
diff --git a/build/MathNet.Numerics.MKL.Win.nuspec b/build/MathNet.Numerics.MKL.Win.nuspec
index d451dc1d..11d7ec51 100644
--- a/build/MathNet.Numerics.MKL.Win.nuspec
+++ b/build/MathNet.Numerics.MKL.Win.nuspec
@@ -19,10 +19,13 @@
-
+
-
-
+
+
+
+
+
diff --git a/build/MathNet.Numerics.OpenBLAS.Win.nuspec b/build/MathNet.Numerics.OpenBLAS.Win.nuspec
index 60875a26..92cfb7aa 100644
--- a/build/MathNet.Numerics.OpenBLAS.Win.nuspec
+++ b/build/MathNet.Numerics.OpenBLAS.Win.nuspec
@@ -27,8 +27,12 @@
-
+
+
+
+
+
diff --git a/build/NativeProvider.targets b/build/NativeProvider.targets
index 805634c5..cede2e7d 100644
--- a/build/NativeProvider.targets
+++ b/build/NativeProvider.targets
@@ -4,11 +4,12 @@
** Math.NET Native Provider Interop Files **
******************************************************************************
-->
-
-
-
+
+
+
+
- %(RecursiveDir)%(FileName)%(Extension)
+ runtimes/%(RecursiveDir)%(FileName)%(Extension)
PreserveNewest
diff --git a/docs/MKL.md b/docs/MKL.md
index b5559c8e..4e20253b 100644
--- a/docs/MKL.md
+++ b/docs/MKL.md
@@ -75,7 +75,7 @@ Default Behavior on Windows
On Windows it is usually enough to make sure the native libraries are in the
same folder as the executable. Reference the appropriate NuGet package and set
-"Copy to Output Directory" for both MathNet.Numerics.MKL.dll and libiomp5md.dll
+"Copy to Output Directory" for both libMathNetNumercisMKL.dll and libiomp5md.dll
to "Copy always", or place the two native DLLs manually into the same directory
as your application's executable. There is no need to set the native provider
path explicitly.
@@ -119,7 +119,7 @@ To build the MKL native provider for OSX:
mkl_build.sh
lionel:OSX Lionel$ sh mkl_build.sh
-Check the /x86 and /x64 folders in mathnet-numerics/out/MKL: you should now find the `libiomp5.dylib` and `MathNet.Numerics.MKL.dll` libaries.
+Check the /x86 and /x64 folders in mathnet-numerics/out/MKL: you should now find the `libiomp5.dylib` and `libMathNetNumercisMKL.dll` libaries.
You need to add the path to the generated libraries in your `DYLD_LIBRARY_PATH` environment variable (which you can move to the folder of you choice before).
To do that, open your /Users/Lionel/.bas_profile.sh file with a text editor and add the following statements.
@@ -190,7 +190,7 @@ and use `ldconfig` to tell where to look for the libraries, but for now we'll ju
[lang=sh]
sudo cp packages/MathNet.Numerics.MKL.Linux-x64.1.3.0/content/libiomp5.so /usr/lib/
- sudo cp packages/MathNet.Numerics.MKL.Linux-x64.1.3.0/content/MathNet.Numerics.MKL.dll /usr/lib/
+ sudo cp packages/MathNet.Numerics.MKL.Linux-x64.1.3.0/content/libMathNetNumercisMKL.dll /usr/lib/
Then we're all set and can just call `Control.UseNativeMKL()` if we want to use the native provider.
Let's create the following C# file `Example.cs`:
diff --git a/src/NativeProviders/Linux/mkl_build.sh b/src/NativeProviders/Linux/mkl_build.sh
index 3f497dac..05eec70f 100644
--- a/src/NativeProviders/Linux/mkl_build.sh
+++ b/src/NativeProviders/Linux/mkl_build.sh
@@ -7,10 +7,10 @@ export OUT=../../../out/MKL/Linux
mkdir -p $OUT/x64
mkdir -p $OUT/x86
-g++ -std=c++11 -D_M_X64 -DGCC -m64 --shared -fPIC -o $OUT/x64/MathNet.Numerics.MKL.dll -I$MKL/include -I../Common -I../MKL ../MKL/memory.c ../MKL/capabilities.cpp ../MKL/vector_functions.c ../Common/blas.c ../Common/lapack.cpp ../MKL/fft.cpp -Wl,--start-group $MKL/lib/intel64/libmkl_intel_lp64.a $MKL/lib/intel64/libmkl_intel_thread.a $MKL/lib/intel64/libmkl_core.a -Wl,--end-group -L$OPENMP/intel64 -liomp5 -lpthread -lm
+g++ -std=c++11 -D_M_X64 -DGCC -m64 --shared -fPIC -o $OUT/x64/libMathNetNumercisMKL.so -I$MKL/include -I../Common -I../MKL ../MKL/memory.c ../MKL/capabilities.cpp ../MKL/vector_functions.c ../Common/blas.c ../Common/lapack.cpp ../MKL/fft.cpp -Wl,--start-group $MKL/lib/intel64/libmkl_intel_lp64.a $MKL/lib/intel64/libmkl_intel_thread.a $MKL/lib/intel64/libmkl_core.a -Wl,--end-group -L$OPENMP/intel64 -liomp5 -lpthread -lm
cp $OPENMP/intel64/libiomp5.so $OUT/x64/
-g++ -std=c++11 -D_M_IX86 -DGCC -m32 --shared -fPIC -o $OUT/x86/MathNet.Numerics.MKL.dll -I$MKL/include -I../Common -I../MKL ../MKL/memory.c ../MKL/capabilities.cpp ../MKL/vector_functions.c ../Common/blas.c ../Common/lapack.cpp ../MKL/fft.cpp -Wl,--start-group $MKL/lib/ia32/libmkl_intel.a $MKL/lib/ia32/libmkl_intel_thread.a $MKL/lib/ia32/libmkl_core.a -Wl,--end-group -L$OPENMP/ia32 -liomp5 -lpthread -lm
+g++ -std=c++11 -D_M_IX86 -DGCC -m32 --shared -fPIC -o $OUT/x86/libMathNetNumercisMKL.so -I$MKL/include -I../Common -I../MKL ../MKL/memory.c ../MKL/capabilities.cpp ../MKL/vector_functions.c ../Common/blas.c ../Common/lapack.cpp ../MKL/fft.cpp -Wl,--start-group $MKL/lib/ia32/libmkl_intel.a $MKL/lib/ia32/libmkl_intel_thread.a $MKL/lib/ia32/libmkl_core.a -Wl,--end-group -L$OPENMP/ia32 -liomp5 -lpthread -lm
cp $OPENMP/ia32/libiomp5.so $OUT/x86/
diff --git a/src/NativeProviders/MKL/resource.rc b/src/NativeProviders/MKL/resource.rc
index b058bbb2..bb0894b6 100644
--- a/src/NativeProviders/MKL/resource.rc
+++ b/src/NativeProviders/MKL/resource.rc
@@ -73,7 +73,7 @@ BEGIN
VALUE "FileVersion", "2.6.0.0"
VALUE "InternalName", "Math.NET"
VALUE "LegalCopyright", "Copyright (C) Math.NET 2009-2021"
- VALUE "OriginalFilename", "MathNet.Numerics.MKL"
+ VALUE "OriginalFilename", "libMathNetNumercisMKL"
VALUE "ProductName", "Math.NET Numerics"
VALUE "ProductVersion", "2.6.0.0"
END
diff --git a/src/NativeProviders/OSX/mkl_build.sh b/src/NativeProviders/OSX/mkl_build.sh
index 15483cbd..3fa11483 100755
--- a/src/NativeProviders/OSX/mkl_build.sh
+++ b/src/NativeProviders/OSX/mkl_build.sh
@@ -6,10 +6,10 @@ export OUT=../../../out/MKL/OSX
mkdir -p $OUT/x64
mkdir -p $OUT/x86
-clang++ -std=c++11 -D_M_X64 -DGCC -m64 --shared -fPIC -o $OUT/x64/MathNet.Numerics.MKL.dll -I$MKL/include -I../Common -I../MKL ../MKL/memory.c ../MKL/capabilities.cpp ../MKL/vector_functions.c ../Common/blas.c ../Common/lapack.cpp ../MKL/fft.cpp $MKL/lib/libmkl_intel_lp64.a $MKL/lib/libmkl_core.a $MKL/lib/libmkl_intel_thread.a -L$OPENMP -liomp5 -lpthread -lm
+clang++ -std=c++11 -D_M_X64 -DGCC -m64 --shared -fPIC -o $OUT/x64/libMathNetNumercisMKL.dylib -I$MKL/include -I../Common -I../MKL ../MKL/memory.c ../MKL/capabilities.cpp ../MKL/vector_functions.c ../Common/blas.c ../Common/lapack.cpp ../MKL/fft.cpp $MKL/lib/libmkl_intel_lp64.a $MKL/lib/libmkl_core.a $MKL/lib/libmkl_intel_thread.a -L$OPENMP -liomp5 -lpthread -lm
cp $OPENMP/libiomp5.dylib $OUT/x64/
-clang++ -std=c++11 -D_M_IX86 -DGCC -m32 --shared -fPIC -o $OUT/x86/MathNet.Numerics.MKL.dll -I$MKL/include -I../Common -I../MKL ../MKL/memory.c ../MKL/capabilities.cpp ../MKL/vector_functions.c ../Common/blas.c ../Common/lapack.cpp ../MKL/fft.cpp $MKL/lib/libmkl_intel_lp64.a $MKL/lib/libmkl_core.a $MKL/lib/libmkl_intel_thread.a -L$OPENMP -liomp5 -lpthread -lm
+clang++ -std=c++11 -D_M_IX86 -DGCC -m32 --shared -fPIC -o $OUT/x86/libMathNetNumercisMKL.dylib -I$MKL/include -I../Common -I../MKL ../MKL/memory.c ../MKL/capabilities.cpp ../MKL/vector_functions.c ../Common/blas.c ../Common/lapack.cpp ../MKL/fft.cpp $MKL/lib/libmkl_intel_lp64.a $MKL/lib/libmkl_core.a $MKL/lib/libmkl_intel_thread.a -L$OPENMP -liomp5 -lpthread -lm
cp $OPENMP/libiomp5.dylib $OUT/x86/
diff --git a/src/NativeProviders/OpenBLAS/resource.rc b/src/NativeProviders/OpenBLAS/resource.rc
index 5be49400..8730bbe9 100644
--- a/src/NativeProviders/OpenBLAS/resource.rc
+++ b/src/NativeProviders/OpenBLAS/resource.rc
@@ -73,7 +73,7 @@ BEGIN
VALUE "FileVersion", "0.2.0.0"
VALUE "InternalName", "Math.NET"
VALUE "LegalCopyright", "Copyright (C) Math.NET 2009-2015"
- VALUE "OriginalFilename", "MathNet.Numerics.OpenBLAS"
+ VALUE "OriginalFilename", "libMathNetNumericsOpenBLAS"
VALUE "ProductName", "Math.NET Numerics"
VALUE "ProductVersion", "0.2.0.0"
END
diff --git a/src/NativeProviders/Windows/CUDA/CUDAWrapper.vcxproj b/src/NativeProviders/Windows/CUDA/CUDAWrapper.vcxproj
index 9b260315..3fb7f56f 100644
--- a/src/NativeProviders/Windows/CUDA/CUDAWrapper.vcxproj
+++ b/src/NativeProviders/Windows/CUDA/CUDAWrapper.vcxproj
@@ -81,21 +81,21 @@
$(ProjectDir)..\..\..\..\out\CUDA\Windows\x86\
$(Platform)\$(Configuration)\
- MathNet.Numerics.CUDA
+ libMathNetNumericsCUDA
$(Platform)\$(Configuration)\
- MathNet.Numerics.CUDA
+ libMathNetNumericsCUDA
$(ProjectDir)..\..\..\..\out\CUDA\Windows\x64\
$(ProjectDir)..\..\..\..\out\CUDA\Windows\x86\
$(Platform)\$(Configuration)\
- MathNet.Numerics.CUDA
+ libMathNetNumericsCUDA
$(Platform)\$(Configuration)\
- MathNet.Numerics.CUDA
+ libMathNetNumericsCUDA
$(ProjectDir)..\..\..\..\out\CUDA\Windows\x64\
diff --git a/src/NativeProviders/Windows/MKL/MKLWrapper.vcxproj b/src/NativeProviders/Windows/MKL/MKLWrapper.vcxproj
index cbdd3597..327dc660 100644
--- a/src/NativeProviders/Windows/MKL/MKLWrapper.vcxproj
+++ b/src/NativeProviders/Windows/MKL/MKLWrapper.vcxproj
@@ -26,7 +26,7 @@
10.0
DynamicLibrary
v142
- MathNet.Numerics.MKL
+ libMathNetNumercisMKL
diff --git a/src/NativeProviders/Windows/OpenBLAS/OpenBLASWrapper.vcxproj b/src/NativeProviders/Windows/OpenBLAS/OpenBLASWrapper.vcxproj
index f22f5323..7e0effc1 100644
--- a/src/NativeProviders/Windows/OpenBLAS/OpenBLASWrapper.vcxproj
+++ b/src/NativeProviders/Windows/OpenBLAS/OpenBLASWrapper.vcxproj
@@ -74,25 +74,25 @@
$(ProjectDir)..\..\..\..\out\OpenBLAS\Windows\x86\
$(Platform)\$(Configuration)\
- MathNet.Numerics.OpenBLAS
+ libMathNetNumericsOpenBLAS
$(OpenBLASIncludeDir);$(IncludePath)
$(ProjectDir)..\..\..\..\out\OpenBLAS\Windows\x64\
$(Platform)\$(Configuration)\
- MathNet.Numerics.OpenBLAS
+ libMathNetNumericsOpenBLAS
$(OpenBLASIncludeDir);$(IncludePath)
$(ProjectDir)..\..\..\..\out\OpenBLAS\Windows\x86\
$(Platform)\$(Configuration)\
- MathNet.Numerics.OpenBLAS
+ libMathNetNumericsOpenBLAS
$(OpenBLASIncludeDir);$(IncludePath)
$(ProjectDir)..\..\..\..\out\OpenBLAS\Windows\x64\
$(Platform)\$(Configuration)\
- MathNet.Numerics.OpenBLAS
+ libMathNetNumericsOpenBLAS
$(OpenBLASIncludeDir);$(IncludePath)
diff --git a/src/Numerics/SpecialFunctions/MarcumQ.cs b/src/Numerics/SpecialFunctions/MarcumQ.cs
index be07f28c..9559b291 100644
--- a/src/Numerics/SpecialFunctions/MarcumQ.cs
+++ b/src/Numerics/SpecialFunctions/MarcumQ.cs
@@ -64,14 +64,6 @@ namespace MathNet.Numerics
///
static readonly double Huge = 1.7976931348623157e+308;
///
- /// The number 3*pi/4
- ///
- static readonly double Pi3Over4 = 2.3561944901923449288;
- ///
- /// The number sqrt(2/pi)
- ///
- static readonly double Sqrt2OverPi = 0.7978845608028653559;
- ///
/// The number 2**(1/4)
///
static readonly double TwoExp1Over4 = 1.18920711500272106671749997;
@@ -92,18 +84,10 @@ namespace MathNet.Numerics
///
static readonly double Giant = Huge / 1000;
///
- /// The number 2/sqrt(pi)
- ///
- static readonly double TwoOverSqrtPi = 1.1283791670955125739;
- ///
/// Lower limit of exponential
///
static readonly double ExpLow = -300;
///
- /// Upper limit of exponential
- ///
- static readonly double ExpHigh = 300;
- ///
/// Demanded accuracy
///
static readonly double Epss = 1e-15;
diff --git a/src/Providers.CUDA/SafeNativeMethods.cs b/src/Providers.CUDA/SafeNativeMethods.cs
index fe242d05..ee25c5ca 100644
--- a/src/Providers.CUDA/SafeNativeMethods.cs
+++ b/src/Providers.CUDA/SafeNativeMethods.cs
@@ -46,7 +46,7 @@ namespace MathNet.Numerics.Providers.CUDA
///
/// Name of the native DLL.
///
- internal const string DllName = "MathNet.Numerics.CUDA.dll";
+ internal const string DllName = "libMathNetNumercisCUDA";
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern int query_capability(int capability);
diff --git a/src/Providers.MKL/MklProvider.cs b/src/Providers.MKL/MklProvider.cs
index 7bad1c84..158cd10f 100644
--- a/src/Providers.MKL/MklProvider.cs
+++ b/src/Providers.MKL/MklProvider.cs
@@ -35,8 +35,8 @@ namespace MathNet.Numerics.Providers.MKL
{
public static class MklProvider
{
- const int DesignTimeRevision = 14;
- const int MinimumCompatibleRevision = 4;
+ const int DesignTimeRevision = 15;
+ const int MinimumCompatibleRevision = 15;
static int _nativeRevision;
static Version _mklVersion;
diff --git a/src/Providers.MKL/NativeProviderLoader.cs b/src/Providers.MKL/NativeProviderLoader.cs
index 5f1d7d6f..8f4ff110 100644
--- a/src/Providers.MKL/NativeProviderLoader.cs
+++ b/src/Providers.MKL/NativeProviderLoader.cs
@@ -39,15 +39,12 @@ using System.Threading;
namespace MathNet.Numerics.Providers.Common
{
- internal enum Runtime
+ internal enum ProcArchitecture
{
- Unknown = 0,
- WindowsX64,
- WindowsX86,
- WindowsArm64,
- WindowsArm,
- LinuxX64,
- LinuxX86,
+ X64,
+ X86,
+ Arm,
+ Arm64
}
///
@@ -62,55 +59,52 @@ namespace MathNet.Numerics.Providers.Common
///
static readonly Lazy> NativeHandles = new Lazy>(LazyThreadSafetyMode.PublicationOnly);
- ///
- /// Gets a string indicating the architecture and bitness of the current process.
- ///
- static readonly Lazy RuntimeKey = new Lazy(EvaluateRuntime, LazyThreadSafetyMode.PublicationOnly);
-
///
/// If the last native library failed to load then gets the corresponding exception
/// which occurred or null if the library was successfully loaded.
///
internal static Exception LastException { get; private set; }
- static bool IsUnix
- {
- get
- {
- var p = Environment.OSVersion.Platform;
- return p == PlatformID.Unix || p == PlatformID.MacOSX;
- }
- }
+ static bool IsWindows { get; }
+ static bool IsLinux { get; }
+ static bool IsMac { get; }
+ static bool IsUnix { get; }
- static Runtime EvaluateRuntime()
- {
- //return (IntPtr.Size == 8) ? X64 : X86;
- if (IsUnix)
- {
- // Only support x86 and amd64 on Unix as there isn't a reliable way to detect the architecture
- return Environment.Is64BitProcess ? Runtime.LinuxX64 : Runtime.LinuxX86;
- }
+ static ProcArchitecture ProcArchitecture { get; }
+ static string Extension { get; }
- var architecture = Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE");
-
- if (string.Equals(architecture, "x86", StringComparison.OrdinalIgnoreCase))
- {
- return Runtime.WindowsX86;
- }
+ static NativeProviderLoader()
+ {
+#if !NET461
+ IsLinux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
+ IsMac = RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
- if (string.Equals(architecture, "amd64", StringComparison.OrdinalIgnoreCase)
- || string.Equals(architecture, "x64", StringComparison.OrdinalIgnoreCase))
- {
- return Environment.Is64BitProcess ? Runtime.WindowsX64 : Runtime.WindowsX86;
- }
+ var a = RuntimeInformation.ProcessArchitecture;
+ bool arm = a == Architecture.Arm || a == Architecture.Arm64;
+#else
+ var p = Environment.OSVersion.Platform;
+ IsLinux = p == PlatformID.Unix;
+ IsMac = p == PlatformID.MacOSX;
- if (string.Equals(architecture, "arm", StringComparison.OrdinalIgnoreCase))
- {
- return Environment.Is64BitProcess ? Runtime.WindowsArm64 : Runtime.WindowsArm;
- }
+ bool arm = false;
+#endif
- // Fallback if unknown
- return Runtime.Unknown;
+ IsUnix = IsLinux || IsMac;
+ IsWindows = !IsUnix;
+
+ Extension = IsWindows
+ ? ".dll"
+ : IsLinux
+ ? ".so"
+ : ".dylib";
+
+ ProcArchitecture = Environment.Is64BitProcess
+ ? arm
+ ? ProcArchitecture.Arm64
+ : ProcArchitecture.X64
+ : arm
+ ? ProcArchitecture.Arm
+ : ProcArchitecture.X86;
}
///
@@ -126,6 +120,11 @@ namespace MathNet.Numerics.Providers.Common
throw new ArgumentNullException(nameof(fileName));
}
+ if (string.IsNullOrEmpty(Path.GetExtension(fileName)))
+ {
+ fileName = Path.ChangeExtension(fileName, Extension);
+ }
+
// If we have hint path provided by the user, look there first
if (hintPath != null && TryLoadFromDirectory(fileName, hintPath))
{
@@ -168,67 +167,110 @@ namespace MathNet.Numerics.Providers.Common
directory = Path.GetFullPath(directory);
- // If we have a know architecture, try the matching subdirectory first
- switch (RuntimeKey.Value)
+ if (IsWindows)
+ {
+ switch (ProcArchitecture)
+ {
+ case ProcArchitecture.X64:
+ return TryLoadFile(directory, "runtimes/win-x64/native", fileName)
+ || TryLoadFile(directory, "win-x64/native", fileName)
+ || TryLoadFile(directory, "win-x64", fileName)
+ || TryLoadFile(directory, "x64", fileName)
+ || TryLoadFile(directory, string.Empty, fileName);
+ case ProcArchitecture.X86:
+ return TryLoadFile(directory, "runtimes/win-x86/native", fileName)
+ || TryLoadFile(directory, "win-x86/native", fileName)
+ || TryLoadFile(directory, "win-x86", fileName)
+ || TryLoadFile(directory, "x86", fileName)
+ || TryLoadFile(directory, string.Empty, fileName);
+ case ProcArchitecture.Arm64:
+ return TryLoadFile(directory, "runtimes/win-arm64/native", fileName)
+ || TryLoadFile(directory, "win-arm64/native", fileName)
+ || TryLoadFile(directory, "win-arm64", fileName)
+ || TryLoadFile(directory, "arm64", fileName)
+ || TryLoadFile(directory, string.Empty, fileName);
+ case ProcArchitecture.Arm:
+ return TryLoadFile(directory, "runtimes/win-arm/native", fileName)
+ || TryLoadFile(directory, "win-arm/native", fileName)
+ || TryLoadFile(directory, "win-arm", fileName)
+ || TryLoadFile(directory, "arm", fileName)
+ || TryLoadFile(directory, string.Empty, fileName);
+ default:
+ return TryLoadFile(directory, string.Empty, fileName);
+ }
+ }
+
+ if (IsLinux)
{
- case Runtime.WindowsX64:
- if (TryLoadFile(directory, "x64", fileName)
- || TryLoadFile(directory, "runtimes/win-x64/native", fileName)
- || TryLoadFile(directory, "win-x64/native", fileName)
- || TryLoadFile(directory, "win-x64", fileName))
- {
- return true;
- }
- break;
- case Runtime.WindowsX86:
- if (TryLoadFile(directory, "x86", fileName)
- || TryLoadFile(directory, "runtimes/win-x86/native", fileName)
- || TryLoadFile(directory, "win-x86/native", fileName)
- || TryLoadFile(directory, "win-x86", fileName))
- {
- return true;
- }
- break;
- case Runtime.WindowsArm64:
- if (TryLoadFile(directory, "arm64", fileName)
- || TryLoadFile(directory, "runtimes/win-arm64/native", fileName)
- || TryLoadFile(directory, "win-arm64/native", fileName)
- || TryLoadFile(directory, "win-arm64", fileName))
- {
- return true;
- }
- break;
- case Runtime.WindowsArm:
- if (TryLoadFile(directory, "arm", fileName)
- || TryLoadFile(directory, "runtimes/win-arm/native", fileName)
- || TryLoadFile(directory, "win-arm/native", fileName)
- || TryLoadFile(directory, "win-arm", fileName))
- {
- return true;
- }
- break;
- case Runtime.LinuxX64:
- if (TryLoadFile(directory, "x64", fileName)
- || TryLoadFile(directory, "runtimes/linux-x64/native", fileName)
- || TryLoadFile(directory, "linux-x64/native", fileName)
- || TryLoadFile(directory, "linux-x64", fileName))
- {
- return true;
- }
- break;
- case Runtime.LinuxX86:
- if (TryLoadFile(directory, "x86", fileName)
- || TryLoadFile(directory, "runtimes/linux-x86/native", fileName)
- || TryLoadFile(directory, "linux-x86/native", fileName)
- || TryLoadFile(directory, "linux-x86", fileName))
- {
- return true;
- }
- break;
+ switch (ProcArchitecture)
+ {
+ case ProcArchitecture.X64:
+ return TryLoadFile(directory, "runtimes/linux-x64/native", fileName)
+ || TryLoadFile(directory, "linux-x64/native", fileName)
+ || TryLoadFile(directory, "linux-x64", fileName)
+ || TryLoadFile(directory, "x64", fileName)
+ || TryLoadFile(directory, string.Empty, fileName);
+ case ProcArchitecture.X86:
+ return TryLoadFile(directory, "runtimes/linux-x86/native", fileName)
+ || TryLoadFile(directory, "linux-x86/native", fileName)
+ || TryLoadFile(directory, "linux-x86", fileName)
+ || TryLoadFile(directory, "x86", fileName)
+ || TryLoadFile(directory, string.Empty, fileName);
+ case ProcArchitecture.Arm64:
+ return TryLoadFile(directory, "runtimes/linux-arm64/native", fileName)
+ || TryLoadFile(directory, "linux-arm64/native", fileName)
+ || TryLoadFile(directory, "linux-arm64", fileName)
+ || TryLoadFile(directory, "arm64", fileName)
+ || TryLoadFile(directory, string.Empty, fileName);
+ case ProcArchitecture.Arm:
+ return TryLoadFile(directory, "runtimes/linux-arm/native", fileName)
+ || TryLoadFile(directory, "linux-arm/native", fileName)
+ || TryLoadFile(directory, "linux-arm", fileName)
+ || TryLoadFile(directory, "arm", fileName)
+ || TryLoadFile(directory, string.Empty, fileName);
+ default:
+ return TryLoadFile(directory, string.Empty, fileName);
+ }
}
- // Otherwise try to load directly from the provided directory
- return TryLoadFile(directory, string.Empty, fileName);
+ if (IsMac)
+ {
+ switch (ProcArchitecture)
+ {
+ case ProcArchitecture.X64:
+ return TryLoadFile(directory, "runtimes/osx-x64/native", fileName)
+ || TryLoadFile(directory, "osx-x64/native", fileName)
+ || TryLoadFile(directory, "osx-x64", fileName)
+ || TryLoadFile(directory, "x64", fileName)
+ || TryLoadFile(directory, string.Empty, fileName);
+ case ProcArchitecture.Arm64:
+ return TryLoadFile(directory, "runtimes/osx-arm64/native", fileName)
+ || TryLoadFile(directory, "osx-arm64/native", fileName)
+ || TryLoadFile(directory, "osx-arm64", fileName)
+ || TryLoadFile(directory, "arm64", fileName)
+ || TryLoadFile(directory, string.Empty, fileName);
+ default:
+ return TryLoadFile(directory, string.Empty, fileName);
+ }
+ }
+
+ switch (ProcArchitecture)
+ {
+ case ProcArchitecture.X64:
+ return TryLoadFile(directory, "x64", fileName)
+ || TryLoadFile(directory, string.Empty, fileName);
+ case ProcArchitecture.X86:
+ return TryLoadFile(directory, "x86", fileName)
+ || TryLoadFile(directory, string.Empty, fileName);
+ case ProcArchitecture.Arm64:
+ return TryLoadFile(directory, "arm64", fileName)
+ || TryLoadFile(directory, string.Empty, fileName);
+ case ProcArchitecture.Arm:
+ return TryLoadFile(directory, "arm", fileName)
+ || TryLoadFile(directory, string.Empty, fileName);
+ default:
+ return TryLoadFile(directory, string.Empty, fileName);
+ }
}
///
@@ -302,7 +344,7 @@ namespace MathNet.Numerics.Providers.Common
const int RTLD_NOW = 2;
- [DllImport("libdl", SetLastError = true)]
+ [DllImport("dl", SetLastError = true)]
static extern IntPtr dlopen(String fileName, int flags);
}
#endif
diff --git a/src/Providers.MKL/SafeNativeMethods.cs b/src/Providers.MKL/SafeNativeMethods.cs
index bfc41556..b3db8a4d 100644
--- a/src/Providers.MKL/SafeNativeMethods.cs
+++ b/src/Providers.MKL/SafeNativeMethods.cs
@@ -46,7 +46,7 @@ namespace MathNet.Numerics.Providers.MKL
///
/// Name of the native DLL.
///
- internal const string DllName = "MathNet.Numerics.MKL.dll";
+ internal const string DllName = "libMathNetNumercisMKL";
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern int query_capability(int capability);
diff --git a/src/Providers.OpenBLAS/SafeNativeMethods.cs b/src/Providers.OpenBLAS/SafeNativeMethods.cs
index b6ad4c1c..cf61e15e 100644
--- a/src/Providers.OpenBLAS/SafeNativeMethods.cs
+++ b/src/Providers.OpenBLAS/SafeNativeMethods.cs
@@ -44,7 +44,7 @@ namespace MathNet.Numerics.Providers.OpenBLAS
///
/// Name of the native DLL.
///
- internal const string DllName = "MathNET.Numerics.OpenBLAS.dll";
+ internal const string DllName = "libMathNetNumercisOpenBLAS";
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern int query_capability(int capability);