getEigenValuesRcpp: Calculates the eigenvalues of a matrix

Description Usage Arguments Value Author(s) See Also Examples

View source: R/RcppExports.R

Description

This is an computational efficient help function to calculate the GCV loss of the KDSN. It is written in C and is faster than the regular R version.

Usage

1

Arguments

M

Numeric Matrix.

Value

Numeric vector eigenvalues in increasing order.

Author(s)

Thomas Welchowski welchow@imbie.meb.uni-bonn.de

See Also

eigen

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
# Define simple binary matrix
M <- cbind(c(1,-1), c(-1,1))

# Calculate eigen values with standard function
eigenVal <- eigen(M, only.values=TRUE)$values

# Calculate eigen values with Rcpp version
eigenValRcpp <- rev(getEigenValuesRcpp(M))

# Check equality
all.equal(eigenVal, eigenValRcpp) # TRUE

# Analyse run time of both variants
if(tryCatch(require("microbenchmark", quietly=TRUE, warn.conflicts=FALSE, 
character.only = TRUE), warning=function(w) FALSE, error=function(e) FALSE)) {
  microbenchmark(Standard=eigen(M, only.values=TRUE), Rcpp=getEigenValuesRcpp(M))
}
# -> Rcpp function is on average about 30 times faster than the standard R function

kernDeepStackNet documentation built on May 2, 2019, 8:16 a.m.