Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uwm.edu!zaphod.mps.ohio-state.edu!sdd.hp.com!elroy.jpl.nasa.gov!aero!plonski From: plonski@aero.aero.org (Mike Plonski) Newsgroups: comp.lang.idl-pvwave Subject: Effecient way to multiply every col in matrix by a col vector?? Message-ID: <82772@aerospace.AERO.ORG> Date: 31 Aug 90 19:11:50 GMT Sender: news@aerospace.aero.org Reply-To: plonski@aero.aero.org (Mike Plonski) Organization: The Aerospace Corporation Lines: 27 What is the most efficient way to multiply every col in a 2D array (ncol x nrow) by a vector of length (ncol). Example: input array vector output array a11 a12 a13 b1 a11b1 a12b1 a13b1 a21 a22 a23 b2 a21b2 a22b2 a23b2 I currently do this by looping over the cols: FOR i=0,ncol-1 DO c(i,*) = a(i,*) * b Is there a more efficient way (w.r.t. computational speed) to do this? I know I could replicate the column vector into a matrix (b # identity row) and then do a ptwise matrix multiply, but my matrices can be very large (1M elements) and I occasionally run out of swap space. I don't know if that would run any faster anyway. ------------------------------------------------------------------------------- . . .__. The opinions expressed herein are soley |\./| !__! Michael Plonski those of the author and do not represent | | | "plonski@aero.org" those of The Aerospace Corporation. _______________________________________________________________________________