-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Linear Algebra
--
-- Types and combinators for low-dimension-count linear algebra on free
-- vector spaces
@package linear
@version 0.4.1
-- | Operations on free vector spaces.
module Linear.Vector
-- | Compute the sum of two vectors
(^+^) :: (Applicative f, Num a) => f a -> f a -> f a
-- | Compute the negation of a vector
gnegate :: (Functor f, Num a) => f a -> f a
-- | Compute the difference between two vectors
(^-^) :: (Applicative f, Num a) => f a -> f a -> f a
-- | Compute the right scalar product
(^*) :: (Functor f, Num a) => f a -> a -> f a
-- | Compute the left scalar product
(*^) :: (Functor f, Num a) => a -> f a -> f a
-- | Compute division by a scalar on the right.
(^/) :: (Functor f, Fractional a) => f a -> a -> f a
-- | Linearly interpolate between two vectors.
lerp :: (Applicative f, Num a) => a -> f a -> f a -> f a
-- | Produce a default basis for a vector space. If the dimensionality of
-- the vector space is not statically known, see basisFor.
basis :: (Applicative t, Traversable t, Num a) => [t a]
-- | Produce a default basis for a vector space from which the argument is
-- drawn.
basisFor :: (Traversable t, Enum a, Num a) => t a -> [t a]
module Linear.Epsilon
-- | Provides a fairly subjective test to see if a quantity is near zero.
class Num a => Epsilon a
nearZero :: Epsilon a => a -> Bool
instance Epsilon Double
instance Epsilon Float
module Linear.Metric
-- | A free inner product/metric space
class Applicative f => Metric f where quadrance v = dot v v qd f g = quadrance (liftA2 (-) f g) distance f g = norm (liftA2 (-) f g) norm v = sqrt (dot v v) signorm v = fmap (/ m) v where m = norm v
dot :: (Metric f, Num a) => f a -> f a -> a
quadrance :: (Metric f, Num a) => f a -> a
qd :: (Metric f, Num a) => f a -> f a -> a
distance :: (Metric f, Floating a) => f a -> f a -> a
norm :: (Metric f, Floating a) => f a -> a
signorm :: (Metric f, Floating a) => f a -> f a
-- | Normalize a Metric functor to have unit norm. This
-- function does not change the functor if its norm is 0 or 1.
normalize :: (Floating a, Metric f, Epsilon a) => f a -> f a
module Linear.V2
-- | A 2-dimensional vector
data V2 a
V2 :: a -> a -> V2 a
-- | A space that distinguishes 2 orthogonal basis vectors _x and
-- _y, but may have more.
class R2 t where _x = _xy . _x _y = _xy . _y
_x :: (R2 t, Functor f) => (a -> f a) -> t a -> f (t a)
_y :: (R2 t, Functor f) => (a -> f a) -> t a -> f (t a)
_xy :: (R2 t, Functor f) => (V2 a -> f (V2 a)) -> t a -> f (t a)
-- | the counter-clockwise perpendicular vector
perp :: Num a => V2 a -> V2 a
instance Typeable1 V2
instance Eq a => Eq (V2 a)
instance Ord a => Ord (V2 a)
instance Show a => Show (V2 a)
instance Read a => Read (V2 a)
instance Data a => Data (V2 a)
instance Storable a => Storable (V2 a)
instance Epsilon a => Epsilon (V2 a)
instance Distributive V2
instance Representable V2
instance R2 V2
instance Metric V2
instance Fractional a => Fractional (V2 a)
instance Num a => Num (V2 a)
instance Monad V2
instance Applicative V2
instance Traversable V2
instance Foldable V2
instance Functor V2
module Linear.V3
-- | A 3-dimensional vector
data V3 a
V3 :: a -> a -> a -> V3 a
-- | cross product
cross :: Num a => V3 a -> V3 a -> V3 a
-- | scalar triple product
triple :: Num a => V3 a -> V3 a -> V3 a -> a
-- | A space that distinguishes 2 orthogonal basis vectors _x and
-- _y, but may have more.
class R2 t where _x = _xy . _x _y = _xy . _y
_x :: (R2 t, Functor f) => (a -> f a) -> t a -> f (t a)
_y :: (R2 t, Functor f) => (a -> f a) -> t a -> f (t a)
_xy :: (R2 t, Functor f) => (V2 a -> f (V2 a)) -> t a -> f (t a)
-- | A space that distinguishes 3 orthogonal basis vectors: _x,
-- _y, and _z. (It may have more)
class R2 t => R3 t
_z :: (R3 t, Functor f) => (a -> f a) -> t a -> f (t a)
_xyz :: (R3 t, Functor f) => (V3 a -> f (V3 a)) -> t a -> f (t a)
instance Typeable1 V3
instance Eq a => Eq (V3 a)
instance Ord a => Ord (V3 a)
instance Show a => Show (V3 a)
instance Read a => Read (V3 a)
instance Data a => Data (V3 a)
instance Epsilon a => Epsilon (V3 a)
instance Storable a => Storable (V3 a)
instance Representable V3
instance R3 V3
instance R2 V3
instance Distributive V3
instance Metric V3
instance Fractional a => Fractional (V3 a)
instance Num a => Num (V3 a)
instance Monad V3
instance Applicative V3
instance Traversable V3
instance Foldable V3
instance Functor V3
module Linear.V4
-- | A 4-dimensional vector.
data V4 a
V4 :: a -> a -> a -> a -> V4 a
-- | Convert a 3-dimensional affine vector into a 4-dimensional homogeneous
-- vector.
vector :: Num a => V3 a -> V4 a
-- | Convert a 3-dimensional affine point into a 4-dimensional homogeneous
-- vector.
point :: Num a => V3 a -> V4 a
-- | A space that distinguishes 2 orthogonal basis vectors _x and
-- _y, but may have more.
class R2 t where _x = _xy . _x _y = _xy . _y
_x :: (R2 t, Functor f) => (a -> f a) -> t a -> f (t a)
_y :: (R2 t, Functor f) => (a -> f a) -> t a -> f (t a)
_xy :: (R2 t, Functor f) => (V2 a -> f (V2 a)) -> t a -> f (t a)
-- | A space that distinguishes 3 orthogonal basis vectors: _x,
-- _y, and _z. (It may have more)
class R2 t => R3 t
_z :: (R3 t, Functor f) => (a -> f a) -> t a -> f (t a)
_xyz :: (R3 t, Functor f) => (V3 a -> f (V3 a)) -> t a -> f (t a)
-- | A space that distinguishes orthogonal basis vectors _x,
-- _y, _z, _w. (It may have more.)
class R3 t => R4 t
_w :: (R4 t, Functor f) => (a -> f a) -> t a -> f (t a)
_xyzw :: (R4 t, Functor f) => (V4 a -> f (V4 a)) -> t a -> f (t a)
instance Typeable1 V4
instance Eq a => Eq (V4 a)
instance Ord a => Ord (V4 a)
instance Show a => Show (V4 a)
instance Read a => Read (V4 a)
instance Data a => Data (V4 a)
instance Epsilon a => Epsilon (V4 a)
instance Storable a => Storable (V4 a)
instance Representable V4
instance R4 V4
instance R3 V4
instance R2 V4
instance Distributive V4
instance Metric V4
instance Fractional a => Fractional (V4 a)
instance Num a => Num (V4 a)
instance Monad V4
instance Applicative V4
instance Traversable V4
instance Foldable V4
instance Functor V4
module Linear.Plucker
-- | Plücker coordinates for lines in a 3-dimensional space.
data Plucker a
Plucker :: a -> a -> a -> a -> a -> a -> Plucker a
-- | Valid Plücker coordinates p will have squaredError
-- p == 0
--
-- That said, floating point makes a mockery of this claim, so you may
-- want to use nearZero.
squaredError :: (Eq a, Num a) => Plucker a -> a
-- | Checks if the line is near-isotropic (isotropic vectors in this
-- quadratic space represent lines in real 3d space)
isotropic :: Epsilon a => Plucker a -> Bool
-- | This isn't th actual metric because this bilinear form gives rise to
-- an isotropic quadratic space
(><) :: Num a => Plucker a -> Plucker a -> a
-- | Given a pair of points represented by homogeneous coordinates generate
-- Plücker coordinates for the line through them.
plucker :: Num a => V4 a -> V4 a -> Plucker a
-- | Checks if the two vectors intersect (or nearly intersect)
intersects :: Epsilon a => Plucker a -> Plucker a -> Bool
instance Eq a => Eq (Plucker a)
instance Ord a => Ord (Plucker a)
instance Show a => Show (Plucker a)
instance Read a => Read (Plucker a)
instance Epsilon a => Epsilon (Plucker a)
instance Metric Plucker
instance Fractional a => Fractional (Plucker a)
instance Num a => Num (Plucker a)
instance Traversable Plucker
instance Foldable Plucker
instance Representable Plucker
instance Distributive Plucker
instance Monad Plucker
instance Applicative Plucker
instance Functor Plucker
module Linear.Conjugate
-- | An involutive ring
class Num a => Conjugate a where conjugate = id
conjugate :: Conjugate a => a -> a
instance (Conjugate a, RealFloat a) => Conjugate (Complex a)
instance Conjugate Float
instance Conjugate Double
module Linear.Quaternion
data Quaternion a
Quaternion :: a -> {-# UNPACK #-} !(V3 a) -> Quaternion a
class Complicated t
_e :: (Complicated t, Functor f) => (a -> f a) -> t a -> f (t a)
_i :: (Complicated t, Functor f) => (a -> f a) -> t a -> f (t a)
class Complicated t => Hamiltonian t
_j :: (Hamiltonian t, Functor f) => (a -> f a) -> t a -> f (t a)
_k :: (Hamiltonian t, Functor f) => (a -> f a) -> t a -> f (t a)
_ijk :: (Hamiltonian t, Functor f) => (V3 a -> f (V3 a)) -> t a -> f (t a)
-- | Spherical linear interpolation between two quaternions.
slerp :: RealFloat a => Quaternion a -> Quaternion a -> a -> Quaternion a
-- | asin with a specified branch cut.
asinq :: RealFloat a => Quaternion a -> Quaternion a -> Quaternion a
-- | acos with a specified branch cut.
acosq :: RealFloat a => Quaternion a -> Quaternion a -> Quaternion a
-- | atan with a specified branch cut.
atanq :: RealFloat a => Quaternion a -> Quaternion a -> Quaternion a
-- | asinh with a specified branch cut.
asinhq :: RealFloat a => Quaternion a -> Quaternion a -> Quaternion a
-- | acosh with a specified branch cut.
acoshq :: RealFloat a => Quaternion a -> Quaternion a -> Quaternion a
-- | atanh with a specified branch cut.
atanhq :: RealFloat a => Quaternion a -> Quaternion a -> Quaternion a
-- | norm of the imaginary component
absi :: Floating a => Quaternion a -> a
-- | raise a Quaternion to a scalar power
pow :: RealFloat a => Quaternion a -> a -> Quaternion a
-- | Apply a rotation to a vector.
rotate :: (Conjugate a, RealFloat a) => Quaternion a -> V3 a -> V3 a
-- | axisAngle axis theta builds a Quaternion
-- representing a rotation of theta radians about axis.
axisAngle :: (Epsilon a, Floating a) => V3 a -> a -> Quaternion a
instance Typeable1 Quaternion
instance Eq a => Eq (Quaternion a)
instance Ord a => Ord (Quaternion a)
instance Read a => Read (Quaternion a)
instance Show a => Show (Quaternion a)
instance Data a => Data (Quaternion a)
instance (RealFloat a, Epsilon a) => Epsilon (Quaternion a)
instance RealFloat a => Floating (Quaternion a)
instance (Conjugate a, RealFloat a) => Conjugate (Quaternion a)
instance Distributive Quaternion
instance Hamiltonian Quaternion
instance Complicated Quaternion
instance Complicated Complex
instance Metric Quaternion
instance RealFloat a => Fractional (Quaternion a)
instance RealFloat a => Num (Quaternion a)
instance Storable a => Storable (Quaternion a)
instance Traversable Quaternion
instance Foldable Quaternion
instance Representable Quaternion
instance Monad Quaternion
instance Applicative Quaternion
instance Functor Quaternion
module Linear.Matrix
-- | matrix product
(!*!) :: (Functor m, Foldable r, Applicative r, Distributive n, Num a) => m (r a) -> r (n a) -> m (n a)
-- | matrix * column vector
(!*) :: (Functor m, Metric r, Num a) => m (r a) -> r a -> m a
-- | row vector * matrix
(*!) :: (Metric r, Distributive n, Num a) => r a -> r (n a) -> n a
-- | hermitian conjugate or conjugate transpose
adjoint :: (Functor m, Distributive n, Conjugate a) => m (n a) -> n (m a)
-- | Matrices use a row-major representation.
type M33 a = V3 (V3 a)
type M44 a = V4 (V4 a)
type M43 a = V4 (V3 a)
m33_to_m44 :: Num a => M33 a -> M44 a
m43_to_m44 :: Num a => M43 a -> M44 a
-- | 3x3 identity matrix.
eye3 :: Num a => M33 a
-- | 4x4 identity matrix.
eye4 :: Num a => M44 a
-- | Compute the trace of a matrix
trace :: (Monad f, Foldable f, Num a) => f (f a) -> a
-- | Extract the translation vector (first three entries of the last
-- column) from a 3x4 or 4x4 matrix
translation :: (R3 t, R4 v, Functor f, Functor t) => (V3 a -> f (V3 a)) -> t (v a) -> f (t a)
-- | Build a rotation matrix from a unit Quaternion.
fromQuaternion :: Num a => Quaternion a -> M33 a
-- | Build a transformation matrix from a rotation expressed as a
-- Quaternion and a translation vector.
mkTransformation :: Num a => Quaternion a -> V3 a -> M44 a
-- | This module simply re-exports everything from the various modules that
-- make up the linear package.
module Linear