<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hello,<div><br></div><div>I need to interface some R code with a numerical library containing functions taking as input double*</div><div><br></div><div>What is the most efficient way to create an array of doubles from a NumericVector.</div><div><br></div><div>I was thinking of something like:</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div>// input is of type Rcpp::NumericVector and passed from R</div><div>std::vector<double> vec;</div><div>std::copy(input.begin(), input.end(), std::back_inserter(vec));</div><div><br></div><div style="text-align: left; ">double* values <font color="#00008b" face="Consolas, Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, serif" size="4"><span style="line-height: 18px; ">= &vec[0];</span></font></div><div style="text-align: left; "><font color="#00008b" face="Consolas, Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, serif" size="4"><span style="line-height: 18px; "><br></span></font></div><div style="text-align: left; "><font color="#00008b" face="Consolas, Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, serif" size="4"><span style="line-height: 18px; ">// now call function taking a double*</span></font></div><div style="text-align: left; "><font color="#00008b" face="Consolas, Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, serif" size="4"><span style="line-height: 18px; "><br></span></font></div><div style="text-align: left; "><font color="#00008b" face="Consolas, Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, serif" size="4"><span style="line-height: 18px; "><br></span></font></div><div style="text-align: left; "><font color="#00008b" face="Consolas, Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, serif" size="4"><span style="line-height: 18px; ">Regards,</span></font></div><div style="text-align: left; "><font color="#00008b" face="Consolas, Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, serif" size="4"><span style="line-height: 18px; "><br></span></font></div><div style="text-align: left; "><font color="#00008b" face="Consolas, Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, serif" size="4"><span style="line-height: 18px; ">Anwar</span></font></div></body></html>