npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

ruvector-math-wasm

v0.1.32

Published

WebAssembly bindings for ruvector-math: Optimal Transport, Information Geometry, Product Manifolds

Readme

ruvector-math-wasm

npm version crates.io License WASM

High-performance WebAssembly bindings for advanced mathematical algorithms in vector search and AI.

Brings Optimal Transport, Information Geometry, and Product Manifolds to the browser with near-native performance.

Features

  • 🚀 Optimal Transport - Sliced Wasserstein, Sinkhorn, Gromov-Wasserstein distances
  • 📐 Information Geometry - Fisher Information Matrix, Natural Gradient, K-FAC
  • 🌐 Product Manifolds - E^n × H^n × S^n (Euclidean, Hyperbolic, Spherical)
  • SIMD Optimized - Vectorized operations where available
  • 🔒 Type-Safe - Full TypeScript definitions included
  • 📦 Zero Dependencies - Pure Rust compiled to WASM

Installation

npm install ruvector-math-wasm
# or
yarn add ruvector-math-wasm
# or
pnpm add ruvector-math-wasm

Quick Start

Browser (ES Modules)

import init, {
  WasmSlicedWasserstein,
  WasmSinkhorn,
  WasmProductManifold
} from 'ruvector-math-wasm';

// Initialize WASM module
await init();

// Compute Sliced Wasserstein distance
const sw = new WasmSlicedWasserstein(100); // 100 projections
const source = new Float64Array([0, 0, 1, 1, 2, 2]); // 3 points in 2D
const target = new Float64Array([0.5, 0.5, 1.5, 1.5, 2.5, 2.5]);
const distance = sw.distance(source, target, 2);
console.log(`Wasserstein distance: ${distance}`);

Node.js

const { WasmSlicedWasserstein } = require('ruvector-math-wasm');

const sw = new WasmSlicedWasserstein(100);
const dist = sw.distance(source, target, 2);

Use Cases

1. Distribution Comparison in ML

Compare probability distributions for generative models, anomaly detection, or data drift monitoring.

// Compare embedding distributions
const sw = new WasmSlicedWasserstein(200).withPower(2); // W2 distance

const trainEmbeddings = new Float64Array(/* ... */);
const testEmbeddings = new Float64Array(/* ... */);

const drift = sw.distance(trainEmbeddings, testEmbeddings, 768);
if (drift > threshold) {
  console.warn('Data drift detected!');
}

2. Semantic Vector Search

Use product manifolds for hierarchical and semantic search.

const manifold = new WasmProductManifold({
  euclidean_dim: 256,
  hyperbolic_dim: 128,
  spherical_dim: 128,
  curvature_h: -1.0,
  curvature_s: 1.0
});

// Compute distance in mixed-curvature space
const dist = manifold.distance(queryVector, documentVector);

3. Optimal Transport for Image Comparison

const sinkhorn = new WasmSinkhorn(0.01, 100); // regularization, max_iters

// Compare image histograms
const result = sinkhorn.solveTransport(
  costMatrix,
  sourceWeights,
  targetWeights,
  n, m
);

console.log(`Transport cost: ${result.cost}`);
console.log(`Converged: ${result.converged}`);

4. Natural Gradient Optimization

const fisher = new WasmFisherInformation(512);

// Compute Fisher Information Matrix
const fim = fisher.compute(activations);

// Apply natural gradient
const naturalGrad = fisher.naturalGradientStep(gradient, 0.01);

API Reference

Optimal Transport

| Class | Description | |-------|-------------| | WasmSlicedWasserstein | Fast approximation via random projections | | WasmSinkhorn | Entropy-regularized optimal transport | | WasmGromovWasserstein | Cross-space structural comparison |

Information Geometry

| Class | Description | |-------|-------------| | WasmFisherInformation | Fisher Information Matrix computation | | WasmNaturalGradient | Natural gradient descent optimizer |

Product Manifolds

| Class | Description | |-------|-------------| | WasmProductManifold | E^n × H^n × S^n mixed-curvature space | | WasmSphericalSpace | Spherical geometry operations |

Performance

Benchmarked on M1 MacBook Pro (WASM in Chrome):

| Operation | Dimension | Time | |-----------|-----------|------| | Sliced Wasserstein (100 proj) | 1000 points × 128D | 2.3ms | | Sinkhorn (100 iter) | 500 × 500 | 8.7ms | | Product Manifold distance | 512D | 0.04ms |

TypeScript Support

Full TypeScript definitions are included:

import { WasmSlicedWasserstein, WasmSinkhornConfig } from 'ruvector-math-wasm';

const sw: WasmSlicedWasserstein = new WasmSlicedWasserstein(100);
const distance: number = sw.distance(source, target, dim);

Building from Source

# Install wasm-pack
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh

# Build
cd crates/ruvector-math-wasm
wasm-pack build --target web --release

# Test
wasm-pack test --headless --chrome

Related Packages

License

MIT OR Apache-2.0

Links