goal-core-0.20: Common, non-geometric tools for use with Goal
Safe HaskellNone
LanguageHaskell2010

Goal.Core.Vector.Boxed

Description

Vectors and Matrices with statically-typed dimensions based on boxed vectors.

Synopsis

Vector

Construction

doubleton :: x -> x -> Vector 2 x Source #

Create a Vector of length 2.

range :: (KnownNat n, Fractional x) => x -> x -> Vector n x Source #

Partition of an interval.

breakStream :: forall n a. KnownNat n => [a] -> [Vector n a] Source #

Cycles a list of elements and breaks it up into an infinite list of Vectors.

breakEvery :: (KnownNat n, KnownNat k) => Vector (n * k) a -> Vector n (Vector k a) Source #

Breaks a Vector into a Vector of Vectors.

Deconstruction

toPair :: Vector 2 x -> (x, x) Source #

Converts a length two Vector into a pair of elements.

concat :: KnownNat n => Vector m (Vector n x) -> Vector (m * n) x Source #

Flatten a Vector of Vectors.

Matrix

type Matrix = Matrix Vector Source #

Matrices with static dimensions (boxed).

nRows :: forall m n a. KnownNat m => Matrix m n a -> Int Source #

The number of rows in the Matrix.

nColumns :: forall m n a. KnownNat n => Matrix m n a -> Int Source #

The number of columns in the Matrix.

Construction

fromRows :: KnownNat n => Vector m (Vector n x) -> Matrix m n x Source #

Create a Matrix from a Vector of row Vectors.

fromColumns :: (KnownNat n, KnownNat m) => Vector n (Vector m x) -> Matrix m n x Source #

Create a Matrix from a Vector of column Vectors.

matrixIdentity :: (KnownNat n, Num a) => Matrix n n a Source #

The identity Matrix.

outerProduct :: (KnownNat m, KnownNat n, Num x) => Vector m x -> Vector n x -> Matrix m n x Source #

Pure implementation of the outer product.

diagonalConcat :: (KnownNat n, KnownNat m, KnownNat o, KnownNat p, Num a) => Matrix n m a -> Matrix o p a -> Matrix (n + o) (m + p) a Source #

Diagonally concatenate two matrices, padding the gaps with zeroes (pure implementation).

Deconstruction

toRows :: (KnownNat m, KnownNat n) => Matrix m n x -> Vector m (Vector n x) Source #

Convert a Matrix into a Vector of Vectors of rows.

toColumns :: (KnownNat m, KnownNat n) => Matrix m n x -> Vector n (Vector m x) Source #

Convert a Matrix into a Vector of Vectors of columns.

Manipulation

columnVector :: Vector n a -> Matrix n 1 a Source #

Turn a Vector into a single column Matrix.

rowVector :: Vector n a -> Matrix 1 n a Source #

Turn a Vector into a single row Matrix.

BLAS

dotProduct :: Num x => Vector n x -> Vector n x -> x Source #

Pure implementation of the dot product.

matrixVectorMultiply :: (KnownNat m, KnownNat n, Num x) => Matrix m n x -> Vector n x -> Vector m x Source #

Pure Matrix x Vector multiplication.

matrixMatrixMultiply :: forall m n o a. (KnownNat m, KnownNat n, KnownNat o, Num a) => Matrix m n a -> Matrix n o a -> Matrix m o a Source #

Pure Matrix x Matrix multiplication.

inverse :: forall a n. (Fractional a, Ord a, KnownNat n) => Matrix n n a -> Maybe (Matrix n n a) Source #

Pure implementation of matrix inversion.

transpose :: (KnownNat m, KnownNat n, Num x) => Matrix m n x -> Matrix n m x Source #

Pure implementation of Matrix transposition.