linear-1.20.5: Linear Algebra

Linear.Trace

Description

Simple matrix operation for low-dimensional primitives.

# Documentation

class Functor m => Trace m where Source #

Methods

trace :: Num a => m (m a) -> a Source #

Compute the trace of a matrix

>>> trace (V2 (V2 a b) (V2 c d))
a + d


trace :: (Foldable m, Num a) => m (m a) -> a Source #

Compute the trace of a matrix

>>> trace (V2 (V2 a b) (V2 c d))
a + d


diagonal :: m (m a) -> m a Source #

Compute the diagonal of a matrix

>>> diagonal (V2 (V2 a b) (V2 c d))
V2 a d


diagonal :: Monad m => m (m a) -> m a Source #

Compute the diagonal of a matrix

>>> diagonal (V2 (V2 a b) (V2 c d))
V2 a d


Instances

 Source # Methodstrace :: Num a => Complex (Complex a) -> a Source #diagonal :: Complex (Complex a) -> Complex a Source # Source # Methodstrace :: Num a => IntMap (IntMap a) -> a Source #diagonal :: IntMap (IntMap a) -> IntMap a Source # Source # Methodstrace :: Num a => V0 (V0 a) -> a Source #diagonal :: V0 (V0 a) -> V0 a Source # Source # Methodstrace :: Num a => V1 (V1 a) -> a Source #diagonal :: V1 (V1 a) -> V1 a Source # Source # Methodstrace :: Num a => V2 (V2 a) -> a Source #diagonal :: V2 (V2 a) -> V2 a Source # Source # Methodstrace :: Num a => V3 (V3 a) -> a Source #diagonal :: V3 (V3 a) -> V3 a Source # Source # Methodstrace :: Num a => V4 (V4 a) -> a Source #diagonal :: V4 (V4 a) -> V4 a Source # Source # Methodstrace :: Num a => Plucker (Plucker a) -> a Source #diagonal :: Plucker (Plucker a) -> Plucker a Source # Source # Methodstrace :: Num a => Quaternion (Quaternion a) -> a Source # Ord k => Trace (Map k) Source # Methodstrace :: Num a => Map k (Map k a) -> a Source #diagonal :: Map k (Map k a) -> Map k a Source # (Eq k, Hashable k) => Trace (HashMap k) Source # Methodstrace :: Num a => HashMap k (HashMap k a) -> a Source #diagonal :: HashMap k (HashMap k a) -> HashMap k a Source # Dim * n => Trace (V * n) Source # Methodstrace :: Num a => V * n (V * n a) -> a Source #diagonal :: V * n (V * n a) -> V * n a Source # (Trace f, Trace g) => Trace (Product * f g) Source # Methodstrace :: Num a => Product * f g (Product * f g a) -> a Source #diagonal :: Product * f g (Product * f g a) -> Product * f g a Source # (Distributive g, Trace g, Trace f) => Trace (Compose * * g f) Source # Methodstrace :: Num a => Compose * * g f (Compose * * g f a) -> a Source #diagonal :: Compose * * g f (Compose * * g f a) -> Compose * * g f a Source #