linear-accelerate-0.4: Lifting linear vector spaces into Accelerate

Copyright2014 Edward Kmett Charles Durham
2015 Trevor L. McDonell
LicenseBSD-style (see the file LICENSE)
MaintainerEdward Kmett <ekmett@gmail.com>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell98

Data.Array.Accelerate.Linear.Vector

Description

Operations on free vector spaces

Synopsis

Documentation

>>> import Data.Array.Accelerate.Linear.V2 ()
>>> import Linear.V2

class Additive f => Additive f where Source #

A vector is an additive group with additional structure.

TODO: Support both Exp and Acc

Methods

zero :: (Elt (f a), Num a) => Exp (f a) Source #

The zero vector

(^+^) :: forall a. (Num a, Box f a) => Exp (f a) -> Exp (f a) -> Exp (f a) infixl 6 Source #

Compute the sum of two vectors

>>> lift (V2 1 2 :: V2 Int) ^+^ lift (V2 3 4 :: V2 Int)
(4,6)

(^-^) :: forall a. (Num a, Box f a) => Exp (f a) -> Exp (f a) -> Exp (f a) infixl 6 Source #

Compute the difference between two vectors

>>> lift (V2 4 5 :: V2 Int) ^-^ lift (V2 3 1 :: V2 Int)
(1,4)

lerp :: forall a. (Num a, Box f a) => Exp a -> Exp (f a) -> Exp (f a) -> Exp (f a) Source #

Linearly interpolate between two vectors

type IsAdditive f a = (Additive f, Box f a) Source #

newtype E t Source #

Basis element

Constructors

E 

Fields

negated :: forall f a. (Functor f, Num a, Box f a) => Exp (f a) -> Exp (f a) Source #

Compute the negation of a vector

>>> negated (lift (V2 2 4 :: V2 Int))
(-2,-4)

(*^) :: forall f a. (Functor f, Num a, Box f a) => Exp a -> Exp (f a) -> Exp (f a) infixl 7 Source #

Compute the left scalar product

>>> 2 *^ lift (V2 3 4 :: V2 Int)
(6,8)

(^*) :: forall f a. (Functor f, Num a, Box f a) => Exp (f a) -> Exp a -> Exp (f a) infixl 7 Source #

Compute the right scalar product

>>> lift (V2 3 4 :: V2 Int) ^* 2
(6,8)

(^/) :: forall f a. (Functor f, Fractional a, Box f a) => Exp (f a) -> Exp a -> Exp (f a) infixl 7 Source #

Compute division by a scalar on the right

lift (V2 4 6 :: V2 Double) ^/ 2 V2 2 3

(/^) :: forall f a. (Functor f, Fractional a, Box f a) => Exp a -> Exp (f a) -> Exp (f a) infixl 7 Source #

Compute division of a scalar on the left

>>> 4 /^ lift (V2 2 4 :: V2 Double)
(2.0,1.0)

(+^) :: forall f a. (Functor f, Num a, Box f a) => Exp a -> Exp (f a) -> Exp (f a) infixl 6 Source #

Addition with a scalar on the left

>>> 2 +^ lift (V2 3 4 :: V2 Int)
(5,6)

(^+) :: forall f a. (Functor f, Num a, Box f a) => Exp (f a) -> Exp a -> Exp (f a) infixl 6 Source #

Addition with a scalar on the right

>>> lift (V2 1 2 :: V2 Int) ^+ 3
(4,5)

(-^) :: forall f a. (Functor f, Num a, Box f a) => Exp a -> Exp (f a) -> Exp (f a) infixl 6 Source #

Subtraction with a scalar on the left

>>> 2 -^ lift (V2 3 4 :: V2 Int)
(-1,-2)

(^-) :: forall f a. (Functor f, Num a, Box f a) => Exp (f a) -> Exp a -> Exp (f a) infixl 6 Source #

Subtraction with a scalar on the right

>>> lift (V2 1 2 :: V2 Int) ^- 3
(-2,-1)