465b
465b

Reputation: 1277

How do I import/call "subpackages" of packages?

I am trying to use a function from LinearAlgebra.jl which is definde in the dense.jl file.

I expected it to be loaded with using LinearAlgebra, since it is a part of the LinearAlgebra package (julia/stdlib/LinearAlgebra/src/dense.jl). However, this seem not to be the case. Calling a function from dense.jl throws an "UndefVarError" while functions from the main LinearAlgebra.jl file work fine.

So: How do I import/call functions from a "subpackage"?

Upvotes: 3

Views: 358

Answers (1)

Bill
Bill

Reputation: 6086

The answer varies depending on whether the function is part of a separate module. However, in this case you may be able to prepend "LinearAlgebra." to the function name, since the problem may just be that the function was not exported by default into your namespace by the LinearAlgebra module:

julia> using LinearAlgebra

julia> isone
isone (generic function with 13 methods)

julia> _isone_cachefriendly
ERROR: UndefVarError: _isone_cachefriendly not defined

julia> LinearAlgebra._isone_cachefriendly
_isone_cachefriendly (generic function with 1 method)

Upvotes: 3

Related Questions