Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // [[Rcpp::depends(RcppEigen)]]
- #include <Rcpp.h>
- #include <RcppEigen.h>
- #include <Eigen/IterativeLinearSolvers>
- using Eigen::SparseMatrix;
- using Eigen::MappedSparseMatrix;
- using Eigen::Map;
- using Eigen::MatrixXd;
- using Eigen::VectorXd;
- using Rcpp::as;
- using Eigen::ConjugateGradient;
- typedef Eigen::MappedSparseMatrix<double> MSpMat;
- // [[Rcpp::export]]
- VectorXd getEigenValues(SEXP As, SEXP bs) {
- const Map<MatrixXd> A(as<Map<MatrixXd> > (As));
- const Map<VectorXd> b(as<Map<VectorXd> > (bs));
- ConjugateGradient<MatrixXd> cg;
- cg.compute(A);
- VectorXd x=cg.solve(b);
- return x;
- }
- // [[Rcpp::depends(RcppEigen)]]
- #include <Rcpp.h>
- #include <RcppEigen.h>
- #include <Eigen/IterativeLinearSolvers>
- using Eigen::SparseMatrix;
- using Eigen::MappedSparseMatrix;
- using Eigen::Map;
- using Eigen::MatrixXd;
- using Eigen::VectorXd;
- using Rcpp::as;
- using Eigen::ConjugateGradient;
- typedef Eigen::MappedSparseMatrix<double> MSpMat;
- // [[Rcpp::export]]
- VectorXd getEigenValues(SEXP As, SEXP bs) {
- const MSpMat A = as<MSpMat>(As);
- const Map<VectorXd> b(as<Map<VectorXd> > (bs));
- ConjugateGradient<SparseMatrix<double> > cg;
- cg.compute(A);
- VectorXd x=cg.solve(b);
- return x;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement