hmatrix is a linear algebra library and matrix computations.

Example code:


-- Creating matrices
let x = (2><2) [0..3] :: Matrix Double

x -- [ 0.0, 1.0
  -- , 2.0, 3.0 ]

let y = fromLists [[0, 1], [2, 3]] :: Matrix Double

-- Random matrices

r <- randn 2 3
r -- [ 0.7764496757867578,    1.246311658930589,    -0.684233085372455
  -- , -2.540045307941425, -0.20975584071908912, -9.039537343065803e-3 ]

-- Matrix multiplication

x <> y -- [ 2.0,  3.0 
       -- , 6.0, 11.0 ]

-- Transpose

tr x -- [ 0.0, 2.0 
     -- , 1.0, 3.0 ]

-- Matrix slicing
r ?? (All, Take 2) -- [ 0.7764496757867578,    1.246311658930589
                   -- , -2.540045307941425, -0.20975584071908912 ]

-- Mapping over matrices

cmap ((+ 2) . (*2)) x -- [ 2.0, 4.0
                      -- , 6.0, 8.0 ]

-- Flatten

flatten x -- [0.0, 1.0, 2.0, 3.0]

Benchmarks

Notes:

Links: Hackage . GitHub . Homepage