eigen1: Compute leading eigenvalue

View source: R/eigen1.R

eigen1R Documentation

Compute leading eigenvalue

Description

Compute the leading eigenvalue for a square matrix

Usage

eigen1(m, ..., method = "power_iteration")

eigen1_power_iteration(
  m,
  max_iterations = 100,
  tolerance = sqrt(.Machine$double.eps),
  initial = NULL,
  ...
)

eigen1_base(m, ...)

Arguments

m

A matrix or 3d array

...

Ignored arguments

method

Select the method to use. Currently only "power_iteration" and "base" are supported

max_iterations

Integer, giving the number of iterations before giving up

tolerance

Number, giving the required tolerance

initial

An optional initial guess at the eigenvector. If omitted we use a random vector

Details

This function exposes two different methods for computing the leading eigenvalue of a matrix. The "base" method simply uses eigen but allows 3d arrays (returning a vector of leading eigenvalues). The "power_iteration" method uses the power iteration method which will work well if there is a significant difference between the first and second eigenvalues.

Value

A scalar real (if m is a matrix) or a vector with length dim(m)[3] if m was a 3d array

Examples

m <- diag(runif(10))
eigen1::eigen1(m)
max(eigen(m)$values)

mrc-ide/eigen1 documentation built on Nov. 6, 2022, 3:47 p.m.