Tuna.Optimization
0.1.0
See the version list below for details.
dotnet add package Tuna.Optimization --version 0.1.0
NuGet\Install-Package Tuna.Optimization -Version 0.1.0
<PackageReference Include="Tuna.Optimization" Version="0.1.0" />
<PackageVersion Include="Tuna.Optimization" Version="0.1.0" />
<PackageReference Include="Tuna.Optimization" />
paket add Tuna.Optimization --version 0.1.0
#r "nuget: Tuna.Optimization, 0.1.0"
#:package Tuna.Optimization@0.1.0
#addin nuget:?package=Tuna.Optimization&version=0.1.0
#tool nuget:?package=Tuna.Optimization&version=0.1.0
Tuna
Tiny Utilities for Numerical Analysis — A pure C#, SIMD-accelerated numerical computing library for .NET 10.
Tuna provides fast linear algebra, special functions, and deterministic random/quasi-random generators with zero native dependencies, alongside modular extension packages for statistics, signal processing, optimization, integration, automatic differentiation, MCMC, and neural networks.
Key Features
- Pure C# & Zero Native Dependencies: Runs anywhere .NET 10 runs, with SIMD-accelerated kernels and no native BLAS/LAPACK binaries to deploy.
- Zero-Copy Views (
readonly ref struct): Transpose (A.T), slice (A[1..3, ..]), row/column/diagonal views, and explicit zero-copy broadcasting (v.Broadcast(cols)) without allocating. - Allocation-Aware API: Elementwise and linear algebra operations in
XMathprovide allocating,destination-based, andXMath.InPlaceoverloads—plus reusable decomposition buffers (Recompute). - Modular Packages: Use
Tunafor core numerics, and combine domain-specificTuna.*packages as needed.
Packages
| Package | Description |
|---|---|
Tuna |
Core package: Vector<T>, Matrix<T>, Tensor<T>, XMath, BLAS & decompositions (LU/Cholesky/QR/Eigen/SVD), special functions, PRNG/QRNG |
Tuna.Statistics |
Continuous, discrete, and multivariate probability distributions (PDF/CDF/quantiles/sampling) |
Tuna.SignalProcessing |
1D/2D FFT, real FFT, DCT/DST, convolution, correlation, and discrete/continuous wavelets |
Tuna.Optimization |
L-BFGS / L-BFGS-B, SGD / Adam / AdamW, proximal methods (FISTA/ADMM), global optimization, genetic algorithms |
Tuna.Integration |
1D adaptive quadrature, multidimensional cubature, and quasi-Monte Carlo integration |
Tuna.Differentiation |
Tape-based reverse-mode automatic differentiation for scalars, vectors, matrices, tensors, and decompositions |
Tuna.Probabilistic |
MCMC samplers (HMC, NUTS, slice, ensemble, parallel tempering) and convergence diagnostics ($\hat{R}$, ESS, MCSE) |
Tuna.NeuralNetwork |
2D convolution, Mamba blocks, normalization layers, and SafeTensors reader |
Quick Start
Linear Algebra & Zero-Copy Views
using Tuna;
using Tuna.LinearAlgebra;
var A = Matrix<double>.FromRowMajor(3, 3,
[
4, 1, 0,
1, 3, 1,
0, 1, 2,
]);
var b = new Vector<double>([1.0, 2.0, 3.0]);
// Solve A * x = b
Vector<double> x = XMath.Solve(A, b);
// Cholesky decomposition
var chol = A.Cholesky();
double logDet = chol.LogDeterminant;
// Zero-copy transpose, slicing, and broadcasting
Matrix<double> C = A.T * A[0..3, 0..2];
Vector<double> rowMeans = XMath.RowMeans(A);
XMath.Subtract(A, rowMeans.Broadcast(A.Columns), A); // center columns in-place
Allocation Control (XMath)
Most XMath operations provide three consistent forms:
var v = new Vector<double>([0.0, 1.0, 2.0]);
var buffer = new Vector<double>(v.Length);
Vector<double> y = XMath.Exp(v); // 1. Allocate a new container
XMath.Exp(v, buffer); // 2. Write into an existing destination buffer
XMath.InPlace.Exp(v); // 3. Mutate in-place
Special Functions & Deterministic RNG
using Tuna;
using Tuna.RandomSource;
double logGamma = XMath.Special.LogGamma(200.0);
double tail = XMath.Special.Erfc(6.0);
var rng = new Pcg64DxsmRandom(seed: 42);
double u = rng.NextDouble();
Extension Packages (e.g. Reverse-Mode Autodiff)
using Tuna;
using Tuna.Differentiation;
var tape = new Tape();
var x = tape.Leaf(2.0);
var y = XMath.Sin(x) + x * x;
tape.Backward(y);
double dydx = tape.GetGradient(x); // cos(2) + 4
Design Highlights
- Column-Major Layout:
Matrix<T>stores elements in column-major order. Datasets follow the convention of 1 column = 1 sample (dimensions × samples). - No Implicit Broadcasting: Shapes must match explicitly; use
v.Broadcast(cols)/v.BroadcastRows(rows)to create zero-copy broadcast views. - Strict Aliasing Rules: Elementwise operations allow exact-match in-place updates (partial overlap throws
ArgumentException). Matrix products, transposes, and reductions forbid input/output overlap.
Requirements
- .NET 10 (
net10.0)
Documentation
Detailed guides, design notes, and generated API references are available in documents/ (Japanese):
- Getting Started (Containers & Views)
XMathGuide- Linear Algebra & Matrix Decompositions
- Special Functions (
XMath.Special) - Random & Quasi-Random Generators
- Extension Packages Overview
- Performance & Memory Optimization
- Design Notes
- API Reference
License
This library is licensed under the MIT License.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. 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. |
-
net10.0
- Tuna (>= 0.1.0)
- Tuna.Differentiation (>= 0.1.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Tuna.Optimization:
| Package | Downloads |
|---|---|
|
Tuna.Probabilistic
Probabilistic inference (HMC, NUTS, slice sampling, ensemble and parallel tempering MCMC) and convergence diagnostics for Tuna. |
GitHub repositories
This package is not used by any popular GitHub repositories.