[Numpy-discussion] Repeated Dot Operations
Robert Kern
robert.kern@gmail....
Mon Jul 20 11:36:02 CDT 2009
On Mon, Jul 20, 2009 at 05:27, T J<tjhnson@gmail.com> wrote:
> Hi,
>
> Is there a good way to perform dot on an arbitrary list of arrays
> which avoids using a loop? Here is what I'd like to avoid:
>
> # m1, m2, m3 are arrays
>>>> out = np.(m1.shape[0])
>>>> prod = [m1, m2, m3, m1, m2, m3, m3, m2]
>>>> for m in prod:
> ... out = np.dot(out, m)
> ...
There isn't really a need to avoid a loop in this case. The lists are
almost certainly not going to be very long. Wrap it up in a function
if you want the convenience of a function call.
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
-- Umberto Eco
More information about the NumPy-Discussion
mailing list