<div dir="ltr">Hi, professor,<div><br></div><div>I think the problem is in ge-r. cpp, you forgot to call <b>initialize</b>.</div><div><br></div><div>The error has nothing to do with Rcpp.</div><div><br></div><div>Best,</div><div><br></div><div>KK</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jul 4, 2017 at 2:45 AM, 井澤 毅 <span dir="ltr"><<a href="mailto:a-izawa@mail.ecc.u-tokyo.ac.jp" target="_blank">a-izawa@mail.ecc.u-tokyo.ac.jp</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
<p>Sorry, I forgot the attached file.<br>
</p>
<div class="m_3086009423684693569moz-cite-prefix">On 2017/07/04 18:43, 井澤 毅 wrote:<br>
</div>
<blockquote type="cite">
<p>Dear KK,</p>
<p>Thanks for your kind reply.</p>
<p>I am afraid that one of the input file is very heavy, this time
but I am sending a ZIP file including all.</p>
<p>Please make v30 package using install.simulate_R_1.r and then
install.simulate_R_2.r. Then, try ge-r_test.r, please.</p>
<p>To make the v30 package, we need ge-r.cpp, ge-model.cpp,
ge-model.h, ge-obs.cpp, ge-obs.h, ge-range.h.</p>
<p>As the input file, we need var.mat.all matrix data in R and
<a href="http://obs.Os01g0182600_g1.nc" target="_blank">obs.Os01g0182600_g1.nc</a> file in the directry. <br>
</p>
<p>Then, you will see the error I have been suffering from for a
month.</p>
<p>The <a href="http://obs.Os01g0182600_g1.nc" target="_blank">obs.Os01g0182600_g1.nc</a> file is a file containing
environmental fluctuation data.</p>
<p>Best,</p>
<p>Takeshi<br>
</p><div><div class="h5">
<br>
<div class="m_3086009423684693569moz-cite-prefix">On 2017/07/04 5:40, Qiang Kou wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr">Hi, I am afraid the example you provided is not a
reproducible example.
<div><br>
</div>
<div>First, we don't know the content of ge-model.h. Second,
we don't know which input will trigger the fault.</div>
<div><br>
</div>
<div>Please provide a reproducible example if you really want
to get help.</div>
<div><br>
</div>
<div>Best,</div>
<div><br>
</div>
<div>KK</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Sat, Jul 1, 2017 at 11:06 AM, 井澤 毅
<span dir="ltr"><<a href="mailto:a-izawa@mail.ecc.u-tokyo.ac.jp" target="_blank">a-izawa@mail.ecc.u-tokyo.ac.<wbr>jp</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
<div class="m_3086009423684693569m_8471227266221235016moz-text-flowed" style="font-family:-moz-fixed;font-size:14px" lang="x-unicode">Dear <a class="m_3086009423684693569m_8471227266221235016moz-txt-link-abbreviated" href="mailto:rcpp-devel@lists.r-forge.r-project.org" target="_blank">rcpp-devel@lists.r-forge.r-pro<wbr>ject.org</a>,
<br>
<br>
Sorry for bothering you much, but do me a favor
please. Please help me some. <br>
<br>
I am just a molecular biologist working on plants.
Thus, I am still a newcomer in this field. <br>
<br>
Recently, I have been working with a script using
RcppArmadillo, This has helped me a lot. However,
after updating the system in our institute, the script
gives me an error repeatedly. My former Postdoc wrote
this script. Thus, I did not know this inside much. <br>
<br>
I have tried to fix it for more than a month, but now
I have no idea how to fix it. I would appreciate it
very much if you could help and give me your advice. <br>
<br>
Please see an attached cpp file, termed ge-r.cpp. With
this cpp file and other ones, I have succeeded to
install a skeleton R package into R using your
function Rcpp.package.skeleton. <br>
<br>
In this ge-r.cpp, there is one R function called
simulate_R() written. In this R fucntion, there are
two C++ functions, load() and simulate(), both are
described in other cpp files, called from C++ into R.
With cout function described in simulate_R(), I
confirmed these two function work in R thanks to
RcppArmadillo, however, it suddenly stops with an
error, address(nil) cause 'unknown' in R. It has
seemed to stop when it return (out) at the last in
ge-r.cpp. I do not know why it happens. Note that the
C++ script works normally after the update of the
system. Only this RcppArmadillo conversion from C++
function into a R function is deformed. <br>
<br>
Please give me an advice, please. Of course, I can
give you more information on the C++ script in details
if you need. <br>
<br>
Best regards, <br>
<br>
Takeshi <br>
<br>
<br>
<br>
</div>
ge-r.cpp<br>
<br>
#ifndef __R__
<div class="m_3086009423684693569m_8471227266221235016moz-text-plain" style="font-family:-moz-fixed;font-size:14px" lang="x-unicode">
<pre>#define __R__
#endif
#ifndef USE_OMP
#define USE_OMP
#endif
#include <RcppArmadillo.h>
#include "ge-model.h"
using namespace arma;
// input:
// parameter matrix: row for particle, col for parameter
// filename of observation
// output:
// simulation for regular time points: row for particle, col for time, slice for term
// existing observation to corresponding regular time points
// [[Rcpp::depends(RcppArmadillo)<wbr>]]
// [[Rcpp::export]]
Rcpp::List simulate_R(const arma::mat& param_r, const char* fobs, const int interval) {
try {
geModel Model;
Model.n_thread=omp_get_num_pro<wbr>cs();
Model._param=param_r;
cout << "params set.\n";
cout << "filename of obs: "<< fobs << ".\n";
Model._obs.load(fobs);
cout << "obs loaded.\n";
Model.n_acc=Model._param.n_row<wbr>s;
cout << "n_acc set to be " << Model.n_acc << ".\n";
Model._obs._out_interval = interval;
Model._obs._n_out_date = (Model._obs._n_date / Model._obs._out_interval) + 1;
Model.out_y=cube(Model.n_acc, Model._obs._n_group, Model._obs._n_out_date);
Model.out_res_1=cube(Model.n_a<wbr>cc,Model._obs._n_group, Model._obs._n_out_date);
Model.out_res_2=cube(Model.n_a<wbr>cc,Model._obs._n_group, Model._obs._n_out_date);
Model.out_res_clock=cube(Model<wbr>.n_acc,Model._obs._n_group, Model._obs._n_out_date);
Model.out_res_dev=cube(Model.n<wbr>_acc,Model._obs._n_group, Model._obs._n_out_date);
cout << "output matrix initialized.\n";
//necessary for simulate_obs
Model._distance=vec(Model.n_ac<wbr>c);
Model.simulate(0,Model.n_acc-1<wbr>,true);
cout << "simulation complete.\n";
fflush(stdout);
cout << size(Model.out_y)<<".\n"<< Model.out_y[0]<<".\n"<<Model.o<wbr>ut_y[1]<<".\n"<<Model.out_y[2]<wbr><<".\n";
Rcpp::List out = Rcpp::List::create(
Rcpp::Named("out_y")=Model.out<wbr>_y,
Rcpp::Named("out_res_1")=Model<wbr>.out_res_1,
Rcpp::Named("out_res_2")=Model<wbr>.out_res_2,
Rcpp::Named("out_res_clock")=M<wbr>odel.out_res_clock,
Rcpp::Named("out_res_dev")=Mod<wbr>el.out_res_dev
);
cout << "List constructed.\n";
fflush(stdout);
return (out);
}
catch(char* e) {
cout << e << "\n";
exit(EXIT_FAILURE);
}
catch(...) {
cout << "Error\n";
exit(EXIT_FAILURE);
}
}
</pre>
</div>
</div>
______________________________<wbr>_________________
Rcpp-devel mailing list
<a href="mailto:Rcpp-devel@lists.r-forge.r-project.org" target="_blank">Rcpp-devel@lists.r-forge.r-pro<wbr>ject.org</a>
<a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel" rel="noreferrer" target="_blank">https://lists.r-forge.r-projec<wbr>t.org/cgi-bin/mailman/listinfo<wbr>/rcpp-devel</a>
</blockquote></div>
<div>
</div>--
<div class="m_3086009423684693569gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Qiang Kou<div><a href="mailto:qkou@umail.iu.edu" target="_blank">qkou@umail.iu.edu</a>
<div>School of Informatics and Computing, Indiana University</div><div>
</div></div></div></div>
</div>
</blockquote>
</div></div></blockquote>
</div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Qiang Kou<div><a href="mailto:qkou@umail.iu.edu" target="_blank">qkou@umail.iu.edu</a><br><div>School of Informatics and Computing, Indiana University</div><div><br></div></div></div></div>
</div>