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

@univ-lehavre/matrix

v1.0.0

Published

Une classe pour le calcul matriciel en TypeScript

Downloads

3

Readme

@univ-lehavre/matrix

Une petite bibliothèque TypeScript pour le calcul matriciel dense et creux (CSR) avec un focus sur:

  • Stockage efficace (Float64Array pour dense, CSR pour creux)
  • Opérations de base rapides (add, sub, mul [scalaire/matriciel], transpose, matvec)
  • API commune via l’interface IMatrix

Installation

Ce package fait partie du monorepo. Pour travailler localement:

pnpm -w i
pnpm -w build
pnpm -C packages/matrix test

Utilisation rapide

import { DenseMatrix, CSRMatrix, zeros, identity, from2D } from '@univ-lehavre/matrix';

// Dense
const A = from2D([
  [1, 2],
  [3, 4],
]);
const B = identity(2);
const C = A.mul(B); // produit matriciel Dense x Dense

// Vecteur
const x = new Float64Array([2, 1]);
const y = A.matvec(x); // -> [1*2 + 2*1, 3*2 + 4*1]

// Sparse (CSR)
const S = CSRMatrix.fromCOO(2, 3, [
  { i: 0, j: 0, v: 1 },
  { i: 0, j: 2, v: 2 },
  { i: 1, j: 1, v: 3 },
]);
const D = S.mul(A.transpose()); // CSR x Dense -> Dense

API

  • DenseMatrix (stockage row-major via Float64Array)
    • get/set, add/sub, mul(number|IMatrix), transpose, matvec, toDense
    • static from2D, static identity, static zeros
  • CSRMatrix (Compressed Sparse Row)
    • fromCOO(rows, cols, entries) et fromDense(DenseMatrix)
    • get/set, add/sub, mul(number|IMatrix) dont CSR × CSR → CSR optimisé (Gustavson), transpose, matvec, toDense
  • Helpers
    • zeros(rows, cols), identity(n), from2D(values)

Notes de perf et limites

  • Les opérations mixant dense et CSR privilégient des chemins optimisés (ex: CSR * Dense). CSR × CSR est maintenant optimisé et renvoie une CSR sans conversion intermédiaire.
  • CSRMatrix.set reconstruit actuellement la structure; pour des mises à jour massives, préférez construire depuis un COO.
  • Les calculs sont en number (double précision). Pas de support BigInt/complexe pour l’instant.

Bench rapide (optionnel)

Un petit script de bench est disponible pour comparer rapidement les temps d’exécution de CSR × CSR et Dense × Dense en fonction de la taille et de la densité.

Exécution locale:

pnpm -C packages/matrix bench

Le script génère deux sections:

  • "Bench par taille": multiplie des matrices carrées de tailles croissantes (densité ~5%).
  • "Bench par densité": multiplie des matrices fixes (150×150) avec différentes densités.

Astuce: les mesures varient selon la machine et la charge. Utilisez-les pour comparer des tendances, pas comme des chiffres absolus.

Licence

UNLICENSED (interne pour l’instant).

Documentation API (TypeDoc)

Vous pouvez générer une documentation HTML à partir de la JSDoc via TypeDoc:

pnpm -C packages/matrix i
pnpm -C packages/matrix docs

La doc sera construite dans packages/matrix/docs. Pour la prévisualiser dans VS Code, ouvrez le fichier index.html dans ce dossier.