Linear algebra (cupy.linalg)#

Matrix and vector products#

dot(a, b[, out])

Returns a dot product of two arrays.

vdot(a, b)

Returns the dot product of two vectors.

inner(a, b)

Returns the inner product of two arrays.

outer(a, b[, out])

Returns the outer product of two vectors.


matmul(x1, x2, /, out=None, **kwargs)

tensordot(a, b[, axes])

Returns the tensor dot product of two arrays along specified axes.

einsum(subscripts, *operands[, dtype, optimize])

Evaluates the Einstein summation convention on the operands.

linalg.matrix_power(M, n)

Raise a square matrix to the (integer) power n.

kron(a, b)

Returns the kronecker product of two arrays.



Cholesky decomposition.

linalg.qr(a[, mode])

QR decomposition.

linalg.svd(a[, full_matrices, compute_uv])

Singular Value Decomposition.

Matrix eigenvalues#

linalg.eigh(a[, UPLO])

Return the eigenvalues and eigenvectors of a complex Hermitian (conjugate symmetric) or a real symmetric matrix.

linalg.eigvalsh(a[, UPLO])

Compute the eigenvalues of a complex Hermitian or real symmetric matrix.

Norms and other numbers#

linalg.norm(x[, ord, axis, keepdims])

Returns one of matrix norms specified by ord parameter.


Returns the determinant of an array.

linalg.matrix_rank(M[, tol])

Return matrix rank of array using SVD method


Returns sign and logarithm of the determinant of an array.

trace(a[, offset, axis1, axis2, dtype, out])

Returns the sum along the diagonals of an array.

Solving equations and inverting matrices#

linalg.solve(a, b)

Solves a linear matrix equation.

linalg.tensorsolve(a, b[, axes])

Solves tensor equations denoted by ax = b.

linalg.lstsq(a, b[, rcond])

Return the least-squares solution to a linear matrix equation.


Computes the inverse of a matrix.

linalg.pinv(a[, rcond])

Compute the Moore-Penrose pseudoinverse of a matrix.

linalg.tensorinv(a[, ind])

Computes the inverse of a tensor.