# Kolbe.LitMath 0.5.0

.NET 6.0
NuGet\Install-Package Kolbe.LitMath -Version 0.5.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
dotnet add package Kolbe.LitMath --version 0.5.0
<PackageReference Include="Kolbe.LitMath" Version="0.5.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Kolbe.LitMath --version 0.5.0
#r "nuget: Kolbe.LitMath, 0.5.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 Kolbe.LitMath as a Cake Addin

// Install Kolbe.LitMath as a Cake Tool
#tool nuget:?package=Kolbe.LitMath&version=0.5.0

## LitMath

A collection of AVX-256 accelerated mathematical functions for .NET

I rewrote Exp, Log, 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:

• Exp and Sqrt run at double precision limits
• ERF at 1e-13
• Sin and Cos at 1e-15
• Tan in $[0,\pi/4]$ at 2e-16
• ATan at 1e-10 (working on it)

There are examples in the benchmark and tests. But here is one to get you started anyway.

Calculate 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);


### Parallel Processing

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.

### Non-Math Things

Making a library like this involves reinventing the wheel so to speak on very basic concepts. LitUtilities includes methods like Max and Min and IfElse, which are key to many programming problems in AVX programming, because it needs to be branch-free.

Product Versions
.NET net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows
Compatible target framework(s)
• #### net6.0

• No dependencies.

### NuGet packages

This package is not used by any NuGet packages.

### GitHub repositories

This package is not used by any popular GitHub repositories.

0.5.0 30 9/24/2022
0.4.1 35 9/21/2022
0.4.0 34 9/21/2022
0.3.8 60 9/15/2022
0.3.7 58 9/14/2022
0.3.6 62 9/14/2022
0.3.5 67 9/14/2022
0.3.4 80 7/22/2022
0.3.3 80 7/21/2022
0.3.2 87 7/20/2022
0.3.1 85 7/20/2022
0.3.0 95 7/18/2022
0.2.1 102 7/9/2022
0.2.0 93 6/5/2022
0.1.2 86 6/3/2022
0.1.1 75 6/2/2022
0.1.0 89 6/2/2022

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.