JoelSjogren icon

Untitled

JoelSjogren | PRO | 11/15/20 01:43:08 PM UTC | 0 ⭐ | 575 👁️ | Never ⏰ | []
text |

840 B

|

None

|

0 👍

/

0 👎

box% python
Python 3.8.6 (default, Sep 30 2020, 04:00:38) 
[GCC 10.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> e_0 = np.array([1,0,0,0])
>>> e_1 = np.array([0,1,0,0])
>>> e_2 = np.array([0,0,1,0])
>>> e_3 = np.array([0,0,0,1])
>>> np.einsum('a,b->ab', e_0, e_1)
array([[0, 1, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])
>>> np.einsum('a,b,c->abc', e_0, e_1, e_2)
array([[[0, 0, 0, 0],
        [0, 0, 1, 0],
        [0, 0, 0, 0],
        [0, 0, 0, 0]],
        [[0, 0, 0, 0],
        [0, 0, 0, 0],
        [0, 0, 0, 0],
        [0, 0, 0, 0]],
        [[0, 0, 0, 0],
        [0, 0, 0, 0],
        [0, 0, 0, 0],
        [0, 0, 0, 0]],
        [[0, 0, 0, 0],
        [0, 0, 0, 0],
        [0, 0, 0, 0],
        [0, 0, 0, 0]]])
>>> 

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎