[R] Element-wise multiplication

GiusVa sigakernel at yahoo.com
Sat Apr 16 19:31:19 CEST 2005

Dear members,

The code I am writing heavily use element-wise multiplication of
matrix and vectors, e.g.

X, is nxm matrix
e, is nx1 matrix

Doing Z=X*e[,], I obtain a nxm matrix, Z, where each column of X is
multiplied (element-wise) by e. Is this the best way to achieve the
result I want? By best way, I mean the fastest way. By profiling my
code, 45% of the time is spent by "*" and even a 30% speedup in
obtaining Z would greatly benefit the total speed of the code. 

Aby suggestion is greatly appreciated. 

|Giuseppe Ragusa
|University of California, San Diego
Please avoid sending me Word or PowerPoint attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html

More information about the R-help mailing list