/sparsemat

A simple sparse matrix for values over binary Galois Field - GF(2).

Primary LanguageGoMIT LicenseMIT

sparsemat

A simple sparse matrix for values over binary Galois Field - GF(2).

Currently implemented:

Future implementations:

Usage

Importing:

import mat "github.com/nathanhack/sparsemat"

Creating a matrix:

m1 := mat.CSRIdentity(3)
m2 := mat.DOKMat(3,3, 1,0,0,0,1,0,0,0,1)

Multiplying: Mul

r := mat.CSRMat(3,3)
r.Mul(m1,m2) // multiplies m1xm2 and stores into r

Accessors: At and Set

fmt.Printf("value at (%v,%v) is %v\n",1,1,r.At(1,1))
r.Set(1,1,0)
fmt.Printf("value at (%v,%v) is now %v\n",1,1,r.At(1,1))

Slices: Slice

m := mat.DOKMat(1,4, 1,1,1,1) // creates matrix [1 1 1 1]
s := m.Slice(0,1,1,2) // creates a slice (new matrix) of the two middle 1's [1 1]

Transposes: T

t := m.T() // note this creates a new allocated matrix

Deps

Golang

Version 1.14+

Libs

github.com/olekukonko/tablewriter