31 May 2012 01:59
Optimizing a simple Common Lisp Gibbs sampler program
Faheem Mitha <faheem <at> faheem.info>
2012-05-30 23:59:21 GMT
2012-05-30 23:59:21 GMT
Hi, I posted the following at http://stackoverflow.com/questions/10813398/optimizing-simple-common-lisp-gibbs-sampler-program I reproduce the question below. The cl-rmath is a wrapper for R's math library, and it located at https://github.com/tpapp/cl-rmath. As the question says, I'm looking for optimization hints. This is just an exercise; I took it from Darren Wilkinson's blog, and it looked simple enough to be something I could learn from. First, I should mention that trying this code without any attempt at optimization or type declaration, I got slightly over 1 minute runtime. With the added declarations etc, it is now about 52/54 seconds; not a dramatic improvement. The C code runs about 25 seconds, so this is not too bad, but I'd like to see if I can get some improvement. BTW, by way of comparison, Darren's Python version runs on my machine at around 9 1/2 minutes. Per Rainer's feedback, I tried wrapping the sqrt value in a double-float d (the double-float (sqrt (+ (* 2 x) 2))) However, I still get the following note, but I'm not sure what the compiler is complaining about now. If I understand this correctly, the issue is that the argument to sqrt might be negative, and hence the result might be complex. However, I've said that the sqrt expression(Continue reading)
RSS Feed