Skip to content

HMath.Matrix.LAPACK

Module index · Numerical conventions

Description

Double-precision optional, dynamically loaded LAPACKE spectral routines. All foreign buffers are private copies; no Haskell storage is exposed or mutated. Inputs must be finite and dimensions must fit 32-bit indices; the adapter widens them for ILP64. The default system liblapacke SONAME has its conventional LP64 ABI. A custom HMATH_LAPACKE_LIBRARY requires an explicit HMATH_LAPACKE_INTEGER_BITS=32/64 declaration before first use. HMATH_BACKEND=pure disables native routines. Missing native routines fail explicitly; pure alternatives live in HMath.Backend. Pure wrappers are safe because the called routines have no observable effects outside those buffers. LAPACKE interfaces: https://www.netlib.org/lapack/lapacke.html

On this page

API Purpose
SVD Real singular-value decomposition with U,descending nonnegative singular values,and VT.
SVD Declaration and type contract below.
svdU Left singular vectors as columns of the real thin/full SVD factor.
singularValues Nonnegative real singular values in descending order.
svdVT Transposed right singular-vector factor in A=Udiag(s)VT.
svd Compute thin real SVD A=Udiag(s)VT via LAPACK, with descending nonnegative singular values and k=min(m,n).
fullSVD Full square U and V^T, including null-space completion.
truncatedSVD Given retained rank k then real matrix, compute thin SVD and retain its first k components.
randomizedSVD Randomized range finder with an explicit seed, oversampling, and power iterations, followed by a small deterministic SVD.
Eigen Complex eigenvalues with corresponding right eigenvector columns, including conjugate pairs from real input.
Eigen Declaration and type contract below.
eigenvalues Complex eigenvalues matching eigenvector column order.
eigenvectors Right eigenvectors as complex matrix columns.
eigen Compute complex eigenvalues and right eigenvectors of a finite real square matrix via LAPACK.
symmetricEigen Real symmetric eigensolver with orthonormal columns, sorted ascending.
GeneralizedEigen Projective eigenvalues alpha/beta preserve infinite eigenvalues and indeterminate singular pencils without dividing by a zero beta.
GeneralizedEigen Declaration and type contract below.
eigenAlpha Generalized-eigenvalue numerators alpha; retain with beta to represent infinite eigenvalues.
eigenBeta Generalized-eigenvalue denominators beta; zero beta can represent an infinite eigenvalue.
generalizedEigenvectors Right eigenvector columns satisfying betaAv=alphaBv.
generalizedEigen Given equally sized square matrices A,B, compute generalized alpha/beta eigenvalue representation and right eigenvectors.
Schur Real Schur factors A=QTtranspose(Q), with quasi-triangular T and complex eigenvalues.
Schur Declaration and type contract below.
schurQ Orthogonal basis in A=QTtranspose(Q).
schurT Real quasi-upper-triangular Schur form, including 2-by-2 blocks for conjugate pairs.
schurEigenvalues Complex eigenvalues decoded from the real Schur form.
schur Compute real Schur form A=QTtranspose(Q), returning orthogonal Q, quasi-upper-triangular T and complex eigenvalues.
QZ Generalized real Schur factors for a matrix pair, retaining alpha/beta eigenvalue representation to allow infinite eigenvalues.
QZ Declaration and type contract below.
qzQ Left orthogonal QZ transform, with A=QStranspose(Z).
qzZ Right orthogonal QZ transform for both matrix factors.
qzS First generalized real Schur factor S.
qzT Second generalized real Schur factor T.
qzAlpha Generalized Schur eigenvalue numerators alpha.
qzBeta Generalized Schur eigenvalue denominators beta; do not divide blindly when zero.
qz Compute generalized real Schur factors for a finite square matrix pair A,B, retaining Q,Z,S,T and alphabeta eigenvalues.
Hessenberg Orthogonal reduction A=QHtranspose(Q), with H upper Hessenberg.
Hessenberg Declaration and type contract below.
hessenbergQ Orthogonal transform in A=QHtranspose(Q).
hessenbergH Upper Hessenberg form with zeros below the first subdiagonal.
hessenberg Reduce finite real square A to upper Hessenberg H with orthogonal Q, satisfying A=QHtranspose(Q).
Balance D^-1 A D = balancedMatrix.
Balance Declaration and type contract below.
balancedMatrix Matrix after LAPACK diagonal balancing.
balanceScales Diagonal basis scaling factors used by the balancing transformation.
balance Balance a real square matrix by diagonal scaling, returning the balanced matrix and scales needed to interpret its basis.
ComplexSVD Complex128 thin SVD: A = U diag(s) V, where complexVT already stores V.
ComplexSVD Declaration and type contract below.
complexU Complex left singular vectors as columns.
complexSingularValues Descending nonnegative real singular values of the complex matrix.
complexVT Conjugate-transposed right singular vectors in complex SVD.
complexSVD Compute thin complex SVD with conjugate-transposed right factor VT and real nonnegative singular values.
complexEigen Compute complex eigenvalues and right eigenvectors of a finite complex square matrix via LAPACK.

Documentation

SVD

data SVD Source #

Real singular-value decomposition with U,descending nonnegative singular values,and VT. Thin/full dimensions follow the selected factorization function.

Constructors

SVD 

Fields

Instances

Instances details
Show SVD Source # 
Instance details

Defined in HMath.Matrix.LAPACK

Methods

showsPrec :: Int -> SVD -> ShowS #

show :: SVD -> String #

showList :: [SVD] -> ShowS #

Eq SVD Source # 
Instance details

Defined in HMath.Matrix.LAPACK

Methods

(==) :: SVD -> SVD -> Bool #

(/=) :: SVD -> SVD -> Bool #

svd

svd :: Matrix Double -> Either MathError SVD Source #

Compute thin real SVD A=U*diag(s)*VT via LAPACK, with descending nonnegative singular values and k=min(m,n). Return m-by-k U and k-by-n VT. Invalid input, unavailable backend, allocation bounds or LAPACK failure returns Left MathError.

fullSVD

fullSVD :: Matrix Double -> Either MathError SVD Source #

Full square U and V^T, including null-space completion.

truncatedSVD

truncatedSVD :: Int -> Matrix Double -> Either MathError SVD Source #

Given retained rank k then real matrix, compute thin SVD and retain its first k components. Reject k outside the available rank dimensions; decomposition failures propagate.

randomizedSVD

randomizedSVD :: Int -> Int -> Int -> Integer -> Matrix Double -> Either MathError SVD Source #

Randomized range finder with an explicit seed, oversampling, and power iterations, followed by a small deterministic SVD. The Gaussian test matrix uses Box-Muller on a local LCG, so results are reproducible, not cryptographic.

Eigen

data Eigen Source #

Complex eigenvalues with corresponding right eigenvector columns, including conjugate pairs from real input.

Constructors

Eigen 

Fields

Instances

Instances details
Show Eigen Source # 
Instance details

Defined in HMath.Matrix.LAPACK

Methods

showsPrec :: Int -> Eigen -> ShowS #

show :: Eigen -> String #

showList :: [Eigen] -> ShowS #

Eq Eigen Source # 
Instance details

Defined in HMath.Matrix.LAPACK

Methods

(==) :: Eigen -> Eigen -> Bool #

(/=) :: Eigen -> Eigen -> Bool #

eigen

eigen :: Matrix Double -> Either MathError Eigen Source #

Compute complex eigenvalues and right eigenvectors of a finite real square matrix via LAPACK. Complex-conjugate pairs are decoded into complex columns. Invalid shapebackendnumeric failures return Left MathError.

symmetricEigen

symmetricEigen :: Matrix Double -> Either MathError Eigen Source #

Real symmetric eigensolver with orthonormal columns, sorted ascending.

GeneralizedEigen

data GeneralizedEigen Source #

Projective eigenvalues alpha/beta preserve infinite eigenvalues and indeterminate singular pencils without dividing by a zero beta.

Constructors

GeneralizedEigen 

Fields

generalizedEigen

generalizedEigen :: Matrix Double -> Matrix Double -> Either MathError GeneralizedEigen Source #

Given equally sized square matrices A,B, compute generalized alpha/beta eigenvalue representation and right eigenvectors. Retain alpha/beta to represent infinite eigenvalues safely; invalid input or LAPACK failure propagates.

Schur

data Schur Source #

Real Schur factors A=Q*T*transpose(Q), with quasi-triangular T and complex eigenvalues.

Constructors

Schur 

Fields

Instances

Instances details
Show Schur Source # 
Instance details

Defined in HMath.Matrix.LAPACK

Methods

showsPrec :: Int -> Schur -> ShowS #

show :: Schur -> String #

showList :: [Schur] -> ShowS #

Eq Schur Source # 
Instance details

Defined in HMath.Matrix.LAPACK

Methods

(==) :: Schur -> Schur -> Bool #

(/=) :: Schur -> Schur -> Bool #

schur

schur :: Matrix Double -> Either MathError Schur Source #

Compute real Schur form A=Q*T*transpose(Q), returning orthogonal Q, quasi-upper-triangular T and complex eigenvalues. Require finite square input and available LAPACK; failures return Left MathError.

QZ

data QZ Source #

Generalized real Schur factors for a matrix pair, retaining alpha/beta eigenvalue representation to allow infinite eigenvalues.

Constructors

QZ 

Fields

Instances

Instances details
Show QZ Source # 
Instance details

Defined in HMath.Matrix.LAPACK

Methods

showsPrec :: Int -> QZ -> ShowS #

show :: QZ -> String #

showList :: [QZ] -> ShowS #

Eq QZ Source # 
Instance details

Defined in HMath.Matrix.LAPACK

Methods

(==) :: QZ -> QZ -> Bool #

(/=) :: QZ -> QZ -> Bool #

qz

qz :: Matrix Double -> Matrix Double -> Either MathError QZ Source #

Compute generalized real Schur factors for a finite square matrix pair A,B, retaining Q,Z,S,T and alphabeta eigenvalues. Shapebackend/LAPACK errors return Left MathError.

Hessenberg

data Hessenberg Source #

Orthogonal reduction A=Q*H*transpose(Q), with H upper Hessenberg.

Constructors

Hessenberg 

Fields

Instances

Instances details
Show Hessenberg Source # 
Instance details

Defined in HMath.Matrix.LAPACK

Eq Hessenberg Source # 
Instance details

Defined in HMath.Matrix.LAPACK

hessenberg

hessenberg :: Matrix Double -> Either MathError Hessenberg Source #

Reduce finite real square A to upper Hessenberg H with orthogonal Q, satisfying A=Q*H*transpose(Q). Invalid shape or backend/decomposition failures propagate.

Balance

data Balance Source #

D^-1 A D = balancedMatrix. Scale-only balancing preserves index order.

Constructors

Balance 

Fields

Instances

Instances details
Show Balance Source # 
Instance details

Defined in HMath.Matrix.LAPACK

Eq Balance Source # 
Instance details

Defined in HMath.Matrix.LAPACK

Methods

(==) :: Balance -> Balance -> Bool #

(/=) :: Balance -> Balance -> Bool #

balance

balance :: Matrix Double -> Either MathError Balance Source #

Balance a real square matrix by diagonal scaling, returning the balanced matrix and scales needed to interpret its basis. Invalid finite-input/shape checks or LAPACK failures return Left MathError.

ComplexSVD

data ComplexSVD Source #

Complex128 thin SVD: A = U diag(s) V*, where complexVT already stores V*.

Constructors

ComplexSVD 

Fields

Instances

Instances details
Show ComplexSVD Source # 
Instance details

Defined in HMath.Matrix.LAPACK

Eq ComplexSVD Source # 
Instance details

Defined in HMath.Matrix.LAPACK

complexSVD

complexSVD :: Matrix (Complex Double) -> Either MathError ComplexSVD Source #

Compute thin complex SVD with conjugate-transposed right factor VT and real nonnegative singular values. Require finite complex entries and available LAPACK. Invalid storage sizesbackenddecomposition fails.

complexEigen

complexEigen :: Matrix (Complex Double) -> Either MathError Eigen Source #

Compute complex eigenvalues and right eigenvectors of a finite complex square matrix via LAPACK. Invalid shape, backend availability, bounds or decomposition errors return Left MathError.