diff --git a/MathNet.Numerics.NativeProviders.sln b/MathNet.Numerics.NativeProviders.sln
index 617bed0c..91791dc5 100644
--- a/MathNet.Numerics.NativeProviders.sln
+++ b/MathNet.Numerics.NativeProviders.sln
@@ -12,9 +12,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Common", "Common", "{5A0892
src\NativeProviders\Common\wrapper_common.h = src\NativeProviders\Common\wrapper_common.h
EndProjectSection
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MKLWrapper", "src\NativeProviders\Windows\MKL\MKLWrapper.vcxproj", "{C0B0DBA9-7FB0-4C87-BDB1-3EED19DC2B8F}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MKL", "src\NativeProviders\Windows\MKL\MKLWrapper.vcxproj", "{C0B0DBA9-7FB0-4C87-BDB1-3EED19DC2B8F}"
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ATLASWrapper", "src\NativeProviders\Windows\ATLAS\ATLASWrapper.vcxproj", "{2362B8AC-C52B-45E4-A1BF-C682A4DB4220}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ATLAS", "src\NativeProviders\Windows\ATLAS\ATLASWrapper.vcxproj", "{2362B8AC-C52B-45E4-A1BF-C682A4DB4220}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
diff --git a/MathNet.Numerics.sln.DotSettings b/MathNet.Numerics.sln.DotSettings
index 5787163f..ef16aa28 100644
--- a/MathNet.Numerics.sln.DotSettings
+++ b/MathNet.Numerics.sln.DotSettings
@@ -58,6 +58,7 @@ OTHER DEALINGS IN THE SOFTWARE.
MC
MCMC
MILU
+ MKL
MSE
PDF
QR
diff --git a/src/Numerics/Control.cs b/src/Numerics/Control.cs
index 82ad7777..edecd791 100644
--- a/src/Numerics/Control.cs
+++ b/src/Numerics/Control.cs
@@ -38,10 +38,11 @@ namespace MathNet.Numerics
///
public static class Control
{
- private static int _numberOfThreads;
- private static int _blockSize;
- private static int _parallelizeOrder;
- private static int _parallelizeElements;
+ static int _numberOfThreads;
+ static int _blockSize;
+ static int _parallelizeOrder;
+ static int _parallelizeElements;
+ static ILinearAlgebraProvider _linearAlgebraProvider;
static Control()
{
@@ -66,10 +67,8 @@ namespace MathNet.Numerics
_parallelizeElements = 300;
// Linear Algebra Provider
-#if PORTABLE
- // GetEnvironmentVariable is not available in portable!
LinearAlgebraProvider = new ManagedLinearAlgebraProvider();
-#else
+#if !PORTABLE
try
{
const string name = "MathNetNumericsLAProvider";
@@ -81,14 +80,11 @@ namespace MathNet.Numerics
LinearAlgebraProvider = new Providers.LinearAlgebra.Mkl.MklLinearAlgebraProvider();
break;
#endif
- default:
- LinearAlgebraProvider = new ManagedLinearAlgebraProvider();
- break;
}
}
catch
{
- // We don't care about any failures here at all
+ // We don't care about any failures here at all (because "auto")
LinearAlgebraProvider = new ManagedLinearAlgebraProvider();
}
#endif
@@ -135,10 +131,20 @@ namespace MathNet.Numerics
public static bool DisableParallelization { get; set; }
///
- /// Gets or sets the linear algebra provider.
+ /// Gets or sets the linear algebra provider. Consider to use UseNativeMKL or UseManaged instead.
///
/// The linear algebra provider.
- public static ILinearAlgebraProvider LinearAlgebraProvider { get; set; }
+ public static ILinearAlgebraProvider LinearAlgebraProvider
+ {
+ get { return _linearAlgebraProvider; }
+ set
+ {
+ value.InitializeVerify();
+
+ // only actually set if verification did not throw
+ _linearAlgebraProvider = value;
+ }
+ }
///
/// Gets or sets a value indicating how many parallel worker threads shall be used
diff --git a/src/Numerics/Numerics.csproj b/src/Numerics/Numerics.csproj
index de97f5d9..ff7e5d47 100644
--- a/src/Numerics/Numerics.csproj
+++ b/src/Numerics/Numerics.csproj
@@ -153,9 +153,10 @@
+
-
+
diff --git a/src/Numerics/Providers/LinearAlgebra/ILinearAlgebraProvider.cs b/src/Numerics/Providers/LinearAlgebra/ILinearAlgebraProvider.cs
index 4c8e89e1..820a2328 100644
--- a/src/Numerics/Providers/LinearAlgebra/ILinearAlgebraProvider.cs
+++ b/src/Numerics/Providers/LinearAlgebra/ILinearAlgebraProvider.cs
@@ -94,6 +94,10 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
ILinearAlgebraProvider,
ILinearAlgebraProvider
{
+ ///
+ /// Initialize and verify that the provided is indeed available. If not, fall back to alernatives like the managed provider
+ ///
+ void InitializeVerify();
}
///
diff --git a/src/Numerics/Providers/LinearAlgebra/ManagedLinearAlgebraProvider.Complex.cs b/src/Numerics/Providers/LinearAlgebra/ManagedLinearAlgebraProvider.Complex.cs
index d366b9ab..75021366 100644
--- a/src/Numerics/Providers/LinearAlgebra/ManagedLinearAlgebraProvider.Complex.cs
+++ b/src/Numerics/Providers/LinearAlgebra/ManagedLinearAlgebraProvider.Complex.cs
@@ -28,11 +28,11 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
+using System;
using MathNet.Numerics.LinearAlgebra.Complex.Factorization;
using MathNet.Numerics.LinearAlgebra.Factorization;
using MathNet.Numerics.Properties;
using MathNet.Numerics.Threading;
-using System;
namespace MathNet.Numerics.Providers.LinearAlgebra
{
diff --git a/src/Numerics/Providers/LinearAlgebra/ManagedLinearAlgebraProvider.Complex32.cs b/src/Numerics/Providers/LinearAlgebra/ManagedLinearAlgebraProvider.Complex32.cs
index 0298a3ac..85966372 100644
--- a/src/Numerics/Providers/LinearAlgebra/ManagedLinearAlgebraProvider.Complex32.cs
+++ b/src/Numerics/Providers/LinearAlgebra/ManagedLinearAlgebraProvider.Complex32.cs
@@ -28,12 +28,12 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
+using System;
using MathNet.Numerics.LinearAlgebra.Complex32;
using MathNet.Numerics.LinearAlgebra.Complex32.Factorization;
using MathNet.Numerics.LinearAlgebra.Factorization;
using MathNet.Numerics.Properties;
using MathNet.Numerics.Threading;
-using System;
namespace MathNet.Numerics.Providers.LinearAlgebra
{
diff --git a/src/Numerics/Providers/LinearAlgebra/ManagedLinearAlgebraProvider.Double.cs b/src/Numerics/Providers/LinearAlgebra/ManagedLinearAlgebraProvider.Double.cs
index 9365eec9..8290e256 100644
--- a/src/Numerics/Providers/LinearAlgebra/ManagedLinearAlgebraProvider.Double.cs
+++ b/src/Numerics/Providers/LinearAlgebra/ManagedLinearAlgebraProvider.Double.cs
@@ -28,10 +28,10 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
+using System;
using MathNet.Numerics.LinearAlgebra.Factorization;
using MathNet.Numerics.Properties;
using MathNet.Numerics.Threading;
-using System;
namespace MathNet.Numerics.Providers.LinearAlgebra
{
@@ -43,7 +43,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
///
/// The managed linear algebra provider.
///
- public partial class ManagedLinearAlgebraProvider : ILinearAlgebraProvider
+ public partial class ManagedLinearAlgebraProvider
{
///
/// Adds a scaled vector to another: result = y + alpha*x.
diff --git a/src/Numerics/Providers/LinearAlgebra/ManagedLinearAlgebraProvider.Single.cs b/src/Numerics/Providers/LinearAlgebra/ManagedLinearAlgebraProvider.Single.cs
index 6094cb83..78a122f6 100644
--- a/src/Numerics/Providers/LinearAlgebra/ManagedLinearAlgebraProvider.Single.cs
+++ b/src/Numerics/Providers/LinearAlgebra/ManagedLinearAlgebraProvider.Single.cs
@@ -28,10 +28,10 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
+using System;
using MathNet.Numerics.LinearAlgebra.Factorization;
using MathNet.Numerics.Properties;
using MathNet.Numerics.Threading;
-using System;
namespace MathNet.Numerics.Providers.LinearAlgebra
{
diff --git a/src/Numerics/Providers/LinearAlgebra/ManagedLinearAlgebraProvider.cs b/src/Numerics/Providers/LinearAlgebra/ManagedLinearAlgebraProvider.cs
new file mode 100644
index 00000000..c92a2ca0
--- /dev/null
+++ b/src/Numerics/Providers/LinearAlgebra/ManagedLinearAlgebraProvider.cs
@@ -0,0 +1,50 @@
+//
+// Math.NET Numerics, part of the Math.NET Project
+// http://numerics.mathdotnet.com
+// http://github.com/mathnet/mathnet-numerics
+// http://mathnetnumerics.codeplex.com
+//
+// Copyright (c) 2009-2013 Math.NET
+//
+// Permission is hereby granted, free of charge, to any person
+// obtaining a copy of this software and associated documentation
+// files (the "Software"), to deal in the Software without
+// restriction, including without limitation the rights to use,
+// copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following
+// conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+//
+
+namespace MathNet.Numerics.Providers.LinearAlgebra
+{
+ ///
+ /// The managed linear algebra provider.
+ ///
+ public partial class ManagedLinearAlgebraProvider : ILinearAlgebraProvider
+ {
+ ///
+ /// Initialize and verify that the provided is indeed available. If not, fall back to alernatives like the managed provider
+ ///
+ public virtual void InitializeVerify()
+ {
+ }
+
+ public override string ToString()
+ {
+ return "Managed";
+ }
+ }
+}
diff --git a/src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Complex.cs b/src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Complex.cs
index da2837c4..44226a5f 100644
--- a/src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Complex.cs
+++ b/src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Complex.cs
@@ -30,11 +30,11 @@
#if NATIVEMKL
-using MathNet.Numerics.LinearAlgebra.Factorization;
-using MathNet.Numerics.Properties;
using System;
using System.Numerics;
using System.Security;
+using MathNet.Numerics.LinearAlgebra.Factorization;
+using MathNet.Numerics.Properties;
namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
{
diff --git a/src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Complex32.cs b/src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Complex32.cs
index bf358352..fea0881e 100644
--- a/src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Complex32.cs
+++ b/src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Complex32.cs
@@ -30,10 +30,10 @@
#if NATIVEMKL
-using MathNet.Numerics.LinearAlgebra.Factorization;
-using MathNet.Numerics.Properties;
using System;
using System.Security;
+using MathNet.Numerics.LinearAlgebra.Factorization;
+using MathNet.Numerics.Properties;
namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
{
diff --git a/src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Single.cs b/src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Single.cs
index ee2ec1f0..7a9cd46c 100644
--- a/src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Single.cs
+++ b/src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Single.cs
@@ -30,11 +30,11 @@
#if NATIVEMKL
-using MathNet.Numerics.LinearAlgebra.Factorization;
-using MathNet.Numerics.Properties;
using System;
using System.Numerics;
using System.Security;
+using MathNet.Numerics.LinearAlgebra.Factorization;
+using MathNet.Numerics.Properties;
namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
{
diff --git a/src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.cs b/src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.cs
index 3541b4f5..6d04ab14 100644
--- a/src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.cs
+++ b/src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.cs
@@ -45,6 +45,21 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
SafeNativeMethods.SetImprovedConsistency();
}
}
+
+ ///
+ /// Initialize and verify that the provided is indeed available. If not, fall back to alernatives like the managed provider
+ ///
+ public override void InitializeVerify()
+ {
+ // TODO: Choose x86 or x64 based on Environment.Is64BitProcess
+ // TODO: call into MKL to verify
+ }
+
+ public override string ToString()
+ {
+ // TODO: query version and platform and add to string
+ return "Intel MKL";
+ }
}
}
diff --git a/src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.double.cs b/src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.double.cs
index ddbadc2a..7ba45140 100644
--- a/src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.double.cs
+++ b/src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.double.cs
@@ -30,11 +30,11 @@
#if NATIVEMKL
-using MathNet.Numerics.LinearAlgebra.Factorization;
-using MathNet.Numerics.Properties;
using System;
using System.Numerics;
using System.Security;
+using MathNet.Numerics.LinearAlgebra.Factorization;
+using MathNet.Numerics.Properties;
namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
{