geigen (version 2.3)

# geigen: Generalized Eigenvalues

## Description

Computes generalized eigenvalues and eigenvectors of a pair of matrices.

## Usage

geigen(A, B, symmetric, only.values=FALSE)

## Arguments

A

left hand side matrix.

B

right hand side matrix.

symmetric

if TRUE, both matrices are assumed to be symmetric (or Hermitian if complex) and only their lower triangle (diagonal included) is used. If symmetric is not specified, the matrices are inspected for symmetry.

only.values

if TRUE only eigenvalues are computed otherwise both eigenvalues and eigenvctors are returned.

## Value

A list containing components

values

a vector containing the $$n$$ generalized eigenvalues.

vectors

an $$n\times n$$ matrix containing the generalized eigenvectors or NULL if only.values is TRUE.

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.

## Details

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 $$A x = \lambda Bx$$ 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 $$\lambda$$ are calculated as the ratio $$\alpha / \beta$$ where $$\beta$$ may be zero or very small leading to non finite or very large values for the eigenvalues. Therefore the values for $$\alpha$$ and $$\beta$$ are also included in the return value of the function. When both matrices are complex (or coerced to be so) the generalized eigenvalues, $$\alpha$$ and $$\beta$$ are complex. When both matrices are numeric $$\alpha$$ may be numeric or complex and $$\beta$$ is numeric.

When both matrices are symmetric (or Hermitian) the generalized eigenvalues are numeric and no components $$\alpha$$ and $$\beta$$ are available.

## References

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

## Examples

Run this code
# NOT RUN {
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;z2
# }


Run the code above in your browser using DataCamp Workspace