hmatrix-0.20.2: Numeric Linear Algebra

Copyright | (c) Alberto Ruiz 2006-15
License | BSD3
Maintainer | Alberto Ruiz
Stability | provisional
Safe Haskell | None
Language | Haskell2010

Numeric.LinearAlgebra

Contents

- Basic types and data manipulation
- Numeric classes
- Autoconformable dimensions
- Products
  - Dot
  - Matrix-vector
  - Matrix-matrix
  - Other
- Linear systems
  - General
  - Determined
  - Symmetric indefinite
  - Positive definite
  - Triangular
  - Tridiagonal
  - Sparse
- Inverse and pseudoinverse
- Determinant and rank
- Norms
- Nullspace and range
- Singular value decomposition
- Eigendecomposition
- QR
- Cholesky
- LU
- Hessenberg
- Schur
- Matrix functions
- Correlation and convolution
- Random arrays
- Misc
- Auxiliary classes

Description

Synopsis

- module Numeric.LinearAlgebra.Data
- dot :: Numeric t => Vector t -> Vector t -> t
- (<.>) :: Numeric t => Vector t -> Vector t -> t
- (#>) :: Numeric t => Matrix t -> Vector t -> Vector t
- (<#) :: Numeric t => Vector t -> Matrix t -> Vector t
- (!#>) :: GMatrix -> Vector Double -> Vector Double
- (<>) :: Numeric t => Matrix t -> Matrix t -> Matrix t
- outer :: Product t => Vector t -> Vector t -> Matrix t
- kronecker :: Product t => Matrix t -> Matrix t -> Matrix t
- cross :: Product t => Vector t -> Vector t -> Vector t
- scale :: Linear t c => t -> c t -> c t
- add :: Additive c => c -> c -> c
- sumElements :: Container c e => c e -> e
- prodElements :: Container c e => c e -> e
- (<\>) :: (LSDiv c, Field t) => Matrix t -> c t -> c t
- linearSolveLS :: Field t => Matrix t -> Matrix t -> Matrix t
- linearSolveSVD :: Field t => Matrix t -> Matrix t -> Matrix t
- linearSolve :: Field t => Matrix t -> Matrix t -> Maybe (Matrix t)
- luSolve :: Field t => LU t -> Matrix t -> Matrix t
- luPacked :: Field t => Matrix t -> LU t
- luSolve' :: (Fractional t, Container Vector t) => LU t -> Matrix t -> Matrix t
- luPacked' :: (Container Vector t, Fractional t, Normed (Vector t), Num (Vector t)) => Matrix t -> LU t
- ldlSolve :: Field t => LDL t -> Matrix t -> Matrix t
- ldlPacked :: Field t => Herm t -> LDL t
- cholSolve :: Field t => Matrix t -> Matrix t -> Matrix t
- data UpLo
  - = Lower
  - | Upper
- triSolve :: Field t => UpLo -> Matrix t -> Matrix t -> Matrix t
- triDiagSolve :: Field t => Vector t -> Vector t -> Vector t -> Matrix t -> Matrix t
- cgSolve :: Bool -> GMatrix -> Vector R -> Vector R
- cgSolve' :: Bool -> R -> R -> Int -> GMatrix -> Vector R -> Vector R -> [CGState]
- inv :: Field t => Matrix t -> Matrix t
- pinv :: Field t => Matrix t -> Matrix t
- pinvTol :: Field t => Double -> Matrix t -> Matrix t
- rcond :: Field t => Matrix t -> Double
- rank :: Field t => Matrix t -> Int
- det :: Field t => Matrix t -> t
- invlndet :: Field t => Matrix t -> (Matrix t, (t, t))
- class Normed a where
  - norm_0 :: a -> R
  - norm_1 :: a -> R
  - norm_2 :: a -> R
  - norm_Inf :: a -> R
- norm_Frob :: (Normed (Vector t), Element t) => Matrix t -> R
- norm_nuclear :: Field t => Matrix t -> R
- orth :: Field t => Matrix t -> Matrix t
- nullspace :: Field t => Matrix t -> Matrix t
- null1 :: Matrix R -> Vector R
- null1sym :: Herm R -> Vector R
- svd :: Field t => Matrix t -> (Matrix t, Vector Double, Matrix t)
- thinSVD :: Field t => Matrix t -> (Matrix t, Vector Double, Matrix t)
- compactSVD :: Field t => Matrix t -> (Matrix t, Vector Double, Matrix t)
- compactSVDTol :: Field t => Double -> Matrix t -> (Matrix t, Vector Double, Matrix t)
- singularValues :: Field t => Matrix t -> Vector Double
- leftSV :: Field t => Matrix t -> (Matrix t, Vector Double)
- rightSV :: Field t => Matrix t -> (Vector Double, Matrix t)
- eig :: Field t => Matrix t -> (Vector (Complex Double), Matrix (Complex Double))
- geig :: Field t => Matrix t -> Matrix t -> (Vector (Complex Double), Vector t, Matrix (Complex Double))
- eigSH :: Field t => Herm t -> (Vector Double, Matrix t)
- eigenvalues :: Field t => Matrix t -> Vector (Complex Double)
- geigenvalues :: Field t => Matrix t -> Matrix t -> (Vector (Complex Double), Vector t)
- eigenvaluesSH :: Field t => Herm t -> Vector Double
- geigSH :: Field t => Herm t -> Herm t -> (Vector Double, Matrix t)
- qr :: Field t => Matrix t -> (Matrix t, Matrix t)
- thinQR :: Field t => Matrix t -> (Matrix t, Matrix t)
- rq :: Field t => Matrix t -> (Matrix t, Matrix t)
- thinRQ :: Field t => Matrix t -> (Matrix t, Matrix t)
- qrRaw :: Field t => Matrix t -> QR t
- qrgr :: Field t => Int -> QR t -> Matrix t
- chol :: Field t => Herm t -> Matrix t
- mbChol :: Field t => Herm t -> Maybe (Matrix t)
- lu :: Field t => Matrix t -> (Matrix t, Matrix t, Matrix t, t)
- luFact :: Numeric t => LU t -> (Matrix t, Matrix t, Matrix t, t)
- hess :: Field t => Matrix t -> (Matrix t, Matrix t)
- schur :: Field t => Matrix t -> (Matrix t, Matrix t)
- expm :: Field t => Matrix t -> Matrix t
- sqrtm :: Field t => Matrix t -> Matrix t
- matFunc :: (Complex Double -> Complex Double) -> Matrix (Complex Double) -> Matrix (Complex Double)
- corr :: (Container Vector t, Product t) => Vector t -> Vector t -> Vector t
- conv :: (Container Vector t, Product t, Num t) => Vector t -> Vector t -> Vector t
- corrMin :: (Container Vector t, RealElement t, Product t) => Vector t -> Vector t -> Vector t
- corr2 :: Product a => Matrix a -> Matrix a -> Matrix a
- conv2 :: (Num (Matrix a), Product a, Container Vector a) => Matrix a -> Matrix a -> Matrix a
- type Seed = Int
- data RandDist
  - = Uniform
  - | Gaussian
- randomVector :: Seed -> RandDist -> Int -> Vector Double
- rand :: Int -> Int -> IO (Matrix Double)
- randn :: Int -> Int -> IO (Matrix Double)
- gaussianSample :: Seed -> Int -> Vector Double -> Herm Double -> Matrix Double
- uniformSample :: Seed -> Int -> [(Double, Double)] -> Matrix Double
- meanCov :: Matrix Double -> (Vector Double, Herm Double)
- rowOuters :: Matrix Double -> Matrix Double -> Matrix Double
- pairwiseD2 :: Matrix Double -> Matrix Double -> Matrix Double
- normalize :: (Normed (Vector t), Num (Vector t), Field t) => Vector t -> Vector t
- peps :: RealFloat x => x
- relativeError :: Num a => (a -> Double) -> a -> a -> Double
- magnit :: (Element t, Normed (Vector t)) => R -> t -> Bool
- haussholder :: Field a => a -> Vector a -> Matrix a
- optimiseMult :: Monoid (Matrix t) => [Matrix t] -> Matrix t
- udot :: Product e => Vector e -> Vector e -> e
- nullspaceSVD :: Field t => Either Double Int -> Matrix t -> (Vector Double, Matrix t) -> Matrix t
- orthSVD :: Field t => Either Double Int -> Matrix t -> (Matrix t, Vector Double) -> Matrix t
- ranksv :: Double -> Int -> [Double] -> Int
- iC :: C
- sym :: Field t => Matrix t -> Herm t
- mTm :: Numeric t => Matrix t -> Herm t
- trustSym :: Matrix t -> Herm t
- unSym :: Herm t -> Matrix t
- class Storable a => Element a
- class Element e => Container (c :: Type -> Type) e
- class (Num e, Element e) => Product e
- class (Container Vector t, Container Matrix t, Konst t Int Vector, Konst t (Int, Int) Matrix, CTrans t, Product t, Additive (Vector t), Additive (Matrix t), Linear t Vector, Linear t Matrix) => Numeric t
- class LSDiv (c :: Type -> Type)
- data Herm t
- class Complexable (c :: Type -> Type)
- class (Element t, Element (Complex t), RealFloat t) => RealElement t
- type family RealOf x
- type ComplexOf x = Complex (RealOf x)
- type family SingleOf x
- type family DoubleOf x
- type family IndexOf (c :: Type -> Type)
- class (Numeric t, Convert t, Normed Matrix t, Normed Vector t, Floating t, Linear t Vector, Linear t Matrix, Additive (Vector t), Additive (Matrix t), RealOf t ~ Double) => Field t
- class Linear t (c :: Type -> Type)
- class Additive c
- class Transposable m mt | m -> mt, mt -> m
- data LU t = LU (Matrix t) [Int]
- data LDL t = LDL (Matrix t) [Int]
- data QR t = QR (Matrix t) (Vector t)
- data CGState = CGState {
  - cgp :: Vector R
  - cgr :: Vector R
  - cgr2 :: R
  - cgx :: Vector R
  - cgdx :: R
  }
- class Testable t where
  - checkT :: t -> (Bool, IO ())
  - ioCheckT :: t -> IO (Bool, IO ())

# Basic types and data manipulation

This package works with 2D (`Matrix`) and 1D (`Vector`) arrays of real (`R`) or complex (`C`) double precision numbers. Single precision and machine integers are also supported for basic arithmetic and data manipulation.

module Numeric.LinearAlgebra.Data

# Numeric classes

The standard numeric classes are defined elementwise (commonly referred to as the Hadamard product or the Schur product):

    >>> vector [1,2,3] * vector [3,0,-2]
    [3.0,0.0,-6.0]
    it :: Vector R

    >>> matrix 3 [1..9] * ident 3
    (3><3)
     [ 1.0, 0.0, 0.0
     , 0.0, 5.0, 0.0
     , 0.0, 0.0, 9.0 ]

# Autoconformable dimensions

In most operations, single-element vectors and matrices (created from numeric literals or using `scalar`), and matrices with just one row or column, automatically expand to match the dimensions of the other operand:

    >>> 5 + 2*ident 3 :: Matrix Double
    (3><3)
     [ 7.0, 5.0, 5.0
     , 5.0, 7.0, 5.0
     , 5.0, 5.0, 7.0 ]

    >>> (4><3) [1..] + row [10,20,30]
    (4><3)
     [ 11.0, 22.0, 33.0
     , 14.0, 25.0, 36.0
     , 17.0, 28.0, 39.0
     , 20.0, 31.0, 42.0 ]

# Products

## Dot

dot :: Numeric t => Vector t -> Vector t -> t Source #

(<.>) :: Numeric t => Vector t -> Vector t -> t infixr 8 Source #

An infix synonym for `dot`

    >>> vector [1,2,3,4] <.> vector [-2,0,1,1]
    5.0

    >>> let 𝑖 = 0:+1 :: C
    >>> fromList [1+𝑖,1] <.> fromList [1,1+𝑖]
    2.0 :+ 0.0

## Matrix-vector

(#>) :: Numeric t => Matrix t -> Vector t -> Vector t infixr 8 Source #

dense matrix-vector product

    >>> let m = (2><3) [1..]
    >>> m
    (2><3)
     [ 1.0, 2.0, 3.0
     , 4.0, 5.0, 6.0 ]

    >>> let v = vector [10,20,30]

    >>> m #> v
    [140.0,320.0]
    it :: Vector Numeric.LinearAlgebra.Data.R

(<#) :: Numeric t => Vector t -> Matrix t -> Vector t infixl 8 Source #

dense vector-matrix product

(!#>) :: GMatrix -> Vector Double -> Vector Double infixr 8 Source #

general matrix - vector product

    >>> let m = mkSparse [((0,999),1.0),((1,1999),2.0)]
    m :: GMatrix
    >>> m !#> vector [1..2000]
    [1000.0,4000.0]
    it :: Vector Double

## Matrix-matrix

(<>) :: Numeric t => Matrix t -> Matrix t -> Matrix t infixr 8 Source #

dense matrix product

    >>> let a = (3><5) [1..]
    >>> a
    (3><5)
     [  1.0,  2.0,  3.0,  4.0,  5.0
     ,  6.0,  7.0,  8.0,  9.0, 10.0
     , 11.0, 12.0, 13.0, 14.0, 15.0 ]

    >>> let b = (5><2) [1,3, 0,2, -1,5, 7,7, 6,0]
    >>> b
    (5><2)
     [  1.0, 3.0
     ,  0.0, 2.0
     , -1.0, 5.0
     ,  7.0, 7.0
     ,  6.0, 0.0 ]

    >>> a <> b
    (3><2)
     [  56.0,  50.0
     , 121.0, 135.0
     , 186.0, 220.0 ]

The matrix product is also implemented in the Data.Monoid instance, where single-element matrices (created from numeric literals or using `scalar`) are used for scaling.

    >>> import Data.Monoid as M
    >>>  let m = matrix 3 [1..6]
    >>> m M.<> 2 M.<> diagl[0.5,1,0]
    (2><3)
     [ 1.0,  4.0, 0.0
     , 4.0, 10.0, 0.0 ]

`mconcat` uses `optimiseMult` to get the optimal association order.

## Other

outer :: Product t => Vector t -> Vector t -> Matrix t Source #

Outer product of two vectors.

    >>> fromList [1,2,3] `outer` fromList [5,2,3]
    (3><3)
     [  5.0, 2.0, 3.0
     , 10.0, 4.0, 6.0
     , 15.0, 6.0, 9.0 ]

kronecker :: Product t => Matrix t -> Matrix t -> Matrix t Source #

Kronecker product of two matrices.

    m1=(2><3)
     [ 1.0,  2.0, 0.0
     , 0.0, -1.0, 3.0 ]
    m2=(4><3)
     [  1.0,  2.0,  3.0
     ,  4.0,  5.0,  6.0
     ,  7.0,  8.0,  9.0
     , 10.0, 11.0, 12.0 ]

    >>> kronecker m1 m2
    (8><9)
     [  1.0,  2.0,  3.0,   2.0,   4.0,   6.0,  0.0,  0.0,  0.0
     ,  4.0,  5.0,  6.0,   8.0,  10.0,  12.0,  0.0,  0.0,  0.0
     ,  7.0,  8.0,  9.0,  14.0,  16.0,  18.0,  0.0,  0.0,  0.0
     , 10.0, 11.0, 12.0,  20.0,  22.0,  24.0,  0.0,  0.0,  0.0
     ,  0.0,  0.0,  0.0,  -1.0,  -2.0,  -3.0,  3.0,  6.0,  9.0
     ,  0.0,  0.0,  0.0,  -4.0,  -5.0,  -6.0, 12.0, 15.0, 18.0
     ,  0.0,  0.0,  0.0,  -7.0,  -8.0,  -9.0, 21.0, 24.0, 27.0
     ,  0.0,  0.0,  0.0, -10.0, -11.0, -12.0, 30.0, 33.0, 36.0 ]

cross :: Product t => Vector t -> Vector t -> Vector t Source #

cross product (for three-element vectors)

scale :: Linear t c => t -> c t -> c t Source #

add :: Additive c => c -> c -> c Source #

sumElements :: Container c e => c e -> e Source #

the sum of elements

prodElements :: Container c e => c e -> e Source #

the product of elements

# Linear systems

## General

(<\>) :: (LSDiv c, Field t) => Matrix t -> c t -> c t infixl 7 Source #

Least squares solution of a linear system, similar to the \ operator of Matlab/Octave (based on linearSolveSVD)

    a = (3><2)
     [ 1.0,  2.0
     , 2.0,  4.0
     , 2.0, -1.0 ]

    v = vector [13.0,27.0,1.0]

    >>> let x = a <\> v
    >>> x
    [3.0799999999999996,5.159999999999999]
    it :: Vector Numeric.LinearAlgebra.Data.R

    >>> a #> x
    [13.399999999999999,26.799999999999997,0.9999999999999991]
    it :: Vector Numeric.LinearAlgebra.Data.R

It also admits multiple right-hand sides stored as columns in a matrix.

linearSolveLS :: Field t => Matrix t -> Matrix t -> Matrix t Source #

Least squared error solution of an overconstrained linear system, or the minimum norm solution of an underconstrained system. For rank-deficient systems use `linearSolveSVD`.

linearSolveSVD :: Field t => Matrix t -> Matrix t -> Matrix t Source #

Minimum norm solution of a general linear least squares problem Ax=B using the SVD. Admits rank-deficient systems but it is slower than `linearSolveLS`. The effective rank of A is determined by treating as zero those singular valures which are less than `eps` times the largest singular value.

## Determined

linearSolve :: Field t => Matrix t -> Matrix t -> Maybe (Matrix t) Source #

Solve a linear system (for square coefficient matrix and several right-hand sides) using the LU decomposition, returning Nothing for a singular system. For underconstrained or overconstrained systems use `linearSolveLS` or `linearSolveSVD`.

    a = (2><2)
     [ 1.0, 2.0
     , 3.0, 5.0 ]

    b = (2><3)
     [  6.0, 1.0, 10.0
     , 15.0, 3.0, 26.0 ]

    >>> linearSolve a b
    Just (2><3)
     [ -1.4802973661668753e-15,     0.9999999999999997, 1.999999999999997
     ,       3.000000000000001, 1.6653345369377348e-16, 4.000000000000002 ]

    >>> let Just x = it
    >>> disp 5 x
    2x3
    -0.00000  1.00000  2.00000
     3.00000  0.00000  4.00000

    >>> a <> x
    (2><3)
     [  6.0, 1.0, 10.0
     , 15.0, 3.0, 26.0 ]

luSolve :: Field t => LU t -> Matrix t -> Matrix t Source #

Solution of a linear system (for several right hand sides) from the precomputed LU factorization obtained by `luPacked`.

luPacked :: Field t => Matrix t -> LU t Source #

Obtains the LU decomposition of a matrix in a compact data structure suitable for `luSolve`.

luSolve' :: (Fractional t, Container Vector t) => LU t -> Matrix t -> Matrix t Source #

Experimental implementation of `luSolve` for any Fractional element type, including `Mod` n `I` and `Mod` n `Z`.

    >>> let a = (2><2) [1,2,3,5] :: Matrix (Z ./. 13)
    (2><2)
     [ 1, 2
     , 3, 5 ]
    >>> b
    (2><3)
     [ 5, 1, 3
     , 8, 6, 3 ]

    >>> luSolve' (luPacked' a) b
    (2><3)
     [ 4,  7, 4
     , 7, 10, 6 ]

luPacked' :: (Container Vector t, Fractional t, Normed (Vector t), Num (Vector t)) => Matrix t -> LU t Source #

Experimental implementation of `luPacked` for any Fractional element type, including `Mod` n `I` and `Mod` n `Z`.

    >>> let m = ident 5 + (5><5) [0..] :: Matrix (Z ./. 17)
    (5><5)
     [  1,  1,  2,  3,  4
     ,  5,  7,  7,  8,  9
     , 10, 11, 13, 13, 14
     , 15, 16,  0,  2,  2
     ,  3,  4,  5,  6,  8 ]

    >>> let (l,u,p,s) = luFact $ luPacked' m
    >>> l
    (5><5)
     [  1,  0, 0,  0, 0
     ,  6,  1, 0,  0, 0
     , 12,  7, 1,  0, 0
     ,  7, 10, 7,  1, 0
     ,  8,  2, 6, 11, 1 ]
    >>> u
    (5><5)
     [ 15, 16,  0,  2,  2
     ,  0, 13,  7, 13, 14
     ,  0,  0, 15,  0, 11
     ,  0,  0,  0, 15, 15
     ,  0,  0,  0,  0,  1 ]

## Symmetric indefinite

ldlSolve :: Field t => LDL t -> Matrix t -> Matrix t Source #

Solution of a linear system (for several right hand sides) from a precomputed LDL factorization obtained by `ldlPacked`.

Note: this can be slower than the general solver based on the LU decomposition.

ldlPacked :: Field t => Herm t -> LDL t Source #

Obtains the LDL decomposition of a matrix in a compact data structure suitable for `ldlSolve`.

## Positive definite

cholSolve Source #

Arguments

:: Field t |
=> Matrix t | Cholesky decomposition of the coefficient matrix
-> Matrix t | right hand sides
-> Matrix t | solution

Solve a symmetric or Hermitian positive definite linear system using a precomputed Cholesky decomposition obtained by `chol`.

## Triangular

data UpLo Source #

Constructors

Lower |
Upper |

triSolve Source #

Arguments

:: Field t |
=> UpLo | `Lower` or `Upper`
-> Matrix t | coefficient matrix
-> Matrix t | right hand sides
-> Matrix t | solution

Solve a triangular linear system. If `Upper` is specified then all elements below the diagonal are ignored; if `Lower` is specified then all elements above the diagonal are ignored.

## Tridiagonal

triDiagSolve Source #

Arguments

:: Field t |
=> Vector t | lower diagonal: \(n - 1\) elements
-> Vector t | diagonal: \(n\) elements
-> Vector t | upper diagonal: \(n - 1\) elements
-> Matrix t | right hand sides
-> Matrix t | solution

Solve a tridiagonal linear system. Suppose you wish to solve \(Ax = b\) where

\[ A = \begin{bmatrix} 1.0 & 4.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 \\ 3.0 & 1.0 & 4.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 \\ 0.0 & 3.0 & 1.0 & 4.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 \\ 0.0 & 0.0 & 3.0 & 1.0 & 4.0 & 0.0 & 0.0 & 0.0 & 0.0 \\ 0.0 & 0.0 & 0.0 & 3.0 & 1.0 & 4.0 & 0.0 & 0.0 & 0.0 \\ 0.0 & 0.0 & 0.0 & 0.0 & 3.0 & 1.0 & 4.0 & 0.0 & 0.0 \\ 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 3.0 & 1.0 & 4.0 & 0.0 \\ 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 3.0 & 1.0 & 4.0 \\ 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 3.0 & 1.0 \end{bmatrix} \quad b = \begin{bmatrix} 1.0 & 1.0 & 1.0 \\ 1.0 & -1.0 & 2.0 \\ 1.0 & 1.0 & 3.0 \\ 1.0 & -1.0 & 4.0 \\ 1.0 & 1.0 & 5.0 \\ 1.0 & -1.0 & 6.0 \\ 1.0 & 1.0 & 7.0 \\ 1.0 & -1.0 & 8.0 \\ 1.0 & 1.0 & 9.0 \end{bmatrix} \]

then

    dL =  fromList [3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0]
    d  =  fromList [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
    dU =  fromList [4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0]

    b = (9><3)
        [
          1.0,   1.0,   1.0,
          1.0,  -1.0,   2.0,
          1.0,   1.0,   3.0,
          1.0,  -1.0,   4.0,
          1.0,   1.0,   5.0,
          1.0,  -1.0,   6.0,
          1.0,   1.0,   7.0,
          1.0,  -1.0,   8.0,
          1.0,   1.0,   9.0
        ]

    x = triDiagSolve dL d dU b

## Sparse

cgSolve Source #

Arguments

:: Bool | is symmetric
-> GMatrix | coefficient matrix
-> Vector R | right-hand side
-> Vector R | solution

Solve a sparse linear system using the conjugate gradient method with default parameters.

cgSolve' Source #

Arguments

:: Bool | symmetric
-> R | relative tolerance for the residual (e.g. 1E-4)
-> R | relative tolerance for δx (e.g. 1E-3)
-> Int | maximum number of iterations
-> GMatrix | coefficient matrix
-> Vector R | initial solution
-> Vector R | right-hand side
-> [CGState] | solution

Solve a sparse linear system using the conjugate gradient method with default parameters.

# Inverse and pseudoinverse

inv :: Field t => Matrix t -> Matrix t Source #

Inverse of a square matrix. See also `invlndet`.

pinv :: Field t => Matrix t -> Matrix t Source #

Pseudoinverse of a general matrix with default tolerance (`pinvTol` 1, similar to GNU-Octave).

pinvTol :: Field t => Double -> Matrix t -> Matrix t Source #

`pinvTol r` computes the pseudoinverse of a matrix with tolerance `tol=r*g*eps*(max rows cols)`, where g is the greatest singular value.

    m = (3><3) [ 1, 0,    0
               , 0, 1,    0
               , 0, 0, 1e-10] :: Matrix Double

    >>> pinv m
    1. 0.           0.
    0. 1.           0.
    0. 0. 10000000000.

    >>> pinvTol 1E8 m
    1. 0. 0.
    0. 1. 0.
    0. 0. 1.

# Determinant and rank

rcond :: Field t => Matrix t -> Double Source #

Reciprocal of the 2-norm condition number of a matrix, computed from the singular values.

rank :: Field t => Matrix t -> Int Source #

Number of linearly independent rows or columns. See also `ranksv`

det :: Field t => Matrix t -> t Source #

Determinant of a square matrix. To avoid possible overflow or underflow use `invlndet`.

invlndet Source #

Arguments

:: Field t |
=> Matrix t |
-> (Matrix t, (t, t)) | (inverse, (log abs det, sign or phase of det))

Joint computation of inverse and logarithm of determinant of a square matrix.

# Norms

class Normed a where Source #

p-norm for vectors, operator norm for matrices

Methods

norm_0 :: a -> R Source #

norm_1 :: a -> R Source #

norm_2 :: a -> R Source #

norm_Inf :: a -> R Source #

#### Instances

Instances details

Normed (Matrix C) Source # |
Instance details Defined in Internal.Util Methods norm_0 :: Matrix C -> R Source # norm_1 :: Matrix C -> R Source # norm_2 :: Matrix C -> R Source # norm_Inf :: Matrix C -> R Source #
Normed (Matrix R) Source # |
Instance details Defined in Internal.Util Methods norm_0 :: Matrix R -> R Source # norm_1 :: Matrix R -> R Source # norm_2 :: Matrix R -> R Source # norm_Inf :: Matrix R -> R Source #
KnownNat n => Normed (R n) Source # |
Instance details Defined in Numeric.LinearAlgebra.Static Methods norm_0 :: R n -> R Source # norm_1 :: R n -> R Source # norm_2 :: R n -> R Source # norm_Inf :: R n -> R Source #
Normed (Vector (Complex Float)) Source # |
Instance details Defined in Internal.Util Methods norm_0 :: Vector (Complex Float) -> R Source # norm_1 :: Vector (Complex Float) -> R Source # norm_2 :: Vector (Complex Float) -> R Source # norm_Inf :: Vector (Complex Float) -> R Source #
KnownNat m => Normed (Vector (Mod m I)) Source # |
Instance details Defined in Internal.Modular Methods norm_0 :: Vector (Mod m I) -> R Source # norm_1 :: Vector (Mod m I) -> R Source # norm_2 :: Vector (Mod m I) -> R Source # norm_Inf :: Vector (Mod m I) -> R Source #
KnownNat m => Normed (Vector (Mod m Z)) Source # |
Instance details Defined in Internal.Modular Methods norm_0 :: Vector (Mod m Z) -> R Source # norm_1 :: Vector (Mod m Z) -> R Source # norm_2 :: Vector (Mod m Z) -> R Source # norm_Inf :: Vector (Mod m Z) -> R Source #
Normed (Vector C) Source # |
Instance details Defined in Internal.Util Methods norm_0 :: Vector C -> R Source # norm_1 :: Vector C -> R Source # norm_2 :: Vector C -> R Source # norm_Inf :: Vector C -> R Source #
Normed (Vector I) Source # |
Instance details Defined in Internal.Util Methods norm_0 :: Vector I -> R Source # norm_1 :: Vector I -> R Source # norm_2 :: Vector I -> R Source # norm_Inf :: Vector I -> R Source #
Normed (Vector R) Source # |
Instance details Defined in Internal.Util Methods norm_0 :: Vector R -> R Source # norm_1 :: Vector R -> R Source # norm_2 :: Vector R -> R Source # norm_Inf :: Vector R -> R Source #
Normed (Vector Z) Source # |
Instance details Defined in Internal.Util Methods norm_0 :: Vector Z -> R Source # norm_1 :: Vector Z -> R Source # norm_2 :: Vector Z -> R Source # norm_Inf :: Vector Z -> R Source #
Normed (Vector Float) Source # |
Instance details Defined in Internal.Util Methods norm_0 :: Vector Float -> R Source # norm_1 :: Vector Float -> R Source # norm_2 :: Vector Float -> R Source # norm_Inf :: Vector Float -> R Source #
(KnownNat m, KnownNat n) => Normed (L m n) Source # |
Instance details Defined in Numeric.LinearAlgebra.Static Methods norm_0 :: L m n -> R Source # norm_1 :: L m n -> R Source # norm_2 :: L m n -> R Source # norm_Inf :: L m n -> R Source #

norm_Frob :: (Normed (Vector t), Element t) => Matrix t -> R Source #

Frobenius norm (Schatten p-norm with p=2)

norm_nuclear :: Field t => Matrix t -> R Source #

Sum of singular values (Schatten p-norm with p=1)

# Nullspace and range

orth :: Field t => Matrix t -> Matrix t Source #

return an orthonormal basis of the range space of a matrix. See also `orthSVD`.

nullspace :: Field t => Matrix t -> Matrix t Source #

return an orthonormal basis of the null space of a matrix. See also `nullspaceSVD`.

null1 :: Matrix R -> Vector R Source #

solution of overconstrained homogeneous linear system

null1sym :: Herm R -> Vector R Source #

solution of overconstrained homogeneous symmetric linear system

# Singular value decomposition

svd :: Field t => Matrix t -> (Matrix t, Vector Double, Matrix t) Source #

Full singular value decomposition.

    a = (5><3)
     [  1.0,  2.0,  3.0
     ,  4.0,  5.0,  6.0
     ,  7.0,  8.0,  9.0
     , 10.0, 11.0, 12.0
     , 13.0, 14.0, 15.0 ] :: Matrix Double

    >>> let (u,s,v) = svd a

    >>> disp 3 u
    5x5
    -0.101   0.768   0.614   0.028  -0.149
    -0.249   0.488  -0.503   0.172   0.646
    -0.396   0.208  -0.405  -0.660  -0.449
    -0.543  -0.072  -0.140   0.693  -0.447
    -0.690  -0.352   0.433  -0.233   0.398

    >>> s
    [35.18264833189422,1.4769076999800903,1.089145439970417e-15]
    it :: Vector Double

    >>> disp 3 v
    3x3
    -0.519  -0.751   0.408
    -0.576  -0.046  -0.816
    -0.632   0.659   0.408

    >>> let d = diagRect 0 s 5 3
    >>> disp 3 d
    5x3
    35.183  0.000  0.000
     0.000  1.477  0.000
     0.000  0.000  0.000
     0.000  0.000  0.000

    >>> disp 3 $ u <> d <> tr v
    5x3
     1.000   2.000   3.000
     4.000   5.000   6.000
     7.000   8.000   9.000
    10.000  11.000  12.000
    13.000  14.000  15.000

thinSVD :: Field t => Matrix t -> (Matrix t, Vector Double, Matrix t) Source #

A version of `svd` which returns only the `min (rows m) (cols m)` singular vectors of `m`.

If `(u,s,v) = thinSVD m` then `m == u <> diag s <> tr v`.

    a = (5><3)
     [  1.0,  2.0,  3.0
     ,  4.0,  5.0,  6.0
     ,  7.0,  8.0,  9.0
     , 10.0, 11.0, 12.0
     , 13.0, 14.0, 15.0 ] :: Matrix Double

    >>> let (u,s,v) = thinSVD a

    >>> disp 3 u
    5x3
    -0.101   0.768   0.614
    -0.249   0.488  -0.503
    -0.396   0.208  -0.405
    -0.543  -0.072  -0.140
    -0.690  -0.352   0.433

    >>> s
    [35.18264833189422,1.4769076999800903,1.089145439970417e-15]
    it :: Vector Double

    >>> disp 3 v
    3x3
    -0.519  -0.751   0.408
    -0.576  -0.046  -0.816
    -0.632   0.659   0.408

    >>> disp 3 $ u <> diag s <> tr v
    5x3
     1.000   2.000   3.000
     4.000   5.000   6.000
     7.000   8.000   9.000
    10.000  11.000  12.000
    13.000  14.000  15.000

compactSVD :: Field t => Matrix t -> (Matrix t, Vector Double, Matrix t) Source #

Similar to `thinSVD`, returning only the nonzero singular values and the corresponding singular vectors.

    a = (5><3)
     [  1.0,  2.0,  3.0
     ,  4.0,  5.0,  6.0
     ,  7.0,  8.0,  9.0
     , 10.0, 11.0, 12.0
     , 13.0, 14.0, 15.0 ] :: Matrix Double

    >>> let (u,s,v) = compactSVD a

    >>> disp 3 u
    5x2
    -0.101   0.768
    -0.249   0.488
    -0.396   0.208
    -0.543  -0.072
    -0.690  -0.352

    >>> s
    [35.18264833189422,1.476907699980091]
    it :: Vector Double

    >>> disp 3 u
    5x2
    -0.101   0.768
    -0.249   0.488
    -0.396   0.208
    -0.543  -0.072
    -0.690  -0.352

    >>> disp 3 $ u <> diag s <> tr v
    5x3
     1.000   2.000   3.000
     4.000   5.000   6.000
     7.000   8.000   9.000
    10.000  11.000  12.000
    13.000  14.000  15.000

compactSVDTol :: Field t => Double -> Matrix t -> (Matrix t, Vector Double, Matrix t) Source #

`compactSVDTol r` is similar to `compactSVD` (for which `r=1`), but uses tolerance `tol=r*g*eps*(max rows cols)` to distinguish nonzero singular values, where `g` is the greatest singular value. If `g<r*eps`, then only one singular value is returned.

singularValues :: Field t => Matrix t -> Vector Double Source #

Singular values only.

leftSV :: Field t => Matrix t -> (Matrix t, Vector Double) Source #

Singular values and all left singular vectors (as columns).

rightSV :: Field t => Matrix t -> (Vector Double, Matrix t) Source #

Singular values and all right singular vectors (as columns).

# Eigendecomposition

eig :: Field t => Matrix t -> (Vector (Complex Double), Matrix (Complex Double)) Source #

Eigenvalues (not ordered) and eigenvectors (as columns) of a general square matrix.

If `(s,v) = eig m` then `m <> v == v <> diag s`

    a = (3><3)
     [ 3, 0, -2
     , 4, 5, -1
     , 3, 1,  0 ] :: Matrix Double

    >>> let (l, v) = eig a

    >>> putStr . dispcf 3 . asRow $ l
    1x3
    1.925+1.523i  1.925-1.523i  4.151

    >>> putStr . dispcf 3 $ v
    3x3
    -0.455+0.365i  -0.455-0.365i   0.181
            0.603          0.603  -0.978
     0.033+0.543i   0.033-0.543i  -0.104

    >>> putStr . dispcf 3 $ complex a <> v
    3x3
    -1.432+0.010i  -1.432-0.010i   0.753
     1.160+0.918i   1.160-0.918i  -4.059
    -0.763+1.096i  -0.763-1.096i  -0.433

    >>> putStr . dispcf 3 $ v <> diag l
    3x3
    -1.432+0.010i  -1.432-0.010i   0.753
     1.160+0.918i   1.160-0.918i  -4.059
    -0.763+1.096i  -0.763-1.096i  -0.433

geig :: Field t => Matrix t -> Matrix t -> (Vector (Complex Double), Vector t, Matrix (Complex Double)) Source #

Generalized eigenvalues (not ordered) and eigenvectors (as columns) of a pair of nonsymmetric matrices. Eigenvalues are represented as pairs of alpha, beta, where eigenvalue = alpha / beta. Alpha is always complex, but betas has the same type as the input matrix.

If `(alphas, betas, v) = geig a b`, then `a <> v == b <> v <> diag (alphas / betas)`

Note that beta can be 0 and that has reasonable interpretation.

eigSH :: Field t => Herm t -> (Vector Double, Matrix t) Source #

Eigenvalues and eigenvectors (as columns) of a complex hermitian or real symmetric matrix, in descending order.

If `(s,v) = eigSH m` then `m == v <> diag s <> tr v`

    a = (3><3)
     [ 1.0, 2.0, 3.0
     , 2.0, 4.0, 5.0
     , 3.0, 5.0, 6.0 ]

    >>> let (l, v) = eigSH a

    >>> l
    [11.344814282762075,0.17091518882717918,-0.5157294715892575]

    >>> disp 3 $ v <> diag l <> tr v
    3x3
    1.000  2.000  3.000
    2.000  4.000  5.000
    3.000  5.000  6.000

eigenvalues :: Field t => Matrix t -> Vector (Complex Double) Source #

Eigenvalues (not ordered) of a general square matrix.

geigenvalues :: Field t => Matrix t -> Matrix t -> (Vector (Complex Double), Vector t) Source #

Generalized eigenvalues of a pair of matrices. Represented as pairs of alpha, beta, where eigenvalue is alpha / beta as in `geig`.

eigenvaluesSH :: Field t => Herm t -> Vector Double Source #

Eigenvalues (in descending order) of a complex hermitian or real symmetric matrix.

geigSH Source #

Arguments

:: Field t |
=> Herm t | A
-> Herm t | B
-> (Vector Double, Matrix t) |

Generalized symmetric positive definite eigensystem Av = lBv, for A and B symmetric, B positive definite.

# QR

qr :: Field t => Matrix t -> (Matrix t, Matrix t) Source #

QR factorization.

If `(q,r) = qr m` then `m == q <> r`, where q is unitary and r is upper triangular. Note: the current implementation is very slow for large matrices. `thinQR` is much faster.

thinQR :: Field t => Matrix t -> (Matrix t, Matrix t) Source #

A version of `qr` which returns only the `min (rows m) (cols m)` columns of `q` and rows of `r`.

rq :: Field t => Matrix t -> (Matrix t, Matrix t) Source #

RQ factorization.

If `(r,q) = rq m` then `m == r <> q`, where q is unitary and r is upper triangular. Note: the current implementation is very slow for large matrices. `thinRQ` is much faster.

thinRQ :: Field t => Matrix t -> (Matrix t, Matrix t) Source #

A version of `rq` which returns only the `min (rows m) (cols m)` columns of `r` and rows of `q`.

qrRaw :: Field t => Matrix t -> QR t Source #

Compute the QR decomposition of a matrix in compact form.

qrgr :: Field t => Int -> QR t -> Matrix t Source #

generate a matrix with k orthogonal columns from the compact QR decomposition obtained by `qrRaw`.

# Cholesky

chol :: Field t => Herm t -> Matrix t Source #

Cholesky factorization of a positive definite hermitian or symmetric matrix.

If `c = chol m` then `c` is upper triangular and `m == tr c <> c`.

mbChol :: Field t => Herm t -> Maybe (Matrix t) Source #

Similar to `chol`, but instead of an error (e.g., caused by a matrix not positive definite) it returns `Nothing`.

# LU

lu :: Field t => Matrix t -> (Matrix t, Matrix t, Matrix t, t) Source #

Explicit LU factorization of a general matrix.

If `(l,u,p,s) = lu m` then `m == p <> l <> u`, where l is lower triangular, u is upper triangular, p is a permutation matrix and s is the signature of the permutation.

luFact :: Numeric t => LU t -> (Matrix t, Matrix t, Matrix t, t) Source #

Compute the explicit LU decomposition from the compact one obtained by `luPacked`.

# Hessenberg

hess :: Field t => Matrix t -> (Matrix t, Matrix t) Source #

Hessenberg factorization.

If `(p,h) = hess m` then `m == p <> h <> tr p`, where p is unitary and h is in upper Hessenberg form (it has zero entries below the first subdiagonal).

# Schur

schur :: Field t => Matrix t -> (Matrix t, Matrix t) Source #

Schur factorization.

If `(u,s) = schur m` then `m == u <> s <> tr u`, where u is unitary and s is a Shur matrix. A complex Schur matrix is upper triangular. A real Schur matrix is upper triangular in 2x2 blocks.

"Anything that the Jordan decomposition can do, the Schur decomposition can do better!" (Van Loan)

# Matrix functions

expm :: Field t => Matrix t -> Matrix t Source #

Matrix exponential. It uses a direct translation of Algorithm 11.3.1 in Golub & Van Loan, based on a scaled Pade approximation.

sqrtm :: Field t => Matrix t -> Matrix t Source #

Matrix square root. Currently it uses a simple iterative algorithm described in Wikipedia. It only works with invertible matrices that have a real solution.

    m = (2><2) [4,9
               ,0,4] :: Matrix Double

    >>> sqrtm m
    (2><2)
     [ 2.0, 2.25
     , 0.0,  2.0 ]

For diagonalizable matrices you can try `matFunc` `sqrt`:

    >>> matFunc sqrt ((2><2) [1,0,0,-1])
    (2><2)
     [ 1.0 :+ 0.0, 0.0 :+ 0.0
     , 0.0 :+ 0.0, 0.0 :+ 1.0 ]

matFunc :: (Complex Double -> Complex Double) -> Matrix (Complex Double) -> Matrix (Complex Double) Source #

Generic matrix functions for diagonalizable matrices. For instance:

    logm = matFunc log

# Correlation and convolution

corr Source #

Arguments

:: (Container Vector t, Product t) |
=> Vector t | kernel
-> Vector t | source
-> Vector t |

correlation

    >>> corr (fromList[1,2,3]) (fromList [1..10])
    [14.0,20.0,26.0,32.0,38.0,44.0,50.0,56.0]
    it :: (Enum t, Product t, Container Vector t) => Vector t

conv :: (Container Vector t, Product t, Num t) => Vector t -> Vector t -> Vector t Source #

convolution (`corr` with reversed kernel and padded input, equivalent to polynomial product)

    >>> conv (fromList[1,1]) (fromList [-1,1])
    [-1.0,0.0,1.0]
    it :: (Product t, Container Vector t) => Vector t

corrMin :: (Container Vector t, RealElement t, Product t) => Vector t -> Vector t -> Vector t Source #

similar to `corr`, using `min` instead of (*)

corr2 :: Product a => Matrix a -> Matrix a -> Matrix a Source #

2D correlation (without padding)

    >>> disp 5 $ corr2 (konst 1 (3,3)) (ident 10 :: Matrix Double)
    8x8
    3  2  1  0  0  0  0  0
    2  3  2  1  0  0  0  0
    1  2  3  2  1  0  0  0
    0  1  2  3  2  1  0  0
    0  0  1  2  3  2  1  0
    0  0  0  1  2  3  2  1
    0  0  0  0  1  2  3  2
    0  0  0  0  0  1  2  3

conv2 Source #

Arguments

:: (Num (Matrix a), Product a, Container Vector a) |
=> Matrix a | kernel
-> Matrix a |
-> Matrix a |

2D convolution

    >>> disp 5 $ conv2 (konst 1 (3,3)) (ident 10 :: Matrix Double)
    12x12
    1  1  1  0  0  0  0  0  0  0  0  0
    1  2  2  1  0  0  0  0  0  0  0  0
    1  2  3  2  1  0  0  0  0  0  0  0
    0  1  2  3  2  1  0  0  0  0  0  0
    0  0  1  2  3  2  1  0  0  0  0  0
    0  0  0  1  2  3  2  1  0  0  0  0
    0  0  0  0  1  2  3  2  1  0  0  0
    0  0  0  0  0  1  2  3  2  1  0  0
    0  0  0  0  0  0  1  2  3  2  1  0
    0  0  0  0  0  0  0  1  2  3  2  1
    0  0  0  0  0  0  0  0  1  2  2  1
    0  0  0  0  0  0  0  0  0  1  1  1

# Random arrays

type Seed = Int Source #

data RandDist Source #

Constructors

Uniform | uniform distribution in [0,1)
Gaussian | normal distribution with mean zero and standard deviation one

#### Instances

Instances details

Enum RandDist Source # |

Instance details

Defined in Internal.Vectorized

Methods

succ :: RandDist -> RandDist Source #

pred :: RandDist -> RandDist Source #

toEnum :: Int -> RandDist Source #

fromEnum :: RandDist -> Int Source #

enumFrom :: RandDist -> [RandDist] Source #

enumFromThen :: RandDist -> RandDist -> [RandDist] Source #

enumFromTo :: RandDist -> RandDist -> [RandDist] Source #

enumFromThenTo :: RandDist -> RandDist -> RandDist -> [RandDist] Source #

randomVector Source #

Arguments

:: Seed |
-> RandDist | distribution
-> Int | vector size
-> Vector Double |

Obtains a vector of pseudorandom elements (use randomIO to get a random seed).

rand :: Int -> Int -> IO (Matrix Double) Source #

pseudorandom matrix with uniform elements between 0 and 1

randn :: Int -> Int -> IO (Matrix Double) Source #

pseudorandom matrix with normal elements

    >>> disp 3 =<< randn 3 5
    3x5
    0.386  -1.141   0.491  -0.510   1.512
    0.069  -0.919   1.022  -0.181   0.745
    0.313  -0.670  -0.097  -1.575  -0.583

gaussianSample Source #

Arguments

:: Seed |
-> Int | number of rows
-> Vector Double | mean vector
-> Herm Double | covariance matrix
-> Matrix Double | result

Obtains a matrix whose rows are pseudorandom samples from a multivariate Gaussian distribution.

uniformSample Source #

Arguments

:: Seed |
-> Int | number of rows
-> [(Double, Double)] | ranges for each column
-> Matrix Double | result

Obtains a matrix whose rows are pseudorandom samples from a multivariate uniform distribution.

# Misc

meanCov :: Matrix Double -> (Vector Double, Herm Double) Source #

Compute mean vector and covariance matrix of the rows of a matrix.

    >>> meanCov $ gaussianSample 666 1000 (fromList[4,5]) (trustSym $ diagl [2,3])
    ([3.9933155655086696,5.061409102770331],Herm (2><2)
     [    1.9963242906624408, -4.227815571404954e-2
     , -4.227815571404954e-2,    3.2003833097832857 ])
    it :: (Vector Double, Herm Double)

rowOuters :: Matrix Double -> Matrix Double -> Matrix Double Source #

outer products of rows

    >>> a
    (3><2)
     [   1.0,   2.0
     ,  10.0,  20.0
     , 100.0, 200.0 ]
    >>> b
    (3><3)
     [ 1.0, 2.0, 3.0
     , 4.0, 5.0, 6.0
     , 7.0, 8.0, 9.0 ]

    >>> rowOuters a (b ||| 1)
    (3><8)
     [   1.0,   2.0,   3.0,   1.0,    2.0,    4.0,    6.0,   2.0
     ,  40.0,  50.0,  60.0,  10.0,   80.0,  100.0,  120.0,  20.0
     , 700.0, 800.0, 900.0, 100.0, 1400.0, 1600.0, 1800.0, 200.0 ]

pairwiseD2 :: Matrix Double -> Matrix Double -> Matrix Double Source #

Matrix of pairwise squared distances of row vectors (using the matrix product trick in blog.smola.org)

normalize :: (Normed (Vector t), Num (Vector t), Field t) => Vector t -> Vector t Source #

Obtains a vector in the same direction with 2-norm=1

peps :: RealFloat x => x Source #

1 + 0.5*peps == 1, 1 + 0.6*peps /= 1

relativeError :: Num a => (a -> Double) -> a -> a -> Double Source #

magnit :: (Element t, Normed (Vector t)) => R -> t -> Bool Source #

Check if the absolute value or complex magnitude is greater than a given threshold

    >>> magnit 1E-6 (1E-12 :: R)
    False
    >>> magnit 1E-6 (3+iC :: C)
    True
    >>> magnit 0 (3 :: I ./. 5)
    True

haussholder :: Field a => a -> Vector a -> Matrix a Source #

optimiseMult :: Monoid (Matrix t) => [Matrix t] -> Matrix t Source #

udot :: Product e => Vector e -> Vector e -> e Source #

unconjugated dot product

nullspaceSVD Source #

Arguments

:: Field t |
=> Either Double Int | Left "numeric" zero (eg. 1*`eps`), or Right "theoretical" matrix rank.
-> Matrix t | input matrix m
-> (Vector Double, Matrix t) | `rightSV` of m
-> Matrix t | nullspace

The nullspace of a matrix from its precomputed SVD decomposition.

orthSVD Source #

Arguments

:: Field t |
=> Either Double Int | Left "numeric" zero (eg. 1*`eps`), or Right "theoretical" matrix rank.
-> Matrix t | input matrix m
-> (Matrix t, Vector Double) | `leftSV` of m
-> Matrix t | orth

The range space a matrix from its precomputed SVD decomposition.

ranksv Source #

Arguments

:: Double | numeric zero (e.g. 1*`eps`)
-> Int | maximum dimension of the matrix
-> [Double] | singular values
-> Int | rank of m

Numeric rank of a matrix from its singular values.

iC :: C Source #

imaginary unit

sym :: Field t => Matrix t -> Herm t Source #

Compute the complex Hermitian or real symmetric part of a square matrix (`(x + tr x)/2`).

mTm :: Numeric t => Matrix t -> Herm t Source #

Compute the contraction `tr x <> x` of a general matrix.

trustSym :: Matrix t -> Herm t Source #

At your own risk, declare that a matrix is complex Hermitian or real symmetric for usage in `chol`, `eigSH`, etc. Only a triangular part of the matrix will be used.

unSym :: Herm t -> Matrix t Source #

Extract the general matrix from a `Herm` structure, forgetting its symmetric or Hermitian property.

# Auxiliary classes

class Storable a => Element a Source #

Supported matrix elements.

Minimal complete definition

constantD, extractR, setRect, sortI, sortV, compareV, selectV, remapM, rowOp, gemm, reorderV

#### Instances

Instances details

Element CInt Source # |

Instance details

Defined in Internal.Matrix

Methods

constantD :: CInt -> Int -> Vector CInt

extractR :: MatrixOrder -> Matrix CInt -> CInt -> Vector CInt -> CInt -> Vector CInt -> IO (Matrix CInt)

setRect :: Int -> Int -> Matrix CInt -> Matrix CInt -> IO ()

sortI :: Vector CInt -> Vector CInt

sortV :: Vector CInt -> Vector CInt

compareV :: Vector CInt -> Vector CInt -> Vector CInt

selectV :: Vector CInt -> Vector CInt -> Vector CInt -> Vector CInt -> Vector CInt

remapM :: Matrix CInt -> Matrix CInt -> Matrix CInt -> Matrix CInt

rowOp :: Int -> CInt -> Int -> Int -> Int -> Int -> Matrix CInt -> IO ()

gemm :: Vector CInt -> Matrix CInt -> Matrix CInt -> Matrix CInt -> IO ()

reorderV :: Vector CInt -> Vector CInt -> Vector CInt -> Vector CInt

Element Z Source # |

Instance details

Defined in Internal.Matrix

Methods

constantD :: Z -> Int -> Vector Z

extractR :: MatrixOrder -> Matrix Z -> CInt -> Vector CInt -> CInt -> Vector CInt -> IO (Matrix Z)

setRect :: Int -> Int -> Matrix Z -> Matrix Z -> IO ()

sortI :: Vector Z -> Vector CInt

sortV :: Vector Z -> Vector Z

compareV :: Vector Z -> Vector Z -> Vector CInt

selectV :: Vector CInt -> Vector Z -> Vector Z -> Vector Z -> Vector Z

remapM :: Matrix CInt -> Matrix CInt -> Matrix Z -> Matrix Z

rowOp :: Int -> Z -> Int -> Int -> Int -> Int -> Matrix Z -> IO ()

gemm :: Vector Z -> Matrix Z -> Matrix Z -> Matrix Z -> IO ()

reorderV :: Vector CInt -> Vector CInt -> Vector Z -> Vector Z

Element Double Source # |

Instance details

Defined in Internal.Matrix

Methods

constantD :: Double -> Int -> Vector Double

extractR :: MatrixOrder -> Matrix Double -> CInt -> Vector CInt -> CInt -> Vector CInt -> IO (Matrix Double)

setRect :: Int -> Int -> Matrix Double -> Matrix Double -> IO ()

sortI :: Vector Double -> Vector CInt

sortV :: Vector Double -> Vector Double

compareV :: Vector Double -> Vector Double -> Vector CInt

selectV :: Vector CInt -> Vector Double -> Vector Double -> Vector Double -> Vector Double

remapM :: Matrix CInt -> Matrix CInt -> Matrix Double -> Matrix Double

rowOp :: Int -> Double -> Int -> Int -> Int -> Int -> Matrix Double -> IO ()

gemm :: Vector Double -> Matrix Double -> Matrix Double -> Matrix Double -> IO ()

reorderV :: Vector CInt -> Vector CInt -> Vector Double -> Vector Double

Element Float Source # |

Instance details

Defined in Internal.Matrix

Methods

constantD :: Float -> Int -> Vector Float

extractR :: MatrixOrder -> Matrix Float -> CInt -> Vector CInt -> CInt -> Vector CInt -> IO (Matrix Float)

setRect :: Int -> Int -> Matrix Float -> Matrix Float -> IO ()

sortI :: Vector Float -> Vector CInt

sortV :: Vector Float -> Vector Float

compareV :: Vector Float -> Vector Float -> Vector CInt

selectV :: Vector CInt -> Vector Float -> Vector Float -> Vector Float -> Vector Float

remapM :: Matrix CInt -> Matrix CInt -> Matrix Float -> Matrix Float

rowOp :: Int -> Float -> Int -> Int -> Int -> Int -> Matrix Float -> IO ()

gemm :: Vector Float -> Matrix Float -> Matrix Float -> Matrix Float -> IO ()

reorderV :: Vector CInt -> Vector CInt -> Vector Float -> Vector Float

Element (Complex Double) Source # |

Instance details

Defined in Internal.Matrix

Methods

constantD :: Complex Double -> Int -> Vector (Complex Double)

extractR :: MatrixOrder -> Matrix (Complex Double) -> CInt -> Vector CInt -> CInt -> Vector CInt -> IO (Matrix (Complex Double))

setRect :: Int -> Int -> Matrix (Complex Double) -> Matrix (Complex Double) -> IO ()

sortI :: Vector (Complex Double) -> Vector CInt

sortV :: Vector (Complex Double) -> Vector (Complex Double)

compareV :: Vector (Complex Double) -> Vector (Complex Double) -> Vector CInt

selectV :: Vector CInt -> Vector (Complex Double) -> Vector (Complex Double) -> Vector (Complex Double) -> Vector (Complex Double)

remapM :: Matrix CInt -> Matrix CInt -> Matrix (Complex Double) -> Matrix (Complex Double)

rowOp :: Int -> Complex Double -> Int -> Int -> Int -> Int -> Matrix (Complex Double) -> IO ()

gemm :: Vector (Complex Double) -> Matrix (Complex Double) -> Matrix (Complex Double) -> Matrix (Complex Double) -> IO ()

reorderV :: Vector CInt -> Vector CInt -> Vector (Complex Double) -> Vector (Complex Double)

Element (Complex Float) Source # |

Instance details

Defined in Internal.Matrix

Methods

constantD :: Complex Float -> Int -> Vector (Complex Float)

extractR :: MatrixOrder -> Matrix (Complex Float) -> CInt -> Vector CInt -> CInt -> Vector CInt -> IO (Matrix (Complex Float))

setRect :: Int -> Int -> Matrix (Complex Float) -> Matrix (Complex Float) -> IO ()

sortI :: Vector (Complex Float) -> Vector CInt

sortV :: Vector (Complex Float) -> Vector (Complex Float)

compareV :: Vector (Complex Float) -> Vector (Complex Float) -> Vector CInt

selectV :: Vector CInt -> Vector (Complex Float) -> Vector (Complex Float) -> Vector (Complex Float) -> Vector (Complex Float)

remapM :: Matrix CInt -> Matrix CInt -> Matrix (Complex Float) -> Matrix (Complex Float)

rowOp :: Int -> Complex Float -> Int -> Int -> Int -> Int -> Matrix (Complex Float) -> IO ()

gemm :: Vector (Complex Float) -> Matrix (Complex Float) -> Matrix (Complex Float) -> Matrix (Complex Float) -> IO ()

reorderV :: Vector CInt -> Vector CInt -> Vector (Complex Float) -> Vector (Complex Float)

KnownNat m => Element (Mod m I) Source # |

Instance details

Defined in Internal.Modular

Methods

constantD :: Mod m I -> Int -> Vector (Mod m I)

extractR :: MatrixOrder -> Matrix (Mod m I) -> CInt -> Vector CInt -> CInt -> Vector CInt -> IO (Matrix (Mod m I))

setRect :: Int -> Int -> Matrix (Mod m I) -> Matrix (Mod m I) -> IO ()

sortI :: Vector (Mod m I) -> Vector CInt

sortV :: Vector (Mod m I) -> Vector (Mod m I)

compareV :: Vector (Mod m I) -> Vector (Mod m I) -> Vector CInt

selectV :: Vector CInt -> Vector (Mod m I) -> Vector (Mod m I) -> Vector (Mod m I) -> Vector (Mod m I)

remapM :: Matrix CInt -> Matrix CInt -> Matrix (Mod m I) -> Matrix (Mod m I)

rowOp :: Int -> Mod m I -> Int -> Int -> Int -> Int -> Matrix (Mod m I) -> IO ()

gemm :: Vector (Mod m I) -> Matrix (Mod m I) -> Matrix (Mod m I) -> Matrix (Mod m I) -> IO ()

reorderV :: Vector CInt -> Vector CInt -> Vector (Mod m I) -> Vector (Mod m I)

KnownNat m => Element (Mod m Z) Source # |

Instance details

Defined in Internal.Modular

Methods

constantD :: Mod m Z -> Int -> Vector (Mod m Z)

extractR :: MatrixOrder -> Matrix (Mod m Z) -> CInt -> Vector CInt -> CInt -> Vector CInt -> IO (Matrix (Mod m Z))

setRect :: Int -> Int -> Matrix (Mod m Z) -> Matrix (Mod m Z) -> IO ()

sortI :: Vector (Mod m Z) -> Vector CInt

sortV :: Vector (Mod m Z) -> Vector (Mod m Z)

compareV :: Vector (Mod m Z) -> Vector (Mod m Z) -> Vector CInt

selectV :: Vector CInt -> Vector (Mod m Z) -> Vector (Mod m Z) -> Vector (Mod m Z) -> Vector (Mod m Z)

remapM :: Matrix CInt -> Matrix CInt -> Matrix (Mod m Z) -> Matrix (Mod m Z)

rowOp :: Int -> Mod m Z -> Int -> Int -> Int -> Int -> Matrix (Mod m Z) -> IO ()

gemm :: Vector (Mod m Z) -> Matrix (Mod m Z) -> Matrix (Mod m Z) -> Matrix (Mod m Z) -> IO ()

reorderV :: Vector CInt -> Vector CInt -> Vector (Mod m Z) -> Vector (Mod m Z)

class Element e => Container (c :: Type -> Type) e Source #

Basic element-by-element functions for numeric containers

Minimal complete definition

conj', size', scalar', scale', addConstant, add', sub, mul, equal, cmap', konst', build', atIndex', minIndex', maxIndex', minElement', maxElement', sumElements', prodElements', step', ccompare', cselect', find', assoc', accum', scaleRecip, divide, arctan2', cmod', fromInt', toInt', fromZ', toZ'

#### Instances

Instances details

(Num a, Element a, Container Vector a) => Container Matrix a Source # |

Instance details

Defined in Internal.Numeric

Methods

conj' :: Matrix a -> Matrix a

size' :: Matrix a -> IndexOf Matrix

scalar' :: a -> Matrix a

scale' :: a -> Matrix a -> Matrix a

addConstant :: a -> Matrix a -> Matrix a

add' :: Matrix a -> Matrix a -> Matrix a

sub :: Matrix a -> Matrix a -> Matrix a

mul :: Matrix a -> Matrix a -> Matrix a

equal :: Matrix a -> Matrix a -> Bool

cmap' :: Element b => (a -> b) -> Matrix a -> Matrix b

konst' :: a -> IndexOf Matrix -> Matrix a

build' :: IndexOf Matrix -> ArgOf Matrix a -> Matrix a

atIndex' :: Matrix a -> IndexOf Matrix -> a

minIndex' :: Matrix a -> IndexOf Matrix

maxIndex' :: Matrix a -> IndexOf Matrix

minElement' :: Matrix a -> a

maxElement' :: Matrix a -> a

sumElements' :: Matrix a -> a

prodElements' :: Matrix a -> a

step' :: Matrix a -> Matrix a

ccompare' :: Matrix a -> Matrix a -> Matrix I

cselect' :: Matrix I -> Matrix a -> Matrix a -> Matrix a -> Matrix a

find' :: (a -> Bool) -> Matrix a -> [IndexOf Matrix]

assoc' :: IndexOf Matrix -> a -> [(IndexOf Matrix, a)] -> Matrix a

accum' :: Matrix a -> (a -> a -> a) -> [(IndexOf Matrix, a)] -> Matrix a

scaleRecip :: a -> Matrix a -> Matrix a

divide :: Matrix a -> Matrix a -> Matrix a

arctan2' :: Matrix a -> Matrix a -> Matrix a

cmod' :: a -> Matrix a -> Matrix a

fromInt' :: Matrix I -> Matrix a

toInt' :: Matrix a -> Matrix I

fromZ' :: Matrix Z -> Matrix a

toZ' :: Matrix a -> Matrix Z

Container Vector I Source # |

Instance details

Defined in Internal.Numeric

Methods

conj' :: Vector I -> Vector I

size' :: Vector I -> IndexOf Vector

scalar' :: I -> Vector I

scale' :: I -> Vector I -> Vector I

addConstant :: I -> Vector I -> Vector I

add' :: Vector I -> Vector I -> Vector I

sub :: Vector I -> Vector I -> Vector I

mul :: Vector I -> Vector I -> Vector I

equal :: Vector I -> Vector I -> Bool

cmap' :: Element b => (I -> b) -> Vector I -> Vector b

konst' :: I -> IndexOf Vector -> Vector I

build' :: IndexOf Vector -> ArgOf Vector I -> Vector I

atIndex' :: Vector I -> IndexOf Vector -> I

minIndex' :: Vector I -> IndexOf Vector

maxIndex' :: Vector I -> IndexOf Vector

minElement' :: Vector I -> I

maxElement' :: Vector I -> I

sumElements' :: Vector I -> I

prodElements' :: Vector I -> I

step' :: Vector I -> Vector I

ccompare' :: Vector I -> Vector I -> Vector I

cselect' :: Vector I -> Vector I -> Vector I -> Vector I -> Vector I

find' :: (I -> Bool) -> Vector I -> [IndexOf Vector]

assoc' :: IndexOf Vector -> I -> [(IndexOf Vector, I)] -> Vector I

accum' :: Vector I -> (I -> I -> I) -> [(IndexOf Vector, I)] -> Vector I

scaleRecip :: I -> Vector I -> Vector I

divide :: Vector I -> Vector I -> Vector I

arctan2' :: Vector I -> Vector I -> Vector I

cmod' :: I -> Vector I -> Vector I

fromInt' :: Vector I -> Vector I

toInt' :: Vector I -> Vector I

fromZ' :: Vector Z -> Vector I

toZ' :: Vector I -> Vector Z

Container Vector Z Source # |

Instance details

Defined in Internal.Numeric

Methods

conj' :: Vector Z -> Vector Z

size' :: Vector Z -> IndexOf Vector

scalar' :: Z -> Vector Z

scale' :: Z -> Vector Z -> Vector Z

addConstant :: Z -> Vector Z -> Vector Z

add' :: Vector Z -> Vector Z -> Vector Z

sub :: Vector Z -> Vector Z -> Vector Z

mul :: Vector Z -> Vector Z -> Vector Z

equal :: Vector Z -> Vector Z -> Bool

cmap' :: Element b => (Z -> b) -> Vector Z -> Vector b

konst' :: Z -> IndexOf Vector -> Vector Z

build' :: IndexOf Vector -> ArgOf Vector Z -> Vector Z

atIndex' :: Vector Z -> IndexOf Vector -> Z

minIndex' :: Vector Z -> IndexOf Vector

maxIndex' :: Vector Z -> IndexOf Vector

minElement' :: Vector Z -> Z

maxElement' :: Vector Z -> Z

sumElements' :: Vector Z -> Z

prodElements' :: Vector Z -> Z

step' :: Vector Z -> Vector Z

ccompare' :: Vector Z -> Vector Z -> Vector I

cselect' :: Vector I -> Vector Z -> Vector Z -> Vector Z -> Vector Z

find' :: (Z -> Bool) -> Vector Z -> [IndexOf Vector]

assoc' :: IndexOf Vector -> Z -> [(IndexOf Vector, Z)] -> Vector Z

accum' :: Vector Z -> (Z -> Z -> Z) -> [(IndexOf Vector, Z)] -> Vector Z

scaleRecip :: Z -> Vector Z -> Vector Z

divide :: Vector Z -> Vector Z -> Vector Z

arctan2' :: Vector Z -> Vector Z -> Vector Z

cmod' :: Z -> Vector Z -> Vector Z

fromInt' :: Vector I -> Vector Z

toInt' :: Vector Z -> Vector I

fromZ' :: Vector Z -> Vector Z

toZ' :: Vector Z -> Vector Z

Container Vector Double Source # |

Instance details

Defined in Internal.Numeric

Methods

conj' :: Vector Double -> Vector Double

size' :: Vector Double -> IndexOf Vector

scalar' :: Double -> Vector Double

scale' :: Double -> Vector Double -> Vector Double

addConstant :: Double -> Vector Double -> Vector Double

add' :: Vector Double -> Vector Double -> Vector Double

sub :: Vector Double -> Vector Double -> Vector Double

mul :: Vector Double -> Vector Double -> Vector Double

equal :: Vector Double -> Vector Double -> Bool

cmap' :: Element b => (Double -> b) -> Vector Double -> Vector b

konst' :: Double -> IndexOf Vector -> Vector Double

build' :: IndexOf Vector -> ArgOf Vector Double -> Vector Double

atIndex' :: Vector Double -> IndexOf Vector -> Double

minIndex' :: Vector Double -> IndexOf Vector

maxIndex' :: Vector Double -> IndexOf Vector

minElement' :: Vector Double -> Double

maxElement' :: Vector Double -> Double

sumElements' :: Vector Double -> Double

prodElements' :: Vector Double -> Double

step' :: Vector Double -> Vector Double

ccompare' :: Vector Double -> Vector Double -> Vector I

cselect' :: Vector I -> Vector Double -> Vector Double -> Vector Double -> Vector Double

find' :: (Double -> Bool) -> Vector Double -> [IndexOf Vector]

assoc' :: IndexOf Vector -> Double -> [(IndexOf Vector, Double)] -> Vector Double

accum' :: Vector Double -> (Double -> Double -> Double) -> [(IndexOf Vector, Double)] -> Vector Double

scaleRecip :: Double -> Vector Double -> Vector Double

divide :: Vector Double -> Vector Double -> Vector Double

arctan2' :: Vector Double -> Vector Double -> Vector Double

cmod' :: Double -> Vector Double -> Vector Double

fromInt' :: Vector I -> Vector Double

toInt' :: Vector Double -> Vector I

fromZ' :: Vector Z -> Vector Double

toZ' :: Vector Double -> Vector Z

Container Vector Float Source # |

Instance details

Defined in Internal.Numeric

Methods

conj' :: Vector Float -> Vector Float

size' :: Vector Float -> IndexOf Vector

scalar' :: Float -> Vector Float

scale' :: Float -> Vector Float -> Vector Float

addConstant :: Float -> Vector Float -> Vector Float

add' :: Vector Float -> Vector Float -> Vector Float

sub :: Vector Float -> Vector Float -> Vector Float

mul :: Vector Float -> Vector Float -> Vector Float

equal :: Vector Float -> Vector Float -> Bool

cmap' :: Element b => (Float -> b) -> Vector Float -> Vector b

konst' :: Float -> IndexOf Vector -> Vector Float

build' :: IndexOf Vector -> ArgOf Vector Float -> Vector Float

atIndex' :: Vector Float -> IndexOf Vector -> Float

minIndex' :: Vector Float -> IndexOf Vector

maxIndex' :: Vector Float -> IndexOf Vector

minElement' :: Vector Float -> Float

maxElement' :: Vector Float -> Float

sumElements' :: Vector Float -> Float

prodElements' :: Vector Float -> Float

step' :: Vector Float -> Vector Float

ccompare' :: Vector Float -> Vector Float -> Vector I

cselect' :: Vector I -> Vector Float -> Vector Float -> Vector Float -> Vector Float

find' :: (Float -> Bool) -> Vector Float -> [IndexOf Vector]

assoc' :: IndexOf Vector -> Float -> [(IndexOf Vector, Float)] -> Vector Float

accum' :: Vector Float -> (Float -> Float -> Float) -> [(IndexOf Vector, Float)] -> Vector Float

scaleRecip :: Float -> Vector Float -> Vector Float

divide :: Vector Float -> Vector Float -> Vector Float

arctan2' :: Vector Float -> Vector Float -> Vector Float

cmod' :: Float -> Vector Float -> Vector Float

fromInt' :: Vector I -> Vector Float

toInt' :: Vector Float -> Vector I

fromZ' :: Vector Z -> Vector Float

toZ' :: Vector Float -> Vector Z

Container Vector (Complex Double) Source # |

Instance details

Defined in Internal.Numeric

Methods

conj' :: Vector (Complex Double) -> Vector (Complex Double)

size' :: Vector (Complex Double) -> IndexOf Vector

scalar' :: Complex Double -> Vector (Complex Double)

scale' :: Complex Double -> Vector (Complex Double) -> Vector (Complex Double)

addConstant :: Complex Double -> Vector (Complex Double) -> Vector (Complex Double)

add' :: Vector (Complex Double) -> Vector (Complex Double) -> Vector (Complex Double)

sub :: Vector (Complex Double) -> Vector (Complex Double) -> Vector (Complex Double)

mul :: Vector (Complex Double) -> Vector (Complex Double) -> Vector (Complex Double)

equal :: Vector (Complex Double) -> Vector (Complex Double) -> Bool

cmap' :: Element b => (Complex Double -> b) -> Vector (Complex Double) -> Vector b

konst' :: Complex Double -> IndexOf Vector -> Vector (Complex Double)

build' :: IndexOf Vector -> ArgOf Vector (Complex Double) -> Vector (Complex Double)

atIndex' :: Vector (Complex Double) -> IndexOf Vector -> Complex Double

minIndex' :: Vector (Complex Double) -> IndexOf Vector

maxIndex' :: Vector (Complex Double) -> IndexOf Vector

minElement' :: Vector (Complex Double) -> Complex Double

maxElement' :: Vector (Complex Double) -> Complex Double

sumElements' :: Vector (Complex Double) -> Complex Double

prodElements' :: Vector (Complex Double) -> Complex Double

step' :: Vector (Complex Double) -> Vector (Complex Double)

ccompare' :: Vector (Complex Double) -> Vector (Complex Double) -> Vector I

cselect' :: Vector I -> Vector (Complex Double) -> Vector (Complex Double) -> Vector (Complex Double) -> Vector (Complex Double)

find' :: (Complex Double -> Bool) -> Vector (Complex Double) -> [IndexOf Vector]

assoc' :: IndexOf Vector -> Complex Double -> [(IndexOf Vector, Complex Double)] -> Vector (Complex Double)

accum' :: Vector (Complex Double) -> (Complex Double -> Complex Double -> Complex Double) -> [(IndexOf Vector, Complex Double)] -> Vector (Complex Double)

scaleRecip :: Complex Double -> Vector (Complex Double) -> Vector (Complex Double)

divide :: Vector (Complex Double) -> Vector (Complex Double) -> Vector (Complex Double)

arctan2' :: Vector (Complex Double) -> Vector (Complex Double) -> Vector (Complex Double)

cmod' :: Complex Double -> Vector (Complex Double) -> Vector (Complex Double)

fromInt' :: Vector I -> Vector (Complex Double)

toInt' :: Vector (Complex Double) -> Vector I

fromZ' :: Vector Z -> Vector (Complex Double)

toZ' :: Vector (Complex Double) -> Vector Z

Container Vector (Complex Float) Source # |

Instance details

Defined in Internal.Numeric

Methods

conj' :: Vector (Complex Float) -> Vector (Complex Float)

size' :: Vector (Complex Float) -> IndexOf Vector

scalar' :: Complex Float -> Vector (Complex Float)

scale' :: Complex Float -> Vector (Complex Float) -> Vector (Complex Float)

addConstant :: Complex Float -> Vector (Complex Float) -> Vector (Complex Float)

add' :: Vector (Complex Float) -> Vector (Complex Float) -> Vector (Complex Float)

sub :: Vector (Complex Float) -> Vector (Complex Float) -> Vector (Complex Float)

mul :: Vector (Complex Float) -> Vector (Complex Float) -> Vector (Complex Float)

equal :: Vector (Complex Float) -> Vector (Complex Float) -> Bool

cmap' :: Element b => (Complex Float -> b) -> Vector (Complex Float) -> Vector b

konst' :: Complex Float -> IndexOf Vector -> Vector (Complex Float)

build' :: IndexOf Vector -> ArgOf Vector (Complex Float) -> Vector (Complex Float)

atIndex' :: Vector (Complex Float) -> IndexOf Vector -> Complex Float

minIndex' :: Vector (Complex Float) -> IndexOf Vector

maxIndex' :: Vector (Complex Float) -> IndexOf Vector

minElement' :: Vector (Complex Float) -> Complex Float

maxElement' :: Vector (Complex Float) -> Complex Float

sumElements' :: Vector (Complex Float) -> Complex Float

prodElements' :: Vector (Complex Float) -> Complex Float

step' :: Vector (Complex Float) -> Vector (Complex Float)

ccompare' :: Vector (Complex Float) -> Vector (Complex Float) -> Vector I

cselect' :: Vector I -> Vector (Complex Float) -> Vector (Complex Float) -> Vector (Complex Float) -> Vector (Complex Float)

find' :: (Complex Float -> Bool) -> Vector (Complex Float) -> [IndexOf Vector]

assoc' :: IndexOf Vector -> Complex Float -> [(IndexOf Vector, Complex Float)] -> Vector (Complex Float)

accum' :: Vector (Complex Float) -> (Complex Float -> Complex Float -> Complex Float) -> [(IndexOf Vector, Complex Float)] -> Vector (Complex Float)

scaleRecip :: Complex Float -> Vector (Complex Float) -> Vector (Complex Float)

divide :: Vector (Complex Float) -> Vector (Complex Float) -> Vector (Complex Float)

arctan2' :: Vector (Complex Float) -> Vector (Complex Float) -> Vector (Complex Float)

cmod' :: Complex Float -> Vector (Complex Float) -> Vector (Complex Float)

fromInt' :: Vector I -> Vector (Complex Float)

toInt' :: Vector (Complex Float) -> Vector I

fromZ' :: Vector Z -> Vector (Complex Float)

toZ' :: Vector (Complex Float) -> Vector Z

KnownNat m => Container Vector (Mod m I) Source # |

Instance details

Defined in Internal.Modular

Methods

conj' :: Vector (Mod m I) -> Vector (Mod m I)

size' :: Vector (Mod m I) -> IndexOf Vector

scalar' :: Mod m I -> Vector (Mod m I)

scale' :: Mod m I -> Vector (Mod m I) -> Vector (Mod m I)

addConstant :: Mod m I -> Vector (Mod m I) -> Vector (Mod m I)

add' :: Vector (Mod m I) -> Vector (Mod m I) -> Vector (Mod m I)

sub :: Vector (Mod m I) -> Vector (Mod m I) -> Vector (Mod m I)

mul :: Vector (Mod m I) -> Vector (Mod m I) -> Vector (Mod m I)

equal :: Vector (Mod m I) -> Vector (Mod m I) -> Bool

cmap' :: Element b => (Mod m I -> b) -> Vector (Mod m I) -> Vector b

konst' :: Mod m I -> IndexOf Vector -> Vector (Mod m I)

build' :: IndexOf Vector -> ArgOf Vector (Mod m I) -> Vector (Mod m I)

atIndex' :: Vector (Mod m I) -> IndexOf Vector -> Mod m I

minIndex' :: Vector (Mod m I) -> IndexOf Vector

maxIndex' :: Vector (Mod m I) -> IndexOf Vector

minElement' :: Vector (Mod m I) -> Mod m I

maxElement' :: Vector (Mod m I) -> Mod m I

sumElements' :: Vector (Mod m I) -> Mod m I

prodElements' :: Vector (Mod m I) -> Mod m I

step' :: Vector (Mod m I) -> Vector (Mod m I)

ccompare' :: Vector (Mod m I) -> Vector (Mod m I) -> Vector I

cselect' :: Vector I -> Vector (Mod m I) -> Vector (Mod m I) -> Vector (Mod m I) -> Vector (Mod m I)

find' :: (Mod m I -> Bool) -> Vector (Mod m I) -> [IndexOf Vector]

assoc' :: IndexOf Vector -> Mod m I -> [(IndexOf Vector, Mod m I)] -> Vector (Mod m I)

accum' :: Vector (Mod m I) -> (Mod m I -> Mod m I -> Mod m I) -> [(IndexOf Vector, Mod m I)] -> Vector (Mod m I)

scaleRecip :: Mod m I -> Vector (Mod m I) -> Vector (Mod m I)

divide :: Vector (Mod m I) -> Vector (Mod m I) -> Vector (Mod m I)

arctan2' :: Vector (Mod m I) -> Vector (Mod m I) -> Vector (Mod m I)

cmod' :: Mod m I -> Vector (Mod m I) -> Vector (Mod m I)

fromInt' :: Vector I -> Vector (Mod m I)

toInt' :: Vector (Mod m I) -> Vector I

fromZ' :: Vector Z -> Vector (Mod m I)

toZ' :: Vector (Mod m I) -> Vector Z

KnownNat m => Container Vector (Mod m Z) Source # |

Instance details

Defined in Internal.Modular

Methods

conj' :: Vector (Mod m Z) -> Vector (Mod m Z)

size' :: Vector (Mod m Z) -> IndexOf Vector

scalar' :: Mod m Z -> Vector (Mod m Z)

scale' :: Mod m Z -> Vector (Mod m Z) -> Vector (Mod m Z)

addConstant :: Mod m Z -> Vector (Mod m Z) -> Vector (Mod m Z)

add' :: Vector (Mod m Z) -> Vector (Mod m Z) -> Vector (Mod m Z)

sub :: Vector (Mod m Z) -> Vector (Mod m Z) -> Vector (Mod m Z)

mul :: Vector (Mod m Z) -> Vector (Mod m Z) -> Vector (Mod m Z)

equal :: Vector (Mod m Z) -> Vector (Mod m Z) -> Bool

cmap' :: Element b => (Mod m Z -> b) -> Vector (Mod m Z) -> Vector b

konst' :: Mod m Z -> IndexOf Vector -> Vector (Mod m Z)

build' :: IndexOf Vector -> ArgOf Vector (Mod m Z) -> Vector (Mod m Z)

atIndex' :: Vector (Mod m Z) -> IndexOf Vector -> Mod m Z

minIndex' :: Vector (Mod m Z) -> IndexOf Vector

maxIndex' :: Vector (Mod m Z) -> IndexOf Vector

minElement' :: Vector (Mod m Z) -> Mod m Z

maxElement' :: Vector (Mod m Z) -> Mod m Z

sumElements' :: Vector (Mod m Z) -> Mod m Z

prodElements' :: Vector (Mod m Z) -> Mod m Z

step' :: Vector (Mod m Z) -> Vector (Mod m Z)

ccompare' :: Vector (Mod m Z) -> Vector (Mod m Z) -> Vector I

cselect' :: Vector I -> Vector (Mod m Z) -> Vector (Mod m Z) -> Vector (Mod m Z) -> Vector (Mod m Z)

find' :: (Mod m Z -> Bool) -> Vector (Mod m Z) -> [IndexOf Vector]

assoc' :: IndexOf Vector -> Mod m Z -> [(IndexOf Vector, Mod m Z)] -> Vector (Mod m Z)

accum' :: Vector (Mod m Z) -> (Mod m Z -> Mod m Z -> Mod m Z) -> [(IndexOf Vector, Mod m Z)] -> Vector (Mod m Z)

scaleRecip :: Mod m Z -> Vector (Mod m Z) -> Vector (Mod m Z)

divide :: Vector (Mod m Z) -> Vector (Mod m Z) -> Vector (Mod m Z)

arctan2' :: Vector (Mod m Z) -> Vector (Mod m Z) -> Vector (Mod m Z)

cmod' :: Mod m Z -> Vector (Mod m Z) -> Vector (Mod m Z)

fromInt' :: Vector I -> Vector (Mod m Z)

toInt' :: Vector (Mod m Z) -> Vector I

fromZ' :: Vector Z -> Vector (Mod m Z)

toZ' :: Vector (Mod m Z) -> Vector Z

class (Num e, Element e) => Product e Source #

Matrix product and related functions

Minimal complete definition

multiply, absSum, norm1, norm2, normInf

#### Instances

Instances details

Product I Source # |
Instance details Defined in Internal.Numeric Methods multiply :: Matrix I -> Matrix I -> Matrix I absSum :: Vector I -> RealOf I norm1 :: Vector I -> RealOf I norm2 :: Vector I -> RealOf I normInf :: Vector I -> RealOf I
Product Z Source # |
Instance details Defined in Internal.Numeric Methods multiply :: Matrix Z -> Matrix Z -> Matrix Z absSum :: Vector Z -> RealOf Z norm1 :: Vector Z -> RealOf Z norm2 :: Vector Z -> RealOf Z normInf :: Vector Z -> RealOf Z
Product Double Source # |
Instance details Defined in Internal.Numeric Methods multiply :: Matrix Double -> Matrix Double -> Matrix Double absSum :: Vector Double -> RealOf Double norm1 :: Vector Double -> RealOf Double norm2 :: Vector Double -> RealOf Double normInf :: Vector Double -> RealOf Double
Product Float Source # |
Instance details Defined in Internal.Numeric Methods multiply :: Matrix Float -> Matrix Float -> Matrix Float absSum :: Vector Float -> RealOf Float norm1 :: Vector Float -> RealOf Float norm2 :: Vector Float -> RealOf Float normInf :: Vector Float -> RealOf Float
Product (Complex Double) Source # |
Instance details Defined in Internal.Numeric Methods multiply :: Matrix (Complex Double) -> Matrix (Complex Double) -> Matrix (Complex Double) absSum :: Vector (Complex Double) -> RealOf (Complex Double) norm1 :: Vector (Complex Double) -> RealOf (Complex Double) norm2 :: Vector (Complex Double) -> RealOf (Complex Double) normInf :: Vector (Complex Double) -> RealOf (Complex Double)
Product (Complex Float) Source # |
Instance details Defined in Internal.Numeric Methods multiply :: Matrix (Complex Float) -> Matrix (Complex Float) -> Matrix (Complex Float) absSum :: Vector (Complex Float) -> RealOf (Complex Float) norm1 :: Vector (Complex Float) -> RealOf (Complex Float) norm2 :: Vector (Complex Float) -> RealOf (Complex Float) normInf :: Vector (Complex Float) -> RealOf (Complex Float)
KnownNat m => Product (Mod m I) Source # |
Instance details Defined in Internal.Modular Methods multiply :: Matrix (Mod m I) -> Matrix (Mod m I) -> Matrix (Mod m I) absSum :: Vector (Mod m I) -> RealOf (Mod m I) norm1 :: Vector (Mod m I) -> RealOf (Mod m I) norm2 :: Vector (Mod m I) -> RealOf (Mod m I) normInf :: Vector (Mod m I) -> RealOf (Mod m I)
KnownNat m => Product (Mod m Z) Source # |
Instance details Defined in Internal.Modular Methods multiply :: Matrix (Mod m Z) -> Matrix (Mod m Z) -> Matrix (Mod m Z) absSum :: Vector (Mod m Z) -> RealOf (Mod m Z) norm1 :: Vector (Mod m Z) -> RealOf (Mod m Z) norm2 :: Vector (Mod m Z) -> RealOf (Mod m Z) normInf :: Vector (Mod m Z) -> RealOf (Mod m Z)

class (Container Vector t, Container Matrix t, Konst t Int Vector, Konst t (Int, Int) Matrix, CTrans t, Product t, Additive (Vector t), Additive (Matrix t), Linear t Vector, Linear t Matrix) => Numeric t Source #

#### Instances

Instances details

Numeric I Source # |
Instance details Defined in Internal.Numeric
Numeric Z Source # |
Instance details Defined in Internal.Numeric
Numeric Double Source # |
Instance details Defined in Internal.Numeric
Numeric Float Source # |
Instance details Defined in Internal.Numeric
Numeric (Complex Double) Source # |
Instance details Defined in Internal.Numeric
Numeric (Complex Float) Source # |
Instance details Defined in Internal.Numeric
KnownNat m => Numeric (Mod m I) Source # |
Instance details Defined in Internal.Modular
KnownNat m => Numeric (Mod m Z) Source # |
Instance details Defined in Internal.Modular

class LSDiv (c :: Type -> Type) Source #

Minimal complete definition

linSolve

#### Instances

Instances details

LSDiv Matrix Source # |
Instance details Defined in Internal.Container Methods linSolve :: Field t => Matrix t -> Matrix t -> Matrix t
LSDiv Vector Source # |
Instance details Defined in Internal.Container Methods linSolve :: Field t => Matrix t -> Vector t -> Vector t

data Herm t Source #

A matrix that, by construction, it is known to be complex Hermitian or real symmetric.

It can be created using `sym`, `mTm`, or `trustSym`, and the matrix can be extracted using `unSym`.

#### Instances

Instances details

Field t => Linear t Herm Source # |
Instance details Defined in Internal.Algorithms Methods scale :: t -> Herm t -> Herm t Source #
(NFData t, Numeric t) => NFData (Herm t) Source # |
Instance details Defined in Internal.Algorithms Methods rnf :: Herm t -> () Source #
(Show t, Element t) => Show (Herm t) Source # |
Instance details Defined in Internal.Algorithms Methods showsPrec :: Int -> Herm t -> ShowS Source # show :: Herm t -> String Source # showList :: [Herm t] -> ShowS Source #
Field t => Additive (Herm t) Source # |
Instance details Defined in Internal.Algorithms Methods add :: Herm t -> Herm t -> Herm t Source #

class Complexable (c :: Type -> Type) Source #

Structures that may contain complex numbers

Minimal complete definition

toComplex', fromComplex', comp', single', double'

#### Instances

Instances details

Complexable Matrix Source # |
Instance details Defined in Internal.Conversion Methods toComplex' :: RealElement e => (Matrix e, Matrix e) -> Matrix (Complex e) fromComplex' :: RealElement e => Matrix (Complex e) -> (Matrix e, Matrix e) comp' :: RealElement e => Matrix e -> Matrix (Complex e) single' :: Precision a b => Matrix b -> Matrix a double' :: Precision a b => Matrix a -> Matrix b
Complexable Vector Source # |
Instance details Defined in Internal.Conversion Methods toComplex' :: RealElement e => (Vector e, Vector e) -> Vector (Complex e) fromComplex' :: RealElement e => Vector (Complex e) -> (Vector e, Vector e) comp' :: RealElement e => Vector e -> Vector (Complex e) single' :: Precision a b => Vector b -> Vector a double' :: Precision a b => Vector a -> Vector b

class (Element t, Element (Complex t), RealFloat t) => RealElement t Source #

Supported real types

#### Instances

Instances details

RealElement Double Source # |
Instance details Defined in Internal.Conversion
RealElement Float Source # |
Instance details Defined in Internal.Conversion

type family RealOf x Source #

#### Instances

Instances details

type RealOf I Source # |
Instance details Defined in Internal.Numeric type RealOf I = I
type RealOf Z Source # |
Instance details Defined in Internal.Numeric type RealOf Z = Z
type RealOf Double Source # |
Instance details Defined in Internal.Numeric type RealOf Double = Double
type RealOf Float Source # |
Instance details Defined in Internal.Numeric type RealOf Float = Float
type RealOf (Complex Double) Source # |
Instance details Defined in Internal.Numeric type RealOf (Complex Double) = Double
type RealOf (Complex Float) Source # |
Instance details Defined in Internal.Numeric type RealOf (Complex Float) = Float
type RealOf (Mod n I) Source # |
Instance details Defined in Internal.Modular type RealOf (Mod n I) = I
type RealOf (Mod n Z) Source # |
Instance details Defined in Internal.Modular type RealOf (Mod n Z) = Z

type ComplexOf x = Complex (RealOf x) Source #

type family SingleOf x Source #

#### Instances

Instances details

type SingleOf Double Source # |
Instance details Defined in Internal.Numeric type SingleOf Double = Float
type SingleOf Float Source # |
Instance details Defined in Internal.Numeric type SingleOf Float = Float
type SingleOf (Complex a) Source # |
Instance details Defined in Internal.Numeric type SingleOf (Complex a) = Complex (SingleOf a)

type family DoubleOf x Source #

#### Instances

Instances details

type DoubleOf Double Source # |
Instance details Defined in Internal.Numeric type DoubleOf Double = Double
type DoubleOf Float Source # |
Instance details Defined in Internal.Numeric type DoubleOf Float = Double
type DoubleOf (Complex a) Source # |
Instance details Defined in Internal.Numeric type DoubleOf (Complex a) = Complex (DoubleOf a)

type family IndexOf (c :: Type -> Type) Source #

#### Instances

Instances details

type IndexOf Matrix Source # |
Instance details Defined in Internal.Numeric type IndexOf Matrix = (Int, Int)
type IndexOf Vector Source # |
Instance details Defined in Internal.Numeric type IndexOf Vector = Int

class (Numeric t, Convert t, Normed Matrix t, Normed Vector t, Floating t, Linear t Vector, Linear t Matrix, Additive (Vector t), Additive (Matrix t), RealOf t ~ Double) => Field t Source #

Generic linear algebra functions for double precision real and complex matrices.

(Single precision data can be converted using `single` and `double`).

Minimal complete definition

svd', thinSVD', sv', luPacked', luSolve', mbLinearSolve', linearSolve', cholSolve', triSolve', triDiagSolve', ldlPacked', ldlSolve', linearSolveSVD', linearSolveLS', eig', geig', eigSH'', eigOnly, geigOnly, eigOnlySH, cholSH', mbCholSH', qr', qrgr', hess', schur'

#### Instances

Instances details

Field Double Source # |

Instance details

Defined in Internal.Algorithms

Methods

svd' :: Matrix Double -> (Matrix Double, Vector Double, Matrix Double)

thinSVD' :: Matrix Double -> (Matrix Double, Vector Double, Matrix Double)

sv' :: Matrix Double -> Vector Double

luPacked' :: Matrix Double -> (Matrix Double, [Int])

luSolve' :: (Matrix Double, [Int]) -> Matrix Double -> Matrix Double

mbLinearSolve' :: Matrix Double -> Matrix Double -> Maybe (Matrix Double)

linearSolve' :: Matrix Double -> Matrix Double -> Matrix Double

cholSolve' :: Matrix Double -> Matrix Double -> Matrix Double

triSolve' :: UpLo -> Matrix Double -> Matrix Double -> Matrix Double

triDiagSolve' :: Vector Double -> Vector Double -> Vector Double -> Matrix Double -> Matrix Double

ldlPacked' :: Matrix Double -> (Matrix Double, [Int])

ldlSolve' :: (Matrix Double, [Int]) -> Matrix Double -> Matrix Double

linearSolveSVD' :: Matrix Double -> Matrix Double -> Matrix Double

linearSolveLS' :: Matrix Double -> Matrix Double -> Matrix Double

eig' :: Matrix Double -> (Vector (Complex Double), Matrix (Complex Double))

geig' :: Matrix Double -> Matrix Double -> (Vector (Complex Double), Vector Double, Matrix (Complex Double))

eigSH'' :: Matrix Double -> (Vector Double, Matrix Double)

eigOnly :: Matrix Double -> Vector (Complex Double)

geigOnly :: Matrix Double -> Matrix Double -> (Vector (Complex Double), Vector Double)

eigOnlySH :: Matrix Double -> Vector Double

cholSH' :: Matrix Double -> Matrix Double

mbCholSH' :: Matrix Double -> Maybe (Matrix Double)

qr' :: Matrix Double -> (Matrix Double, Vector Double)

qrgr' :: Int -> (Matrix Double, Vector Double) -> Matrix Double

hess' :: Matrix Double -> (Matrix Double, Matrix Double)

schur' :: Matrix Double -> (Matrix Double, Matrix Double)

Field (Complex Double) Source # |

Instance details

Defined in Internal.Algorithms

Methods

svd' :: Matrix (Complex Double) -> (Matrix (Complex Double), Vector Double, Matrix (Complex Double))

thinSVD' :: Matrix (Complex Double) -> (Matrix (Complex Double), Vector Double, Matrix (Complex Double))

sv' :: Matrix (Complex Double) -> Vector Double

luPacked' :: Matrix (Complex Double) -> (Matrix (Complex Double), [Int])

luSolve' :: (Matrix (Complex Double), [Int]) -> Matrix (Complex Double) -> Matrix (Complex Double)

mbLinearSolve' :: Matrix (Complex Double) -> Matrix (Complex Double) -> Maybe (Matrix (Complex Double))

linearSolve' :: Matrix (Complex Double) -> Matrix (Complex Double) -> Matrix (Complex Double)

cholSolve' :: Matrix (Complex Double) -> Matrix (Complex Double) -> Matrix (Complex Double)

triSolve' :: UpLo -> Matrix (Complex Double) -> Matrix (Complex Double) -> Matrix (Complex Double)

triDiagSolve' :: Vector (Complex Double) -> Vector (Complex Double) -> Vector (Complex Double) -> Matrix (Complex Double) -> Matrix (Complex Double)

ldlPacked' :: Matrix (Complex Double) -> (Matrix (Complex Double), [Int])

ldlSolve' :: (Matrix (Complex Double), [Int]) -> Matrix (Complex Double) -> Matrix (Complex Double)

linearSolveSVD' :: Matrix (Complex Double) -> Matrix (Complex Double) -> Matrix (Complex Double)

linearSolveLS' :: Matrix (Complex Double) -> Matrix (Complex Double) -> Matrix (Complex Double)

eig' :: Matrix (Complex Double) -> (Vector (Complex Double), Matrix (Complex Double))

geig' :: Matrix (Complex Double) -> Matrix (Complex Double) -> (Vector (Complex Double), Vector (Complex Double), Matrix (Complex Double))

eigSH'' :: Matrix (Complex Double) -> (Vector Double, Matrix (Complex Double))

eigOnly :: Matrix (Complex Double) -> Vector (Complex Double)

geigOnly :: Matrix (Complex Double) -> Matrix (Complex Double) -> (Vector (Complex Double), Vector (Complex Double))

eigOnlySH :: Matrix (Complex Double) -> Vector Double

cholSH' :: Matrix (Complex Double) -> Matrix (Complex Double)

mbCholSH' :: Matrix (Complex Double) -> Maybe (Matrix (Complex Double))

qr' :: Matrix (Complex Double) -> (Matrix (Complex Double), Vector (Complex Double))

qrgr' :: Int -> (Matrix (Complex Double), Vector (Complex Double)) -> Matrix (Complex Double)

hess' :: Matrix (Complex Double) -> (Matrix (Complex Double), Matrix (Complex Double))

schur' :: Matrix (Complex Double) -> (Matrix (Complex Double), Matrix (Complex Double))

class Linear t (c :: Type -> Type) Source #

Minimal complete definition

scale

#### Instances

Instances details

Field t => Linear t Herm Source # |
Instance details Defined in Internal.Algorithms Methods scale :: t -> Herm t -> Herm t Source #
Container Matrix t => Linear t Matrix Source # |
Instance details Defined in Internal.Numeric Methods scale :: t -> Matrix t -> Matrix t Source #
Container Vector t => Linear t Vector Source # |
Instance details Defined in Internal.Numeric Methods scale :: t -> Vector t -> Vector t Source #

class Additive c Source #

Minimal complete definition

add

#### Instances

Instances details

Field t => Additive (Herm t) Source # |
Instance details Defined in Internal.Algorithms Methods add :: Herm t -> Herm t -> Herm t Source #
Container Matrix t => Additive (Matrix t) Source # |
Instance details Defined in Internal.Numeric Methods add :: Matrix t -> Matrix t -> Matrix t Source #
Additive (C n) Source # |
Instance details Defined in Internal.Static Methods add :: C n -> C n -> C n Source #
Additive (R n) Source # |
Instance details Defined in Internal.Static Methods add :: R n -> R n -> R n Source #
KnownNat n => Additive (Sym n) Source # |
Instance details Defined in Numeric.LinearAlgebra.Static Methods add :: Sym n -> Sym n -> Sym n Source #
Container Vector t => Additive (Vector t) Source # |
Instance details Defined in Internal.Numeric Methods add :: Vector t -> Vector t -> Vector t Source #
(KnownNat m, KnownNat n) => Additive (L m n) Source # |
Instance details Defined in Internal.Static Methods add :: L m n -> L m n -> L m n Source #
(KnownNat m, KnownNat n) => Additive (M m n) Source # |
Instance details Defined in Internal.Static Methods add :: M m n -> M m n -> M m n Source #

class Transposable m mt | m -> mt, mt -> m Source #

Minimal complete definition

tr, tr'

#### Instances

Instances details

Transposable GMatrix GMatrix Source # |
Instance details Defined in Internal.Sparse Methods tr :: GMatrix -> GMatrix Source # tr' :: GMatrix -> GMatrix Source #
(CTrans t, Container Vector t) => Transposable (Matrix t) (Matrix t) Source # |
Instance details Defined in Internal.Numeric Methods tr :: Matrix t -> Matrix t Source # tr' :: Matrix t -> Matrix t Source #
KnownNat n => Transposable (Her n) (Her n) Source # |
Instance details Defined in Numeric.LinearAlgebra.Static Methods tr :: Her n -> Her n Source # tr' :: Her n -> Her n Source #
KnownNat n => Transposable (Sym n) (Sym n) Source # |
Instance details Defined in Numeric.LinearAlgebra.Static Methods tr :: Sym n -> Sym n Source # tr' :: Sym n -> Sym n Source #
(KnownNat n, KnownNat m) => Transposable (L m n) (L n m) Source # |
Instance details Defined in Internal.Static Methods tr :: L m n -> L n m Source # tr' :: L m n -> L n m Source #
(KnownNat n, KnownNat m) => Transposable (M m n) (M n m) Source # |
Instance details Defined in Internal.Static Methods tr :: M m n -> M n m Source # tr' :: M m n -> M n m Source #

data LU t Source #

LU decomposition of a matrix in a compact format.

Constructors

LU (Matrix t) [Int] |

#### Instances

Instances details

(NFData t, Numeric t) => NFData (LU t) Source # |
Instance details Defined in Internal.Algorithms Methods rnf :: LU t -> () Source #
(Show t, Element t) => Show (LU t) Source # |
Instance details Defined in Internal.Algorithms Methods showsPrec :: Int -> LU t -> ShowS Source # show :: LU t -> String Source # showList :: [LU t] -> ShowS Source #

data LDL t Source #

LDL decomposition of a complex Hermitian or real symmetric matrix in a compact format.

Constructors

LDL (Matrix t) [Int] |

#### Instances

Instances details

(NFData t, Numeric t) => NFData (LDL t) Source # |
Instance details Defined in Internal.Algorithms Methods rnf :: LDL t -> () Source #
(Show t, Element t) => Show (LDL t) Source # |
Instance details Defined in Internal.Algorithms Methods showsPrec :: Int -> LDL t -> ShowS Source # show :: LDL t -> String Source # showList :: [LDL t] -> ShowS Source #

data QR t Source #

QR decomposition of a matrix in compact form. (The orthogonal matrix is not explicitly formed.)

Constructors

QR (Matrix t) (Vector t) |

#### Instances

Instances details

(NFData t, Numeric t) => NFData (QR t) Source # |
Instance details Defined in Internal.Algorithms Methods rnf :: QR t -> () Source #

data CGState Source #

Constructors

CGState |

Fields

- cgp :: Vector R

  conjugate gradient

- cgr :: Vector R

  residual

- cgr2 :: R

  squared norm of residual

- cgx :: Vector R

  current solution

- cgdx :: R

  normalized size of correction

class Testable t where Source #

Minimal complete definition

checkT

Methods

checkT :: t -> (Bool, IO ()) Source #

ioCheckT :: t -> IO (Bool, IO ()) Source #

#### Instances

Instances details

Testable GMatrix Source # |
Instance details Defined in Internal.CG Methods checkT :: GMatrix -> (Bool, IO ()) Source # ioCheckT :: GMatrix -> IO (Bool, IO ()) Source #
KnownNat m => Testable (Matrix (Mod m I)) Source # |
Instance details Defined in Internal.Modular Methods checkT :: Matrix (Mod m I) -> (Bool, IO ()) Source # ioCheckT :: Matrix (Mod m I) -> IO (Bool, IO ()) Source #
Testable (Matrix I) Source # |
Instance details Defined in Internal.Util Methods checkT :: Matrix I -> (Bool, IO ()) Source # ioCheckT :: Matrix I -> IO (Bool, IO ()) Source #
(KnownNat n', KnownNat m') => Testable (L n' m') Source # |
Instance details Defined in Numeric.LinearAlgebra.Static Methods checkT :: L n' m' -> (Bool, IO ()) Source # ioCheckT :: L n' m' -> IO (Bool, IO ()) Source #