Add documentation
This commit is contained in:
parent
d610874abc
commit
98223b180f
6 changed files with 170 additions and 28 deletions
|
|
@ -8,19 +8,27 @@ module Data.NumIdr.Interfaces
|
|||
--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
||| An interface synonym for types which form a field, such as `Double`.
|
||||
public export
|
||||
Field : Type -> Type
|
||||
Field a = (Eq a, Neg a, Fractional a)
|
||||
|
||||
|
||||
||| An interface for number types which allow for LUP decomposition to be performed.
|
||||
|||
|
||||
||| The function `abslt` is required for the internal decomposition algorithm.
|
||||
||| An instance of this interface must satisfy:
|
||||
||| * The relation `abslt` is a preorder.
|
||||
||| * `0` is a minimum of `abslt`.
|
||||
public export
|
||||
interface (Eq a, Neg a, Fractional a) => FieldCmp a where
|
||||
abscmp : a -> a -> Ordering
|
||||
||| Compare the absolute values of two inputs.
|
||||
abslt : a -> a -> Bool
|
||||
|
||||
|
||||
export
|
||||
(Ord a, Abs a, Neg a, Fractional a) => FieldCmp a where
|
||||
abscmp x y = compare (abs x) (abs y)
|
||||
abslt x y = abs x < abs y
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
|
@ -38,8 +46,11 @@ infixr 10 ^
|
|||
||| * If `x *. (y *. z)` is defined, then `(x *. y) *. z` is defined and equal.
|
||||
public export
|
||||
interface Mult a b c | a,b where
|
||||
||| A generalized multiplication/application operator for matrices and
|
||||
||| vector transformations.
|
||||
(*.) : a -> b -> c
|
||||
|
||||
||| A synonym for `Mult a a a`, or homogenous multiplication.
|
||||
public export
|
||||
Mult' : Type -> Type
|
||||
Mult' a = Mult a a a
|
||||
|
|
@ -52,6 +63,10 @@ Mult' a = Mult a a a
|
|||
||| * `identity *. x == x`
|
||||
public export
|
||||
interface Mult' a => MultMonoid a where
|
||||
||| Construct an identity matrix or transformation.
|
||||
|||
|
||||
||| NOTE: Creating an identity element for an `n`-dimensional transformation
|
||||
||| usually requires `n` to be available at runtime.
|
||||
identity : a
|
||||
|
||||
||| An interface for groups using the `*.` operator.
|
||||
|
|
@ -61,6 +76,10 @@ interface Mult' a => MultMonoid a where
|
|||
||| * `inverse x *. x == identity`
|
||||
public export
|
||||
interface MultMonoid a => MultGroup a where
|
||||
||| Calculate the inverse of the matrix or transformation.
|
||||
||| WARNING: This function will not check if an inverse exists for the given
|
||||
||| input, and will happily return results containing NaN values. To avoid
|
||||
||| this, use `tryInverse` instead.
|
||||
inverse : a -> a
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue