linear-1.20.4: Linear Algebra

Copyright(C) 2012-2015 Edward Kmett
LicenseBSD-style (see the file LICENSE)
MaintainerEdward Kmett <ekmett@gmail.com>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellSafe
LanguageHaskell98

Linear.Trace

Description

Simple matrix operation for low-dimensional primitives.

Documentation

class Functor m => Trace m where Source

Minimal complete definition

Nothing

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

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

Compute the diagonal of a matrix

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