Title: | Classical Jacobi Eigenvalue Algorithm |
---|---|
Description: | Implements the classical Jacobi algorithm for the eigenvalues and eigenvectors of a real symmetric matrix, both in pure 'R' and in 'C++' using 'Rcpp'. Mainly as a programming example for teaching purposes. |
Authors: | Bill Venables |
Maintainer: | Bill Venables <[email protected]> |
License: | GPL (>= 2) |
Version: | 0.3-4 |
Built: | 2024-11-06 04:12:08 UTC |
Source: | https://github.com/cran/JacobiEigen |
The Classical Jacobi Algorithm
Jacobi(x, symmetric = TRUE, only.values = FALSE, eps = 0)
Jacobi(x, symmetric = TRUE, only.values = FALSE, eps = 0)
x |
A real symmetric matrix |
symmetric |
a logical value. Is the matrix symmetric? (Only symmetric matrices are allowed.) |
only.values |
A logical value: do you want only the eigenvalues? |
eps |
an error tolerance. 0.0 implies |
Eigenvalues and optionally, eigenvectore, of a real symmetric matrix using the classical Jacobi algorithm, (Jacobi, 1854)
a list of two components as for base::eigen
V <- crossprod(matrix(runif(40, -1, 1), 8)) Jacobi(V) identical(Jacobi(V), JacobiR(V)) all.equal(Jacobi(V)$values, base::eigen(V)$values)
V <- crossprod(matrix(runif(40, -1, 1), 8)) Jacobi(V) identical(Jacobi(V), JacobiR(V)) all.equal(Jacobi(V)$values, base::eigen(V)$values)
The Jacobi Algorithm
JacobiR(x, symmetric = TRUE, only.values = FALSE, eps = if (!only.values) .Machine$double.eps else sqrt(.Machine$double.eps))
JacobiR(x, symmetric = TRUE, only.values = FALSE, eps = if (!only.values) .Machine$double.eps else sqrt(.Machine$double.eps))
x |
a real symmetric matrix |
symmetric |
a logical value. Is the matrix symmetric? (Only symmetric matrices are allowed.) |
only.values |
A logical value: Do you want only the eigenvalues? |
eps |
a small positive error tolerance |
Eigenvalues and optionally, eigenvectore of a real symmetric matrix using the classical Jacobi algorithm, (Jacobi, 1854)
a list of two components as for base::eigen
V <- crossprod(matrix(rnorm(25), 5)) JacobiR(V) identical(Jacobi(V), JacobiR(V)) all.equal(Jacobi(V)$values, base::eigen(V)$values)
V <- crossprod(matrix(rnorm(25), 5)) JacobiR(V) identical(Jacobi(V), JacobiR(V)) all.equal(Jacobi(V)$values, base::eigen(V)$values)
The Classical Jacobi Algorithm with a stagewise protocol
JacobiS(x, symmetric = TRUE, only.values = FALSE, eps = 0)
JacobiS(x, symmetric = TRUE, only.values = FALSE, eps = 0)
x |
A real symmetric matrix |
symmetric |
a logical value. Is the matrix symmetric? (Only symmetric matrices are allowed.) |
only.values |
A logical value: do you want only the eigenvalues? |
eps |
an error tolerance. 0.0 implies |
Eigenvalues and optionally, eigenvectore, of a real symmetric matrix using the classical Jacobi algorithm, (Jacobi, 1846) using a stagewise rotation protocol
a list of two components as for base::eigen
V <- crossprod(matrix(runif(40, -1, 1), 8)) JacobiS(V) all.equal(JacobiS(V)$values, Jacobi(V)$values) zapsmall(crossprod(JacobiS(V)$vectors, Jacobi(V)$vectors))
V <- crossprod(matrix(runif(40, -1, 1), 8)) JacobiS(V) all.equal(JacobiS(V)$values, Jacobi(V)$values) zapsmall(crossprod(JacobiS(V)$vectors, Jacobi(V)$vectors))