NuGet\Install-Package Kolbe.LitMath -Version 0.5.0
dotnet add package Kolbe.LitMath --version 0.5.0
<PackageReference Include="Kolbe.LitMath" Version="0.5.0" />
paket add Kolbe.LitMath --version 0.5.0
#r "nuget: Kolbe.LitMath, 0.5.0"
// Install Kolbe.LitMath as a Cake Addin #addin nuget:?package=Kolbe.LitMath&version=0.5.0 // Install Kolbe.LitMath as a Cake Tool #tool nuget:?package=Kolbe.LitMath&version=0.5.0
A collection of AVX-256 accelerated mathematical functions for .NET
Sin and a few other useful functions using pure AVX intrinsics, so instead of doing one calculation per core, you can now do 4 doubles or 8 floats per core. I added the
Sqrt, ERF function and a Normal Distribution CDF as well. On doubles, the following accuracies apply:
Sqrtrun at double precision limits
Tanin $[0,\pi/4]$ at
1e-10(working on it)
There are examples in the benchmark and tests. But here is one to get you started anyway.
n $e^x$'s in chunks of 4 and store the result in y.
int n = 40; Span<double> x = new Span<double>(Enumerable.Range(0 , n).Select(z => (double)z/n).ToArray()); Span<double> y = new Span<double>(new double[n]); Lit.Exp(ref x, ref y);
LitMath leverages SIMD for instruction level parallelism, but not compute cores. For array sizes large enough, it would be a really good idea to do multicore processing. There's an example called
LitExpDoubleParallel in the ExpBenchmark.cs file to see one way to go about this.
Making a library like this involves reinventing the wheel so to speak on very basic concepts.
LitUtilities includes methods like
IfElse, which are key to many programming problems in AVX programming, because it needs to be branch-free.
|.NET||net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows|
- No dependencies.
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
MAJOR BREAKING CHANGES.
I've eliminated all pointer interfaces and usage of raw pointers.
I've changed the class names from Lit[thing] (e.g. LitExp) to just a large shared class called Lit.
Polynomial changed its name as well.