Safe Haskell | None |
---|---|

Language | Haskell98 |

- data Matrix = Matrix {}
- fromList :: [[Double]] -> Matrix
- toList :: Matrix -> [[Double]]
- generate :: Int -> Int -> (Int -> Int -> Double) -> Matrix
- empty :: Matrix
- zero :: Int -> Int -> Matrix
- ones :: Int -> Int -> Matrix
- identity :: Int -> Matrix
- constant :: Int -> Int -> Double -> Matrix
- cols :: Matrix -> Int
- rows :: Matrix -> Int
- coeff :: Int -> Int -> Matrix -> Double
- minCoeff :: Matrix -> Double
- maxCoeff :: Matrix -> Double
- col :: Int -> Matrix -> [Double]
- row :: Int -> Matrix -> [Double]
- block :: Int -> Int -> Int -> Int -> Matrix -> Matrix
- topRows :: Int -> Matrix -> Matrix
- bottomRows :: Int -> Matrix -> Matrix
- leftCols :: Int -> Matrix -> Matrix
- rightCols :: Int -> Matrix -> Matrix
- norm :: Matrix -> Double
- squaredNorm :: Matrix -> Double
- determinant :: Matrix -> Double
- add :: Matrix -> Matrix -> Matrix
- sub :: Matrix -> Matrix -> Matrix
- mul :: Matrix -> Matrix -> Matrix
- inverse :: Matrix -> Matrix
- adjoint :: Matrix -> Matrix
- conjugate :: Matrix -> Matrix
- transpose :: Matrix -> Matrix
- normalize :: Matrix -> Matrix
- modify :: (forall s. MMatrix s -> ST s ()) -> Matrix -> Matrix
- thaw :: PrimMonad m => Matrix -> m (MMatrix (PrimState m))
- freeze :: PrimMonad m => MMatrix (PrimState m) -> m Matrix
- unsafeThaw :: PrimMonad m => Matrix -> m (MMatrix (PrimState m))
- unsafeFreeze :: PrimMonad m => MMatrix (PrimState m) -> m Matrix

# Matrix type

constant Matrix class to be used in pure computations, uses the same column major memory layout as Eigen MatrixXd

# Matrix conversions

fromList :: [[Double]] -> Matrix Source

construct matrix from a list of rows, column count is detected as maximum row length

generate :: Int -> Int -> (Int -> Int -> Double) -> Matrix Source

craete matrix using generator function f :: row -> col -> val

# Standard matrices and special cases

constant :: Int -> Int -> Double -> Matrix Source

matrix where all coeffs are filled with given value

# Accessing matrix data

block :: Int -> Int -> Int -> Int -> Matrix -> Matrix Source

extract rectangular block from matrix defined by startRow startCol blockRows blockCols

bottomRows :: Int -> Matrix -> Matrix Source

bottom n rows of matrix

# Matrix properties

norm :: Matrix -> Double Source

for vectors, the l2 norm, and for matrices the Frobenius norm. In both cases, it consists in the square root of the sum of the square of all the matrix entries. For vectors, this is also equals to the square root of the dot product of this with itself.

squaredNorm :: Matrix -> Double Source

for vectors, the squared l2 norm, and for matrices the Frobenius norm. In both cases, it consists in the sum of the square of all the matrix entries. For vectors, this is also equals to the dot product of this with itself.

determinant :: Matrix -> Double Source

the determinant of the matrix

# Matrix operations

# Matrix transformations

inverse :: Matrix -> Matrix Source

inverse of the matrix

For small fixed sizes up to 4x4, this method uses cofactors. In the general case, this method uses class `PartialPivLU`

modify :: (forall s. MMatrix s -> ST s ()) -> Matrix -> Matrix Source

Apply a destructive operation to a matrix. The operation will be performed in place if it is safe to do so and will modify a copy of the matrix otherwise.

# Mutable matrices

thaw :: PrimMonad m => Matrix -> m (MMatrix (PrimState m)) Source

Yield a mutable copy of the immutable matrix

freeze :: PrimMonad m => MMatrix (PrimState m) -> m Matrix Source

Yield an immutable copy of the mutable matrix