<br><br><div class="gmail_quote">On Wed, Jun 1, 2011 at 3:51 AM, Christian Gunning <span dir="ltr">&lt;<a href="mailto:xian@unm.edu">xian@unm.edu</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
On Tue, May 31, 2011 at 10:55 AM,<br>
&lt;<a href="mailto:rcpp-devel-request@r-forge.wu-wien.ac.at">rcpp-devel-request@r-forge.wu-wien.ac.at</a>&gt; wrote:<br><br>
<br>
I didn&#39;t see anything.  If you&#39;re not subscribed to the list,<br>
submissions silently fail.  Plus, you must send from the subscribing<br>
address.  I&#39;ve made this mistake a few times...<br></blockquote><div> Yeah, I did the same mistake.</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br><br>
<br>
I&#39;m attaching a cleanup of the code using inline -- you can now just<br>
source this in R.  I&#39;m not sure, but I think you might be working<br>
under some mistaken assumptions.  Hopefully the attached code is more<br>
conceptually clear.<br>
<br></blockquote><div>Actually I used .Call for calling the cpp function and as I said this worked perfectly for small datasets, but for some large datasets, it doesn&#39;t work</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

There were a few offhand things that I modified, e.g. maxItr wasn&#39;t<br>
used in the attached code.  There are a number of things that I<br>
*didn&#39;t* change for which there seem to be faster/better methods, but<br>
I&#39;m not sure of your purpose.  For example, can any of the in-loop<br>
assignments (qnum, qlength) be moved to the top?<br>
<br></blockquote><div>Well, I wrote this attached function just to show the basic structure of my code, in the original code I have to pick a topic for each word in each question and also pick a persona for each question in document, and I think I have no other option.</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Lastly, are you *just* using rmultinom and Cwhich to roll a K or P<br>
sided die?  If so, what about something like as&lt;int&gt;(runif(1, 0, K))?<br>
Even if you&#39;re rolling a weighted die, it seems like there&#39;s a better<br>
way...<br>
<br></blockquote><div>yeah, I used Cwhich for that purpose, I will try your suggestion as well, Thanks   </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hopefully this sheds at least a bit of light on your question.<br>
Apologies if I&#39;ve misunderstood.<br>
-Christian<br>
<br>
## Compile/run from R using the following (assuming inline package is<br>
installed):<br>
source(&#39;gibbs.R.txt&#39;)<br>
fun1(10)<br>
<font color="#888888"><br></font></blockquote><div>Thanks you so much for suggesting inline, it really helped me.  I changed my code to this format and ran it on one of the largest dataset, it is still running and usually it takes 3,4 days to be completed for 3000 iteration, so far I haven&#39;t seen the former exceptions that happened in .Call version, I hope it doesn&#39;t occur again. I let you know if it ends without any exception.</div>
<div>but still I cant understand why that exceptions happen in .Call version.</div><div>Thank you.</div><div><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<font color="#888888">
--<br>
A man, a plan, a cat, a ham, a yak, a yam, a hat, a canal – Panama!<br>
</font></blockquote></div><br>