Module
Linear.Vector
- Package
- purescript-linear
- Repository
- afcondon/purescript-linear
The Additive typeclass for vector spaces.
This module provides the foundational Additive typeclass that represents
vectors as an additive group, along with scalar multiplication operations.
#Additive Source
class Additive :: (Type -> Type) -> Constraintclass (Functor f) <= Additive f where
A vector space with addition and scalar multiplication.
Laws:
add zero v = v(left identity)add v zero = v(right identity)add (add u v) w = add u (add v w)(associativity)add u v = add v u(commutativity)sub v v = zero
Members
zero :: forall a. Semiring a => f aadd :: forall a. Semiring a => f a -> f a -> f aVector addition
sub :: forall a. Ring a => f a -> f a -> f aVector subtraction
lerp :: forall a. Ring a => a -> f a -> f a -> f aLinear interpolation:
lerp t a b = a + t * (b - a)lerp 0.0 a b = alerp 1.0 a b = b
liftU2 :: forall a. (a -> a -> a) -> f a -> f a -> f aApply a function to non-zero values (union semantics)
liftI2 :: forall a b c. (a -> b -> c) -> f a -> f b -> f cApply a function component-wise (intersection semantics)
#scalarDiv Source
scalarDiv :: forall f a. Functor f => EuclideanRing a => f a -> a -> f aRight scalar division
V2 6.0 9.0 ^/ 3.0 = V2 2.0 3.0
The zero vector