MKL.NET.Matrix 1.0.0

.NET 5.0 .NET Standard 2.0
Install-Package MKL.NET.Matrix -Version 1.0.0
dotnet add package MKL.NET.Matrix --version 1.0.0
<PackageReference Include="MKL.NET.Matrix" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MKL.NET.Matrix --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: MKL.NET.Matrix, 1.0.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install MKL.NET.Matrix as a Cake Addin
#addin nuget:?package=MKL.NET.Matrix&version=1.0.0

// Install MKL.NET.Matrix as a Cake Tool
#tool nuget:?package=MKL.NET.Matrix&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.



A simple cross platform .NET API for Intel MKL.

Exposing functions from MKL keeping the syntax as close to the c developer reference as possible.

Reference the MKL.NET package and required runtime packages and use the static MKL functions. The correct native libraries will be included and loaded at runtime.

runtimes: MKL.NET MKL.NET
MKL.NET.linux-x64 MKL.NET
MKL.NET.linux-x86 MKL.NET
MKL.NET.Optimization MKL.NET
MKL.NET.Statistics MKL.NET


  • Use freely available Intel MKL packages repackaged to work for each runtime.
  • The MKL.NET API is just a thin .NET wrapper around the native API keeping the syntax as close as possible.
  • The project is well defined, with an open design, and no business logic and could benefit from external input.
  • Cross platform testing is easy and free using Github actions.
  • MKL.NET native packages can just be referenced for needed runtimes at library or application level.


  • Performance and memory optimised matrix algebra library.
  • Matrix expressions are optimised to perform intermediate calculations inplace and reuse memory.
  • Operations such as scale, transpose, +, * are combined into single MKL calls.
  • Intermediate matrices are disposed (or reused) automatically.
  • ArrayPool underlying memory model using IDisposable and Finalizers.
  • Uses the Pinned Object Heap for net5.0.
  • All these combined result in it being much faster than other matrix libraries.

The following example only results in one new matrix r (using ArrayPool) without mutating inputs.

public static matrix Example(matrix ma, matrix mb, vector va, vector vb)
    using matrix r = 0.5 * Matrix.Abs(1.0 - ma) * mb.T + Math.PI * va.T * Vector.Sin(vb);

Example statistics matrix function:

public static (vector, matrix) MeanAndCovariance(matrix samples, vector weights)
    if (samples.Rows != weights.Length) ThrowHelper.ThrowIncorrectDimensionsForOperation();
    var mean = new vector(samples.Cols);
    var cov = new matrix(samples.Cols, samples.Cols);
    var task = Vsl.SSNewTask(samples.Cols, samples.Rows, VslStorage.ROWS, samples.Array, weights.Array);
    ThrowHelper.Check(Vsl.SSEditCovCor(task, mean.Array, cov.Array, VslFormat.FULL, null, VslFormat.FULL));
    ThrowHelper.Check(Vsl.SSCompute(task, VslEstimate.COV, VslMethod.FAST));
    return (mean, cov);

Note: arrays need to be pinned across all MKL function calls when there are multiple as above as MKL stores native pointers and the arrays could be moved between calls. MKL.NET handles pinning automatically, unpinning when the task is deleted. This is a common seen bug when using MKL directly from .NET which causes occasional crashes.


Simple and high performance optimization and root finding library loosely based on the scipy.optimize API.

The aim is to include the latest algorithms such as Toms748, robustly tested with CsCheck. Full use of MKL.NET will be made to improve performance. Algorithms will be performance tested and default to the best for given inputs.

  • Root - root finding algorithms. Default algorithm has 20% fewer function calls than Brent, Toms748, Newton and Halley. Further details here.
  • Calculus - derivative and integral numeric calculations and check to any precision using Richardson extrapolation.
  • Minimum - minimum finding algorithms in one dimension. Default algorithm has 50% fewer function calls than Brent.
  • Minimum - in N dimensions. Intuative tolerance parameters. Optimised no array allocation in main loop using in place symmetric MKL rank-k, rank-2k functions.
    Should scale well with the number of dimensions. ~ 50-70% fewer function calls than other BFGS algorithms.
  • CurveFit and non-linear LeastSquares - helper functions based on Minimum.
  • Minimum_Global - global minimum algorithm in N dimensions returning a sequence of parallel grid BFGS searches ever reducing the spacing between prior searches.


Simple and high performance statistics functions.

  • Summary - Sum, Mean, Median, MAD, Raw/Central/Standard Moments, Quartiles, Quantiles, Covariance, Correlation. All can be weighted.
  • Estimator - Running high performance, low memory estimators for Quantile, Quartiles, Quantiles, Histogram, Central/Standard Moments. Further details here.
Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on MKL.NET.Matrix:

Package Downloads

Optimization and root finding based on cross platform MKL.NET.


Statistics functions based on cross platform MKL.NET.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 116 3/6/2022
1.0.0-rc1 44 2/23/2022
0.7.2 459 9/26/2021
0.7.0 291 8/26/2021
0.6.4 200 6/23/2021
0.6.3 187 2/5/2021
0.6.2 187 1/30/2021
0.6.1 176 1/28/2021
0.6.0 189 1/27/2021
0.5.0 194 1/18/2021
0.4.0 208 1/16/2021
0.3.0 234 11/13/2020
0.2.0 244 11/9/2020
0.1.0 283 11/4/2020

Version updating to 1.0.0 with MKL.NET.Optimization.