{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE StandaloneKindSignatures #-}
module OAlg.Structure.Vectorial.Definition
(
Vectorial(..), Vec, ForgetfulVec
, Euclidean(..)
)
where
import Control.Exception
import OAlg.Prelude
import OAlg.Structure.Exception
import OAlg.Structure.Oriented.Definition(Orientation(..))
import OAlg.Structure.Multiplicative.Definition
import OAlg.Structure.Fibred.Definition
import OAlg.Structure.Additive.Definition
import OAlg.Structure.Ring.Definition
import OAlg.Structure.Number.Definition
infixr 8 !
class (Semiring (Scalar v), Commutative (Scalar v), Additive v) => Vectorial v where
type Scalar v
(!) :: Scalar v -> v -> v
instance Vectorial () where
type Scalar () = Q
! :: Scalar () -> () -> ()
(!) = forall a. Acyclic a => Q -> a -> a
qtimes
instance Vectorial Int where
type Scalar Int = Int
! :: Scalar Int -> Int -> Int
(!) = forall c. Multiplicative c => c -> c -> c
(*)
instance Vectorial Integer where
type Scalar Integer = Integer
! :: Scalar Integer -> Integer -> Integer
(!) = forall c. Multiplicative c => c -> c -> c
(*)
instance Vectorial N where
type Scalar N = N
! :: Scalar N -> N -> N
(!) = forall c. Multiplicative c => c -> c -> c
(*)
instance Vectorial Z where
type Scalar Z = Z
! :: Scalar Z -> Z -> Z
(!) = forall c. Multiplicative c => c -> c -> c
(*)
instance Vectorial Q where
type Scalar Q = Q
! :: Scalar Q -> Q -> Q
(!) = forall c. Multiplicative c => c -> c -> c
(*)
instance Entity p => Vectorial (Orientation p) where
type Scalar (Orientation p) = Q
Scalar (Orientation p)
_ ! :: Scalar (Orientation p) -> Orientation p -> Orientation p
! Orientation p
o = Orientation p
o
instance (Vectorial v, FibredOriented v) => Vectorial (Op v) where
type Scalar (Op v) = Scalar v
Scalar (Op v)
s ! :: Scalar (Op v) -> Op v -> Op v
! (Op v
v) = forall x. x -> Op x
Op (Scalar (Op v)
sforall v. Vectorial v => Scalar v -> v -> v
!v
v)
infix 7 <!>
class Vectorial v => Euclidean v where
(<!>) :: v -> v -> Scalar v
instance Euclidean N where
<!> :: N -> N -> Scalar N
(<!>) = forall c. Multiplicative c => c -> c -> c
(*)
instance Euclidean Z where
<!> :: Z -> Z -> Scalar Z
(<!>) = forall c. Multiplicative c => c -> c -> c
(*)
instance Euclidean Q where
<!> :: Q -> Q -> Scalar Q
(<!>) = forall c. Multiplicative c => c -> c -> c
(*)
instance Entity p => Euclidean (Orientation p) where
Orientation p
a <!> :: Orientation p -> Orientation p -> Scalar (Orientation p)
<!> Orientation p
b | forall f. Fibred f => f -> Root f
root Orientation p
a forall a. Eq a => a -> a -> Bool
== forall f. Fibred f => f -> Root f
root Orientation p
b = Q
0
| Bool
otherwise = forall a e. Exception e => e -> a
throw ArithmeticException
UndefinedScalarproduct
data Vec k
type instance Structure (Vec k) x = (Vectorial x, k ~ Scalar x)
instance Transformable (Vec k) Typ where tau :: forall x. Struct (Vec k) x -> Struct Typ x
tau Struct (Vec k) x
Struct = forall s x. Structure s x => Struct s x
Struct
instance Transformable (Vec k) Ent where tau :: forall x. Struct (Vec k) x -> Struct Ent x
tau Struct (Vec k) x
Struct = forall s x. Structure s x => Struct s x
Struct
instance Transformable (Vec k) Fbr where tau :: forall x. Struct (Vec k) x -> Struct Fbr x
tau Struct (Vec k) x
Struct = forall s x. Structure s x => Struct s x
Struct
instance Transformable (Vec k) Add where tau :: forall x. Struct (Vec k) x -> Struct Add x
tau Struct (Vec k) x
Struct = forall s x. Structure s x => Struct s x
Struct
class ( ForgetfulFbr (s k), ForgetfulAdd (s k)
, Transformable (s k) (Vec k)
) => ForgetfulVec k s
instance ForgetfulTyp (Vec k)
instance ForgetfulFbr (Vec k)
instance ForgetfulAdd (Vec k)
instance ForgetfulVec k Vec