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.dotfor 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.ndarraywithout copying whenever possible. Arrays musthave 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
aandb. 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
aandbdo not match, or if the dtype is not supported.
- Parameters:
a (_Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str])
b (_Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str])
- Return type:
See also
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 callsnumpy.asarrayon them.At the moment the following NumPy dtypes are supported:
float64float32int64
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])