BlasSharp.OpenBlas
0.3.0
dotnet add package BlasSharp.OpenBlas --version 0.3.0
NuGet\Install-Package BlasSharp.OpenBlas -Version 0.3.0
<PackageReference Include="BlasSharp.OpenBlas" Version="0.3.0" />
<PackageVersion Include="BlasSharp.OpenBlas" Version="0.3.0" />
<PackageReference Include="BlasSharp.OpenBlas" />
paket add BlasSharp.OpenBlas --version 0.3.0
#r "nuget: BlasSharp.OpenBlas, 0.3.0"
#:package BlasSharp.OpenBlas@0.3.0
#addin nuget:?package=BlasSharp.OpenBlas&version=0.3.0
#tool nuget:?package=BlasSharp.OpenBlas&version=0.3.0
BlasSharp
BLAS/LAPACK bindings for .NET (OpenBLAS, MKL, Apple Accelerate)
English | 日本語
Overview
BlasSharp is a library that provides bindings to BLAS/LAPACK for .NET.
BLAS/LAPACK libraries optimized for various CPUs are provided by Intel, Apple, and others. By bringing these libraries into C#, you can perform linear algebra computations with optimal performance.
Usage
You can use the bindings by installing the package that corresponds to the desired library. Below is a sample using OpenBLAS:
using BlasSharp;
using static BlasSharp.OpenBlas.NativeMethods;
unsafe
{
double[] A = [
1.0, 2.0, 3.0,
4.0, 5.0, 6.0,
7.0, 8.0, 9.0
];
double[] B = [
1.0, 2.0, 3.0,
4.0, 5.0, 6.0,
7.0, 8.0, 9.0,
];
double[] C = new double[9];
fixed (double* a = A, b = B, c = C)
{
cblas_dgemm(CBLAS_ORDER.CblasColMajor,
CBLAS_TRANSPOSE.CblasNoTrans,
CBLAS_TRANSPOSE.CblasNoTrans,
3, 3, 3, 1.0, a, 3, b, 3, 0.0, c, 3);
}
Console.WriteLine(string.Join(',', C));
}
IBlasOperations / ILapackOperations
The BlasSharp.Shared package provides IBlasOperations / ILapackOperations, which abstracts BLAS/LAPACK routines. Each package provides its own implementation.
public interface IBlasOperations : IBlasLevel1, IBlasLevel2, IBlasLevel3
{
}
public unsafe interface IBlasLevel1
{
void Saxpy(int n, float alpha, float* x, int incX, float* y, int incY);
void Daxpy(int n, double alpha, double* x, int incX, double* y, int incY);
void Caxpy(int n, void* alpha, void* x, int incX, void* y, int incY);
void Zaxpy(int n, void* alpha, void* x, int incX, void* y, int incY);
...
}
public interface ILapackOperations : ILapackDriverRoutines, ILapackComputationalRoutines, ILapackAuxiliaryRoutines
{
}
public unsafe interface ILapackDriverRoutines
{
int Sgesv(int* n, int* nrhs, float* a, int* lda, int* ipiv, float* b, int* ldb, int* info);
int Cgesv(int* n, int* nrhs, void* a, int* lda, int* ipiv, void* b, int* ldb, int* info);
int Dgesv(int* n, int* nrhs, double* a, int* lda, int* ipiv, double* b, int* ldb, int* info);
int Zgesv(int* n, int* nrhs, void* a, int* lda, int* ipiv, void* b, int* ldb, int* info);
...
}
OpenBLAS
You can use the OpenBLAS binaries and bindings by adding BlasSharp.OpenBlas to your project.
BlasSharp.OpenBlas supports multiple platforms:
win-x64, osx-x64, osx-arm64, linux-x64, and linux-arm64.
.NET CLI
dotnet add package BlasSharp.OpenBlas
Package Manager
Install-Package BlasSharp.OpenBlas
MKL
You can use the bindings for Intel's MKL by adding BlasSharp.Mkl to your project.
.NET CLI
dotnet add package BlasSharp.Mkl
Package Manager
Install-Package BlasSharp.Mkl
To use MKL, you also need to install the official Intel MKL NuGet package (e.g., intelmkl.devel.win-x64).
See the MKL download page for more details.
Accelerate (Apple)
You can use the bindings for Apple’s Accelerate framework by adding BlasSharp.AppleAccelerate to your project.
BlasSharp.AppleAccelerate currently supports only osx-arm64.
.NET CLI
dotnet add package BlasSharp.AppleAccelerate
Package Manager
Install-Package BlasSharp.AppleAccelerate
License
This library is released under the MIT License.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- BlasSharp.Shared (>= 0.3.0)
-
net9.0
- BlasSharp.Shared (>= 0.3.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.