Skip to content

Latest commit

 

History

History
58 lines (46 loc) · 3.24 KB

README.md

File metadata and controls

58 lines (46 loc) · 3.24 KB

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) 1. This means using things with kind Constraint (class/type/type family) instead of type families.

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 ([]).

Footnotes

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