Function numpy::dot

source · []
pub fn dot<'py, T, DIN1, DIN2, DOUT>(
    array1: &'py PyArray<T, DIN1>,
    array2: &'py PyArray<T, DIN2>
) -> PyResult<&'py PyArray<T, DOUT>> where
    DIN1: Dimension,
    DIN2: Dimension,
    DOUT: Dimension,
    T: Element
Expand description

Return the dot product of two arrays.

Example

pyo3::Python::with_gil(|py| {
    let a = numpy::pyarray![py, [1, 0], [0, 1]];
    let b = numpy::pyarray![py, [4, 1], [2, 2]];
    let dot: &numpy::PyArray2::<_> = numpy::dot(a, b).unwrap();
    assert_eq!(
        dot.readonly().as_array(),
        ndarray::array![[4, 1], [2, 2]]
    );
});