Module

Data.FastVect.FastVect.Matrix

Package
purescript-fast-vect
Repository
sigma-andex/purescript-fast-vect

#Matrix Source

newtype Matrix :: Int -> Int -> Type -> Typenewtype Matrix h w a

A matrix of elements of type a, implemented as a array vector of array vectors. The first type argument represents the height of the matrix and the second type argument represents the width. Note that the internal implementation is a horizontal row of vertical vectors. This is because in mathematics, matrices are often treated as a row of vertical vectors.

Constructors

Instances

#diag Source

diag :: forall h elem. Diag Vect Matrix h elem

Create Matrix from its diagonal elements.

#dotProduct Source

dotProduct :: forall h elem. DotProduct Vect h elem

Dot product of two vectors.

#empty Source

empty :: forall elem. Empty Matrix elem

Create empty Matrix.

#fromArrayArray Source

fromArrayArray :: forall h w elem. Compare h NegOne GT => Compare w NegOne GT => Reflectable w Int => Compare h NegOne GT => Reflectable h Int => Array (Array elem) -> Maybe (Matrix h w elem)

Convert an array of arrays to a Matrix.

#fromVect Source

fromVect :: forall h elem. Compare h NegOne GT => Vect h elem -> Matrix h 1 elem

Convert a vector to a nx1 Matrix.

#fromVectArray Source

fromVectArray :: forall h w elem. Compare h NegOne GT => Compare w NegOne GT => Reflectable w Int => Array (Vect h elem) -> Maybe (Matrix h w elem)

Convert a vector of arrays to a Matrix.

#fromVectVect Source

fromVectVect :: forall h w elem. Vect w (Vect h elem) -> Matrix h w elem

Convert a vector of vectors to a Matrix.

#generate Source

generate :: forall h w elem. Generate Matrix h w elem

Generate a Matrix by applying the given function to each type-level index.

#index Source

index :: forall h w i j elem. Index Matrix h w i j elem

Safely accesses the j -th element of the i -th row of Matrix.

#mapWithTerm Source

mapWithTerm :: forall h w elem elem'. MapWithTerm Matrix h w elem elem'

Map a function over the elements of a Matrix with its type-level indices.

#modify Source

modify :: forall h w i j elem. Modify Matrix h w i j elem

Modify the j -th element of the i -th row of a Matrix.

#outerMap Source

outerMap :: forall h w elemH elemW elem. OuterMap Vect Matrix h w elemH elemW elem

Outer product with multiplication function

#outerProduct Source

outerProduct :: forall h w elem. OuterProduct Vect Matrix h w elem

Outer product

#product Source

product :: forall h m w elem. Product Matrix h m w elem

Matrix multiplication.

#replicate Source

replicate :: forall h w a. Replicate Matrix h w a

Create a Matrix by replicating the given element.

#set Source

set :: forall h w i j elem. Set Matrix h w i j elem

Set the j -th element of the i -th row of a Matrix.

#singleton Source

singleton :: forall elem. elem -> Matrix 1 1 elem

Create Matrix of one element.

#toArrayArray Source

toArrayArray :: forall h w elem. Compare h NegOne GT => Compare w NegOne GT => Matrix h w elem -> Array (Array elem)

Convert a Matrix to a array of arrays.

#toVect Source

toVect :: forall h elem. Compare h NegOne GT => Matrix h 1 elem -> Vect h elem

Convert a nx1 Matrix to a vector.

#toVectArray Source

toVectArray :: forall h w elem. Compare h NegOne GT => Compare w NegOne GT => Matrix h w elem -> Array (Vect h elem)

Convert a Matrix to a array of vectors.

#toVectVect Source

toVectVect :: forall h w elem. Matrix h w elem -> Vect w (Vect h elem)

Convert a Matrix to a vector of vectors.

#trace Source

trace :: forall h elem. Trace Matrix h elem

Get sum of diagonal elements of a Matrix.

#traced Source

traced :: forall h elem. Traced Vect Matrix h elem

Get the diagonal elements of a Matrix.

#transform Source

transform :: forall h w elem. Transform Vect Matrix h w elem

Transform a Vector by a Matrix.

#transpose Source

transpose :: forall h w elem. Transpose Matrix h w elem

Transpose a Matrix.