linear-1.20.7: Linear Algebra

Copyright (C) 2012-2015 Edward Kmett BSD-style (see the file LICENSE) Edward Kmett experimental non-portable Safe Haskell98

Linear.Trace

Description

Simple matrix operation for low-dimensional primitives.

# Documentation

class Functor m => Trace m where #

Methods

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

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 #

Compute the trace of a matrix

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


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

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 #

Compute the diagonal of a matrix

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


Instances

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