{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
module Numeric.Matrix.Class
( MatrixTranspose (..)
, SquareMatrix (..)
, MatrixDeterminant (..)
, MatrixInverse (..)
, MatrixLU (..), LUFact (..)
, Matrix
, HomTransform4 (..)
, Mat22f, Mat23f, Mat24f
, Mat32f, Mat33f, Mat34f
, Mat42f, Mat43f, Mat44f
, Mat22d, Mat23d, Mat24d
, Mat32d, Mat33d, Mat34d
, Mat42d, Mat43d, Mat44d
) where
import Numeric.DataFrame.Family
import Numeric.Dimensions (Nat)
import Numeric.Scalar
import Numeric.Vector
type Matrix (t :: l) (n :: k) (m :: k) = DataFrame t '[n,m]
class MatrixTranspose t (n :: k) (m :: k) where
transpose :: Matrix t n m -> Matrix t m n
class SquareMatrix t (n :: Nat) where
eye :: Matrix t n n
diag :: Scalar t -> Matrix t n n
trace :: Matrix t n n -> Scalar t
class MatrixDeterminant t (n :: Nat) where
det :: Matrix t n n -> Scalar t
class MatrixInverse t (n :: Nat) where
inverse :: Matrix t n n -> Matrix t n n
data LUFact t n
= LUFact
{ luLower :: Matrix t n n
, luUpper :: Matrix t n n
, luPerm :: Matrix t n n
, luPermSign :: Scalar t
}
deriving instance (Show (Matrix t n n), Show t) => Show (LUFact t n)
deriving instance (Eq (Matrix t n n), Eq t) => Eq (LUFact t n)
class MatrixLU t (n :: Nat) where
lu :: Matrix t n n -> LUFact t n
class HomTransform4 t where
translate4 :: Vector t 4 -> Matrix t 4 4
translate3 :: Vector t 3 -> Matrix t 4 4
rotateX :: t -> Matrix t 4 4
rotateY :: t -> Matrix t 4 4
rotateZ :: t -> Matrix t 4 4
rotate :: Vector t 3 -> t -> Matrix t 4 4
rotateEuler :: t -> t -> t -> Matrix t 4 4
lookAt :: Vector t 3
-> Vector t 3
-> Vector t 3
-> Matrix t 4 4
perspective :: t
-> t
-> t
-> t
-> Matrix t 4 4
orthogonal :: t
-> t
-> t
-> t
-> Matrix t 4 4
toHomPoint :: Vector t 3 -> Vector t 4
toHomVector :: Vector t 3 -> Vector t 4
fromHom :: Vector t 4 -> Vector t 3
type Mat22f = Matrix Float 2 2
type Mat32f = Matrix Float 3 2
type Mat42f = Matrix Float 4 2
type Mat23f = Matrix Float 2 3
type Mat33f = Matrix Float 3 3
type Mat43f = Matrix Float 4 3
type Mat24f = Matrix Float 2 4
type Mat34f = Matrix Float 3 4
type Mat44f = Matrix Float 4 4
type Mat22d = Matrix Double 2 2
type Mat32d = Matrix Double 3 2
type Mat42d = Matrix Double 4 2
type Mat23d = Matrix Double 2 3
type Mat33d = Matrix Double 3 3
type Mat43d = Matrix Double 4 3
type Mat24d = Matrix Double 2 4
type Mat34d = Matrix Double 3 4
type Mat44d = Matrix Double 4 4