[Numpy-discussion] kind of a matrix multiplication

Martin Raspaud martin.raspaud at smhi.se
Tue Oct 11 01:49:10 EDT 2011


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi all,

I have a stack of vectors:

v1 = np.arange(3)
v2 = np.arange(3) + 3
stack = np.vstack(v1, v2)

(now stack is :
array([[0, 1, 2],
       [3, 4, 5]]))

and a 3d matrix:

mat = np.dstack((np.eye(3), np.eye(3) * 2))
(mat is now
array([[[ 1.,  2.],
        [ 0.,  0.],
        [ 0.,  0.]],

       [[ 0.,  0.],
        [ 1.,  2.],
        [ 0.,  0.]],

       [[ 0.,  0.],
        [ 0.,  0.],
        [ 1.,  2.]]]))

I'm looking for the operation needed to get the two (stacked) vectors
array([[0, 1, 2],
       [6, 8, 10]]))
or its transpose.

I tried various combinations of tensor products, but I always get a
result in 3 dimensions, while I just want two.

Any suggestions ?

Thanks,
Martin
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
Comment: Using GnuPG with Red Hat - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJOk9jWAAoJEBdvyODiyJI4y30IAJu6YIHK+ED8pN5M2TFrEKj8
k/K22MjitlQ8wTFDxwc5xBRI+yoniqgAfpzWjdU3pc5MxzXRgbZrRZagYWjepZyI
CtN/CHy+BfM8EPJulFeVcInAgo1pgfAhH4xwEakbu88XhKSgat1Y9xlNRcrohTUQ
oBVd+DNmBYpEUAa0pDjkMYXM8vaJqzePZZGaviZxY0AY2MBDrbZN/z6t4u2Unajn
8X1vjCg/XfDbm9v7FK/52MUorAJinZRdHiWBTE9rOmAqjJxTBoFKkN+0FMTUk6Sj
acJNjr5KFjl6o3JPxqU4jRfw1zFRO9BEouzosKfYcs/kLozNjTBmfZztg0np/dg=
=Ykij
-----END PGP SIGNATURE-----
-------------- next part --------------
A non-text attachment was scrubbed...
Name: martin_raspaud.vcf
Type: text/x-vcard
Size: 293 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20111011/07bfe3b8/attachment.vcf>


More information about the NumPy-Discussion mailing list