[Numpy-discussion] Tuple outer product?

Robert Kern robert.kern@gmail....
Fri Sep 25 17:42:15 CDT 2009


On Fri, Sep 25, 2009 at 17:38, Mads Ipsen <mpi@comxnet.dk> wrote:
> Yes, but it should also work for [2.1,3.2,4.5] combined with
> [4.6,-2.3,5.6] - forgot to tell that.

In [5]: np.transpose(np.meshgrid([2.1,3.2,4.5], [4.6,-2.3,5.6]))
Out[5]:
array([[[ 2.1,  4.6],
        [ 2.1, -2.3],
        [ 2.1,  5.6]],

       [[ 3.2,  4.6],
        [ 3.2, -2.3],
        [ 3.2,  5.6]],

       [[ 4.5,  4.6],
        [ 4.5, -2.3],
        [ 4.5,  5.6]]])

-- 
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