, y_gpu, transa='N', transb='N', handle=None, out=None)[source]

Dot product of two arrays.

For 1D arrays, this function computes the inner product. For 2D arrays of shapes (m, k) and (k, n), it computes the matrix product; the result has shape (m, n).

  • x_gpu (pycuda.gpuarray.GPUArray) – Input array.
  • y_gpu (pycuda.gpuarray.GPUArray) – Input array.
  • transa (char) – If ‘T’, compute the product of the transpose of x_gpu. If ‘C’, compute the product of the Hermitian of x_gpu.
  • transb (char) – If ‘T’, compute the product of the transpose of y_gpu. If ‘C’, compute the product of the Hermitian of y_gpu.
  • handle (int) – CUBLAS context. If no context is specified, the default handle from skcuda.misc._global_cublas_handle is used.
  • out (pycuda.gpuarray.GPUArray, optional) – Output argument. Will be used to store the result.

c_gpu – Inner product of x_gpu and y_gpu. When the inputs are 1D arrays, the result will be returned as a scalar.

Return type:

pycuda.gpuarray.GPUArray, float{32,64}, or complex{64,128}


The input matrices must all contain elements of the same data type.


>>> import pycuda.autoinit
>>> import pycuda.gpuarray as gpuarray
>>> import numpy as np
>>> import skcuda.linalg as linalg
>>> import skcuda.misc as misc
>>> linalg.init()
>>> a = np.asarray(np.random.rand(4, 2), np.float32)
>>> b = np.asarray(np.random.rand(2, 2), np.float32)
>>> a_gpu = gpuarray.to_gpu(a)
>>> b_gpu = gpuarray.to_gpu(b)
>>> c_gpu =, b_gpu)
>>> np.allclose(, b), c_gpu.get())
>>> d = np.asarray(np.random.rand(5), np.float32)
>>> e = np.asarray(np.random.rand(5), np.float32)
>>> d_gpu = gpuarray.to_gpu(d)
>>> e_gpu = gpuarray.to_gpu(e)
>>> f =, e_gpu)
>>> np.allclose(, e), f)