image thumbnail

Tridiagonalization of a Hermitian or symmetric matrix based on Lapack interface

version 1.5.0.0 (18.7 KB) by Sung-Eun Jo
The code computes the tridiagonal decomposition of a Hermitian matrix by calling Lapack routines.

535 Downloads

Updated 11 Sep 2014

View License

This code provides a reliable tridiagonal matrix decomposition routine based on Lapack subroutines ZHETRD and ZUNGTR.
Lapack is one of most reliable fortran routines in numerical analysis.
In Lapack, the tridiagonalization is used to calculate eigenvalue decomposition of a Hermitian matrix.
See http://www.netlib.org/lapack/lug/node48.html But, Matlab does not support it as a standalone style.
Thus, this submission helps people to use tridiagonalization of a Hermitian/symmetric matrix, A = Q * T * Q',
where A is Hermitian or symmetric, T is real symmetric tridiagonal, and Q is unitary or orthogonal.
The original Lapack interface routine comes from the previous work by Tim Toolan in "File Exchange".
Note that the Hermitian tridiagonalization is a good tool for matrix reduction preserving eigenvalues.
For non-Hermitian/-symmetric matrices, Hessenberg decomposition (hess) is the best choice for matrix reduction.
The tridiagonalization is not unique: It has many decomposition sets according to the choice of the first column vector of Q.
This code can be used for understanding the Lapack interface.
This code is also compatible with Octave platform.
The following is the function header for the usage example.
----
function [varargout]=tridiag_lapack(varargin)
% TRIDIAG_LAPACK computes the matrix tridiagonal decomposition
% by calling LAPACK subroutines.
%
% [Q, T] = tridiag_lapack (A)
% [Q, T] = tridiag_lapack (A, UPLO)
% R = tridiag_lapack (A, ...)
% [Q, D, E] = tridiag_lapack (A, ...)
% [Q, D, E, err] = tridiag_lapack (A, ...)
%
% Compute a real symmetric tridiagonal matrix decomposition of
% a complex Hermitian matrix A:
% A = Q*T*Q'
% where A is complex Hermitian or real symmetric,
% Q is unitary or orthogonal, and
% T is real symmetric tridiagonal.
%
% The tridiagonalization has applications in matrix reduction
% preserving eigenvalues. Thus, the eigenvalues of T are
% identical to those of A.
%
% When called with one return value, it returns R, a compressed form of T
% and Householder reflector of Q, which is computed in LAPACK
% subroutine ZHETRD.
%
% If the second argument UPLO is used, the order of the reflector
% vectors are chosen according to UPLO value 'L' (default) or 'U'.
% See http://www.netlib.org/lapack/explore-html/df/d7d/zhetrd_8f_source.html
%
% When called with 3 return values, it returns D and E, which are
% the diagonal vector and the off-diagonal vector of T:
% T = diag(D) + diag(E,1) + diag(E,-1)
%
% When called with 4 return values, it returns the residual error:
% err = norm(A-Q*T*Q')/norm(A).
%
% See also: svd, hess, eig, qr.
% See LAPACK subroutines ZHETRD and ZUNGTR.

Cite As

Sung-Eun Jo (2021). Tridiagonalization of a Hermitian or symmetric matrix based on Lapack interface (https://www.mathworks.com/matlabcentral/fileexchange/47803-tridiagonalization-of-a-hermitian-or-symmetric-matrix-based-on-lapack-interface), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2012a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!