Hi, I have found some example of R code : http://commons.wikimedia.org/wiki/File:Mandelbrot_Creation_Animation_%28800x600%29.gif When I run this code on my computer it takes few seconds. I wanted to make similar program in Maxima CAS : http://thread.gmane.org/gmane.comp.mathematics.maxima.general/29949/focus=29968 for example : f(x,y,n) : block([i:0, c:x+y*%i,ER:4,iMax:n,z:0], while abs(z)<ER and i<iMax do (z:z*z + c,i:i+1), min(ER,abs(z)))$ wxanimate_draw3d( n, 5, enhanced3d=true, user_preamble="set pm3d at b; set view map", xu_grid=70, yv_grid=70, explicit('f(x,y,n), x, -2, 0.7, y, -1.2, 1.2))$ But it takes so long to make even one image ( hours) What makes the difference, and why R so fast ? Regards Adam
Hard to say. You might want to run a profile of each set of code and see where it is spending its time. It looks like from the R code that they are using vectorized operations and depending on how some of them are implemented, they might be calling C code to do most of the work. With the proper use of vectorized operations, R can be pretty fast. I don't understand CAS code, but it looks like there is a lot of iteration, and function calls, that might be adding to the time. Profiling will help you localize the issues. On Tue, Mar 9, 2010 at 4:49 PM, Adam Majewski <adammaj1@o2.pl> wrote:> Hi, > > I have found some example of R code : > > http://commons.wikimedia.org/wiki/File:Mandelbrot_Creation_Animation_%28800x600%29.gif > > When I run this code on my computer it takes few seconds. > > I wanted to make similar program in Maxima CAS : > > > http://thread.gmane.org/gmane.comp.mathematics.maxima.general/29949/focus=29968 > > for example : > > f(x,y,n) :> block([i:0, c:x+y*%i,ER:4,iMax:n,z:0], > while abs(z)<ER and i<iMax > do (z:z*z + c,i:i+1), > min(ER,abs(z)))$ > > wxanimate_draw3d( > n, 5, > enhanced3d=true, > user_preamble="set pm3d at b; set view map", > xu_grid=70, > yv_grid=70, > explicit('f(x,y,n), x, -2, 0.7, y, -1.2, 1.2))$ > > > But it takes so long to make even one image ( hours) > > What makes the difference, and why R so fast ? > > Regards > > Adam > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html> > and provide commented, minimal, self-contained, reproducible code. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? [[alternative HTML version deleted]]
Your choice of subject line alone shows some people that you missed some small details from the posting guide. The ability to notice small details may be important for you to demonstrate in future. Any answer in this thread is unlikely to be found by a topic search on subject lines alone since "speed" is a single word. One fast way to increase your reputation is to contribute. You now have an opportunity. If you follow Jim's good advice, discover the answer for yourself, and post it back to the group, changing the subject line so that its easier for others to find in future, thats one way you can contribute and increase your reputation. If you don't do that, thats your choice. It is entirely up to you. Whatever action you take next, even doing nothing is an action, it is visible in public for everyone to search back and find out within seconds. HTH "Adam Majewski" <adammaj1 at o2.pl> wrote in message news:hn6fp4$2gp$1 at dough.gmane.org...> Hi, > > I have found some example of R code : > http://commons.wikimedia.org/wiki/File:Mandelbrot_Creation_Animation_%28800x600%29.gif > > When I run this code on my computer it takes few seconds. > > I wanted to make similar program in Maxima CAS : > > http://thread.gmane.org/gmane.comp.mathematics.maxima.general/29949/focus=29968 > > for example : > > f(x,y,n) :> block([i:0, c:x+y*%i,ER:4,iMax:n,z:0], > while abs(z)<ER and i<iMax > do (z:z*z + c,i:i+1), > min(ER,abs(z)))$ > > wxanimate_draw3d( > n, 5, > enhanced3d=true, > user_preamble="set pm3d at b; set view map", > xu_grid=70, > yv_grid=70, > explicit('f(x,y,n), x, -2, 0.7, y, -1.2, 1.2))$ > > > But it takes so long to make even one image ( hours) > > What makes the difference, and why R so fast ? > > Regards > > Adam >