roll @pie

NumPy array - Outer product of vectors | Python

The outer product of NumPy vectors can be calculated by outer.

import numpy

a = numpy.array([1, 2])
b = numpy.array([3, 4])

c = numpy.outer(a, b)

print(c)
# [[3 4]
#  [6 8]]

print(type(c))  # <class 'numpy.ndarray'>
0
35 Views
0 Comments

Comments

Powered by Markdown

More

  • roll @pie

    NumPy Vector

    0
    133 Views
    0 Comments
  • roll @pie

    NumPy norm: How to calculate the norm of a vector in Python

    This is an example to calculate a vector norm using Python NumPy. python import numpy as np from numpy import linalg as LA v = np.array...

    0
    350 Views
    0 Comments
  • roll @pie

    NumPy dot: How to calculate the inner product of vectors in Python

    Here is an example to calculate an inner product of two vectors in Python. python import numpy as np v = np.array([1, 2]) w = np.array(...

    0
    135 Views
    0 Comments
  • roll @pie

    Calculate the angle between two vectors in NumPy (Python)

    You can get the angle between two vectors in NumPy (Python) as follows. python import numpy as np import numpy.linalg as LA a = np.arra...

    0
    10275 Views
    0 Comments
  • roll @pie

    Rotate a vector by angle (degree, radian) in NumPy

    How to rotate the 2D vector by degree in Python: python from math import cos, sin import numpy as np theta = np.deg2rad(30) rot = ...

    0
    9874 Views
    0 Comments
NumPy

NumPy Array

21

NumPy Vector

6

NumPy Matrix

7

NumPy Statistics

4

NumPy function

2
Legends
Terms Privacy

© Rollpie