Feldspar.Matrix
Description
Operations on matrices (doubly-nested parallel vectors). All operations in this module assume rectangular matrices.
Synopsis
type Matrix a = Vector (Vector (Data a))
freezeMatrix :: Storable a => Matrix a -> Data [[a]]
unfreezeMatrix :: Storable a => Data Length -> Data Length -> Data [[a]] -> Matrix a
matrix :: Storable a => [[a]] -> Matrix a
indexedMat :: Data Int -> Data Int -> (Data Int -> Data Int -> Data a) -> Matrix a
transpose :: Matrix a -> Matrix a
flatten :: Matrix a -> Vector (Data a)
diagonal :: Matrix a -> Vector (Data a)
distributeL :: (a -> b -> c) -> a -> Vector b -> Vector c
distributeR :: (a -> b -> c) -> Vector a -> b -> Vector c
class Mul a b where
 type Prod a b (**) :: a -> b -> Prod a b
mulMat :: Numeric a => Matrix a -> Matrix a -> Matrix a
mul :: Numeric a => Matrix a -> Matrix a -> Matrix a
class ElemWise a where
 type Elem a elemWise :: (Elem a -> Elem a -> Elem a) -> a -> a -> a
(.+) :: (ElemWise a, Numeric (Elem a)) => a -> a -> a
(.-) :: (ElemWise a, Numeric (Elem a)) => a -> a -> a
(.*) :: (ElemWise a, Numeric (Elem a)) => a -> a -> a
Documentation
 type Matrix a = Vector (Vector (Data a)) Source
 freezeMatrix :: Storable a => Matrix a -> Data [[a]] Source
Converts a matrix to a core array.
 unfreezeMatrix :: Storable a => Data Length -> Data Length -> Data [[a]] -> Matrix a Source
Converts a core array to a matrix. The first length argument is the number of rows (outer vector), and the second argument is the number of columns (inner argument).
 matrix :: Storable a => [[a]] -> Matrix a Source
Constructs a matrix. The elements are stored in a core array.
 indexedMat :: Data Int -> Data Int -> (Data Int -> Data Int -> Data a) -> Matrix a Source

Constructing a matrix from an index function.

indexedMat m n ixf:

• m is the number of rows.
• n is the number of columns.
• ifx is a function mapping indexes to elements (first argument is row index; second argument is column index).
 transpose :: Matrix a -> Matrix a Source
Transpose of a matrix
 flatten :: Matrix a -> Vector (Data a) Source
Concatenates the rows of a matrix.
 diagonal :: Matrix a -> Vector (Data a) Source
The diagonal vector of a square matrix. It happens to work if the number of rows is less than the number of columns, but not the other way around (this would require some overhead).
 distributeL :: (a -> b -> c) -> a -> Vector b -> Vector c Source
 distributeR :: (a -> b -> c) -> Vector a -> b -> Vector c Source
 class Mul a b where Source
Associated Types
 type Prod a b Source
Methods
 (**) :: a -> b -> Prod a b Source
General multiplication operator Instances
 Numeric a => Mul (Data a) (Matrix a) Numeric a => Mul (Data a) (DVector a) Numeric a => Mul (Data a) (Data a) Numeric a => Mul (DVector a) (Matrix a) Numeric a => Mul (DVector a) (DVector a) Numeric a => Mul (DVector a) (Data a) Numeric a => Mul (Matrix a) (Matrix a) Numeric a => Mul (Matrix a) (DVector a) Numeric a => Mul (Matrix a) (Data a)
 mulMat :: Numeric a => Matrix a -> Matrix a -> Matrix a Source
Matrix multiplication
 mul :: Numeric a => Matrix a -> Matrix a -> Matrix a Source
Matrix multiplication
 class ElemWise a where Source
Associated Types
 type Elem a Source
Methods
 elemWise :: (Elem a -> Elem a -> Elem a) -> a -> a -> a Source
Operator for general element-wise multiplication Instances
 ElemWise (Data a) ElemWise (DVector a) ElemWise (Matrix a)
 (.+) :: (ElemWise a, Numeric (Elem a)) => a -> a -> a Source
 (.-) :: (ElemWise a, Numeric (Elem a)) => a -> a -> a Source
 (.*) :: (ElemWise a, Numeric (Elem a)) => a -> a -> a Source