JacobiR: The Jacobi Algorithm in Pure R

Description Usage Arguments Details Value Examples

View source: R/JacobiR.R

Description

The Jacobi Algorithm

Usage

1
2
JacobiR(x, symmetric = TRUE, only.values = FALSE, eps = if
  (!only.values) .Machine$double.eps else sqrt(.Machine$double.eps))

Arguments

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

Details

Eigenvalues and optionally, eigenvectore of a real symmetric matrix using the classical Jacobi algorithm, (Jacobi, 1854)

Value

a list of two components as for base::eigen

Examples

1
2
3
4
V <- crossprod(matrix(rnorm(25), 5))
JacobiR(V)
identical(Jacobi(V), JacobiR(V))
all.equal(Jacobi(V)$values, base::eigen(V)$values)

Example output

eigen decomposition (Jacobi algorithm)
$values
[1] 11.097223018  7.125782580  4.091586522  0.563247265  0.002640397

$vectors
            [,1]        [,2]       [,3]        [,4]        [,5]
[1,]  0.05264201 -0.96040558 -0.2053225  0.15899573  0.08609858
[2,]  0.05643221  0.06769028 -0.3136061  0.43873056 -0.83749637
[3,]  0.31412362 -0.12186404 -0.1632039 -0.84919696 -0.37243058
[4,] -0.28073510 -0.24044231  0.8427825 -0.06187231 -0.38634803
[5,]  0.90363620  0.01938562  0.3501087  0.23931612  0.05672322

[1] TRUE
[1] TRUE

JacobiEigen documentation built on April 17, 2021, 9:06 a.m.