Skip to content

Symmetric eigen memory usage for eigenvectors. #1425

@m-a-stewart

Description

@m-a-stewart

Commit 57e9a0d to reduce allocations in syevr! seems to have a potential negative impact on the method

eigen(A::RealHermSymComplexHerm, vl::Real, vh::Real)

when the interval is such that a small number of eigenvalues/vectors are returned. The resizing and reshaping of the storage passed to LAPACK in syevr! means that space for an $n\times n$ eigenvector matrix is retained even if only a few eigenvectors are returned. This can be painful for large matrices.

With 1.12.0-rc1 the following code illustrates this:

using LinearAlgebra

n = 2000
A = Hermitian(randn(n,n))
e, V = eigen(A)
println("All eigenvectors:")
@show size(V)
@show Base.summarysize(V)

println("\nEigenvectors in [-1,1]:")
e1, V1 = eigen(A, -1, 1)
@show size(V1)
@show Base.summarysize(V1)

println("\nEigenvectors in [-1,1], copied:")
V1 = copy(V1)
@show size(V1)
@show Base.summarysize(V1)

The output is:

All eigenvectors:
size(V) = (2000, 2000)
Base.summarysize(V) = 32000048

Eigenvectors in [-1,1]:
size(V1) = (2000, 30)
Base.summarysize(V1) = 32000048

Eigenvectors in [-1,1], copied:
size(V1) = (2000, 30)
Base.summarysize(V1) = 480048

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions