RInside Version 0.2.12
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
rinside_eigen0.cpp
Go to the documentation of this file.
1 // -*- c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*-
2 //
3 // Simple example using Eigen classes
4 //
5 // Copyright (C) 2012 Dirk Eddelbuettel and Romain Francois
6 
7 #include <RInside.h> // for the embedded R via RInside
8 #include <RcppEigen.h>
9 
10 int main(int argc, char *argv[]) {
11 
12  RInside R(argc, argv); // create an embedded R instance
13 
14  std::string cmd = "diag(3)"; // create a Matrix in r
15 
16  const Eigen::Map<Eigen::MatrixXd> m = // parse, eval + return result
17  Rcpp::as<Eigen::Map<Eigen::MatrixXd> >(R.parseEval(cmd));
18 
19  std::cout << m << std::endl; // and use Eigen i/o
20 
21  exit(0);
22 }
int parseEval(const std::string &line, SEXP &ans)
Definition: RInside.cpp:308
int main(int argc, char *argv[])