Skip to content

Element-wise multiplication

2 messages · GiusVa, Gabor Grothendieck

#
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
#
On 4/16/05, GiusVa <sigakernel at yahoo.com> wrote:
Try this:
[1] 0.26 0.02 0.28   NA   NA
[1] 0.07 0.00 0.07   NA   NA
[1] 0.06 0.00 0.06   NA   NA