Safe Haskell | None |
---|---|
Language | Haskell2010 |
Adapted from Linear.Matrix
Synopsis
- (!*!) :: (Vec m, Vec t, Vec n, Num a) => m (t a) -> t (n a) -> m (n a)
- (!*) :: (Vec m, Vec r, Num a) => m (r a) -> r a -> m a
- (*!) :: (Vec f, Vec t, Num a, Num (f a)) => t a -> t (f a) -> f a
- (!!*) :: (Vec m, Vec r, Num a) => m (r a) -> a -> m (r a)
- (*!!) :: (Vec m, Vec r, Num a) => a -> m (r a) -> m (r a)
- (!!/) :: (Vec r, Vec m, Fractional (r a), Fractional a) => m (r a) -> a -> m (r a)
- column :: Vec v => Lens' a b -> Lens' (v a) (v b)
- diagonal :: Vec v => v (v a) -> v a
- trace :: (Vec v, Num a) => v (v a) -> a
- type M22 a = V2 (V2 a)
- type M23 a = V2 (V3 a)
- type M24 a = V2 (V4 a)
- type M32 a = V3 (V2 a)
- type M33 a = V3 (V3 a)
- type M34 a = V3 (V4 a)
- type M42 a = V4 (V2 a)
- type M43 a = V4 (V3 a)
- type M44 a = V4 (V4 a)
- det22 :: Num a => M22 a -> a
- det33 :: Num a => M33 a -> a
- det44 :: Num a => M44 a -> a
- inv22 :: Fractional a => M22 a -> M22 a
- inv33 :: Fractional a => M33 a -> M33 a
- inv44 :: Fractional a => M44 a -> M44 a
- identity :: (Vec v, Num a) => v (v a)
- transpose :: (Vec f, Vec g) => f (g a) -> g (f a)
- fromQuaternion :: Num a => Quaternion a -> M33 a
- _m22 :: (Vec t, R2 t, R2 v) => Lens' (t (v a)) (M22 a)
- _m23 :: (Vec t, R2 t, R3 v) => Lens' (t (v a)) (M23 a)
- _m24 :: (Vec t, R2 t, R4 v) => Lens' (t (v a)) (M24 a)
- _m32 :: (Vec t, R3 t, R2 v) => Lens' (t (v a)) (M32 a)
- _m33 :: (Vec t, R3 t, R3 v) => Lens' (t (v a)) (M33 a)
- _m34 :: (Vec t, R3 t, R4 v) => Lens' (t (v a)) (M34 a)
- _m42 :: (Vec t, R4 t, R2 v) => Lens' (t (v a)) (M42 a)
- _m43 :: (Vec t, R4 t, R3 v) => Lens' (t (v a)) (M43 a)
- _m44 :: (Vec t, R4 t, R4 v) => Lens' (t (v a)) (M44 a)
Documentation
(!*!) :: (Vec m, Vec t, Vec n, Num a) => m (t a) -> t (n a) -> m (n a) infixl 7 Source #
Matrix product
>>>
V2 (V3 1 2 3) (V3 4 5 6) !*! V3 (V2 1 2) (V2 3 4) (V2 4 5)
V2 (V2 19 25) (V2 43 58)
(!*) :: (Vec m, Vec r, Num a) => m (r a) -> r a -> m a infixl 7 Source #
Matrix * column vector
>>>
V2 (V3 1 2 3) (V3 4 5 6) !* V3 7 8 9
V2 50 122
(*!) :: (Vec f, Vec t, Num a, Num (f a)) => t a -> t (f a) -> f a infixl 7 Source #
Row vector * matrix
>>>
V2 1 2 *! V2 (V3 3 4 5) (V3 6 7 8)
V3 15 18 21
(!!*) :: (Vec m, Vec r, Num a) => m (r a) -> a -> m (r a) infixl 7 Source #
Matrix-scalar product
>>>
V2 (V2 1 2) (V2 3 4) !!* 5
V2 (V2 5 10) (V2 15 20)
(*!!) :: (Vec m, Vec r, Num a) => a -> m (r a) -> m (r a) infixl 7 Source #
Scalar-matrix product
>>>
5 *!! V2 (V2 1 2) (V2 3 4)
V2 (V2 5 10) (V2 15 20)
(!!/) :: (Vec r, Vec m, Fractional (r a), Fractional a) => m (r a) -> a -> m (r a) infixl 7 Source #
Matrix-scalar division
column :: Vec v => Lens' a b -> Lens' (v a) (v b) Source #
This is more restrictive than linear's LensLike (Context a b) s t a b -> Lens (f s) (f t) (f a) (f b)
, but in return we get a much simpler implementation which should suffice in 99% of cases.
det22 :: Num a => M22 a -> a Source #
2x2 matrix determinant.
>>>
det22 (V2 (V2 a b) (V2 c d))
a * d - b * c
det33 :: Num a => M33 a -> a Source #
3x3 matrix determinant.
>>>
det33 (V3 (V3 a b c) (V3 d e f) (V3 g h i))
a * (e * i - f * h) - d * (b * i - c * h) + g * (b * f - c * e)
inv22 :: Fractional a => M22 a -> M22 a Source #
2x2 matrix inverse.
>>>
inv22 $ V2 (V2 1 2) (V2 3 4)
V2 (V2 (-2.0) 1.0) (V2 1.5 (-0.5))
inv33 :: Fractional a => M33 a -> M33 a Source #
3x3 matrix inverse.
>>>
inv33 $ V3 (V3 1 2 4) (V3 4 2 2) (V3 1 1 1)
V3 (V3 0.0 0.5 (-1.0)) (V3 (-0.5) (-0.75) 3.5) (V3 0.5 0.25 (-1.5))
identity :: (Vec v, Num a) => v (v a) Source #
The identity matrix for any dimension vector.
>>>
identity :: M44 Int
V4 (V4 1 0 0 0) (V4 0 1 0 0) (V4 0 0 1 0) (V4 0 0 0 1)>>>
identity :: V3 (V3 Int)
V3 (V3 1 0 0) (V3 0 1 0) (V3 0 0 1)
transpose :: (Vec f, Vec g) => f (g a) -> g (f a) Source #
transpose
is just an alias for distribute
transpose (V3 (V2 1 2) (V2 3 4) (V2 5 6))
V2 (V3 1 3 5) (V3 2 4 6)
fromQuaternion :: Num a => Quaternion a -> M33 a Source #
Build a rotation matrix from a unit Quaternion
.
_m22 :: (Vec t, R2 t, R2 v) => Lens' (t (v a)) (M22 a) Source #
Extract a 2x2 matrix from a matrix of higher dimensions by dropping excess rows and columns.
_m23 :: (Vec t, R2 t, R3 v) => Lens' (t (v a)) (M23 a) Source #
Extract a 2x3 matrix from a matrix of higher dimensions by dropping excess rows and columns.
_m24 :: (Vec t, R2 t, R4 v) => Lens' (t (v a)) (M24 a) Source #
Extract a 2x4 matrix from a matrix of higher dimensions by dropping excess rows and columns.
_m32 :: (Vec t, R3 t, R2 v) => Lens' (t (v a)) (M32 a) Source #
Extract a 3x2 matrix from a matrix of higher dimensions by dropping excess rows and columns.
_m33 :: (Vec t, R3 t, R3 v) => Lens' (t (v a)) (M33 a) Source #
Extract a 3x3 matrix from a matrix of higher dimensions by dropping excess rows and columns.
_m34 :: (Vec t, R3 t, R4 v) => Lens' (t (v a)) (M34 a) Source #
Extract a 3x4 matrix from a matrix of higher dimensions by dropping excess rows and columns.
_m42 :: (Vec t, R4 t, R2 v) => Lens' (t (v a)) (M42 a) Source #
Extract a 4x2 matrix from a matrix of higher dimensions by dropping excess rows and columns.