## On this page

# torch.linalg

Common linear algebra operations.

See Linear algebra (torch.linalg) for some common numerical edge-cases.

## Matrix Properties

`norm` |
Computes a vector or matrix norm. |

`vector_norm` |
Computes a vector norm. |

`matrix_norm` |
Computes a matrix norm. |

`diagonal` |
Alias for |

`det` |
Computes the determinant of a square matrix. |

`slogdet` |
Computes the sign and natural logarithm of the absolute value of the determinant of a square matrix. |

`cond` |
Computes the condition number of a matrix with respect to a matrix norm. |

`matrix_rank` |
Computes the numerical rank of a matrix. |

## Decompositions

`cholesky` |
Computes the Cholesky decomposition of a complex Hermitian or real symmetric positive-definite matrix. |

`qr` |
Computes the QR decomposition of a matrix. |

`lu` |
Computes the LU decomposition with partial pivoting of a matrix. |

`lu_factor` |
Computes a compact representation of the LU factorization with partial pivoting of a matrix. |

`eig` |
Computes the eigenvalue decomposition of a square matrix if it exists. |

`eigvals` |
Computes the eigenvalues of a square matrix. |

`eigh` |
Computes the eigenvalue decomposition of a complex Hermitian or real symmetric matrix. |

`eigvalsh` |
Computes the eigenvalues of a complex Hermitian or real symmetric matrix. |

`svd` |
Computes the singular value decomposition (SVD) of a matrix. |

`svdvals` |
Computes the singular values of a matrix. |

## Solvers

`solve` |
Computes the solution of a square system of linear equations with a unique solution. |

`solve_triangular` |
Computes the solution of a triangular system of linear equations with a unique solution. |

`lu_solve` |
Computes the solution of a square system of linear equations with a unique solution given an LU decomposition. |

`lstsq` |
Computes a solution to the least squares problem of a system of linear equations. |

## Inverses

`inv` |
Computes the inverse of a square matrix if it exists. |

`pinv` |
Computes the pseudoinverse (Moore-Penrose inverse) of a matrix. |

## Matrix Functions

`matrix_exp` |
Computes the matrix exponential of a square matrix. |

`matrix_power` |
Computes the |

## Matrix Products

`cross` |
Computes the cross product of two 3-dimensional vectors. |

`matmul` |
Alias for |

`vecdot` |
Computes the dot product of two batches of vectors along a dimension. |

`multi_dot` |
Efficiently multiplies two or more matrices by reordering the multiplications so that the fewest arithmetic operations are performed. |

`householder_product` |
Computes the first |

## Tensor Operations

`tensorinv` |
Computes the multiplicative inverse of |

`tensorsolve` |
Computes the solution |

## Misc

`vander` |
Generates a Vandermonde matrix. |

## Experimental Functions

`cholesky_ex` |
Computes the Cholesky decomposition of a complex Hermitian or real symmetric positive-definite matrix. |

`inv_ex` |
Computes the inverse of a square matrix if it is invertible. |

`solve_ex` |
A version of |

`lu_factor_ex` |
This is a version of |

`ldl_factor` |
Computes a compact representation of the LDL factorization of a Hermitian or symmetric (possibly indefinite) matrix. |

`ldl_factor_ex` |
This is a version of |

`ldl_solve` |
Computes the solution of a system of linear equations using the LDL factorization. |

© 2024, PyTorch Contributors

PyTorch has a BSD-style license, as found in the LICENSE file.

https://pytorch.org/docs/2.1/linalg.html