Skip to content
compile-time checked units for linear algebra
Haskell Shell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
DimMat
examples
.gitignore
DimMat.cabal
DimMat.hs
LICENSE
README.md
Setup.hs
sources.txt
syncdocs.sh

README.md

Compile-time checked units for matrices

Two related generalizations of dimensional are explored in this package:

  • wrap hmatrix operations to check physical units and dimensions at compile time.
  • automatic differentiation (ad package) that knows about units

This comes at a cost, since type errors become more complicated, and type signatures for functions that operate on the involved quantities are more difficult (see examples/controlspace.hs). In return, you get a stronger assurance that the program does the right thing.

Additionally, there is an emphasis on type inference going both ways: in ordinary haskell this is pretty much provided. For example if we have, z = x + y, then if due to other parts of the program the compiler knows x :: (Int,_1,_2), y :: (_3,Int,_4) and z :: (_5,_6,Int), it can conclude that (+) is needed with type (Int,Int,Int) -> (Int,Int,Int) -> (Int,Int,Int) [^note]. This means using things with kind Constraint (class/type/type family) instead of type families.

[^note]: which isn't available by default, but you can check http://hackage.haskell.org/package/NumInstances or write it by hand

Haddocks are available at http://aavogt.github.io/haddock/DimMat

Installation

Get ghc-7.6 or ghc-7.8 and cabal-install. Then:

cabal install cabal-meta cabal-src
git clone https://github.com/aavogt/DimMat
cd DimMat/
cabal-meta install

Related Work

Units and AD or linear algebra

Matrix dimensions statically checked

These packages provide operations where the typechecker will prevent invalid operations, such as multiplying an m×n matrix with a p×q matrix when n /= p, at compile-time.

units

Records

extensible records have many needs in common with DimMat. Types in HMatrix like fromBlocks :: [[Matrix t]] -> Matrix t are (or will be) generalized to use HList instead of ordinary lists ([]).

You can’t perform that action at this time.