blas-0.6: Bindings to the BLAS librarySource codeContentsIndex
Data.Matrix.Dense.Class
Stabilityexperimental
MaintainerPatrick Perry <patperry@stanford.edu>
Contents
The dense matrix type classes
Matrix shape
Creating matrices
Reading and writing matrixelements
Special matrices
Matrix views
Row and Column views
Getting rows and columns
Copying matrices
Swapping rows and columns
Matrix operations
Unsary
Binary
Unsafe
Low-level functions
Description
Synopsis
class (BaseMatrix a, BaseVector x) => BaseMatrix a x | a -> x where
matrixViewArray :: ForeignPtr e -> Ptr e -> Int -> Int -> Int -> Bool -> a mn e
arrayFromMatrix :: a mn e -> (ForeignPtr e, Ptr e, Int, Int, Int, Bool)
class (UnsafeIOToM m, ReadTensor a (Int, Int) m, BaseMatrix a x, ReadVector x m) => ReadMatrix a x m | a -> x
class (WriteTensor a (Int, Int) m, WriteVector x m, ReadMatrix a x m) => WriteMatrix a x m | a -> m, m -> a, a -> x
module BLAS.Tensor.Base
module BLAS.Matrix.Base
coerceMatrix :: BaseMatrix a x => a mn e -> a mn' e
newMatrix_ :: (WriteMatrix a x m, Elem e) => (Int, Int) -> m (a mn e)
newMatrix :: (WriteMatrix a x m, Elem e) => (Int, Int) -> [((Int, Int), e)] -> m (a mn e)
newListMatrix :: (WriteMatrix a x m, Elem e) => (Int, Int) -> [e] -> m (a mn e)
newRowsMatrix :: (ReadVector x m, WriteMatrix a y m, BLAS1 e) => (Int, Int) -> [x l e] -> m (a (k, l) e)
newColsMatrix :: (ReadVector x m, WriteMatrix a y m, BLAS1 e) => (Int, Int) -> [x k e] -> m (a (k, l) e)
newRowMatrix :: (ReadVector x m, WriteMatrix a y m, BLAS1 e) => x l e -> m (a (one, l) e)
newColMatrix :: (ReadVector x m, WriteMatrix a y m, BLAS1 e) => x k e -> m (a (k, one) e)
unsafeNewMatrix :: (WriteMatrix a x m, Elem e) => (Int, Int) -> [((Int, Int), e)] -> m (a mn e)
module BLAS.Tensor.Read
module BLAS.Tensor.Write
newZeroMatrix :: (WriteMatrix a x m, Elem e) => (Int, Int) -> m (a mn e)
setZeroMatrix :: (WriteMatrix a x m, Elem e) => a mn e -> m ()
newConstantMatrix :: (WriteMatrix a x m, Elem e) => (Int, Int) -> e -> m (a mn e)
setConstantMatrix :: (WriteMatrix a x m, Elem e) => e -> a mn e -> m ()
newIdentityMatrix :: (WriteMatrix a x m, Elem e) => (Int, Int) -> m (a mn e)
setIdentityMatrix :: (WriteMatrix a x m, Elem e) => a mn e -> m ()
submatrixView :: (BaseMatrix a x, Storable e) => a mn e -> (Int, Int) -> (Int, Int) -> a mn' e
splitRowsAt :: (BaseMatrix a x, Storable e) => Int -> a (m, n) e -> (a (m1, n) e, a (m2, n) e)
splitColsAt :: (BaseMatrix a x, Storable e) => Int -> a (m, n) e -> (a (m, n1) e, a (m, n2) e)
unsafeSubmatrixView :: (BaseMatrix a x, Storable e) => a mn e -> (Int, Int) -> (Int, Int) -> a mn' e
unsafeSplitRowsAt :: (BaseMatrix a x, Storable e) => Int -> a (m, n) e -> (a (m1, n) e, a (m2, n) e)
unsafeSplitColsAt :: (BaseMatrix a x, Storable e) => Int -> a (m, n) e -> (a (m, n1) e, a (m, n2) e)
rowViews :: (BaseMatrix a x, Storable e) => a (m, n) e -> [x n e]
colViews :: (BaseMatrix a x, Storable e) => a (m, n) e -> [x m e]
rowView :: (BaseMatrix a x, Storable e) => a (m, n) e -> Int -> x n e
colView :: (BaseMatrix a x, Storable e) => a (m, n) e -> Int -> x m e
diagView :: (BaseMatrix a x, Storable e) => a mn e -> Int -> x k e
unsafeRowView :: (BaseMatrix a x, Storable e) => a (k, l) e -> Int -> x l e
unsafeColView :: (BaseMatrix a x, Storable e) => a (k, l) e -> Int -> x k e
unsafeDiagView :: (BaseMatrix a x, Storable e) => a mn e -> Int -> x k e
getDiag :: (ReadMatrix a x m, WriteVector y m, BLAS1 e) => a mn e -> Int -> m (y k e)
unsafeGetDiag :: (ReadMatrix a x m, WriteVector y m, BLAS1 e) => a mn e -> Int -> m (y k e)
newCopyMatrix :: (BLAS1 e, ReadMatrix a x m, WriteMatrix b y m) => a mn e -> m (b mn e)
copyMatrix :: (WriteMatrix b y m, ReadMatrix a x m, BLAS1 e) => b mn e -> a mn e -> m ()
swapMatrix :: (WriteMatrix a x m, BLAS1 e) => a mn e -> a mn e -> m ()
unsafeCopyMatrix :: (BLAS1 e, WriteMatrix b y m, ReadMatrix a x m) => b mn e -> a mn e -> m ()
unsafeSwapMatrix :: (WriteMatrix a x m, BLAS1 e) => a mn e -> a mn e -> m ()
swapRows :: (WriteMatrix a x m, BLAS1 e) => a (r, s) e -> Int -> Int -> m ()
swapCols :: (WriteMatrix a x m, BLAS1 e) => a (r, s) e -> Int -> Int -> m ()
unsafeSwapRows :: (WriteMatrix a x m, BLAS1 e) => a (r, s) e -> Int -> Int -> m ()
unsafeSwapCols :: (WriteMatrix a x m, BLAS1 e) => a (r, s) e -> Int -> Int -> m ()
getConjMatrix :: (ReadMatrix a x m, WriteMatrix b y m, BLAS1 e) => a mn e -> m (b mn e)
getScaledMatrix :: (ReadMatrix a x m, WriteMatrix b y m, BLAS1 e) => e -> a mn e -> m (b mn e)
getShiftedMatrix :: (ReadMatrix a x m, WriteMatrix b y m, BLAS1 e) => e -> a mn e -> m (b mn e)
getAddMatrix :: (ReadMatrix a x m, ReadMatrix b x m, WriteMatrix c z m, BLAS1 e) => a mn e -> b mn e -> m (c mn e)
getSubMatrix :: (ReadMatrix a x m, ReadMatrix b x m, WriteMatrix c z m, BLAS1 e) => a mn e -> b mn e -> m (c mn e)
getMulMatrix :: (ReadMatrix a x m, ReadMatrix b x m, WriteMatrix c z m, BLAS1 e) => a mn e -> b mn e -> m (c mn e)
getDivMatrix :: (ReadMatrix a x m, ReadMatrix b x m, WriteMatrix c z m, BLAS1 e) => a mn e -> b mn e -> m (c mn e)
addMatrix :: (WriteMatrix b y m, ReadMatrix a x m, BLAS1 e) => b n e -> a n e -> m ()
subMatrix :: (WriteMatrix b y m, ReadMatrix a x m, BLAS1 e) => b n e -> a n e -> m ()
axpyMatrix :: (ReadMatrix a x m, WriteMatrix b y m, BLAS1 e) => e -> a n e -> b n e -> m ()
mulMatrix :: (WriteMatrix b y m, ReadMatrix a x m, BLAS1 e) => b n e -> a n e -> m ()
divMatrix :: (WriteMatrix b y m, ReadMatrix a x m, BLAS1 e) => b n e -> a n e -> m ()
unsafeGetAddMatrix :: (ReadMatrix a x m, ReadMatrix b x m, WriteMatrix c z m, BLAS1 e) => a mn e -> b mn e -> m (c mn e)
unsafeGetSubMatrix :: (ReadMatrix a x m, ReadMatrix b x m, WriteMatrix c z m, BLAS1 e) => a mn e -> b mn e -> m (c mn e)
unsafeGetMulMatrix :: (ReadMatrix a x m, ReadMatrix b x m, WriteMatrix c z m, BLAS1 e) => a mn e -> b mn e -> m (c mn e)
unsafeGetDivMatrix :: (ReadMatrix a x m, ReadMatrix b x m, WriteMatrix c z m, BLAS1 e) => a mn e -> b mn e -> m (c mn e)
unsafeAddMatrix :: (WriteMatrix b y m, ReadMatrix a x m, BLAS1 e) => b n e -> a n e -> m ()
unsafeSubMatrix :: (WriteMatrix b y m, ReadMatrix a x m, BLAS1 e) => b n e -> a n e -> m ()
unsafeAxpyMatrix :: (ReadMatrix a x m, WriteMatrix b y m, BLAS1 e) => e -> a mn e -> b mn e -> m ()
unsafeMulMatrix :: (WriteMatrix b y m, ReadMatrix a x m, BLAS1 e) => b mn e -> a mn e -> m ()
unsafeDivMatrix :: (WriteMatrix b y m, ReadMatrix a x m, BLAS1 e) => b mn e -> a mn e -> m ()
module BLAS.Matrix.Mutable
ldaOfMatrix :: BaseMatrix a x => a mn e -> Int
isHermMatrix :: BaseMatrix a x => a mn e -> Bool
withMatrixPtr :: BaseMatrix a x => a mn e -> (Ptr e -> IO b) -> IO b
The dense matrix type classes
class (BaseMatrix a, BaseVector x) => BaseMatrix a x | a -> x whereSource
Methods
matrixViewArray :: ForeignPtr e -> Ptr e -> Int -> Int -> Int -> Bool -> a mn eSource
arrayFromMatrix :: a mn e -> (ForeignPtr e, Ptr e, Int, Int, Int, Bool)Source
show/hide Instances
class (UnsafeIOToM m, ReadTensor a (Int, Int) m, BaseMatrix a x, ReadVector x m) => ReadMatrix a x m | a -> xSource
show/hide Instances
class (WriteTensor a (Int, Int) m, WriteVector x m, ReadMatrix a x m) => WriteMatrix a x m | a -> m, m -> a, a -> xSource
show/hide Instances
Matrix shape
module BLAS.Tensor.Base
module BLAS.Matrix.Base
coerceMatrix :: BaseMatrix a x => a mn e -> a mn' eSource
Cast the shape type of the matrix.
Creating matrices
newMatrix_ :: (WriteMatrix a x m, Elem e) => (Int, Int) -> m (a mn e)Source
Create a new matrix of given shape, but do not initialize the elements.
newMatrix :: (WriteMatrix a x m, Elem e) => (Int, Int) -> [((Int, Int), e)] -> m (a mn e)Source
Creates a new matrix with the given association list. Unspecified indices will get initialized to zero.
newListMatrix :: (WriteMatrix a x m, Elem e) => (Int, Int) -> [e] -> m (a mn e)Source
Create a new matrix with the given elements in column-major order.
newRowsMatrix :: (ReadVector x m, WriteMatrix a y m, BLAS1 e) => (Int, Int) -> [x l e] -> m (a (k, l) e)Source
Form a matrix from a list of row vectors.
newColsMatrix :: (ReadVector x m, WriteMatrix a y m, BLAS1 e) => (Int, Int) -> [x k e] -> m (a (k, l) e)Source
Form a matrix from a list of column vectors.
newRowMatrix :: (ReadVector x m, WriteMatrix a y m, BLAS1 e) => x l e -> m (a (one, l) e)Source
Create a new matrix from a row vector.
newColMatrix :: (ReadVector x m, WriteMatrix a y m, BLAS1 e) => x k e -> m (a (k, one) e)Source
Create a new matrix from a column vector.
unsafeNewMatrix :: (WriteMatrix a x m, Elem e) => (Int, Int) -> [((Int, Int), e)] -> m (a mn e)Source
Same as newMatrix but indices are not range-checked.
Reading and writing matrixelements
module BLAS.Tensor.Read
module BLAS.Tensor.Write
Special matrices
newZeroMatrix :: (WriteMatrix a x m, Elem e) => (Int, Int) -> m (a mn e)Source
Create a zero matrix of the specified shape.
setZeroMatrix :: (WriteMatrix a x m, Elem e) => a mn e -> m ()Source
newConstantMatrix :: (WriteMatrix a x m, Elem e) => (Int, Int) -> e -> m (a mn e)Source
Create a constant matrix of the specified shape.
setConstantMatrix :: (WriteMatrix a x m, Elem e) => e -> a mn e -> m ()Source
newIdentityMatrix :: (WriteMatrix a x m, Elem e) => (Int, Int) -> m (a mn e)Source
Create a new matrix of the given shape with ones along the diagonal, and zeros everywhere else.
setIdentityMatrix :: (WriteMatrix a x m, Elem e) => a mn e -> m ()Source
Set diagonal elements to one and all other elements to zero.
Matrix views
submatrixView :: (BaseMatrix a x, Storable e) => a mn e -> (Int, Int) -> (Int, Int) -> a mn' eSource
submatrixView a ij mn returns a view of the submatrix of a with element (0,0) being element ij in a, and having shape mn.
splitRowsAt :: (BaseMatrix a x, Storable e) => Int -> a (m, n) e -> (a (m1, n) e, a (m2, n) e)Source
splitColsAt :: (BaseMatrix a x, Storable e) => Int -> a (m, n) e -> (a (m, n1) e, a (m, n2) e)Source
unsafeSubmatrixView :: (BaseMatrix a x, Storable e) => a mn e -> (Int, Int) -> (Int, Int) -> a mn' eSource
Same as submatrixView but indices are not range-checked.
unsafeSplitRowsAt :: (BaseMatrix a x, Storable e) => Int -> a (m, n) e -> (a (m1, n) e, a (m2, n) e)Source
unsafeSplitColsAt :: (BaseMatrix a x, Storable e) => Int -> a (m, n) e -> (a (m, n1) e, a (m, n2) e)Source
Row and Column views
rowViews :: (BaseMatrix a x, Storable e) => a (m, n) e -> [x n e]Source
Get a list of vector views of the rows of the matrix.
colViews :: (BaseMatrix a x, Storable e) => a (m, n) e -> [x m e]Source
Get a list of vector views of the columns of the matrix.
rowView :: (BaseMatrix a x, Storable e) => a (m, n) e -> Int -> x n eSource
Get a vector view of the given row in a matrix.
colView :: (BaseMatrix a x, Storable e) => a (m, n) e -> Int -> x m eSource
Get a vector view of the given column in a matrix.
diagView :: (BaseMatrix a x, Storable e) => a mn e -> Int -> x k eSource
Get a vector view of the given diagonal in a matrix.
unsafeRowView :: (BaseMatrix a x, Storable e) => a (k, l) e -> Int -> x l eSource
unsafeColView :: (BaseMatrix a x, Storable e) => a (k, l) e -> Int -> x k eSource
unsafeDiagView :: (BaseMatrix a x, Storable e) => a mn e -> Int -> x k eSource
Getting rows and columns
getDiag :: (ReadMatrix a x m, WriteVector y m, BLAS1 e) => a mn e -> Int -> m (y k e)Source
Get the given diagonal in a matrix. Negative indices correspond to sub-diagonals.
unsafeGetDiag :: (ReadMatrix a x m, WriteVector y m, BLAS1 e) => a mn e -> Int -> m (y k e)Source
Same as getDiag but not range-checked.
Copying matrices
newCopyMatrix :: (BLAS1 e, ReadMatrix a x m, WriteMatrix b y m) => a mn e -> m (b mn e)Source
copyMatrix :: (WriteMatrix b y m, ReadMatrix a x m, BLAS1 e) => b mn e -> a mn e -> m ()Source
copyMatrix dst src replaces the values in dst with those in source. The operands must be the same shape.
swapMatrix :: (WriteMatrix a x m, BLAS1 e) => a mn e -> a mn e -> m ()Source
swapMatrix x y swaps the values stored in two matrices.
unsafeCopyMatrix :: (BLAS1 e, WriteMatrix b y m, ReadMatrix a x m) => b mn e -> a mn e -> m ()Source
unsafeSwapMatrix :: (WriteMatrix a x m, BLAS1 e) => a mn e -> a mn e -> m ()Source
Swapping rows and columns
swapRows :: (WriteMatrix a x m, BLAS1 e) => a (r, s) e -> Int -> Int -> m ()Source
swapCols :: (WriteMatrix a x m, BLAS1 e) => a (r, s) e -> Int -> Int -> m ()Source
unsafeSwapRows :: (WriteMatrix a x m, BLAS1 e) => a (r, s) e -> Int -> Int -> m ()Source
unsafeSwapCols :: (WriteMatrix a x m, BLAS1 e) => a (r, s) e -> Int -> Int -> m ()Source
Matrix operations
Unsary
getConjMatrix :: (ReadMatrix a x m, WriteMatrix b y m, BLAS1 e) => a mn e -> m (b mn e)Source
Get a new matrix with elements with the conjugates of the elements of the given matrix.
getScaledMatrix :: (ReadMatrix a x m, WriteMatrix b y m, BLAS1 e) => e -> a mn e -> m (b mn e)Source
Get a new matrix by scaling the elements of another matrix by a given value.
getShiftedMatrix :: (ReadMatrix a x m, WriteMatrix b y m, BLAS1 e) => e -> a mn e -> m (b mn e)Source
Get a new matrix by shifting the elements of another matrix by a given value.
Binary
getAddMatrix :: (ReadMatrix a x m, ReadMatrix b x m, WriteMatrix c z m, BLAS1 e) => a mn e -> b mn e -> m (c mn e)Source
getAddMatrix a b creates a new matrix equal to the sum a+b. The operands must have the same shape.
getSubMatrix :: (ReadMatrix a x m, ReadMatrix b x m, WriteMatrix c z m, BLAS1 e) => a mn e -> b mn e -> m (c mn e)Source
getSubMatrix a b creates a new matrix equal to the difference a-b. The operands must have the same shape.
getMulMatrix :: (ReadMatrix a x m, ReadMatrix b x m, WriteMatrix c z m, BLAS1 e) => a mn e -> b mn e -> m (c mn e)Source
getMulMatrix a b creates a new matrix equal to the elementwise product a*b. The operands must have the same shape.
getDivMatrix :: (ReadMatrix a x m, ReadMatrix b x m, WriteMatrix c z m, BLAS1 e) => a mn e -> b mn e -> m (c mn e)Source
getDivMatrix a b creates a new matrix equal to the elementwise ratio a/b. The operands must have the same shape.
addMatrix :: (WriteMatrix b y m, ReadMatrix a x m, BLAS1 e) => b n e -> a n e -> m ()Source
subMatrix :: (WriteMatrix b y m, ReadMatrix a x m, BLAS1 e) => b n e -> a n e -> m ()Source
axpyMatrix :: (ReadMatrix a x m, WriteMatrix b y m, BLAS1 e) => e -> a n e -> b n e -> m ()Source
mulMatrix :: (WriteMatrix b y m, ReadMatrix a x m, BLAS1 e) => b n e -> a n e -> m ()Source
divMatrix :: (WriteMatrix b y m, ReadMatrix a x m, BLAS1 e) => b n e -> a n e -> m ()Source
Unsafe
unsafeGetAddMatrix :: (ReadMatrix a x m, ReadMatrix b x m, WriteMatrix c z m, BLAS1 e) => a mn e -> b mn e -> m (c mn e)Source
unsafeGetSubMatrix :: (ReadMatrix a x m, ReadMatrix b x m, WriteMatrix c z m, BLAS1 e) => a mn e -> b mn e -> m (c mn e)Source
unsafeGetMulMatrix :: (ReadMatrix a x m, ReadMatrix b x m, WriteMatrix c z m, BLAS1 e) => a mn e -> b mn e -> m (c mn e)Source
unsafeGetDivMatrix :: (ReadMatrix a x m, ReadMatrix b x m, WriteMatrix c z m, BLAS1 e) => a mn e -> b mn e -> m (c mn e)Source
unsafeAddMatrix :: (WriteMatrix b y m, ReadMatrix a x m, BLAS1 e) => b n e -> a n e -> m ()Source
unsafeSubMatrix :: (WriteMatrix b y m, ReadMatrix a x m, BLAS1 e) => b n e -> a n e -> m ()Source
unsafeAxpyMatrix :: (ReadMatrix a x m, WriteMatrix b y m, BLAS1 e) => e -> a mn e -> b mn e -> m ()Source
unsafeMulMatrix :: (WriteMatrix b y m, ReadMatrix a x m, BLAS1 e) => b mn e -> a mn e -> m ()Source
unsafeDivMatrix :: (WriteMatrix b y m, ReadMatrix a x m, BLAS1 e) => b mn e -> a mn e -> m ()Source
module BLAS.Matrix.Mutable
Low-level functions
ldaOfMatrix :: BaseMatrix a x => a mn e -> IntSource
isHermMatrix :: BaseMatrix a x => a mn e -> BoolSource
withMatrixPtr :: BaseMatrix a x => a mn e -> (Ptr e -> IO b) -> IO bSource
Produced by Haddock version 2.3.0