# Numba supporting numpy.dot

Hey guys,

In the documentation, Supported Numpy Features → Functions → Linear algebra, it supports numpy.dot(). However, in Other methods, it says it support dot() (only the 1-argument form), which GPT tells me is dot product of two same vector. This is a bit confusing. Does Numba support dot product of two different np arrays? Many thanks.

It does. Can you supply a simple sample demo program?

Hey @aeyou ,

In the documentation, when it mentions “dot() (only the 1-argument form),” it is likely referring to the `dot` method of a NumPy array. The `dot` method, when used as a class method of a NumPy array, takes only one argument.

However, this does not mean that Numba does not support dot products between different arrays. Both `np.dot` and the `ndarray.dot` method can handle dot products between different arrays.

You can use either `np.dot` or the `ndarray.dot` method of a NumPy array for dot products between different arrays in Numba.

``````import numpy as np
import numba as nb

@nb.njit
def dot_function(arrA, arrB):
"""numpy.dot as function takes 2 arguments."""
return np.dot(arrA, arrB)

@nb.njit
def dot_method(arrA, arrB):
"""np.ndarray.dot as class method takes 1 argument."""
return arrA.dot(arrB)

arrA = np.arange(6.).reshape((3,2))
arrB = np.arange(6.).reshape((2,3))

print('dot_function')
print(dot_function(arrA, arrB))
print('dot_method')
print(dot_method(arrA, arrB))
# dot_function
# [[ 3.  4.  5.]
#  [ 9. 14. 19.]
#  [15. 24. 33.]]
# dot_method
# [[ 3.  4.  5.]
#  [ 9. 14. 19.]
#  [15. 24. 33.]]
``````
1 Like