All Projects → james-bowman → sparse

james-bowman / sparse

Licence: MIT license
Sparse matrix formats for linear algebra supporting scientific and machine learning applications

Programming Languages

go
31211 projects - #10 most used programming language
assembly
5116 projects

Projects that are alternatives of or similar to sparse

Armadillo Code
Armadillo: fast C++ library for linear algebra & scientific computing - http://arma.sourceforge.net
Stars: ✭ 388 (+185.29%)
Mutual labels:  vector, matrix, scientific-computing, blas
monolish
monolish: MONOlithic LInear equation Solvers for Highly-parallel architecture
Stars: ✭ 166 (+22.06%)
Mutual labels:  matrix, scientific-computing, blas, sparse-matrix
Tensor
A library and extension that provides objects for scientific computing in PHP.
Stars: ✭ 146 (+7.35%)
Mutual labels:  vector, matrix, scientific-computing, matrix-multiplication
Fmatvec
A fast vector/matrix library
Stars: ✭ 5 (-96.32%)
Mutual labels:  vector, matrix, matrices, blas
dbcsr
DBCSR: Distributed Block Compressed Sparse Row matrix library
Stars: ✭ 65 (-52.21%)
Mutual labels:  matrix-multiplication, blas, sparse-matrix
Eigen Git Mirror
THIS MIRROR IS DEPRECATED -- New url: https://gitlab.com/libeigen/eigen
Stars: ✭ 1,659 (+1119.85%)
Mutual labels:  matrix, blas, sparse-matrix
mir-glas
[Experimental] LLVM-accelerated Generic Linear Algebra Subprograms
Stars: ✭ 99 (-27.21%)
Mutual labels:  matrix, matrix-multiplication, blas
Lacaml
OCaml bindings for BLAS/LAPACK (high-performance linear algebra Fortran libraries)
Stars: ✭ 101 (-25.74%)
Mutual labels:  vector, matrix, blas
Blasjs
Pure Javascript manually written 👌 implementation of BLAS, Many numerical software applications use BLAS computations, including Armadillo, LAPACK, LINPACK, GNU Octave, Mathematica, MATLAB, NumPy, R, and Julia.
Stars: ✭ 241 (+77.21%)
Mutual labels:  vector, matrix, blas
Sharpmath
A small .NET math library.
Stars: ✭ 36 (-73.53%)
Mutual labels:  vector, matrix, matrices
GenericTensor
The only library allowing to create Tensors (matrices extension) with custom types
Stars: ✭ 42 (-69.12%)
Mutual labels:  vector, matrix, matrix-multiplication
Phpsci Carray
PHP library for scientific computing powered by C
Stars: ✭ 176 (+29.41%)
Mutual labels:  matrix, scientific-computing, matrices
Libxsmm
Library for specialized dense and sparse matrix operations, and deep learning primitives.
Stars: ✭ 518 (+280.88%)
Mutual labels:  vector, matrix, blas
Vectorious
Linear algebra in TypeScript.
Stars: ✭ 616 (+352.94%)
Mutual labels:  vector, matrix, blas
Algebra
means completeness and balancing, from the Arabic word الجبر
Stars: ✭ 92 (-32.35%)
Mutual labels:  vector, matrix
Numphp
Mathematical PHP library for scientific computing
Stars: ✭ 120 (-11.76%)
Mutual labels:  vector, matrix
Matrixstats
R package: Methods that Apply to Rows and Columns of Matrices (and to Vectors)
Stars: ✭ 151 (+11.03%)
Mutual labels:  vector, matrix
Matrix Puppet Hangouts
Matrix bridge for Google Hangouts
Stars: ✭ 42 (-69.12%)
Mutual labels:  vector, matrix
Node Sylvester
🐱 Sylvester is a vector, matrix, and geometry library for JavaScript, that runs in the browser and on the server.
Stars: ✭ 144 (+5.88%)
Mutual labels:  vector, matrix
Hlslpp
Math library using hlsl syntax with SSE/NEON support
Stars: ✭ 153 (+12.5%)
Mutual labels:  vector, matrix

Sparse matrix formats

License: MIT GoDoc Build Status Go Report Card codecov Mentioned in Awesome Go Sourcegraph

Implementations of selected sparse matrix formats for linear algebra supporting scientific and machine learning applications. Compatible with the APIs in the Gonum package and interoperable with Gonum dense matrix types.

Overview

Machine learning applications typically model entities as vectors of numerical features so that they may be compared and analysed quantitively. Typically the majority of the elements in these vectors are zeros. In the case of text mining applications, each document within a corpus is represented as a vector and its features represent the vocabulary of unique words. A corpus of several thousand documents might utilise a vocabulary of hundreds of thousands (or perhaps even millions) of unique words but each document will typically only contain a couple of hundred unique words. This means the number of non-zero values in the matrix might only be around 1%.

Sparse matrix formats capitalise on this premise by only storing the non-zero values thereby reducing both storage/memory requirements and processing effort for manipulating the data.

Features

Usage

The sparse matrices in this package implement the Gonum Matrix interface and so are fully interoperable and mutually compatible with the Gonum APIs and dense matrix types.

// Construct a new 3x2 DOK (Dictionary Of Keys) matrix
dokMatrix := sparse.NewDOK(3, 2)

// Populate it with some non-zero values
dokMatrix.Set(0, 0, 5)
dokMatrix.Set(2, 1, 7)

// Demonstrate accessing values (could use Gonum's mat.Formatted()
// function to pretty print but this demonstrates element access)
m, n := dokMatrix.Dims()
for i := 0; i < m; i++ {
    for j := 0; j < n; j++ {
        fmt.Printf("%.0f,", dokMatrix.At(i, j))
    }
    fmt.Printf("\n")
}

// Convert DOK matrix to CSR (Compressed Sparse Row) matrix
// just for fun (not required for upcoming multiplication operation)
csrMatrix := dokMatrix.ToCSR()

// Create a random 2x3 COO (COOrdinate) matrix with
// density of 0.5 (half the elements will be non-zero)
cooMatrix := sparse.Random(sparse.COOFormat, 2, 3, 0.5)

// Convert CSR matrix to Gonum mat.Dense matrix just for fun
// (not required for upcoming multiplication operation)
// then transpose so it is the right shape/dimensions for
// multiplication with the original CSR matrix
denseMatrix := csrMatrix.ToDense().T()

// Multiply the 2 matrices together and store the result in the
// sparse receiver (multiplication with sparse product)
var csrProduct sparse.CSR
csrProduct.Mul(csrMatrix, cooMatrix)

// As an alternative, use the sparse BLAS routines for efficient
// sparse matrix multiplication with a Gonum mat.Dense product
// (multiplication with dense product)
denseProduct := sparse.MulMatMat(false, 1, csrMatrix, denseMatrix, nil)

Installation

With Go installed, package installation is performed using go get.

go get -u github.com/james-bowman/sparse/...

Acknowledgements

See Also

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].