Hi,<br><br>Thank you for your quick answer.<br>Sorry that I did not explain well enought my issue.<br>I did not know about cppbugs but I just checked and it does not seem that I can use it for my model because it lacks some of the distribution I need.<br>
The fraction of code could seems obscure but it is just the updating for a block of parameters in the model.<br>My problem is rather simple I think.<br>Once I affect a matrix to a variable I can&#39;t manage to overwrite the content of that variable with a different matrix. I really can&#39;t figure out how to do it.<br>
<br>Nicolas<br><br><div class="gmail_quote">On Wed, Jun 15, 2011 at 7:52 PM, Dirk Eddelbuettel <span dir="ltr">&lt;<a href="mailto:edd@debian.org">edd@debian.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
Salut Nicolas,<br>
<div class="im"><br>
On 15 June 2011 at 17:03, Nicolas Heslot wrote:<br>
| Hi rcpp-devel!<br>
| First of all thank you for this awesome tool!<br>
<br>
</div>Pleasure, and welcome.<br>
<div><div></div><div class="h5"><br>
| I started a few days ago coding with Rcpp to try to reduce the computing time<br>
| of a MCMC model.<br>
| However, I don&#39;t have experience with C/C++ and I can&#39;t figure out how to<br>
| reaffect a new content to a variable.<br>
| This seems probably very simple to you but I can&#39;t figure it out, and this is<br>
| the last step preventing my code to work out I think...<br>
| The objects all_ui, all_ui2, all_ui3, all_rd and all_corMat are list objects<br>
| containing matrix<br>
| But once a matrice extracted from one of those lists is affected, to let say<br>
| the object ui I can&#39;t affect the next matrix to ui at the next iteration.<br>
| I tried to find a way to eliminate the object at each iteration or to empty it<br>
| using .reset but without success.<br>
|<br>
| So any help would be very much appreciated!<br>
| (fragment of code posted below)<br>
|<br>
| arma::mat tmp;<br>
| arma::mat tmp2;<br>
| arma::mat tmp3;<br>
| arma::mat ui;<br>
| arma::mat ui2;<br>
| arma::mat ui3;<br>
| arma::mat sigma; <br>
|<br>
| for (int j = 0; j &lt; P-1; j++) {<br>
| tmp2.fill(0);<br>
| tmp3.fill(0);<br>
|  for (int i = 0; i &lt; N-1; i++) {<br>
|  ui = all_ui[i];<br>
| ui2 = all_ui2[i];<br>
|  ui3 = all_ui3[i];<br>
| rdi = all_rd[i];<br>
| all_corMati = all_corMat[i];<br>
|  sigma = sigma2*all_corMat[i];<br>
| // calculate mean and variance<br>
| arma::mat tmp = (solve(sig%all_corMat[i])* gen_a(i,j))*all_ui[i];<br>
| arma::mat tmp2 += (all_rd[i] - mu*trans(all_ui3[i])-(X(i)*alpha)*trans(all_ui2<br>
| [i]) + gen_a(i,j)*a.row(j)*trans(all_ui[i]))*tmp;<br>
| arma::mat tmp3 += (gen_a(i,j)*trans(all_ui[i]))*tmp;<br>
| }<br>
| }<br>
|<br>
| Thank you for your help<br>
<br>
</div></div>I&#39;m with Whit here and confess that I do not know your question is. If you<br>
show us what you tried, what you expected to happen and what actually<br>
happened we may help.<br>
<br>
(By the way, there is no tax on indentation in code and it does make it more<br>
readable for those of us who didn&#39;t write it ;-)<br>
<br>
Dirk<br>
<div class="im"><br>
| It probably does not help much<br>
| but I use R2.13 with the last version of the packages on a windows XP plateform<br>
|<br>
| Nicolas<br>
|<br>
|<br>
</div>| ----------------------------------------------------------------------<br>
<div><div></div><div class="h5">| _______________________________________________<br>
| Rcpp-devel mailing list<br>
| <a href="mailto:Rcpp-devel@lists.r-forge.r-project.org">Rcpp-devel@lists.r-forge.r-project.org</a><br>
| <a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel</a><br>
<br>
</div></div><font color="#888888">--<br>
Gauss once played himself in a zero-sum game and won $50.<br>
                      -- #11 at <a href="http://www.gaussfacts.com" target="_blank">http://www.gaussfacts.com</a><br>
</font></blockquote></div><br>