ERROR: UndefVarError: eigvecs not defined

I am trying to follow the examples of the linear algebra documentation:

https://docs.julialang.org/en/v1/stdlib/LinearAlgebra/#Linear-Algebra-1

But when I try to compute the eigenvalues or eigenvectors I get:

ERROR: UndefVarError: eigvecs not defined

I am literally copying and pasting the example into the REPL, so either there it is not clear that some package must be loaded before using these functions, or there is a bug. I am using v1.0

Thank you very much.

It is a stdlib so using LinearAlgebra is first needed. Perhaps that should be more explicit.

1 Like

Thanks Kristoffer. That was indeed the problem.

For newbies like me facing this question: add

using LinearAlgebra

to the code.

I remark that the manual is not clear on that. It says that Julia provides native implementations of many linear algebra functions, and exemplifies with tr(A), det(A), which work out of the box, and then exemplifies with eigvals(A), eigvecs(A), which result in that error.

In other words, it is just that the manual is not clear in the sense that it suggests that the functions are usable out of the box, and does not indicate that a package must be used, and which is the name of the package.

To be clear, I am referring to this page:

https://docs.julialang.org/en/v1/stdlib/LinearAlgebra/#Linear-Algebra-1

Thank you very much again.

I made a PR to the docs: Make `using LinearAlgebra` explicit by stillyslalom · Pull Request #29188 · JuliaLang/julia · GitHub

3 Likes