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

Copyright2014 Edward Kmett Charles Durham
[2015..2020] Trevor L. McDonell
LicenseBSD-style (see the file LICENSE)
MaintainerTrevor L. McDonell <trevor.mcdonell@gmail.com>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Data.Array.Accelerate.Linear.Vector

Description

Operations on free vector spaces

Synopsis

Documentation

>>> :set -XPatternSynonyms
>>> import Linear.V2
>>> import Data.Array.Accelerate.Linear.V2 ( pattern V2_ )
>>> import Data.Array.Accelerate.Interpreter
>>> :{
  let test :: Elt e => Exp e -> e
      test e = indexArray (run (unit e)) Z
:}

class Additive f => Additive f where Source #

A vector is an additive group with additional structure.

TODO: Support both Exp and Acc

Minimal complete definition

Nothing

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

>>> test $ (V2_ 1 2 :: Exp (V2 Int)) ^+^ (V2_ 3 4 :: Exp (V2 Int))
V2 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

>>> test $ (V2_ 4 5 :: Exp (V2 Int)) ^-^ (V2_ 3 1 :: Exp (V2 Int))
V2 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

Instances
Additive Plucker Source # 
Instance details

Defined in Data.Array.Accelerate.Linear.Plucker

Methods

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

(^+^) :: (Num a, Box Plucker a) => Exp (Plucker a) -> Exp (Plucker a) -> Exp (Plucker a) Source #

(^-^) :: (Num a, Box Plucker a) => Exp (Plucker a) -> Exp (Plucker a) -> Exp (Plucker a) Source #

lerp :: (Num a, Box Plucker a) => Exp a -> Exp (Plucker a) -> Exp (Plucker a) -> Exp (Plucker a) Source #

Additive Quaternion Source # 
Instance details

Defined in Data.Array.Accelerate.Linear.Quaternion

Methods

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

(^+^) :: (Num a, Box Quaternion a) => Exp (Quaternion a) -> Exp (Quaternion a) -> Exp (Quaternion a) Source #

(^-^) :: (Num a, Box Quaternion a) => Exp (Quaternion a) -> Exp (Quaternion a) -> Exp (Quaternion a) Source #

lerp :: (Num a, Box Quaternion a) => Exp a -> Exp (Quaternion a) -> Exp (Quaternion a) -> Exp (Quaternion a) Source #

Additive V0 Source # 
Instance details

Defined in Data.Array.Accelerate.Linear.V0

Methods

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

(^+^) :: (Num a, Box V0 a) => Exp (V0 a) -> Exp (V0 a) -> Exp (V0 a) Source #

(^-^) :: (Num a, Box V0 a) => Exp (V0 a) -> Exp (V0 a) -> Exp (V0 a) Source #

lerp :: (Num a, Box V0 a) => Exp a -> Exp (V0 a) -> Exp (V0 a) -> Exp (V0 a) Source #

Additive V4 Source # 
Instance details

Defined in Data.Array.Accelerate.Linear.V4

Methods

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

(^+^) :: (Num a, Box V4 a) => Exp (V4 a) -> Exp (V4 a) -> Exp (V4 a) Source #

(^-^) :: (Num a, Box V4 a) => Exp (V4 a) -> Exp (V4 a) -> Exp (V4 a) Source #

lerp :: (Num a, Box V4 a) => Exp a -> Exp (V4 a) -> Exp (V4 a) -> Exp (V4 a) Source #

Additive V3 Source # 
Instance details

Defined in Data.Array.Accelerate.Linear.V3

Methods

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

(^+^) :: (Num a, Box V3 a) => Exp (V3 a) -> Exp (V3 a) -> Exp (V3 a) Source #

(^-^) :: (Num a, Box V3 a) => Exp (V3 a) -> Exp (V3 a) -> Exp (V3 a) Source #

lerp :: (Num a, Box V3 a) => Exp a -> Exp (V3 a) -> Exp (V3 a) -> Exp (V3 a) Source #

Additive V2 Source # 
Instance details

Defined in Data.Array.Accelerate.Linear.V2

Methods

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

(^+^) :: (Num a, Box V2 a) => Exp (V2 a) -> Exp (V2 a) -> Exp (V2 a) Source #

(^-^) :: (Num a, Box V2 a) => Exp (V2 a) -> Exp (V2 a) -> Exp (V2 a) Source #

lerp :: (Num a, Box V2 a) => Exp a -> Exp (V2 a) -> Exp (V2 a) -> Exp (V2 a) Source #

Additive V1 Source # 
Instance details

Defined in Data.Array.Accelerate.Linear.V1

Methods

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

(^+^) :: (Num a, Box V1 a) => Exp (V1 a) -> Exp (V1 a) -> Exp (V1 a) Source #

(^-^) :: (Num a, Box V1 a) => Exp (V1 a) -> Exp (V1 a) -> Exp (V1 a) Source #

lerp :: (Num a, Box V1 a) => Exp a -> Exp (V1 a) -> Exp (V1 a) -> Exp (V1 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

>>> test $ negated (V2_ 2 4 :: Exp (V2 Int))
V2 (-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

>>> test $ 2 *^ (V2_ 3 4 :: Exp (V2 Int))
V2 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

>>> test $ (V2_ 3 4 :: Exp (V2 Int)) ^* 2
V2 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

>>> test $ (V2_ 4 6 :: Exp (V2 Double)) ^/ 2
V2 2.0 3.0

(/^) :: 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

>>> test $ 4 /^ (V2_ 2 4 :: Exp (V2 Double))
V2 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

>>> test $ 2 +^ (V2_ 3 4 :: Exp (V2 Int))
V2 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

>>> test $ (V2_ 1 2 :: Exp (V2 Int)) ^+ 3
V2 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

>>> test $ 2 -^ (V2_ 3 4 :: Exp (V2 Int))
V2 (-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

>>> test $ (V2_ 1 2 :: Exp (V2 Int)) ^- 3
V2 (-2) (-1)