Package 'JacobiEigen'

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

Help Index


The Jacobi Algorithm using Rcpp

Description

The Classical Jacobi Algorithm

Usage

Jacobi(x, symmetric = TRUE, only.values = FALSE, eps = 0)

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

an error tolerance. 0.0 implies .Machine$double.eps and sqrt(.Machine$double.eps) if only.values = TRUE

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

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 in Pure R

Description

The Jacobi Algorithm

Usage

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

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

The Jacobi Algorithm using Rcpp with a stagewise rotation protocol

Description

The Classical Jacobi Algorithm with a stagewise protocol

Usage

JacobiS(x, symmetric = TRUE, only.values = FALSE, eps = 0)

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

an error tolerance. 0.0 implies .Machine$double.eps and sqrt(.Machine$double.eps) if only.values = TRUE

Details

Eigenvalues and optionally, eigenvectore, of a real symmetric matrix using the classical Jacobi algorithm, (Jacobi, 1846) using a stagewise rotation protocol

Value

a list of two components as for base::eigen

Examples

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))