dot
Dot product of two arrays. For 1-D arrays, computes the inner product. For 2-D arrays, computes the matrix product (equivalent tomatmul). For higher dimensions, a sum product over the last axis of a and the second-to-last axis of b.
Also available as np.linalg.dot(...).
| Name | Type | Default | Description |
|---|---|---|---|
a | ArrayLike | — | First input array. |
b | ArrayLike | — | Second input array. |
NDArray | number — Scalar if both inputs are 1-D, otherwise an NDArray.
matmul
Matrix product of two arrays. This is the equivalent of the@ operator in NumPy/Python. Unlike dot, matmul does not allow scalar multiplication and follows strict broadcasting rules for stacks of matrices.
Also available as np.linalg.matmul(...).
| Name | Type | Default | Description |
|---|---|---|---|
a | ArrayLike | — | First input array (must be at least 1-D). |
b | ArrayLike | — | Second input array (must be at least 1-D). |
NDArray — The matrix product.
inner
Inner product of two arrays. For 1-D arrays, this is identical todot. For higher-dimensional arrays, it is a sum product over the last axes.
Also available as np.linalg.inner(...).
| Name | Type | Default | Description |
|---|---|---|---|
a | ArrayLike | — | First input array. |
b | ArrayLike | — | Second input array. |
NDArray | number — Scalar if both inputs are 1-D, otherwise an NDArray.
outer
Compute the outer product of two vectors. The inputs are flattened if they are not already 1-D. Also available asnp.linalg.outer(...).
| Name | Type | Default | Description |
|---|---|---|---|
a | ArrayLike | — | First input array (flattened to 1-D). |
b | ArrayLike | — | Second input array (flattened to 1-D). |
NDArray — 2-D array of shape [a.size, b.size] where out[i, j] = a[i] * b[j].
tensordot
Compute tensor dot product along specified axes. Generalizesdot for higher-dimensional arrays.
Also available as np.linalg.tensordot(...).
| Name | Type | Default | Description |
|---|---|---|---|
a | ArrayLike | — | First input array. |
b | ArrayLike | — | Second input array. |
axes | number | [number[], number[]] | 2 | If an integer N, sum over the last N axes of a and the first N axes of b. If a tuple of axis lists, sum over the specified axes. |
NDArray — The tensor dot product.
kron
Kronecker product of two arrays. The result is a block matrix formed by multiplying every element ofa by the entirety of b.
| Name | Type | Default | Description |
|---|---|---|---|
a | ArrayLike | — | First input array. |
b | ArrayLike | — | Second input array. |
NDArray — The Kronecker product.
vdot
Vector dot product. Flattens both inputs to 1-D before computing the dot product. For complex arrays, the complex conjugate ofa is used.
| Name | Type | Default | Description |
|---|---|---|---|
a | ArrayLike | — | First input (flattened to 1-D). |
b | ArrayLike | — | Second input (flattened to 1-D). |
number — Scalar dot product of the flattened inputs.
vecdot
Vector dot product along the specified axis. Unlikevdot, this operates along a given axis rather than flattening.
Also available as np.linalg.vecdot(...).
| Name | Type | Default | Description |
|---|---|---|---|
x1 | ArrayLike | — | First input array. |
x2 | ArrayLike | — | Second input array. |
axis | number | -1 | Axis along which to compute the dot product. |
NDArray — Dot product computed along the given axis.
matvec
Matrix-vector product. Multiplies a matrix by a vector, equivalent tomatmul(a, b) where b is 1-D.
Also available as np.linalg.matvec(...).
| Name | Type | Default | Description |
|---|---|---|---|
x1 | ArrayLike | — | Input matrix (2-D or stack of matrices). |
x2 | ArrayLike | — | Input vector (1-D or stack of vectors). |
NDArray — The matrix-vector product.
vecmat
Vector-matrix product. Multiplies a vector by a matrix, equivalent tomatmul(a, b) where a is 1-D.
Also available as np.linalg.vecmat(...).
| Name | Type | Default | Description |
|---|---|---|---|
x1 | ArrayLike | — | Input vector (1-D or stack of vectors). |
x2 | ArrayLike | — | Input matrix (2-D or stack of matrices). |
NDArray — The vector-matrix product.
einsum
Evaluates the Einstein summation convention on the operands. This is a powerful generalization that can express many common linear algebra operations in a single call.| Name | Type | Default | Description |
|---|---|---|---|
subscripts | string | — | Subscript string describing the operation (e.g. 'ij,jk->ik' for matrix multiplication). |
...operands | ArrayLike[] | — | One or more input arrays. |
NDArray — The result of the Einstein summation.
einsum_path
Evaluate the optimal contraction order for aneinsum expression. Returns the path and a human-readable description of the optimization.
| Name | Type | Default | Description |
|---|---|---|---|
subscripts | string | — | Subscript string (same format as einsum). |
...operands | ArrayLike[] | — | Input arrays. |
[string[], string] — A tuple of the contraction path (list of index pairs) and a printable description of the optimization.