[R] Element-wise multiplication

From: GiusVa <sigakernel_at_yahoo.com>
Date: Sun 17 Apr 2005 - 03:31:19 EST

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

R-help@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 Received on Sun Apr 17 03:33:37 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:31:13 EST