On Wed, 22 Feb 2006, S??ren H??jsgaard wrote:
> I would like to see how the matrix multiplication operator %*% is
> implemented (because I want to see which external Fortran/C routines are
> used). How can I do so? Best S??ren
[This is probably a R-devel question: please study the posting guide.]
> get("%*%")
.Primitive("%*%")
so get your R sources out (I'll use current R-devel), go to
src/main/names.c and search. You find
{"%*%", do_matprod, 0, 1, 2, {PP_BINARY,
PREC_PERCENT,0}},
So this is OP 0 of do_matprod. Search for that in src/main/*.c: it is is
array.c. Find
if (PRIMVAL(op) == 0) { /* op == 0 : matprod() */
and the meat is
if (mode == CPLXSXP)
cmatprod(COMPLEX(CAR(args)), nrx, ncx,
COMPLEX(CADR(args)), nry, ncy, COMPLEX(ans));
else
matprod(REAL(CAR(args)), nrx, ncx,
REAL(CADR(args)), nry, ncy, REAL(ans));
Now look for matprod and cmatprod. The answer is that if there are no
IEEE754 specials, dgemm or zgemm are used. Those are level-3 BLAS
routines.
--
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