A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.pytorch.org/docs/stable/generated/torch.linalg.eigvalsh.html below:

torch.linalg.eigvalsh — PyTorch 2.8 documentation

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

Letting K \mathbb{K} K be R \mathbb{R} R or C \mathbb{C} C, the eigenvalues of a complex Hermitian or real symmetric matrix A ∈ K n × n A \in \mathbb{K}^{n \times n} AKn×n are defined as the roots (counted with multiplicity) of the polynomial p of degree n given by

p ( λ ) = det ⁡ ( A − λ I n ) λ ∈ R p(\lambda) = \operatorname{det}(A - \lambda \mathrm{I}_n)\mathrlap{\qquad \lambda \in \mathbb{R}} p(λ)=det(AλIn)λR

where I n \mathrm{I}_n In is the n-dimensional identity matrix. The eigenvalues of a real symmetric or complex Hermitian matrix are always real.

Supports input of float, double, cfloat and cdouble dtypes. Also supports batches of matrices, and if A is a batch of matrices then the output has the same batch dimensions.

The eigenvalues are returned in ascending order.

A is assumed to be Hermitian (resp. symmetric), but this is not checked internally, instead:

Note

When inputs are on a CUDA device, this function synchronizes that device with the CPU.

Parameters
Keyword Arguments

out (Tensor, optional) – output tensor. Ignored if None. Default: None.

Returns

A real-valued tensor containing the eigenvalues even when A is complex. The eigenvalues are returned in ascending order.

Examples:

>>> A = torch.randn(2, 2, dtype=torch.complex128)
>>> A = A + A.T.conj()  # creates a Hermitian matrix
>>> A
tensor([[2.9228+0.0000j, 0.2029-0.0862j],
        [0.2029+0.0862j, 0.3464+0.0000j]], dtype=torch.complex128)
>>> torch.linalg.eigvalsh(A)
tensor([0.3277, 2.9415], dtype=torch.float64)

>>> A = torch.randn(3, 2, 2, dtype=torch.float64)
>>> A = A + A.mT  # creates a batch of symmetric matrices
>>> torch.linalg.eigvalsh(A)
tensor([[ 2.5797,  3.4629],
        [-4.1605,  1.3780],
        [-3.1113,  2.7381]], dtype=torch.float64)

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4