<div dir="ltr">As per Dirk's suggestion about creating a trivial class, I managed to get this to work.  Thank you for the suggestion Dirk, again sorry if I wasn't initially clear.<br><br>class myEigen {<br>    public:<br>        myEigen(SEXP A_) : A(A_) {}<br>    <br>        MatrixXf matrix() {return as<MatrixXf>(A);}  <br>    private:<br>        SEXP A;<br>};<br><br>// [[Rcpp::export]]<br>SEXP matrixIN(SEXP A)<br>{<br><br>    myEigen *C = new myEigen(A);<br>    XPtr<myEigen> pMat(C);<br>    return(pMat);<br>}<br><br>// [[Rcpp::export]]<br>void matrixOUT(XPtr<myEigen> ptrA, int nr, int nc)<br>{<br>    MatrixXf A = ptrA->matrix();<br>    std::cout << A << std::endl;<br>}<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jun 26, 2015 at 8:54 AM, Charles Determan <span dir="ltr"><<a href="mailto:cdetermanjr@gmail.com" target="_blank">cdetermanjr@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>I apologize if I am not being clear.  I realize that R doesn't have float data types, however I am able to pass a matrix in as a MatrixXf object.  I would like to be able to refer to this MatrixXf object persistently.  Some general code to demonstrate my point.<br><br></div><div># pass R matrix in as MatrixXf object and return pointer to that object<br></div><div>SEXP matrixIN(MatrixXf A)<br>{<br></div><div>    return XPtr<MatrixXf>(A);<br></div><div>}<br><br></div><div># pass previously made pointer and return that matrix<br></div><div>SEXP matrixOUT(XPtr<MatrixXfr> ptrA)<br>{<br></div><div>    MatrixXf A = *ptrA<br></div><div>    return wrap(A)<br></div><div>}<br></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jun 26, 2015 at 8:32 AM, Dirk Eddelbuettel <span dir="ltr"><<a href="mailto:edd@debian.org" target="_blank">edd@debian.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span><br>
On 26 June 2015 at 07:43, Charles Determan wrote:<br>
| I have tried a few more feeble attempts (explicitly create pointer to pass,<br>
| passing just the MatrixXf object) at getting the Eigen object to persist<br>
| between functions without the additional Armadillo wrapper but with no<br>
| success.  Anyone have any additional thoughts?<br>
<br>
</span>You are not making it very easy to help you as you do not clearly say what<br>
you really want.  Some things you talk about don't exist (ie "float matrix in<br>
R"), others make no sense (XPtr of Eigen::Map when the latter already is a<br>
proxy object).<br>
<br>
As for the question of persistence, the single simplest approach I often use<br>
it create a trivial class holding a member variable of the "thing" you want<br>
to persist (often a database or resource handle, could even be a honking<br>
bigmemory object and shared handle) whichI create in the constructor, or an<br>
init() function, and release in the destructor.<br>
<span><font color="#888888"><br>
Dirk<br>
<br>
--<br>
<a href="http://dirk.eddelbuettel.com" rel="noreferrer" target="_blank">http://dirk.eddelbuettel.com</a> | @eddelbuettel | <a href="mailto:edd@debian.org" target="_blank">edd@debian.org</a><br>
</font></span></blockquote></div><br></div>
</div></div></blockquote></div><br></div>