| Title: | Calculate Generalized Eigenvalues, the Generalized Schur Decomposition and the Generalized Singular Value Decomposition of a Matrix Pair with Lapack |
|---|---|
| Description: | Functions to compute generalized eigenvalues and eigenvectors, the generalized Schur decomposition and the generalized Singular Value Decomposition of a matrix pair, using Lapack routines. |
| Authors: | Berend Hasselman [cre, aut], Lapack authors [aut, cph] |
| Maintainer: | Berend Hasselman <[email protected]> |
| License: | GPL (>= 2) |
| Version: | 2.3 |
| Built: | 2026-05-10 09:23:59 UTC |
| Source: | https://github.com/cran/geigen |
Functions to compute generalized eigenvalues and eigenvectors, the generalized Schur decomposition and the generalized Singular Value Decomposition of a matrix pair, using Lapack routines.
The geigen package provides functions to compute the generalized eigenvalues of a pair of matrices and optionally provides the generalized eigenvectors. Both numeric and complex matrices are allowed. The package also provides a function for computing the generalized Schur decomposition of a pair of matrices, either numeric or complex. Finally the package provides a function for computing the generalized singular value decomposition for a pair of matrices, either numeric or complex. The package uses routines provided by the Lapack linear algebra package.
Computes generalized eigenvalues and eigenvectors of a pair of matrices.
geigen(A, B, symmetric, only.values=FALSE)geigen(A, B, symmetric, only.values=FALSE)
A |
left hand side matrix. |
B |
right hand side matrix. |
symmetric |
if |
only.values |
if |
If the argument symmetric is missing, the function
will try to determine if the matrices are symmetric with the function isSymmetric from
the base package. It is faster to specify the argument.
Both matrices must be square. This function provides the solution to the generalized eigenvalue problem defined by
If either one of the matrices is complex the other matrix is coerced to be complex.
If the matrices are symmetric then the matrix B must be positive definite; if it is not
an error message will be issued.
If the matrix B is known to be symmetric but not positive definite then the argument
symmetric should be set to FALSE explicitly.
If the matrix B is not positive definite when it should be an
error message of the form
Leading minor of order ... of B is not positive definite
will be issued. In that case set the argument symmetric to FALSE if not set and try again.
For general matrices the generalized eigenvalues
are calculated as the ratio
where may be zero or very small leading
to non finite or very large values for the eigenvalues.
Therefore the values for and are also included in the return value
of the function.
When both matrices are complex (or coerced to be so) the generalized eigenvalues,
and are complex.
When both matrices are numeric may be numeric or complex and
is numeric.
When both matrices are symmetric (or Hermitian) the generalized eigenvalues are numeric and
no components and are available.
A list containing components
values |
a vector containing the |
vectors |
an |
alpha |
the numerator of the generalized eigenvalues and may be NULL if not applicable. |
beta |
the denominator of the generalized eigenvalues and may be NULL if not applicable. |
geigen uses the LAPACK routines DGGEV,
DSYGV, ZHEGV and ZGGEV.
LAPACK is from http://www.netlib.org/lapack.
The complex routines used by the package come from LAPACK 3.8.0.
Anderson. E. and ten others (1999)
LAPACK Users' Guide. Third Edition. SIAM.
Available on-line at
http://www.netlib.org/lapack/lug/lapack_lug.html.
See the section Generalized Eigenvalue and Singular Value Problems
(http://www.netlib.org/lapack/lug/node33.html).
eigen
A <- matrix(c(14, 10, 12, 10, 12, 13, 12, 13, 14), nrow=3, byrow=TRUE) B <- matrix(c(48, 17, 26, 17, 33, 32, 26, 32, 34), nrow=3, byrow=TRUE) z1 <- geigen(A, B, symmetric=FALSE, only.values=TRUE) z2 <- geigen(A, B, symmetric=FALSE, only.values=FALSE ) z2 # geigen(A, B) z1 <- geigen(A, B, only.values=TRUE) z2 <- geigen(A, B, only.values=FALSE) z1;z2 A.c <- A + 1i B.c <- B + 1i A[upper.tri(A)] <- A[upper.tri(A)] + 1i A[lower.tri(A)] <- Conj(t(A[upper.tri(A)])) B[upper.tri(B)] <- B[upper.tri(B)] + 1i B[lower.tri(B)] <- Conj(t(B[upper.tri(B)])) isSymmetric(A) isSymmetric(B) z1 <- geigen(A, B, only.values=TRUE) z2 <- geigen(A, B, only.values=FALSE) z1;z2A <- matrix(c(14, 10, 12, 10, 12, 13, 12, 13, 14), nrow=3, byrow=TRUE) B <- matrix(c(48, 17, 26, 17, 33, 32, 26, 32, 34), nrow=3, byrow=TRUE) z1 <- geigen(A, B, symmetric=FALSE, only.values=TRUE) z2 <- geigen(A, B, symmetric=FALSE, only.values=FALSE ) z2 # geigen(A, B) z1 <- geigen(A, B, only.values=TRUE) z2 <- geigen(A, B, only.values=FALSE) z1;z2 A.c <- A + 1i B.c <- B + 1i A[upper.tri(A)] <- A[upper.tri(A)] + 1i A[lower.tri(A)] <- Conj(t(A[upper.tri(A)])) B[upper.tri(B)] <- B[upper.tri(B)] + 1i B[lower.tri(B)] <- Conj(t(B[upper.tri(B)])) isSymmetric(A) isSymmetric(B) z1 <- geigen(A, B, only.values=TRUE) z2 <- geigen(A, B, only.values=FALSE) z1;z2
Computes the generalized eigenvalues from an object constructed with gqz.
gevalues(x)gevalues(x)
x |
an object created with |
The function calculates the generalized eigenvalues from elements of the object returned by
the function gqz.
The generalized eigenvalues are computed from a ratio where the denominator
(the component of the argument) may be zero.
The function attempts to guard against nonsensical complex NaN values when dividing by zero
which may happen on some systems.
A vector containing the generalized eigenvalues. The vector is numeric if the imaginary parts of the eigenvalues are all zero and complex otherwise.
geigen, gqz
# Real matrices # example from NAG: http://www.nag.com/lapack-ex/node116.html # Find the generalized Schur decomposition with the real eigenvalues ordered to come first A <- matrix(c( 3.9, 12.5,-34.5,-0.5, 4.3, 21.5,-47.5, 7.5, 4.3, 21.5,-43.5, 3.5, 4.4, 26.0,-46.0, 6.0), nrow=4, byrow=TRUE) B <- matrix(c( 1.0, 2.0, -3.0, 1.0, 1.0, 3.0, -5.0, 4.0, 1.0, 3.0, -4.0, 3.0, 1.0, 3.0, -4.0, 4.0), nrow=4, byrow=TRUE) z <- gqz(A, B,"R") z # compute the generalized eigenvalues ger <- gevalues(z) ger# Real matrices # example from NAG: http://www.nag.com/lapack-ex/node116.html # Find the generalized Schur decomposition with the real eigenvalues ordered to come first A <- matrix(c( 3.9, 12.5,-34.5,-0.5, 4.3, 21.5,-47.5, 7.5, 4.3, 21.5,-43.5, 3.5, 4.4, 26.0,-46.0, 6.0), nrow=4, byrow=TRUE) B <- matrix(c( 1.0, 2.0, -3.0, 1.0, 1.0, 3.0, -5.0, 4.0, 1.0, 3.0, -4.0, 3.0, 1.0, 3.0, -4.0, 4.0), nrow=4, byrow=TRUE) z <- gqz(A, B,"R") z # compute the generalized eigenvalues ger <- gevalues(z) ger
Computes the generalized eigenvalues and Schur form of a pair of matrices.
gqz(A, B, sort=c("N","-","+","S","B","R"))gqz(A, B, sort=c("N","-","+","S","B","R"))
A |
left hand side matrix. |
B |
right hand side matrix. |
sort |
how to sort the generalized eigenvalues. See ‘Details’. |
Both matrices must be square. This function provides the solution to the generalized eigenvalue problem defined by
If either one of the matrices is complex the other matrix is coerced to be complex.
The sort argument specifies how to order the eigenvalues on the
diagonal of the generalized Schur form, where it is noted that non-finite eigenvalues never
satisfy any ordering condition (even in the case of a complex infinity).
Eigenvalues that are placed in the leading block of the Schur form
satisfy
Nunordered.
-negative real part.
+positive real part.
Sabsolute value < 1.
Babsolute value > 1.
Rimaginary part identical to 0 with a tolerance of 100*machine_precision as determined by Lapack.
The generalized Schur form for numeric matrices is
The matrices and are orthogonal. The matrix is quasi-upper triangular and
the matrix is upper triangular.
The return value is a list containing the following components
Sgeneralized Schur form of A.
Tgeneralized Schur form of B.
sdimthe number of eigenvalues (after sorting) for which the sorting condition is true.
alpharnumerator of the real parts of the eigenvalues (numeric).
alphainumerator of the imaginary parts of the eigenvalues (numeric).
betadenominator of the expression for the eigenvalues (numeric).
Qmatrix of left Schur vectors (matrix Q).
Zmatrix of right Schur vectors (matrix Z).
The generalized Schur form for complex matrices is
The matrices and are unitary and the matrices and
are upper triangular.
The return value is a list containing the following components
Sgeneralized Schur form of A.
Tgeneralized Schur form of B.
sdimthe number of eigenvalues. (after sorting) for which the sorting condition is true.
alphanumerator of the eigenvalues (complex).
betadenominator of the eigenvalues (complex).
Qmatrix of left Schur vectors (matrix Q).
Zmatrix of right Schur vectors (matrix Z).
The generalized eigenvalues can be computed by calling function gevalues.
gqz uses the LAPACK routines DGGES and ZGGES.
LAPACK is from http://www.netlib.org/lapack.
The complex routines used by the package come from LAPACK 3.8.0.
Anderson. E. and ten others (1999)
LAPACK Users' Guide. Third Edition. SIAM.
Available on-line at
http://www.netlib.org/lapack/lug/lapack_lug.html.
See the section Eigenvalues, Eigenvectors and Generalized Schur Decomposition
(http://www.netlib.org/lapack/lug/node56.html).
geigen, gevalues
# Real matrices # example from NAG: http://www.nag.com/lapack-ex/node116.html # Find the generalized Schur decomposition with the real eigenvalues ordered to come first A <- matrix(c( 3.9, 12.5,-34.5,-0.5, 4.3, 21.5,-47.5, 7.5, 4.3, 21.5,-43.5, 3.5, 4.4, 26.0,-46.0, 6.0), nrow=4, byrow=TRUE) B <- matrix(c( 1.0, 2.0, -3.0, 1.0, 1.0, 3.0, -5.0, 4.0, 1.0, 3.0, -4.0, 3.0, 1.0, 3.0, -4.0, 4.0), nrow=4, byrow=TRUE) z <- gqz(A, B,"R") z # complexify A <- A+0i B <- B+0i z <- gqz(A, B,"R") z# Real matrices # example from NAG: http://www.nag.com/lapack-ex/node116.html # Find the generalized Schur decomposition with the real eigenvalues ordered to come first A <- matrix(c( 3.9, 12.5,-34.5,-0.5, 4.3, 21.5,-47.5, 7.5, 4.3, 21.5,-43.5, 3.5, 4.4, 26.0,-46.0, 6.0), nrow=4, byrow=TRUE) B <- matrix(c( 1.0, 2.0, -3.0, 1.0, 1.0, 3.0, -5.0, 4.0, 1.0, 3.0, -4.0, 3.0, 1.0, 3.0, -4.0, 4.0), nrow=4, byrow=TRUE) z <- gqz(A, B,"R") z # complexify A <- A+0i B <- B+0i z <- gqz(A, B,"R") z
Computes the generalized singular value decomposition of a pair of matrices.
gsvd(A,B)gsvd(A,B)
A |
a matrix with |
B |
a matrix with |
The matrix A is a -by- matrix and the matrix B is a -by- matrix.
This function decomposes both matrices; if either one is complex than the other matrix
is coerced to be complex.
The Generalized Singular Value Decomposition of numeric matrices and
is given as
and
where
an orthogonal matrix.
a orthogonal matrix.
an orthogonal matrix.
an -by- upper triangular non singular matrix and the matrix
is an -by- matrix. The quantity is the rank of
the matrix with .
,
are quasi diagonal matrices and nonnegative and satisfy
.
is an -by- matrix and is a -by- matrix.
The Generalized Singular Value Decomposition of complex matrices and
is given as
and
where
an unitary matrix.
a unitary matrix.
an unitary matrix.
an -by- upper triangular non singular matrix and the matrix
is an -by- matrix. The quantity is the rank of
the matrix with .
,
are quasi diagonal matrices and nonnegative and satisfy
.
is an -by- matrix and is a -by- matrix.
For details on this decomposition and the structure of the matrices and
see http://www.netlib.org/lapack/lug/node36.html.
The return value is a list containing the following components
Athe upper triangular matrix or a part of .
Blower part of the triangular matrix if
(see below).
mnumber of rows of .
k. The number of rows of the matrix is .
The first generalized singular values are infinite.
leffective rank of the input matrix .
The number of finite generalized singular values after the first infinite ones.
alphaa numeric vector with length containing
the numerators of the generalized singular values in
the first entries.
betaa numeric vector with length containing
the denominators of the generalized singular value in
the first entries.
Uthe matrix .
Vthe matrix .
Qthe matrix .
For a detailed description of these items see http://www.netlib.org/lapack/lug/node36.html. Auxiliary functions are provided for extraction and manipulation of the various items.
gsvd uses the LAPACK routines DGGSVD3 and ZGGSVD3 from Lapack 3.8.0.
LAPACK is from http://www.netlib.org/lapack.
The decomposition is fully explained in http://www.netlib.org/lapack/lug/node36.html.
Anderson. E. and ten others (1999)
LAPACK Users' Guide. Third Edition. SIAM.
Available on-line at
http://www.netlib.org/lapack/lug/lapack_lug.html.
See the section Generalized Eigenvalue and Singular Value Problems
(http://www.netlib.org/lapack/lug/node33.html) and
the section Generalized Singular Value Decomposition (GSVD)
(http://www.netlib.org/lapack/lug/node36.html).
A <- matrix(c(1,2,3,3,2,1,4,5,6,7,8,8), nrow=2, byrow=TRUE) B <- matrix(1:18,byrow=TRUE, ncol=6) A B z <- gsvd(A,B) zA <- matrix(c(1,2,3,3,2,1,4,5,6,7,8,8), nrow=2, byrow=TRUE) B <- matrix(1:18,byrow=TRUE, ncol=6) A B z <- gsvd(A,B) z
Returns a component of the object as a matrix
gsvd.R(z) gsvd.oR(z) gsvd.D1(z) gsvd.D2(z)gsvd.R(z) gsvd.oR(z) gsvd.D1(z) gsvd.D2(z)
z |
an object created with |
gsvd.R returns the R matrix implied by the GSVD.
gsvd.oR returns the matrix implied by the GSVD.
gsvd.D1 returns the matrix D1 implied by the GSVD.
gsvd.D2 returns the matrix D2 implied by the GSVD.
A <- matrix(c(1,2,3,3,2,1,4,5,6,7,8,8), nrow=2, byrow=TRUE) B <- matrix(1:18,byrow=TRUE, ncol=6) A B z <- gsvd(A,B) z R <- gsvd.R(z) oR <- gsvd.oR(z) D1 <- gsvd.D1(z); D2 <- gsvd.D2(z) R;oR D1;D2A <- matrix(c(1,2,3,3,2,1,4,5,6,7,8,8), nrow=2, byrow=TRUE) B <- matrix(1:18,byrow=TRUE, ncol=6) A B z <- gsvd(A,B) z R <- gsvd.R(z) oR <- gsvd.oR(z) D1 <- gsvd.D1(z); D2 <- gsvd.D2(z) R;oR D1;D2