Christofer Bogaso
2010-Sep-09 10:26 UTC
[R] Which language is faster for numerical computation?
Dear all, R offers integration mechanism with different programming languages like C, C++, Fortran, .NET etc. Therefore I am curious on, for heavy numerical computation which language is the fastest? Is there any study? I specially want to know because, if there is some study saying that C is the fastest language for numerical computation then I would change some of my R code into C. Thanks for your time.
Rainer M Krug
2010-Sep-09 11:26 UTC
[R] Which language is faster for numerical computation?
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 09/09/10 12:26, Christofer Bogaso wrote:> Dear all, R offers integration mechanism with different programming > languages like C, C++, Fortran, .NET etc. Therefore I am curious on, > for heavy numerical computation which language is the fastest? Is > there any study? I specially want to know because, if there is some > study saying that C is the fastest language for numerical computation > then I would change some of my R code into C.As far as I am aware, the two choices are C and Fortran - where it depends on the calculations, which one is faster. Cheers, Rainer> > Thanks for your time. > > ______________________________________________ > R-help at 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 > and provide commented, minimal, self-contained, reproducible code.- -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Tel: +33 - (0)9 53 10 27 44 Cell: +27 - (0)8 39 47 90 42 Fax (SA): +27 - (0)8 65 16 27 82 Fax (D) : +49 - (0)3 21 21 25 22 44 Fax (FR): +33 - (0)9 58 10 27 44 email: Rainer at krugs.de Skype: RMkrug -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkyIxHYACgkQoYgNqgF2egofwQCePvkN3xewbSNEeKUiuxlL7Utx CxMAniGRwoAWfJ8VNTPHLXIbtpiZCrMd =fmFx -----END PGP SIGNATURE-----
Matt Shotwell
2010-Sep-09 14:17 UTC
[R] Which language is faster for numerical computation?
For the compiled languages, it depends heavily on the compiler. This sort of comparison is rendered moot by the huge variety of compiler and hardware specific optimizations. My suggestion is to use C, or possibly C++ in conjunction with Rcpp, as these are most compatible with R. Also, C and C++ are consistently rated highly (often in the top 3) in popularity and use. Fortran is not. This would make a difference if you want to collaborate or ask for help. -Matt On Thu, 2010-09-09 at 06:26 -0400, Christofer Bogaso wrote:> Dear all, R offers integration mechanism with different programming > languages like C, C++, Fortran, .NET etc. Therefore I am curious on, > for heavy numerical computation which language is the fastest? Is > there any study? I specially want to know because, if there is some > study saying that C is the fastest language for numerical computation > then I would change some of my R code into C. > > Thanks for your time. > > ______________________________________________ > R-help at 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 > and provide commented, minimal, self-contained, reproducible code.-- Matthew S. Shotwell Graduate Student Division of Biostatistics and Epidemiology Medical University of South Carolina
Prof. John C Nash
2010-Sep-10 13:06 UTC
[R] Which language is faster for numerical computation?
Dirk E. has properly focussed the discussion on measurement rather than opinion. I'll add the issue of the human time taken to convert, and more importantly debug, interfaced code. That too could be measured, but we rarely see human hours to code/debug/test reported. Moreover, I'll mention the cat among the pigeons of Rcgmin, which I wrote to allow me to play with an optimization code more easily to discover where the algorithm might be improved. The resulting package on some problems outperforms C equivalents. Now the code is quite vectorized, but this has still been a very nice surprise. In fact, I've decided to avoid playing around with the interfaces if I can run things well-enough entirely in R. JN