numeric-prelude-0.4.2: An experimental alternative hierarchy of numeric type classes

Safe HaskellNone
LanguageHaskell98

Number.Physical.UnitDatabase

Description

Tools for creating a data base of physical units and for extracting data from it

Synopsis

Documentation

type T i a = [UnitSet i a] Source

data InitUnitSet i a Source

Constructors

InitUnitSet 

data InitScale a Source

Constructors

InitScale 

data UnitSet i a Source

An entry for a unit and there scalings.

Constructors

UnitSet 

Fields

unit :: T i
 
independent :: Bool
 
defScaleIx :: Int
 
reciprocal :: Bool

If True the symbols must be preceded with a /. Though it sounds like an attribute of Scale it must be the same for all scales and we need it to sort positive powered unitsets to the front of the list of unit components.

scales :: [Scale a]
 

Instances

(Show i, Show a) => Show (UnitSet i a) 

data Scale a Source

A common scaling for a unit.

Constructors

Scale 

Fields

symbol :: String
 
magnitude :: a
 

Instances

Show a => Show (Scale a) 

extractOne :: [a] -> a Source

powerOfUnitSet :: (Ord i, C a) => Int -> UnitSet i a -> UnitSet i a Source

Raise all scales of a unit and the unit itself to the n-th power

powerOfScale :: C a => Int -> Scale a -> Scale a Source

positiveToFront :: [UnitSet i a] -> [UnitSet i a] Source

Reorder the unit components in a way that the units with positive exponents lead the list.

decompose :: (Ord i, C a) => T i -> T i a -> [UnitSet i a] Source

Decompose a complex unit into common ones

findIndep :: Eq i => T i -> T i a -> Maybe (UnitSet i a) Source

findClosest :: (Ord i, C a) => T i -> T i a -> UnitSet i a Source

evalDist Source

Arguments

:: (Ord i, C a) 
=> T i 
-> T i a 
-> [(UnitSet i a, Int)]

(UnitSet,distance) the UnitSet may contain powered units

findBestExp :: Ord i => T i -> T i -> (Int, Int) Source

findMinExp :: [(Int, Int)] -> (Int, Int) Source

Find the exponent that lead to minimal distance Since the list is infinite maximum will fail but the sequence is convex and thus we can abort when the distance stop falling

distLE :: (Int, Int) -> (Int, Int) -> Bool Source

distances :: Ord i => T i -> [(Int, T i)] -> [(Int, Int)] Source

listMultiples :: (T i -> T i) -> Int -> [(Int, T i)] Source