vect-floating-0.1.0.3: A low-dimensional linear algebra library, operating on the Floating typeclass

Data.Vect.Floating.Base

Synopsis

Documentation

class AbelianGroup g whereSource

Methods

(&+) :: g -> g -> gSource

(&-) :: g -> g -> gSource

neg :: g -> gSource

zero :: gSource

Instances

 Floating a => AbelianGroup (Mat4 a) Floating a => AbelianGroup (Mat3 a) Floating a => AbelianGroup (Mat2 a) Floating a => AbelianGroup (Vec4 a) Floating a => AbelianGroup (Vec3 a) Floating a => AbelianGroup (Vec2 a) Floating a => AbelianGroup (Quaternion a)

vecSum :: AbelianGroup g => [g] -> gSource

class MultSemiGroup r whereSource

Methods

(.*.) :: r -> r -> rSource

one :: rSource

Instances

 Floating a => MultSemiGroup (Proj4 a) Floating a => MultSemiGroup (Proj3 a) Floating a => MultSemiGroup (Ortho4 a) Floating a => MultSemiGroup (Ortho3 a) Floating a => MultSemiGroup (Ortho2 a) Floating a => MultSemiGroup (Mat4 a) Floating a => MultSemiGroup (Mat3 a) Floating a => MultSemiGroup (Mat2 a) Floating a => MultSemiGroup (UnitQuaternion a) Num a => MultSemiGroup (Quaternion a)

class (AbelianGroup r, MultSemiGroup r) => Ring r Source

Instances

 Floating a => Ring (Mat4 a) Floating a => Ring (Mat3 a) Floating a => Ring (Mat2 a)

class LeftModule r m whereSource

Methods

lmul :: r -> m -> mSource

(*.) :: r -> m -> mSource

Instances

 Floating a => LeftModule (Mat4 a) (Vec4 a) Floating a => LeftModule (Mat3 a) (Vec3 a) Floating a => LeftModule (Mat2 a) (Vec2 a) Num a => LeftModule (UnitQuaternion a) (Vec3 a)

class RightModule m r | m -> r, r -> m whereSource

Methods

rmul :: m -> r -> mSource

(.*) :: m -> r -> mSource

Instances

 Floating a => RightModule (Vec4 a) (Mat4 a) Floating a => RightModule (Vec3 a) (Mat3 a) Floating a => RightModule (Vec2 a) (Mat2 a)

class AbelianGroup (v a) => Vector a v whereSource

Methods

mapVec :: (a -> a) -> v a -> v aSource

scalarMul :: a -> v a -> v aSource

(*&) :: a -> v a -> v aSource

(&*) :: v a -> a -> v aSource

Instances

 Floating a => Vector a Mat4 Floating a => Vector a Vec4 Floating a => Vector a Mat3 Floating a => Vector a Vec3 Floating a => Vector a Mat2 Floating a => Vector a Vec2 Floating a => Vector a Quaternion

class Floating a => DotProd a v whereSource

Methods

(&.) :: v a -> v a -> aSource

norm :: v a -> aSource

normsqr :: v a -> aSource

len :: v a -> aSource

lensqr :: v a -> aSource

dotprod :: v a -> v a -> aSource

Instances

 Floating a => DotProd a Vec4 Floating a => DotProd a Vec3 Floating a => DotProd a Vec2 Floating a => DotProd a Normal4 Floating a => DotProd a Normal3 Floating a => DotProd a Normal2 Floating a => DotProd a UnitQuaternion Floating a => DotProd a Quaternion

class CrossProd v whereSource

Cross product

Methods

crossprod :: v -> v -> vSource

(&^) :: v -> v -> vSource

Instances

 Floating a => CrossProd (Normal3 a) Floating a => CrossProd (Vec3 a)

normalize :: (Vector a v, DotProd a v) => v a -> v aSource

distance :: (Vector a v, DotProd a v) => v a -> v a -> aSource

angle :: (Vector a v, DotProd a v) => v a -> v a -> aSource

the angle between two vectors

angle' :: (Vector a v, UnitVector a v u, DotProd a v) => u a -> u a -> aSource

the angle between two unit vectors

class (Vector a v, DotProd a v) => UnitVector a v u | u -> v, v -> u whereSource

Methods

Arguments

 :: v a -> u a normalizes the input

Arguments

 :: v a -> u a does not normalize the input!

fromNormal :: u a -> v aSource

fromNormalRadius :: a -> u a -> v aSource

Instances

 Floating a => UnitVector a Vec4 Normal4 Floating a => UnitVector a Vec3 Normal3 Floating a => UnitVector a Vec2 Normal2 Floating a => UnitVector a Quaternion UnitQuaternion

class Pointwise v whereSource

Pointwise multiplication

Methods

pointwise :: v -> v -> vSource

(&!) :: v -> v -> vSource

Instances

 Floating a => Pointwise (Mat4 a) Floating a => Pointwise (Mat3 a) Floating a => Pointwise (Mat2 a) Num a => Pointwise (Vec4 a) Num a => Pointwise (Vec3 a) Floating a => Pointwise (Vec2 a)

class Extend a u v whereSource

conversion between vectors (and matrices) of different dimensions

Methods

Arguments

 :: u a -> v a example: `extendZero (Vec2 5 6) = Vec4 5 6 0 0`

Arguments

 :: a -> u a -> v a example: `extendWith 1 (Vec2 5 6) = Vec4 5 6 1 1`

Arguments

 :: v a -> u a example: `trim (Vec4 5 6 7 8) = Vec2 5 6`

Instances

 Floating a => Extend a Mat3 Mat4 Floating a => Extend a Mat2 Mat4 Floating a => Extend a Mat2 Mat3 Floating a => Extend a Vec3 Vec4 Floating a => Extend a Vec2 Vec4 Floating a => Extend a Vec2 Vec3

class HasCoordinates v x | v -> x whereSource

Methods

_1 :: v -> xSource

_2 :: v -> xSource

_3 :: v -> xSource

_4 :: v -> xSource

Instances

 Floating a => HasCoordinates (Vec4 a) a Floating a => HasCoordinates (Vec3 a) a Floating a => HasCoordinates (Vec2 a) a Floating a => HasCoordinates (Mat4 a) (Vec4 a) Floating a => HasCoordinates (Mat3 a) (Vec3 a) Floating a => HasCoordinates (Mat2 a) (Vec2 a)

class Dimension a whereSource

Methods

dim :: a -> IntSource

Instances

 Floating a => Dimension (Ortho4 a) Floating a => Dimension (Ortho3 a) Floating a => Dimension (Ortho2 a) Floating a => Dimension (Normal4 a) Floating a => Dimension (Normal3 a) Floating a => Dimension (Normal2 a) Floating a => Dimension (Mat4 a) Floating a => Dimension (Mat3 a) Floating a => Dimension (Mat2 a) Floating a => Dimension (Vec4 a) Floating a => Dimension (Vec3 a) Floating a => Dimension (Vec2 a)

class Matrix m whereSource

Methods

transpose :: m -> mSource

inverse :: m -> mSource

idmtx :: mSource

Instances

 Floating a => Matrix (Proj4 a) Floating a => Matrix (Proj3 a) Floating a => Matrix (Ortho4 a) Floating a => Matrix (Ortho3 a) Floating a => Matrix (Ortho2 a) Floating a => Matrix (Mat4 a) Floating a => Matrix (Mat3 a) Floating a => Matrix (Mat2 a)

class Tensor t v | t -> v whereSource

Outer product (could be unified with Diagonal?)

Methods

outer :: v -> v -> tSource

Instances

 Floating a => Tensor (Mat4 a) (Vec4 a) Floating a => Tensor (Mat3 a) (Vec3 a) Floating a => Tensor (Mat2 a) (Vec2 a)

class Diagonal s t | t -> s whereSource

makes a diagonal matrix from a vector

Methods

diag :: s -> tSource

Instances

 Floating a => Diagonal (Vec4 a) (Mat4 a) Floating a => Diagonal (Vec3 a) (Mat3 a) Floating a => Diagonal (Vec2 a) (Mat2 a)

class Determinant a m whereSource

Methods

det :: m -> aSource

Instances

 Floating a => Determinant a (Ortho4 a) Floating a => Determinant a (Ortho3 a) Floating a => Determinant a (Ortho2 a) Floating a => Determinant a (Mat4 a) Floating a => Determinant a (Mat3 a) Floating a => Determinant a (Mat2 a) Floating a => Determinant a (Vec2 a, Vec2 a) Floating a => Determinant a (Vec3 a, Vec3 a, Vec3 a)

class Matrix (m a) => Orthogonal a m o | m -> o, o -> m whereSource

Methods

fromOrtho :: o a -> m aSource

toOrthoUnsafe :: m a -> o aSource

Instances

 Floating a => Orthogonal a Mat4 Ortho4 Floating a => Orthogonal a Mat3 Ortho3 Floating a => Orthogonal a Mat2 Ortho2

class (Vector a v, Orthogonal a n o, Diagonal (v a) (n a)) => Projective a v n o m p | m -> p, p -> m, p -> o, o -> p, p -> n, n -> p, p -> v, v -> p, n -> o, n -> v, v -> n whereSource

"Projective" matrices have the following form: the top left corner is an any matrix, the bottom right corner is 1, and the top-right column is zero. These describe the affine orthogonal transformation of the space one dimension less.

Methods

fromProjective :: p a -> m aSource

toProjectiveUnsafe :: m a -> p aSource

orthogonal :: o a -> p aSource

linear :: n a -> p aSource

translation :: v a -> p aSource

scaling :: v a -> p aSource

Instances

 Floating a => Projective a Vec3 Mat3 Ortho3 Mat4 Proj4 Floating a => Projective a Vec2 Mat2 Ortho2 Mat3 Proj3

class (AbelianGroup m, Matrix m) => MatrixNorms a m whereSource

Methods

Arguments

 :: m -> a the frobenius norm (= euclidean norm in the space of matrices)

Arguments

 :: m -> m -> a euclidean distance in the space of matrices

Arguments

 :: m -> a (euclidean) operator norm (not implemented yet)

Instances

 Floating a => MatrixNorms a (Mat4 a) Floating a => MatrixNorms a (Mat3 a) Floating a => MatrixNorms a (Mat2 a)

data Vec2 a Source

Constructors

 Vec2 !a !a

Instances

 Typeable1 Vec2 Floating a => DotProd a Vec2 Floating a => Vector a Vec2 Floating a => Extend a Vec2 Vec4 Floating a => Extend a Vec2 Vec3 Floating a => UnitVector a Vec2 Normal2 Floating a => Projective a Vec2 Mat2 Ortho2 Mat3 Proj3 Floating a => Interpolate a (Vec2 a) Floating a => Determinant a (Vec2 a, Vec2 a) Read a => Read (Vec2 a) Show a => Show (Vec2 a) (Floating a, Storable a) => Storable (Vec2 a) (Floating a, Random a) => Random (Vec2 a) Floating a => Dimension (Vec2 a) Floating a => Pointwise (Vec2 a) Floating a => AbelianGroup (Vec2 a) Floating a => HasCoordinates (Vec2 a) a Floating a => Tensor (Mat2 a) (Vec2 a) Floating a => Diagonal (Vec2 a) (Mat2 a) Floating a => HasCoordinates (Mat2 a) (Vec2 a) Floating a => RightModule (Vec2 a) (Mat2 a) Floating a => LeftModule (Mat2 a) (Vec2 a) Floating a => GramSchmidt (Vec2 a, Vec2 a)

data Vec3 a Source

Constructors

 Vec3 !a !a !a

Instances

 Typeable1 Vec3 Floating a => DotProd a Vec3 Floating a => Vector a Vec3 Floating a => Extend a Vec3 Vec4 Floating a => Extend a Vec2 Vec3 Floating a => UnitVector a Vec3 Normal3 Floating a => Projective a Vec3 Mat3 Ortho3 Mat4 Proj4 Floating a => Interpolate a (Vec3 a) Floating a => Determinant a (Vec3 a, Vec3 a, Vec3 a) Read a => Read (Vec3 a) Show a => Show (Vec3 a) (Floating a, Storable a) => Storable (Vec3 a) (Floating a, Random a) => Random (Vec3 a) Floating a => Dimension (Vec3 a) Num a => Pointwise (Vec3 a) Floating a => CrossProd (Vec3 a) Floating a => AbelianGroup (Vec3 a) Floating a => HasCoordinates (Vec3 a) a Floating a => Tensor (Mat3 a) (Vec3 a) Floating a => Diagonal (Vec3 a) (Mat3 a) Floating a => HasCoordinates (Mat3 a) (Vec3 a) Floating a => RightModule (Vec3 a) (Mat3 a) Floating a => LeftModule (Mat3 a) (Vec3 a) Num a => LeftModule (UnitQuaternion a) (Vec3 a) Floating a => GramSchmidt (Vec3 a, Vec3 a) Floating a => GramSchmidt (Vec3 a, Vec3 a, Vec3 a)

data Vec4 a Source

Constructors

 Vec4 !a !a !a !a

Instances

 Typeable1 Vec4 Floating a => DotProd a Vec4 Floating a => Vector a Vec4 Floating a => Extend a Vec3 Vec4 Floating a => Extend a Vec2 Vec4 Floating a => UnitVector a Vec4 Normal4 Floating a => Interpolate a (Vec4 a) Read a => Read (Vec4 a) Show a => Show (Vec4 a) (Floating a, Storable a) => Storable (Vec4 a) (Floating a, Random a) => Random (Vec4 a) Floating a => Dimension (Vec4 a) Num a => Pointwise (Vec4 a) Floating a => AbelianGroup (Vec4 a) Floating a => HasCoordinates (Vec4 a) a Floating a => Tensor (Mat4 a) (Vec4 a) Floating a => Diagonal (Vec4 a) (Mat4 a) Floating a => HasCoordinates (Mat4 a) (Vec4 a) Floating a => RightModule (Vec4 a) (Mat4 a) Floating a => LeftModule (Mat4 a) (Vec4 a) Floating a => GramSchmidt (Vec4 a, Vec4 a) Floating a => GramSchmidt (Vec4 a, Vec4 a, Vec4 a) Floating a => GramSchmidt (Vec4 a, Vec4 a, Vec4 a, Vec4 a)

data Mat2 a Source

The components are row vectors

Constructors

 Mat2 !(Vec2 a) !(Vec2 a)

Instances

 Floating a => Vector a Mat2 Floating a => Orthogonal a Mat2 Ortho2 Floating a => Extend a Mat2 Mat4 Floating a => Extend a Mat2 Mat3 Floating a => Projective a Vec2 Mat2 Ortho2 Mat3 Proj3 Floating a => Determinant a (Mat2 a) Floating a => MatrixNorms a (Mat2 a) Read a => Read (Mat2 a) Show a => Show (Mat2 a) (Floating a, Storable a) => Storable (Mat2 a) (Floating a, Random a) => Random (Mat2 a) Floating a => Dimension (Mat2 a) Floating a => Matrix (Mat2 a) Floating a => Pointwise (Mat2 a) Floating a => Ring (Mat2 a) Floating a => MultSemiGroup (Mat2 a) Floating a => AbelianGroup (Mat2 a) Floating a => Tensor (Mat2 a) (Vec2 a) Floating a => Diagonal (Vec2 a) (Mat2 a) Floating a => HasCoordinates (Mat2 a) (Vec2 a) Floating a => RightModule (Vec2 a) (Mat2 a) Floating a => LeftModule (Mat2 a) (Vec2 a)

data Mat3 a Source

Constructors

 Mat3 !(Vec3 a) !(Vec3 a) !(Vec3 a)

Instances

 Floating a => Vector a Mat3 Floating a => Orthogonal a Mat3 Ortho3 Floating a => Extend a Mat3 Mat4 Floating a => Extend a Mat2 Mat3 Floating a => Projective a Vec3 Mat3 Ortho3 Mat4 Proj4 Floating a => Projective a Vec2 Mat2 Ortho2 Mat3 Proj3 Floating a => Determinant a (Mat3 a) Floating a => MatrixNorms a (Mat3 a) Read a => Read (Mat3 a) Show a => Show (Mat3 a) (Floating a, Storable a) => Storable (Mat3 a) (Floating a, Random a) => Random (Mat3 a) Floating a => Dimension (Mat3 a) Floating a => Matrix (Mat3 a) Floating a => Pointwise (Mat3 a) Floating a => Ring (Mat3 a) Floating a => MultSemiGroup (Mat3 a) Floating a => AbelianGroup (Mat3 a) Floating a => Tensor (Mat3 a) (Vec3 a) Floating a => Diagonal (Vec3 a) (Mat3 a) Floating a => HasCoordinates (Mat3 a) (Vec3 a) Floating a => RightModule (Vec3 a) (Mat3 a) Floating a => LeftModule (Mat3 a) (Vec3 a)

data Mat4 a Source

Constructors

 Mat4 !(Vec4 a) !(Vec4 a) !(Vec4 a) !(Vec4 a)

Instances

 Floating a => Vector a Mat4 Floating a => Orthogonal a Mat4 Ortho4 Floating a => Extend a Mat3 Mat4 Floating a => Extend a Mat2 Mat4 Floating a => Projective a Vec3 Mat3 Ortho3 Mat4 Proj4 Floating a => Determinant a (Mat4 a) Floating a => MatrixNorms a (Mat4 a) Read a => Read (Mat4 a) Show a => Show (Mat4 a) (Floating a, Storable a) => Storable (Mat4 a) (Floating a, Random a) => Random (Mat4 a) Floating a => Dimension (Mat4 a) Floating a => Matrix (Mat4 a) Floating a => Pointwise (Mat4 a) Floating a => Ring (Mat4 a) Floating a => MultSemiGroup (Mat4 a) Floating a => AbelianGroup (Mat4 a) Floating a => Tensor (Mat4 a) (Vec4 a) Floating a => Diagonal (Vec4 a) (Mat4 a) Floating a => HasCoordinates (Mat4 a) (Vec4 a) Floating a => RightModule (Vec4 a) (Mat4 a) Floating a => LeftModule (Mat4 a) (Vec4 a)

data Ortho2 a Source

Orthogonal matrices.

Note: the Random instances generates orthogonal matrices with determinant 1 (that is, orientation-preserving orthogonal transformations)!

Instances

 Floating a => Orthogonal a Mat2 Ortho2 Floating a => Projective a Vec2 Mat2 Ortho2 Mat3 Proj3 Floating a => Determinant a (Ortho2 a) Read a => Read (Ortho2 a) Show a => Show (Ortho2 a) (Floating a, Storable a) => Storable (Ortho2 a) (Floating a, Ord a, Random a) => Random (Ortho2 a) Floating a => Dimension (Ortho2 a) Floating a => Matrix (Ortho2 a) Floating a => MultSemiGroup (Ortho2 a)

data Ortho3 a Source

Instances

 Floating a => Orthogonal a Mat3 Ortho3 Floating a => Projective a Vec3 Mat3 Ortho3 Mat4 Proj4 Floating a => Determinant a (Ortho3 a) Read a => Read (Ortho3 a) Show a => Show (Ortho3 a) (Floating a, Storable a) => Storable (Ortho3 a) (Floating a, Ord a, Random a) => Random (Ortho3 a) Floating a => Dimension (Ortho3 a) Floating a => Matrix (Ortho3 a) Floating a => MultSemiGroup (Ortho3 a)

data Ortho4 a Source

Instances

 Floating a => Orthogonal a Mat4 Ortho4 Floating a => Determinant a (Ortho4 a) Read a => Read (Ortho4 a) Show a => Show (Ortho4 a) (Floating a, Storable a) => Storable (Ortho4 a) (Floating a, Ord a, Random a) => Random (Ortho4 a) Floating a => Dimension (Ortho4 a) Floating a => Matrix (Ortho4 a) Floating a => MultSemiGroup (Ortho4 a)

data Normal2 a Source

The assumption when dealing with these is always that they are of unit length. Also, interpolation works differently.

Instances

 Typeable1 Normal2 Floating a => DotProd a Normal2 Floating a => UnitVector a Vec2 Normal2 Floating a => Interpolate a (Normal2 a) Read a => Read (Normal2 a) Show a => Show (Normal2 a) (Floating a, Storable a) => Storable (Normal2 a) (Floating a, Random a, Ord a) => Random (Normal2 a) Floating a => Dimension (Normal2 a) Floating a => GramSchmidt (Normal2 a, Normal2 a)

data Normal3 a Source

Instances

 Typeable1 Normal3 Floating a => DotProd a Normal3 Floating a => UnitVector a Vec3 Normal3 Floating a => Interpolate a (Normal3 a) Read a => Read (Normal3 a) Show a => Show (Normal3 a) (Floating a, Storable a) => Storable (Normal3 a) (Floating a, Random a, Ord a) => Random (Normal3 a) Floating a => Dimension (Normal3 a) Floating a => CrossProd (Normal3 a) Floating a => GramSchmidt (Normal3 a, Normal3 a) Floating a => GramSchmidt (Normal3 a, Normal3 a, Normal3 a)

data Normal4 a Source

Instances

 Typeable1 Normal4 Floating a => DotProd a Normal4 Floating a => UnitVector a Vec4 Normal4 Floating a => Interpolate a (Normal4 a) Read a => Read (Normal4 a) Show a => Show (Normal4 a) (Floating a, Storable a) => Storable (Normal4 a) (Floating a, Random a, Ord a) => Random (Normal4 a) Floating a => Dimension (Normal4 a) Floating a => GramSchmidt (Normal4 a, Normal4 a) Floating a => GramSchmidt (Normal4 a, Normal4 a, Normal4 a) Floating a => GramSchmidt (Normal4 a, Normal4 a, Normal4 a, Normal4 a)

data Proj3 a Source

Projective matrices, encoding affine transformations in dimension one less.

Instances

 Floating a => Projective a Vec2 Mat2 Ortho2 Mat3 Proj3 Read a => Read (Proj3 a) Show a => Show (Proj3 a) (Floating a, Storable a) => Storable (Proj3 a) Floating a => Matrix (Proj3 a) Floating a => MultSemiGroup (Proj3 a)

data Proj4 a Source

Instances

 Floating a => Projective a Vec3 Mat3 Ortho3 Mat4 Proj4 Read a => Read (Proj4 a) Show a => Show (Proj4 a) (Floating a, Storable a) => Storable (Proj4 a) Floating a => Matrix (Proj4 a) Floating a => MultSemiGroup (Proj4 a)

mkVec2 :: (a, a) -> Vec2 aSource

mkVec3 :: (a, a, a) -> Vec3 aSource

mkVec4 :: (a, a, a, a) -> Vec4 aSource

project :: (Vector a v, DotProd a v) => v a -> v a -> v aSource

project' :: (Vector a v, UnitVector a v u, DotProd a v) => v a -> u a -> v aSource

Projects the first vector down to the hyperplane orthogonal to the second (unit) vector

projectUnsafe :: (Vector a v, DotProd a v) => v a -> v a -> v aSource

Direction (second argument) is assumed to be a unit vector!

flipNormal :: UnitVector a v n => n a -> n aSource

Since unit vectors are not a group, we need a separate function.

householder :: (Vector a v, UnitVector a v u, Matrix (m a), Vector a m, Tensor (m a) (v a)) => u a -> m aSource

Householder matrix, see http://en.wikipedia.org/wiki/Householder_transformation. In plain words, it is the reflection to the hyperplane orthogonal to the input vector.

householderOrtho :: (Vector a v, UnitVector a v u, Matrix (m a), Vector a m, Tensor (m a) (v a), Orthogonal a m o) => u a -> o aSource