Skip to content

Matrices

Published On:
Feb 21, 2019
Last Updated:
Feb 21, 2019

Dot Product

Numpy

The dot product of arrays of vectors can be calculated using Numpy with:

import numpy as np
a = np.array([[1, 1, 1], [2, 2, 2]])
b = np.array([[1, 2, 3], [4, 5, 6]])
np.sum(a*b, axis=1)

Projection

The dot product can be used to calculate the projection of a vector onto an axis in 3D space.