dot#

scikitplot.nc.dot(a: numpy.ndarray, b: numpy.ndarray) numpy.ndarray[source]#

Dot product of two arrays using the C++ NumCpp backend.

This function behaves similarly to numpy.dot for 1-D and 2-D arrays but executes the computation in C++ via the NumCpp library.

Parameters:
a, barray_like

Input vectors or matrices. They are converted to numpy.ndarray without copying whenever possible. Arrays must

  • have the same dtype, and

  • be 1-D or 2-D.

For 1-D inputs, the result is a scalar 0-D array. For 2-D inputs, standard matrix multiplication rules apply.

Returns:
outnumpy.ndarray

Dot product of a and b. The result dtype matches the input dtype for the supported dtypes.

Raises:
ValueError

If either input has more than 2 dimensions.

TypeError

If the dtypes of a and b do not match, or if the dtype is not supported.

Parameters:
Return type:

ndarray

Notes

Use both NumCpp and Numpy. dpilger26/NumCpp#16

The computation is performed by the C++ NumCpp implementation :cpp:`nc::dot` on :cpp:`nc::NdArray` containers obtained via the NumCpp pybind interface.

This is a low-level C++ binding. It expects NumPy arrays and is typically called via dot, which accepts generic array-like inputs and calls numpy.asarray on them.

At the moment the following NumPy dtypes are supported:

  • float64

  • float32

  • int64

Other dtypes will raise a TypeError.

Examples

>>> import numpy as np
>>> a = np.array([[1,2],[3,4]])
>>> b = np.array([[5,6],[7,8]])
>>> np.dot(a, b)
>>> import scikitplot.nc as nc
>>> nc.dot(a, b)
>>> nc.dot([1,2], [3,4])