我正尝试使用Julia来处理线性代数问题。文档列出了许多适用于矩阵操作的函数。其中一些可以在运行Julia时直接使用。
julia> ones(2,2)
2×2 Array{Float64,2}:
1.0 1.0
1.0 1.0
有些情况下会出现UndefVarError
的错误提示。
julia> eye(2,2)
ERROR: UndefVarError: eye not defined
Stacktrace:
[1] top-level scope at none:0
为什么我只能访问线性代数部分列出的一些功能?我已经尝试导入LinearAlgebra包,但没有任何区别:https://michaelhatherly.github.io/julia-docs/en/latest/stdlib/linalg.html#Base.LinAlg.expm。
julia> using LinearAlgebra
julia> eye(2,2)
ERROR: UndefVarError: eye not defined
Stacktrace:
[1] top-level scope at none:0
实际上,一些函数现在变得可用了,例如dot
,而根据文档,其他也属于线性代数库的函数仍然会报错:
julia> dot
ERROR: UndefVarError: dot not defined
julia> using LinearAlgebra
julia> dot
dot (generic function with 12 methods)
julia> vecdot
ERROR: UndefVarError: vecdot not defined
以上两个函数在文档中均被列为Base.LinAlg.dot
。
我当前安装的软件包有:
(v1.0) pkg> status
Status `~/.julia/environments/v1.0/Project.toml`
[0c46a032] DifferentialEquations v5.3.1
[7073ff75] IJulia v1.13.0
[91a5bcdd] Plots v0.21.0
[37e2e46d] LinearAlgebra
[2f01184e] SparseArrays
这个问题在线性代数页面上讨论的许多其他函数中也会出现:
julia> repmat([1, 2, 3], 2)
ERROR: UndefVarError: repmat not defined
Stacktrace:
[1] top-level scope at none:0
我已经安装了Julia vs1.01。