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

Goal.Core.Vector.Generic

Description

Vectors and Matrices with statically typed dimensions.

Synopsis

# Vector

type VectorClass = Vector Source #

# Construction

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

Collect two values into a length 2 Vector.

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

Uniform partition of an interval into a Vector.

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

Breaks a Vector into a Vector of Vectors.

# Deconstruction

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

Create a Matrix from a Vector of Vectors which represent the rows.

# Matrix

newtype Matrix v (m :: Nat) (n :: Nat) a Source #

Matrices with static dimensions.

Constructors

 Matrix FieldstoVector :: Vector v (m * n) a

#### Instances

Instances details
 Eq (v a) => Eq (Matrix v m n a) Source # Instance detailsDefined in Goal.Core.Vector.Generic Methods(==) :: Matrix v m n a -> Matrix v m n a -> Bool #(/=) :: Matrix v m n a -> Matrix v m n a -> Bool # (KnownNat m, KnownNat n, Numeric x, Floating x) => Floating (Matrix Vector m n x) Source # Instance detailsDefined in Goal.Core.Vector.Generic Methodspi :: Matrix Vector m n x #exp :: Matrix Vector m n x -> Matrix Vector m n x #log :: Matrix Vector m n x -> Matrix Vector m n x #sqrt :: Matrix Vector m n x -> Matrix Vector m n x #(**) :: Matrix Vector m n x -> Matrix Vector m n x -> Matrix Vector m n x #logBase :: Matrix Vector m n x -> Matrix Vector m n x -> Matrix Vector m n x #sin :: Matrix Vector m n x -> Matrix Vector m n x #cos :: Matrix Vector m n x -> Matrix Vector m n x #tan :: Matrix Vector m n x -> Matrix Vector m n x #asin :: Matrix Vector m n x -> Matrix Vector m n x #acos :: Matrix Vector m n x -> Matrix Vector m n x #atan :: Matrix Vector m n x -> Matrix Vector m n x #sinh :: Matrix Vector m n x -> Matrix Vector m n x #cosh :: Matrix Vector m n x -> Matrix Vector m n x #tanh :: Matrix Vector m n x -> Matrix Vector m n x #asinh :: Matrix Vector m n x -> Matrix Vector m n x #acosh :: Matrix Vector m n x -> Matrix Vector m n x #atanh :: Matrix Vector m n x -> Matrix Vector m n x #log1p :: Matrix Vector m n x -> Matrix Vector m n x #expm1 :: Matrix Vector m n x -> Matrix Vector m n x #log1pexp :: Matrix Vector m n x -> Matrix Vector m n x #log1mexp :: Matrix Vector m n x -> Matrix Vector m n x # (KnownNat m, KnownNat n, Numeric x, Fractional x) => Fractional (Matrix Vector m n x) Source # Instance detailsDefined in Goal.Core.Vector.Generic Methods(/) :: Matrix Vector m n x -> Matrix Vector m n x -> Matrix Vector m n x #recip :: Matrix Vector m n x -> Matrix Vector m n x #fromRational :: Rational -> Matrix Vector m n x # (KnownNat m, KnownNat n, Numeric x, Num x) => Num (Matrix Vector m n x) Source # Instance detailsDefined in Goal.Core.Vector.Generic Methods(+) :: Matrix Vector m n x -> Matrix Vector m n x -> Matrix Vector m n x #(-) :: Matrix Vector m n x -> Matrix Vector m n x -> Matrix Vector m n x #(*) :: Matrix Vector m n x -> Matrix Vector m n x -> Matrix Vector m n x #negate :: Matrix Vector m n x -> Matrix Vector m n x #abs :: Matrix Vector m n x -> Matrix Vector m n x #signum :: Matrix Vector m n x -> Matrix Vector m n x #fromInteger :: Integer -> Matrix Vector m n x # Show (v a) => Show (Matrix v m n a) Source # Instance detailsDefined in Goal.Core.Vector.Generic MethodsshowsPrec :: Int -> Matrix v m n a -> ShowS #show :: Matrix v m n a -> String #showList :: [Matrix v m n a] -> ShowS # (KnownNat m, KnownNat n, Storable x) => Storable (Matrix Vector m n x) Source # Instance detailsDefined in Goal.Core.Vector.Generic MethodssizeOf :: Matrix Vector m n x -> Int #alignment :: Matrix Vector m n x -> Int #peekElemOff :: Ptr (Matrix Vector m n x) -> Int -> IO (Matrix Vector m n x) #pokeElemOff :: Ptr (Matrix Vector m n x) -> Int -> Matrix Vector m n x -> IO () #peekByteOff :: Ptr b -> Int -> IO (Matrix Vector m n x) #pokeByteOff :: Ptr b -> Int -> Matrix Vector m n x -> IO () #peek :: Ptr (Matrix Vector m n x) -> IO (Matrix Vector m n x) #poke :: Ptr (Matrix Vector m n x) -> Matrix Vector m n x -> IO () # NFData (v a) => NFData (Matrix v m n a) Source # Instance detailsDefined in Goal.Core.Vector.Generic Methodsrnf :: Matrix v m n a -> () #

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

The number of rows in the Matrix.

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

The number of columns in the Matrix.

## Construction

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

Create a Matrix from a Vector of Vectors which represent the rows.

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

Create a Matrix from a Vector of Vectors which represent the columns.

## Deconstruction

toPair :: Vector v a => Vector v 2 a -> (a, a) Source #

Reshapes a length 2 Vector into a pair of values.

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

Convert a Matrix into a Vector of Vectors of rows.

toColumns :: (Vector v a, Vector v (Vector v m a), KnownNat m, KnownNat n, Vector v Int) => Matrix v m n a -> Vector v n (Vector v m a) Source #

Convert a Matrix into a Vector of Vectors of columns.

## Manipulation

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

Turn a Vector into a single column Matrix.

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

Turn a Vector into a single row Matrix.

## BLAS

transpose :: forall v m n a. (KnownNat m, KnownNat n, Vector v Int, Vector v a, Vector v (Vector v m a)) => Matrix v m n a -> Matrix v n m a Source #

Pure implementation of Matrix transposition.

dotProduct :: (Vector v x, Num x) => Vector v n x -> Vector v n x -> x Source #

Pure implementation of the dot product.

weakDotProduct :: (Vector v x, Num x) => v x -> v x -> x Source #

Pure implementation of the dot product on standard vectors.

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

Pure implementation of the outer product.

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

Pure Matrix x Vector multiplication.

matrixMatrixMultiply :: (KnownNat m, KnownNat n, KnownNat o, Num x, Vector v Int, Vector v x, Vector v (Vector v m x), Vector v (Vector v n x), Vector v (Vector v o x)) => Matrix v m n x -> Matrix v n o x -> Matrix v m o x Source #

Pure Matrix x Matrix multiplication.