eigenPower: Function eigenPower.

Description Usage Arguments Value Note Examples

View source: R/eigen.lib.R

Description

The function implements the power algorithm for EVD.

Function eigenPowerRcpp.

Function eigenPowerRcppEigen.

Function eigenPowerRcppParallel.

Function eigenPowerEigenParallel.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
eigenPower(A, v0, tol = 1e-06, maxit = 1000, sparse = FALSE,
  sparseSymm = FALSE, ncomp = 1, verbose = 0)

eigenPowerRcpp(A, v0, tol = 1e-06, maxit = 1000, mode = 1, verbose = 0)

eigenPowerRcppEigen(A, v0, tol = 1e-06, maxit = 1000, ncomp = 1,
  symmetric = FALSE, verbose = 0)

eigenPowerRcppParallel(A, v0, tol = 1e-06, maxit = 1000, cores = -1,
  chunkSize = 1, verbose = 0)

eigenPowerEigenParallel(A, v0, tol = 1e-06, maxit = 1000, cores = -1,
  chunkSize = 1, verbose = 0)

Arguments

A

A two-dimensional square matrix, either of matrix or Matrix class.

v0

A numeric vector; the initial guess for eignevector. If it is missing, a random vector is generated.

tol

The tolerance threshold used to stop when reaching no improvement if estmiation of eigenvalue. The default value is 1e-6.

maxit

The maximum number of iterations. The default value is 1e4.

sparse

The boolean value, whether to convert the input A matrix to one of the Matrix classes. The default value is FALSE.

sparseSymm

The boolean value, whether to convert the input A matrix to one of the Matrix classes, while trying to convert to a symmetric matrix type. The default value is FALSE.

ncomp

The number of eigenvectors to be extracted. The default value is 1. The value of 0 means extract all eigenvectors.

verbose

The integer value indicating the verbose level. The default value is 0.

mode

An integer indicating the mode of implementation (for eigenPowerRcpp function). The default value is 1.

symmetric

A logical which value says explicetly if the input matrix A is symmetric. The default value is FALSE.

cores

The number of cores (for parallel versions). The default value is -1. This argument is passed next to RcppParallel::setThreadOptions(numThreads = cores).

chunkSize

The minimal size of a chunk (for parallel versions). The default value is 1. This argument is passed next to a wrapper eigenPower_Rcpp_Parallel.

Value

A list several slots: v the first eigenvector; lambda the first eigenvalue; etc.

Note

This function is inspired by the post http://blogs.sas.com/content/iml/2012/05/09/the-power-method.html.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
A <- matrix(c(-261, 209, -49, 
  -530, 422, -98,
  -800, 631, -144),
  ncol = 3, nrow = 3, byrow = TRUE)
  
v0 <- c(1, 2, 3)

out <- eigenPower(A, v0, maxit = 40, verbose = 2)

out[c("lambda", "v")]

variani/cpca documentation built on May 3, 2019, 4:34 p.m.