Re: efficient matrix multiplication [message #3813] |
Sat, 18 March 1995 00:47  |
goyette
Messages: 2 Registered: March 1995
|
Junior Member |
|
|
In article <D5LsIF.417@rockyd.rockefeller.edu>,
orbach@rockvax.rockefeller.edu (Darren Orbach) wrote:
> Here's the question: In order to extract the inner products from this
> big array, I've been looping over the z-variable and doing a "total()"
> operation: for i = 0, 99 do output(i)=total(productarray(*,*,i)).
> This process seems highly inefficient, and since I'm doing this
> hundreds of times every time I need the series of inner products,
> I'm looking for a better method. Is there a function analogous to
> total(), which can be directed to act over a specified dimension without
> looping over every element of that dimension? If it's at all relevant,
> I'm using PV-WAVE Advantage 5.0.
I think that the funtion, total, can do this. A second parameter in total
indicates a dimension to sum over --- i.e., total(z,1) sums over the first
dimension. So you could replace the loop with two lines:
output = total(productarray,1)
output = total(output,2)
or if you prefer 1 line, output = total(total(productarray,1),2)
Good luck!
-John G.
goyette@nwu.edu
|
|
|