vector-space-0.19: Vector & affine spaces, linear maps, and derivatives

Copyright | (c) Conal Elliott 2008
License | BSD3
Maintainer | conal@conal.net
Stability | experimental
Safe Haskell | Safe-Inferred
Language | Haskell2010

Data.Basis

Description

Basis of a vector space, as an associated type This module requires ghc-6.10 or later

Synopsis

- class VectorSpace v => HasBasis v where
  - type Basis v
  - basisValue :: Basis v -> v
  - decompose :: v -> [(Basis v, Scalar v)]
  - decompose' :: v -> Basis v -> Scalar v
- linearCombo :: VectorSpace v => [(v, Scalar v)] -> v
- recompose :: HasBasis v => [(Basis v, Scalar v)] -> v

# Documentation

class VectorSpace v => HasBasis v where Source #

Minimal complete definition

Nothing

Associated Types

type Basis v Source #

Representation of the canonical basis for `v`

type Basis v = Basis (VRep v)

Methods

basisValue :: Basis v -> v Source #

Interpret basis rep as a vector

default basisValue :: (Generic v, HasBasis (VRep v), Basis (VRep v) ~ Basis v) => Basis v -> v Source #

decompose :: v -> [(Basis v, Scalar v)] Source #

Extract coordinates

default decompose :: (Generic v, HasBasis (VRep v), Scalar (VRep v) ~ Scalar v, Basis (VRep v) ~ Basis v) => v -> [(Basis v, Scalar v)] Source #

decompose' :: v -> Basis v -> Scalar v Source #

Experimental version. More elegant definitions, and friendly to infinite-dimensional vector spaces.

default decompose' :: (Generic v, HasBasis (VRep v), Scalar (VRep v) ~ Scalar v, Basis (VRep v) ~ Basis v) => v -> Basis v -> Scalar v Source #

#### Instances

Instances details

HasBasis CDouble Source # |

Instance details

Defined in Data.Basis

Associated Types

type Basis CDouble |
Instance details Defined in Data.Basis type Basis CDouble = ()

Methods

basisValue :: Basis CDouble -> CDouble Source #

decompose :: CDouble -> [(Basis CDouble, Scalar CDouble)] Source #

decompose' :: CDouble -> Basis CDouble -> Scalar CDouble Source #

HasBasis CFloat Source # |

Instance details

Defined in Data.Basis

Associated Types

type Basis CFloat |
Instance details Defined in Data.Basis type Basis CFloat = ()

Methods

basisValue :: Basis CFloat -> CFloat Source #

decompose :: CFloat -> [(Basis CFloat, Scalar CFloat)] Source #

decompose' :: CFloat -> Basis CFloat -> Scalar CFloat Source #

HasBasis Double Source # |

Instance details

Defined in Data.Basis

Associated Types

type Basis Double |
Instance details Defined in Data.Basis type Basis Double = ()

Methods

basisValue :: Basis Double -> Double Source #

decompose :: Double -> [(Basis Double, Scalar Double)] Source #

decompose' :: Double -> Basis Double -> Scalar Double Source #

HasBasis Float Source # |

Instance details

Defined in Data.Basis

Associated Types

type Basis Float |
Instance details Defined in Data.Basis type Basis Float = ()

Methods

basisValue :: Basis Float -> Float Source #

decompose :: Float -> [(Basis Float, Scalar Float)] Source #

decompose' :: Float -> Basis Float -> Scalar Float Source #

Integral a => HasBasis (Ratio a) Source # |

Instance details

Defined in Data.Basis

Associated Types

type Basis (Ratio a) |
Instance details Defined in Data.Basis type Basis (Ratio a) = ()

Methods

basisValue :: Basis (Ratio a) -> Ratio a Source #

decompose :: Ratio a -> [(Basis (Ratio a), Scalar (Ratio a))] Source #

decompose' :: Ratio a -> Basis (Ratio a) -> Scalar (Ratio a) Source #

(HasBasis u, s ~ Scalar u, HasBasis v, s ~ Scalar v) => HasBasis (u, v) Source # |

Instance details

Defined in Data.Basis

Associated Types

type Basis (u, v) |
Instance details Defined in Data.Basis type Basis (u, v) = Either (Basis u) (Basis v)

Methods

basisValue :: Basis (u, v) -> (u, v) Source #

decompose :: (u, v) -> [(Basis (u, v), Scalar (u, v))] Source #

decompose' :: (u, v) -> Basis (u, v) -> Scalar (u, v) Source #

HasBasis a => HasBasis (Rec0 a s) Source # |

Instance details

Defined in Data.Basis

Associated Types

type Basis (Rec0 a s) |
Instance details Defined in Data.Basis type Basis (Rec0 a s) = Basis a

Methods

basisValue :: Basis (Rec0 a s) -> Rec0 a s Source #

decompose :: Rec0 a s -> [(Basis (Rec0 a s), Scalar (Rec0 a s))] Source #

decompose' :: Rec0 a s -> Basis (Rec0 a s) -> Scalar (Rec0 a s) Source #

(HasBasis u, s ~ Scalar u, HasBasis v, s ~ Scalar v, HasBasis w, s ~ Scalar w) => HasBasis (u, v, w) Source # |

Instance details

Defined in Data.Basis

Associated Types

type Basis (u, v, w) |
Instance details Defined in Data.Basis type Basis (u, v, w) = Basis (u, (v, w))

Methods

basisValue :: Basis (u, v, w) -> (u, v, w) Source #

decompose :: (u, v, w) -> [(Basis (u, v, w), Scalar (u, v, w))] Source #

decompose' :: (u, v, w) -> Basis (u, v, w) -> Scalar (u, v, w) Source #

(HasBasis (f p), HasBasis (g p), Scalar (f p) ~ Scalar (g p)) => HasBasis ((f :*: g) p) Source # |

Instance details

Defined in Data.Basis

Associated Types

type Basis ((f :*: g) p) |
Instance details Defined in Data.Basis type Basis ((f :*: g) p) = Either (Basis (f p)) (Basis (g p))

Methods

basisValue :: Basis ((f :*: g) p) -> (f :*: g) p Source #

decompose :: (f :*: g) p -> [(Basis ((f :*: g) p), Scalar ((f :*: g) p))] Source #

decompose' :: (f :*: g) p -> Basis ((f :*: g) p) -> Scalar ((f :*: g) p) Source #

HasBasis (f p) => HasBasis (M1 i c f p) Source # |

Instance details

Defined in Data.Basis

Associated Types

type Basis (M1 i c f p) |
Instance details Defined in Data.Basis type Basis (M1 i c f p) = Basis (f p)

Methods

basisValue :: Basis (M1 i c f p) -> M1 i c f p Source #

decompose :: M1 i c f p -> [(Basis (M1 i c f p), Scalar (M1 i c f p))] Source #

decompose' :: M1 i c f p -> Basis (M1 i c f p) -> Scalar (M1 i c f p) Source #

linearCombo :: VectorSpace v => [(v, Scalar v)] -> v Source #

Linear combination of vectors

recompose :: HasBasis v => [(Basis v, Scalar v)] -> v Source #