dunai-0.5.2.1: Generalised reactive framework supporting classic, arrowized and monadic FRP.

Copyright(c) Ivan Perez and Manuel Bärenz
LicenseSee the LICENSE file in the distribution.
Maintainerivan.perez@keera.co.uk
Stabilityprovisional
Portabilitynon-portable (GHC extensions)
Safe HaskellNone
LanguageHaskell2010

Data.VectorSpace

Contents

Description

Vector space type relation and basic instances. Heavily inspired by Yampa's FRP.Yampa.VectorSpace module.

Synopsis

Vector space classes

class Num (Groundring v) => RModule v where Source #

R-modules. A module v over a ring Groundring v is an abelian group with a linear multiplication. The hat ^ denotes the side of an operation on which the vector stands, i.e. a *^ v for v a vector.

A minimal definition should include the type Groundring and the implementations of zeroVector, ^+^, and one of *^ or ^*.

The following laws must be satisfied:

  • v1 ^+^ v2 == v2 ^+^ v1
  • a *^ zeroVector == zeroVector
  • @a *^ (v1 ^+^ v2) == a *^ v1 ^+^ a*^ v2
  • a *^ v == v ^* a
  • negateVector v == (-1) *^ v
  • v1 ^-^ v2 == v1 ^+^ negateVector v2

Minimal complete definition

zeroVector, (^+^)

Associated Types

type Groundring v Source #

Methods

zeroVector :: v Source #

(*^) :: Groundring v -> v -> v infixr 6 Source #

(^*) :: v -> Groundring v -> v Source #

negateVector :: v -> v Source #

(^+^) :: v -> v -> v infixl 5 Source #

(^-^) :: v -> v -> v infixl 5 Source #

Instances
RModule Double Source # 
Instance details

Defined in Data.VectorSpace

Associated Types

type Groundring Double :: Type Source #

RModule Float Source # 
Instance details

Defined in Data.VectorSpace

Associated Types

type Groundring Float :: Type Source #

RModule Int Source # 
Instance details

Defined in Data.VectorSpace

Associated Types

type Groundring Int :: Type Source #

RModule Integer Source # 
Instance details

Defined in Data.VectorSpace

Associated Types

type Groundring Integer :: Type Source #

Num a => RModule (FractionalVectorSpace a) Source # 
Instance details

Defined in Data.VectorSpace

Associated Types

type Groundring (FractionalVectorSpace a) :: Type Source #

(Groundring a ~ Groundring b, RModule a, RModule b) => RModule (a, b) Source # 
Instance details

Defined in Data.VectorSpace

Associated Types

type Groundring (a, b) :: Type Source #

Methods

zeroVector :: (a, b) Source #

(*^) :: Groundring (a, b) -> (a, b) -> (a, b) Source #

(^*) :: (a, b) -> Groundring (a, b) -> (a, b) Source #

negateVector :: (a, b) -> (a, b) Source #

(^+^) :: (a, b) -> (a, b) -> (a, b) Source #

(^-^) :: (a, b) -> (a, b) -> (a, b) Source #

(Groundring a ~ Groundring b, Groundring a ~ Groundring c, RModule a, RModule b, RModule c) => RModule (a, b, c) Source # 
Instance details

Defined in Data.VectorSpace

Associated Types

type Groundring (a, b, c) :: Type Source #

Methods

zeroVector :: (a, b, c) Source #

(*^) :: Groundring (a, b, c) -> (a, b, c) -> (a, b, c) Source #

(^*) :: (a, b, c) -> Groundring (a, b, c) -> (a, b, c) Source #

negateVector :: (a, b, c) -> (a, b, c) Source #

(^+^) :: (a, b, c) -> (a, b, c) -> (a, b, c) Source #

(^-^) :: (a, b, c) -> (a, b, c) -> (a, b, c) Source #

(Monad m, RModule v) => RModule (MSF m a v) Source #

R-module instance for MSFs.

Instance details

Defined in Data.MonadicStreamFunction.Instances.VectorSpace

Associated Types

type Groundring (MSF m a v) :: Type Source #

Methods

zeroVector :: MSF m a v Source #

(*^) :: Groundring (MSF m a v) -> MSF m a v -> MSF m a v Source #

(^*) :: MSF m a v -> Groundring (MSF m a v) -> MSF m a v Source #

negateVector :: MSF m a v -> MSF m a v Source #

(^+^) :: MSF m a v -> MSF m a v -> MSF m a v Source #

(^-^) :: MSF m a v -> MSF m a v -> MSF m a v Source #

(Groundring a ~ Groundring b, Groundring a ~ Groundring c, Groundring a ~ Groundring d, RModule a, RModule b, RModule c, RModule d) => RModule (a, b, c, d) Source # 
Instance details

Defined in Data.VectorSpace

Associated Types

type Groundring (a, b, c, d) :: Type Source #

Methods

zeroVector :: (a, b, c, d) Source #

(*^) :: Groundring (a, b, c, d) -> (a, b, c, d) -> (a, b, c, d) Source #

(^*) :: (a, b, c, d) -> Groundring (a, b, c, d) -> (a, b, c, d) Source #

negateVector :: (a, b, c, d) -> (a, b, c, d) Source #

(^+^) :: (a, b, c, d) -> (a, b, c, d) -> (a, b, c, d) Source #

(^-^) :: (a, b, c, d) -> (a, b, c, d) -> (a, b, c, d) Source #

(Groundring a ~ Groundring b, Groundring a ~ Groundring c, Groundring a ~ Groundring d, Groundring a ~ Groundring e, RModule a, RModule b, RModule c, RModule d, RModule e) => RModule (a, b, c, d, e) Source # 
Instance details

Defined in Data.VectorSpace

Associated Types

type Groundring (a, b, c, d, e) :: Type Source #

Methods

zeroVector :: (a, b, c, d, e) Source #

(*^) :: Groundring (a, b, c, d, e) -> (a, b, c, d, e) -> (a, b, c, d, e) Source #

(^*) :: (a, b, c, d, e) -> Groundring (a, b, c, d, e) -> (a, b, c, d, e) Source #

negateVector :: (a, b, c, d, e) -> (a, b, c, d, e) Source #

(^+^) :: (a, b, c, d, e) -> (a, b, c, d, e) -> (a, b, c, d, e) Source #

(^-^) :: (a, b, c, d, e) -> (a, b, c, d, e) -> (a, b, c, d, e) Source #

class (Fractional (Groundring v), RModule v) => VectorSpace v where Source #

A vector space is a module over a field, i.e. a commutative ring with inverses.

It needs to satisfy the axiom v ^ a == (1a) *^ v, which is the default implementation.

Minimal complete definition

Nothing

Methods

(^/) :: v -> Groundfield v -> v infixl 6 Source #

Instances
VectorSpace Double Source # 
Instance details

Defined in Data.VectorSpace

VectorSpace Float Source # 
Instance details

Defined in Data.VectorSpace

Fractional a => VectorSpace (FractionalVectorSpace a) Source # 
Instance details

Defined in Data.VectorSpace

(Groundfield a ~ Groundfield b, VectorSpace a, VectorSpace b) => VectorSpace (a, b) Source # 
Instance details

Defined in Data.VectorSpace

Methods

(^/) :: (a, b) -> Groundfield (a, b) -> (a, b) Source #

(Groundring a ~ Groundring b, Groundring a ~ Groundring c, VectorSpace a, VectorSpace b, VectorSpace c) => VectorSpace (a, b, c) Source # 
Instance details

Defined in Data.VectorSpace

Methods

(^/) :: (a, b, c) -> Groundfield (a, b, c) -> (a, b, c) Source #

(Monad m, VectorSpace v) => VectorSpace (MSF m a v) Source #

Vector-space instance for MSFs.

Instance details

Defined in Data.MonadicStreamFunction.Instances.VectorSpace

Methods

(^/) :: MSF m a v -> Groundfield (MSF m a v) -> MSF m a v Source #

(Groundring a ~ Groundring b, Groundring a ~ Groundring c, Groundring a ~ Groundring d, VectorSpace a, VectorSpace b, VectorSpace c, VectorSpace d) => VectorSpace (a, b, c, d) Source # 
Instance details

Defined in Data.VectorSpace

Methods

(^/) :: (a, b, c, d) -> Groundfield (a, b, c, d) -> (a, b, c, d) Source #

(Groundring a ~ Groundring b, Groundring a ~ Groundring c, Groundring a ~ Groundring d, Groundring a ~ Groundring e, VectorSpace a, VectorSpace b, VectorSpace c, VectorSpace d, VectorSpace e) => VectorSpace (a, b, c, d, e) Source # 
Instance details

Defined in Data.VectorSpace

Methods

(^/) :: (a, b, c, d, e) -> Groundfield (a, b, c, d, e) -> (a, b, c, d, e) Source #

type Groundfield v = Groundring v Source #

The ground ring of a vector space is required to be commutative and to possess inverses. It is then called the "ground field". Commutativity amounts to the law a * b = b * a, and the existence of inverses is given by the requirement of the Fractional type class.

class RModule v => InnerProductSpace v where Source #

An inner product space is a module with an inner product, i.e. a map dot satisfying

Methods

dot :: v -> v -> Groundfield v infix 6 Source #

Instances
Num a => InnerProductSpace (FractionalVectorSpace a) Source # 
Instance details

Defined in Data.VectorSpace

(Groundfield a ~ Groundfield b, InnerProductSpace a, InnerProductSpace b) => InnerProductSpace (a, b) Source # 
Instance details

Defined in Data.VectorSpace

Methods

dot :: (a, b) -> (a, b) -> Groundfield (a, b) Source #

(Groundring a ~ Groundring b, Groundring a ~ Groundring c, InnerProductSpace a, InnerProductSpace b, InnerProductSpace c) => InnerProductSpace (a, b, c) Source # 
Instance details

Defined in Data.VectorSpace

Methods

dot :: (a, b, c) -> (a, b, c) -> Groundfield (a, b, c) Source #

(Groundring a ~ Groundring b, Groundring a ~ Groundring c, Groundring a ~ Groundring d, InnerProductSpace a, InnerProductSpace b, InnerProductSpace c, InnerProductSpace d) => InnerProductSpace (a, b, c, d) Source # 
Instance details

Defined in Data.VectorSpace

Methods

dot :: (a, b, c, d) -> (a, b, c, d) -> Groundfield (a, b, c, d) Source #

(Groundring a ~ Groundring b, Groundring a ~ Groundring c, Groundring a ~ Groundring d, Groundring a ~ Groundring e, InnerProductSpace a, InnerProductSpace b, InnerProductSpace c, InnerProductSpace d, InnerProductSpace e) => InnerProductSpace (a, b, c, d, e) Source # 
Instance details

Defined in Data.VectorSpace

Methods

dot :: (a, b, c, d, e) -> (a, b, c, d, e) -> Groundfield (a, b, c, d, e) Source #

class (Floating (Groundfield v), InnerProductSpace v, VectorSpace v) => NormedSpace v where Source #

A normed space is a module with a norm, i.e. a function norm satisfying

  • norm (a ^* v) = a ^* norm v
  • norm (v1 ^+^ v2) <= norm v1 ^+^ norm v2 (the "triangle inequality")

A typical example is sqrt (v dot v), for an inner product space.

Minimal complete definition

Nothing

Methods

norm :: v -> Groundfield v Source #

Instances
Floating a => NormedSpace (FractionalVectorSpace a) Source # 
Instance details

Defined in Data.VectorSpace

(Groundfield a ~ Groundfield b, NormedSpace a, NormedSpace b) => NormedSpace (a, b) Source # 
Instance details

Defined in Data.VectorSpace

Methods

norm :: (a, b) -> Groundfield (a, b) Source #

(Groundring a ~ Groundring b, Groundring a ~ Groundring c, NormedSpace a, NormedSpace b, NormedSpace c) => NormedSpace (a, b, c) Source # 
Instance details

Defined in Data.VectorSpace

Methods

norm :: (a, b, c) -> Groundfield (a, b, c) Source #

(Groundring a ~ Groundring b, Groundring a ~ Groundring c, Groundring a ~ Groundring d, NormedSpace a, NormedSpace b, NormedSpace c, NormedSpace d) => NormedSpace (a, b, c, d) Source # 
Instance details

Defined in Data.VectorSpace

Methods

norm :: (a, b, c, d) -> Groundfield (a, b, c, d) Source #

(Groundring a ~ Groundring b, Groundring a ~ Groundring c, Groundring a ~ Groundring d, Groundring a ~ Groundring e, NormedSpace a, NormedSpace b, NormedSpace c, NormedSpace d, NormedSpace e) => NormedSpace (a, b, c, d, e) Source # 
Instance details

Defined in Data.VectorSpace

Methods

norm :: (a, b, c, d, e) -> Groundfield (a, b, c, d, e) Source #

normalize :: (Eq (Groundfield v), NormedSpace v) => v -> v Source #

Divides a vector by its norm, resulting in a vector of norm 1. Throws an error on vectors with norm 0.

Utilities to work with n-tuples for n = 3, 4, 5

break3Tuple :: (a, b, c) -> ((a, b), c) Source #

join3Tuple :: ((a, b), c) -> (a, b, c) Source #

break4Tuple :: (a, b, c, d) -> ((a, b), (c, d)) Source #

join4Tuple :: ((a, b), (c, d)) -> (a, b, c, d) Source #

break5Tuple :: (a, b, c, d, e) -> ((a, b), (c, d, e)) Source #

join5Tuple :: ((a, b), (c, d, e)) -> (a, b, c, d, e) Source #

Vector spaces from arbitrary Fractionals

newtype FractionalVectorSpace a Source #

Wrap an arbitrary Fractional in this newtype in order to get VectorSpace, and related instances.

Constructors

FractionalVectorSpace 

Fields

Instances
Fractional a => Fractional (FractionalVectorSpace a) Source # 
Instance details

Defined in Data.VectorSpace

Num a => Num (FractionalVectorSpace a) Source # 
Instance details

Defined in Data.VectorSpace

Floating a => NormedSpace (FractionalVectorSpace a) Source # 
Instance details

Defined in Data.VectorSpace

Num a => InnerProductSpace (FractionalVectorSpace a) Source # 
Instance details

Defined in Data.VectorSpace

Fractional a => VectorSpace (FractionalVectorSpace a) Source # 
Instance details

Defined in Data.VectorSpace

Num a => RModule (FractionalVectorSpace a) Source # 
Instance details

Defined in Data.VectorSpace

Associated Types

type Groundring (FractionalVectorSpace a) :: Type Source #

type Groundring (FractionalVectorSpace a) Source # 
Instance details

Defined in Data.VectorSpace