Advertisement
Guest User

Untitled

a guest
Oct 2nd, 2014
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. // [[Rcpp::depends(RcppEigen)]]
  2. #include <Rcpp.h>
  3. #include <RcppEigen.h>
  4. #include <Eigen/IterativeLinearSolvers>
  5. using Eigen::SparseMatrix;
  6. using Eigen::MappedSparseMatrix;
  7. using Eigen::Map;
  8. using Eigen::MatrixXd;
  9. using Eigen::VectorXd;
  10. using Rcpp::as;
  11. using Eigen::ConjugateGradient;
  12. typedef Eigen::MappedSparseMatrix<double> MSpMat;
  13.  
  14. // [[Rcpp::export]]
  15. VectorXd getEigenValues(SEXP As, SEXP bs) {
  16. const Map<MatrixXd> A(as<Map<MatrixXd> > (As));
  17. const Map<VectorXd> b(as<Map<VectorXd> > (bs));
  18. ConjugateGradient<MatrixXd> cg;
  19. cg.compute(A);
  20. VectorXd x=cg.solve(b);
  21. return x;
  22. }
  23.  
  24. // [[Rcpp::depends(RcppEigen)]]
  25. #include <Rcpp.h>
  26. #include <RcppEigen.h>
  27. #include <Eigen/IterativeLinearSolvers>
  28. using Eigen::SparseMatrix;
  29. using Eigen::MappedSparseMatrix;
  30. using Eigen::Map;
  31. using Eigen::MatrixXd;
  32. using Eigen::VectorXd;
  33. using Rcpp::as;
  34. using Eigen::ConjugateGradient;
  35. typedef Eigen::MappedSparseMatrix<double> MSpMat;
  36.  
  37. // [[Rcpp::export]]
  38. VectorXd getEigenValues(SEXP As, SEXP bs) {
  39. const MSpMat A = as<MSpMat>(As);
  40. const Map<VectorXd> b(as<Map<VectorXd> > (bs));
  41. ConjugateGradient<SparseMatrix<double> > cg;
  42. cg.compute(A);
  43. VectorXd x=cg.solve(b);
  44. return x;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement