FsMath 0.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package FsMath --version 0.0.1
                    
NuGet\Install-Package FsMath -Version 0.0.1
                    
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.
<PackageReference Include="FsMath" Version="0.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FsMath" Version="0.0.1" />
                    
Directory.Packages.props
<PackageReference Include="FsMath" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add FsMath --version 0.0.1
                    
#r "nuget: FsMath, 0.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package FsMath@0.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=FsMath&version=0.0.1
                    
Install as a Cake Addin
#tool nuget:?package=FsMath&version=0.0.1
                    
Install as a Cake Tool

FsMath - Fast & Friendly Numerical Foundation for F#

FsMath is a lightweight maths library designed for modern F# workflows. It focuses on zero-friction interop with existing array-centric libraries ( FSharp.Stats, Math.NET Numerics, libtorch via TorchSharp, etc.) while giving you the performance head-room of SIMD-accelerated kernels and a clean, idiomatic F# API.


Why another numeric library?

Goal What it means in practice
Interop first Core types are just aliases or thin wrappers around native F# 'T [] arrays → you can pass data to any array-based .NET or C library without conversion or pinning.
Predictable memory layout Matrices are stored row-major (C-style) to line up with libtorch / TorchSharp, modern BLAS back-ends, and GPU kernels.
SIMD out-of-the-box Tight loops (dot, outer product, reductions ...) auto-detect hardware with SIMD support and pure-managed fallback otherwise.
F#-idiomatic API Pipelining, module functions, inline operators (.+, .*, transpose) and SRTP �type-class� dispatch keep your notebooks & scripts concise.

Key features

  • Vector / RowVector / Matrix - minimal, generic, and structural-equality aware.
  • High-level operators - .+, .-, .*, ./, outer product, Kronecker, hadamard, etc.
  • SIMD optimizes - dot products, outer products, reductions, and more.
  • Unsafe-free - everything is pure managed IL; no native dlls to ship.
  • Perfect interop - drop-in arrays to FSharp.Stats, TorchSharp, DiffSharp, and any BLAS/LAPACK P/Invoke you like.

Getting started

open FsMath
open FSharp.Stats.Distributions

// init vector
let v1  = vector [| 1.0; 2.0; 3.0 |]

// init vector with random samples (using FSharp.Stats)
let v2 = Array.init 3 (fun _ -> Continuous.ChiSquared.Sample 30.)

// SIMD-accelerated element-wise multiply
let result = v1 .* v2              

// interop: pass 'result' straight into e.g. TorchSharp tensor

Documentation

Topic Where
API reference docs/ folder & generated markdown
Benchmarks benchmarks/
Contributing guide CONTRIBUTING.md

build

Check the build project to take a look at the build targets.

# Windows
./build.cmd

# Linux/mac
build.sh

running and writing tests

# Windows
./build.cmd runtests

# Linux/mac
build.sh runtests

docs

The docs are contained in .fsx and .md files in the docs folder. To develop docs on a local server with hot reload, run the following in the root of the project:

# Windows
./build.cmd watchdocs

# Linux/mac
./build.sh watchdocs

pack nuget package(s)

# Windows
./build.cmd pack

# Linux/mac
build.sh pack
Product 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 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on FsMath:

Package Downloads
FSharp.Stats

F#-first linear algebra, machine learning, fitting, signal processing, and statistical testing.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.0.2 198 10/20/2025
0.0.1 268 8/8/2025