eigen value decomposition in RcppArmadillo

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

eigen value decomposition in RcppArmadillo

Kevin Dhingra
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
below


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: [hidden email]
Website: http://www.AppliedAcademics.com

        [[alternative HTML version deleted]]

_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should go.
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: eigen value decomposition in RcppArmadillo

Kevin Dhingra
Hi all,

Apologize for a bug in my reproducible example, I forgot to do add the
transpose of x to the matrix x in order to make it symmetric. Also I found
out using - *eigs_sim(eigval, eigvec, X, k) *and returning eigval and
eigvec can return other components too.

Thank you and even though its 230 on a Friday afternoon, I hope I did not
end up wasting anybody's time.


On Fri, Jul 7, 2017 at 12:56 PM, Kevin Dhingra <
[hidden email]> wrote:

> 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
> below
>
>
> 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 <(917)%20262-0516>
> Mobile: +1.206.696.5945 <(206)%20696-5945>
> Email: [hidden email]
> Website: http://www.AppliedAcademics.com
>



--
Kshitij Dhingra
Applied Academics LLC
Office: +1.917.262.0516
Mobile: +1.206.696.5945
Email: [hidden email]
Website: http://www.AppliedAcademics.com

        [[alternative HTML version deleted]]

_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should go.
Loading...