numeric-prelude-0.0.4: An experimental alternative hierarchy of numeric type classesSource codeContentsIndex
Number.Physical.Unit
Portabilityportable
Stabilityprovisional
Maintainernumericprelude@henning-thielemann.de
Description
Abstract Physical Units
Synopsis
type T i = Map i Int
scalar :: T i
isScalar :: T i -> Bool
fromVector :: (Enum i, Ord i) => [Int] -> T i
toVector :: (Enum i, Ord i) => T i -> [Int]
ratScale :: T Int -> T i -> T i
ratScaleMaybe :: T Int -> T i -> Maybe (T i)
ratScaleMaybe2 :: T Int -> T i -> Map i (Maybe Int)
Documentation
type T i = Map i IntSource

A Unit.T is a sparse vector with integer entries Each map n->m means that the unit of the n-th dimension is given m times.

Example: Let the quantity of length (meter, m) be the zeroth dimension and let the quantity of time (second, s) be the first dimension, then the composed unit m_s corresponds to the Map [(0,1),(1,-2)]

In future I want to have more abstraction here, e.g. a type class from the Edison project that abstracts from the underlying implementation. Then one can easily switch between Arrays, Binary trees (like Map) and what know I.

scalar :: T iSource
The neutral Unit.T
isScalar :: T i -> BoolSource
Test for the neutral Unit.T
fromVector :: (Enum i, Ord i) => [Int] -> T iSource
Convert a List to sparse Map representation Example: [-1,0,-2] -> [(0,-1),(2,-2)]
toVector :: (Enum i, Ord i) => T i -> [Int]Source
Convert Map to a List
ratScale :: T Int -> T i -> T iSource
ratScaleMaybe :: T Int -> T i -> Maybe (T i)Source
ratScaleMaybe2 :: T Int -> T i -> Map i (Maybe Int)Source
Produced by Haddock version 2.6.0