Numba supporting

Hey guys,

In the documentation, Supported Numpy Features → Functions → Linear algebra, it supports 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 and the method can handle dot products between different arrays.

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

import numpy as np
import numba as nb

def dot_function(arrA, arrB):
    """ as function takes 2 arguments."""
    return, arrB)

def dot_method(arrA, arrB):
    """ as class method takes 1 argument."""

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

print(dot_function(arrA, arrB))
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

Ah, I understand. Thank you very much for your reply.