[R-SIG-Finance] eigen value decomposition in RcppArmadillo

Kevin Dhingra kevin.dhingra at appliedacademics.com
Fri Jul 7 18:56:09 CEST 2017

Hi all,

I am trying to use the eigs_sym function from the Armadillo library, which
is basically a counterpart to the eigs_sym function from the rARPACK R
package that helps find a specified number of eigenvalues/vectors for a
square matrix.

I have a couple of questions -

1. I am only able to return the eigen values and not the eigen vector from
the armadillo implementation. Not sure if i need to return a different type
in order for the output to contain both the values and vector?

2. My understanding is that I am using the same input parameters but still
unable to replicate the results from the two implementations, even for the
eigen values that gets outputted from eigs_symC function in the example

Reproducible example -

#include <RcppArmadillo.h>
using namespace arma;

// [[Rcpp::export]]
mat eigs_symC(mat X, int k){
  sp_mat X2 = sp_mat(X);
  mat res = eigs_sym(X2, k);
  return res;

/*** R
x = matrix(rnorm(100), 10, 10)
rARPACK::eigs_sym(x, 5);
eigs_symC(x, 5);

Due to my limited exposure with this particular R package itself, I am
unable to figure out the best way to go about tracking down this mismatch.
Any help would be much appreciated

Thank you

Kshitij Dhingra
Applied Academics LLC
Office: +1.917.262.0516
Mobile: +1.206.696.5945
Email: kshitij.dhingra at appliedacademics.com
Website: http://www.AppliedAcademics.com

	[[alternative HTML version deleted]]

More information about the R-SIG-Finance mailing list