Hello all, A colleague at work set me the challenge to convert some MATLAB code into R, to see which is faster. We'd seen that benchmark comparing MATLAB 6.5 to R1.90 (and others), and so I thought that I should be able to get roughly comparable speeds. The code has lots of multiplications of matrixes, transposes, and MATLAB's "repmat". I did the code conversion, and R was about 6 times slower, so I had a closer look at the benchmark comparison and it seems that I should be using the "Matrix" package. Is there any dummies-level help available for this package? I am struggling even to apply simple functions such as "sum" and "mean" to matrixes constructed from this class (not that I need to yet), and more importantly "kronecker", to convert from "repmat". (The help for "kronecker" from the Matrix package doesn't seem to mention kronecker, so I am a bit stuck). Any guidance greatly accepted -- I have read the overview, looked through the various Matrix-listed functions, and unsuccessfully tried searching R-help. Using R version 2.2.0, windows xp. Cheers, Rob.
The first thing is to ensure that you are using an optimized BLAS. On Windows, use Goto's BLAS if you have it (is not currently available and redistribution is not allowed) or one of the pre-built ATLAS-based Rblas.dll on CRAN or (best of all) optimize your own build of ATLAS. The Matrix package depends on an optimized BLAS even more crucially than base R. On Thu, 13 Oct 2005, rob foxall (IFR) wrote:> Hello all, > A colleague at work set me the challenge to convert some MATLAB > code into R, to see which is faster. We'd seen that benchmark comparing > MATLAB 6.5 to R1.90 (and others), and so I thought that I should be able > to get roughly comparable speeds. The code has lots of multiplications > of matrixes, transposes, and MATLAB's "repmat". I did the code > conversion, and R was about 6 times slower, so I had a closer look at > the benchmark comparison and it seems that I should be using the > "Matrix" package. > Is there any dummies-level help available for this package? I am > struggling even to apply simple functions such as "sum" and "mean" to > matrixes constructed from this class (not that I need to yet), and more > importantly "kronecker", to convert from "repmat". (The help for > "kronecker" from the Matrix package doesn't seem to mention kronecker, > so I am a bit stuck). Any guidance greatly accepted -- I have read the > overview, looked through the various Matrix-listed functions, and > unsuccessfully tried searching R-help. > > Using R version 2.2.0, windows xp.-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
Thanks Prof. Ripley for your prompt reply. With regards to Rblas.dll my current situation is that I have taken the Rblas.dll from CRAN: contrib/ATLAS/P4/, and replaced the default Rblas.dll in my R /bin with this one. Cheers, Rob. -----Original Message----- From: Prof Brian Ripley [mailto:ripley at stats.ox.ac.uk] Sent: 13 October 2005 11:33 To: rob foxall (IFR) Cc: r-help at stat.math.ethz.ch Subject: Re: [R] Help with Matrix package The first thing is to ensure that you are using an optimized BLAS. On Windows, use Goto's BLAS if you have it (is not currently available and redistribution is not allowed) or one of the pre-built ATLAS-based Rblas.dll on CRAN or (best of all) optimize your own build of ATLAS. The Matrix package depends on an optimized BLAS even more crucially than base R. On Thu, 13 Oct 2005, rob foxall (IFR) wrote:> Hello all, > A colleague at work set me the challenge to convert some MATLAB > code into R, to see which is faster. We'd seen that benchmarkcomparing> MATLAB 6.5 to R1.90 (and others), and so I thought that I should beable> to get roughly comparable speeds. The code has lots of multiplications > of matrixes, transposes, and MATLAB's "repmat". I did the code > conversion, and R was about 6 times slower, so I had a closer look at > the benchmark comparison and it seems that I should be using the > "Matrix" package. > Is there any dummies-level help available for this package? I am > struggling even to apply simple functions such as "sum" and "mean" to > matrixes constructed from this class (not that I need to yet), andmore> importantly "kronecker", to convert from "repmat". (The help for > "kronecker" from the Matrix package doesn't seem to mention kronecker, > so I am a bit stuck). Any guidance greatly accepted -- I have read the > overview, looked through the various Matrix-listed functions, and > unsuccessfully tried searching R-help. > > Using R version 2.2.0, windows xp.-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
The Matrix package is under active development and the documentation has not caught up with the code. Examples of usage can be found in the tests subdirectory of the source package. At present we are concentrating on the class hierarchy and writing methods and test cases for those methods. Because everything is in a state of flux we have not created the simple introductory document. The benchmark examples were all simple examples that, for the most part, required just one function call. What you are doing sounds more realistic. On 10/13/05, rob foxall (IFR) <rob.foxall at bbsrc.ac.uk> wrote:> Hello all, > A colleague at work set me the challenge to convert some MATLAB > code into R, to see which is faster. We'd seen that benchmark comparing > MATLAB 6.5 to R1.90 (and others), and so I thought that I should be able > to get roughly comparable speeds. The code has lots of multiplications > of matrixes, transposes, and MATLAB's "repmat". I did the code > conversion, and R was about 6 times slower, so I had a closer look at > the benchmark comparison and it seems that I should be using the > "Matrix" package. > Is there any dummies-level help available for this package? I am > struggling even to apply simple functions such as "sum" and "mean" to > matrixes constructed from this class (not that I need to yet), and more > importantly "kronecker", to convert from "repmat". (The help for > "kronecker" from the Matrix package doesn't seem to mention kronecker, > so I am a bit stuck). Any guidance greatly accepted -- I have read the > overview, looked through the various Matrix-listed functions, and > unsuccessfully tried searching R-help. > > Using R version 2.2.0, windows xp. > > Cheers, > Rob. > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html >