Either input can be an array of 3- (or 2-) element vectors.

```
>>> a=np.array([[1,0,0],[0,1,0],[0,0,1]])
>>> b=np.array([1,0,0])
>>> np.cross(a,b)
array([[ 0, 0, 0],
[ 0, 0, -1],
[ 0, 1, 0]])
```

The result in this case is array([np.cross(a[0],b), np.cross(a[1],b), np.cross(a[2],b)])

`b`

can also be an array of 3- (or 2-) element vectors, but it must have the same shape as `a`

. Otherwise the calculation fails with a "shape mismatch" error. So we can have

```
>>> b=np.array([[0,0,1],[1,0,0],[0,1,0]])
>>> np.cross(a,b)
array([[ 0, -1, 0],
[ 0, 0, -1],
[-1, 0, 0]])
```

and now the result is `array([np.cross(a[0],b[0]), np.cross(a[1],b[1]), np.cross(a[2],b[2])])`

This modified text is an extract of the original Stack Overflow Documentation created by following contributors and released under CC BY-SA 3.0

This website is not affiliated with Stack Overflow