sparse-tensor-0.2.1.2: typesafe tensor algebra library

Copyright (c) 2019 Tobias Reinhart and Nils Alex MIT tobi.reinhart@fau.de, nils.alex@fau.de None Haskell2010

Math.Tensor.Internal.LinearAlgebra

Description

Gaussian elimination algorithm based on hmatrix.

Synopsis

# Gaussian Elimination

gaussianST :: Int -> Int -> STMatrix s Double -> ST s () Source #

Gaussian elimination perfomed in-place in the ST monad.

Gaussian elimination as pure function. Involves a copy of the input matrix.

λ let mat = (3 >< 4) [1, 1, -2, 0, 0, 2, -6, -4, 3, 0, 3, 1]
λ mat
(3><4)
[ 1.0, 1.0, -2.0,  0.0
, 0.0, 2.0, -6.0, -4.0
, 3.0, 0.0,  3.0,  1.0 ]
λ gaussian mat
(3><4)
[ 3.0, 0.0,  3.0,                1.0
, 0.0, 2.0, -6.0,               -4.0
, 0.0, 0.0,  0.0, 1.6666666666666667 ]


# Linearly Independent Columns

Returns the indices of a maximal linearly independent subset of the columns in the matrix.

λ let mat = (3 >< 4) [1, 1, -2, 0, 0, 2, -6, -4, 3, 0, 3, 1]
λ mat
(3><4)
[ 1.0, 1.0, -2.0,  0.0
, 0.0, 2.0, -6.0, -4.0
, 3.0, 0.0,  3.0,  1.0 ]
λ independentColumns mat
[0,1,3]


Returns a sub matrix containing a maximal linearly independent subset of the columns in the matrix.

λ let mat = (3 >< 4) [1, 1, -2, 0, 0, 2, -6, -4, 3, 0, 3, 1]
λ mat
(3><4)
[ 1.0, 1.0, -2.0,  0.0
, 0.0, 2.0, -6.0, -4.0
, 3.0, 0.0,  3.0,  1.0 ]
λ independentColumnsMat mat
(3><3)
[ 1.0, 1.0,  0.0
, 0.0, 2.0, -4.0
, 3.0, 0.0,  1.0 ]


# Pivots

Returns the pivot columns of an upper triangular matrix.

λ let mat = (3 >< 4) [1, 0, 2, -3, 0, 0, 1, 0, 0, 0, 0, 0]
λ mat
(3><4)
[ 1.0, 0.0, 2.0, -3.0
, 0.0, 0.0, 1.0,  0.0
, 0.0, 0.0, 0.0,  0.0 ]
λ pivotsU mat
[0,2]


findPivotMax :: Int -> Int -> Int -> Int -> STMatrix s Double -> ST s (Maybe (Int, Int)) Source #

Find pivot element below position (i, j) with greatest absolute value in the ST monad.