Dear list members, I've got a small question on matrix multiplications in a C code. Because of a really cpu demanding likelihood, I had to use a C code within an R function wrapper. I'm pretty sure that there is already one good code for matrix multiplication in C - maybe in the R source code itself - but I wasn't able to find it. Anyone as an idea on how to handle matrix multiplications? Best, Mathieu -- Institute of Mathematics Ecole Polytechnique F?d?rale de Lausanne STAT-IMA-FSB-EPFL, Station 8 CH-1015 Lausanne Switzerland http://stat.epfl.ch/ Tel: + 41 (0)21 693 7907
On Sun, 6 Apr 2008, Mathieu Ribatet wrote:> Dear list members, > > I've got a small question on matrix multiplications in a C code. Because > of a really cpu demanding likelihood, I had to use a C code within an R > function wrapper. I'm pretty sure that there is already one good code > for matrix multiplication in C - maybe in the R source code itself - but > I wasn't able to find it. > > Anyone as an idea on how to handle matrix multiplications?Well, R does use fast C code where available: see matmult in src/main/array.c which calls the BLAS. It works best if you have an optimized BLAS: otherwise it may not be as fast as the simple version used when there are NAs present. -- 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
Mathieu Ribatet a ?crit :> Dear list members, > > I've got a small question on matrix multiplications in a C code. Because > of a really cpu demanding likelihood, I had to use a C code within an R > function wrapper. I'm pretty sure that there is already one good code > for matrix multiplication in C - maybe in the R source code itself - but > I wasn't able to find it. > > Anyone as an idea on how to handle matrix multiplications?fwiw : from a post on Rd on 4/4/2007 : Just-in-time compiler for R http://www.milbo.users.sonic.net/ra/index.html