Julia: printing of fields in `Eigen` object is a bit misleading

Created on 25 Sep 2019  ·  4Comments  ·  Source: JuliaLang/julia

When an Eigen object is printed it looks like this:

Eigen{Float64,Float64,Array{Float64,2},Array{Float64,1}}
eigenvalues:
3-element Array{Float64,1}:
 -0.6562995480576438 
  0.06506689775753571
  3.7913044805801173 
eigenvectors:
3×3 Array{Float64,2}:
  0.488029  -0.499967   -0.715444
 -0.811934   0.0407496  -0.582325
  0.320298   0.865085   -0.386053

It says eigenvalues and eigenvectors, but the fields are actually called values and vectors, so I think it should print that instead.

display and printing linear algebra

Most helpful comment

No, the idea was the opposite: simply to change the printing to values and vectors so it displayed how it is accessed. I'd wager that the folks who know to use eigen in the first place are very well aware they're getting eigenstuff back.

All 4 comments

I think Eigen objects may be strange at first to new users, but printing “eigenvalues” and “eigenvectors” makes it very clear about what they contain. I wonder if the field names could change instead? (Or have getproperty aliases or something like that to be non-breaking)

@mbauman Just to make sure that I understand this issue correctly. Consider this code:

julia> using LinearAlgebra

julia> F = eigen(randn(3,3));

julia> F.values
3-element Array{Complex{Float64},1}:
 -0.7545639338662014 + 0.0im
 -0.2767164575597549 - 1.847143023327968im
 -0.2767164575597549 + 1.847143023327968im

julia> F.vectors
3×3 Array{Complex{Float64},2}:
 -0.00563199+0.0im  -0.277793-0.465756im  -0.277793+0.465756im
    0.857794+0.0im  0.0942419-0.491659im  0.0942419+0.491659im
    0.513963+0.0im  -0.674753-0.0im       -0.674753+0.0im

You would like to change the field names, so that we can access the eigenvalues by F.eigenvalues
and the eigenvectors by F.eigenvectors?

I guess replacing them is not a good idea, because that would be a breaking change, isn't it? But they could certainly be added.

No, the idea was the opposite: simply to change the printing to values and vectors so it displayed how it is accessed. I'd wager that the folks who know to use eigen in the first place are very well aware they're getting eigenstuff back.

@mbauman Thanks for making this clear.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dpsanders picture dpsanders  ·  3Comments

felixrehren picture felixrehren  ·  3Comments

TotalVerb picture TotalVerb  ·  3Comments

ararslan picture ararslan  ·  3Comments

StefanKarpinski picture StefanKarpinski  ·  3Comments