package spurs

  1. Overview
  2. Docs
A lightweight native sparse matrix library

Install

Dune Dependency

Authors

Maintainers

Sources

spurs-0.1.1.tbz
sha256=c59be7af57a6902941cfa3d446fb83e4cb58876fc7208008d1ae38a1d4e189cc
sha512=86bd6e099ac1441e4fecd2ce59fdc878d437dc0f7f4d2bd21a08fac675a99355b745a009d1040104ef106220ede8aa10f71e7ca85c982d2ddc7bc5e76aa69166

Description

Tags

sparse matrices

Published: 09 Jun 2025

README

spurs

Rust's sprs crate is a sparse linear algebra library for Rust. This is a lightweight, natively implemented port of sprs to OCaml, which will (eventually) support all the same functionality.

The documentation can be found here!

Installation

opam install spurs

Quickstart Guide

wip, here's a snippet:

open Spurs
open Spurs.Csmat
open Spurs.Ops

let () =
  let a =
    [|
      [| 0.; 0.; 2.; 0.; 0. |];
      [| 0.; 1.; 2.; 0.; 0. |];
      [| 0.; 0.; 2.; 0.; 0. |];
      [| 0.; 0.; 0.; 4.; 0. |];
    |]
    |> csr_from_dense
  in
  let b =
    [|
      [| 0.; 0.; 2. |];
      [| 0.; 1.; 2. |];
      [| 0.; 0.; 2. |];
      [| 0.; 0.; 0. |];
      [| 0.; 0.; 0. |];
    |]
    |> csc_from_dense
  in
  let c = a *@ b in
  print_float_matrix c;
  print_matrix (to_dense c)

Prints:

{ Csmat.storage = Csmat.CSR; nrows = 4; ncols = 3; indptr = [0, 1, 3, 4, 4];
  indices = [2, 1, 2, 2]; data = [4, 1, 6, 4] }

[
    [0.00; 0.00; 4.00];
    [0.00; 1.00; 6.00];
    [0.00; 0.00; 4.00];
    [0.00; 0.00; 0.00];
]

Dependencies (5)

  1. fmt
  2. ppx_fields_conv
  3. ppx_deriving
  4. ocaml >= "5.3.0"
  5. dune >= "3.17"

Dev Dependencies (4)

  1. odoc with-doc
  2. qcheck-alcotest with-test
  3. qcheck with-test
  4. alcotest with-test

Used by

None

Conflicts

None

OCaml

Innovation. Community. Security.