朱莉娅中的线性代数

5

我正尝试使用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。


3
"eye" 现在改为 "LinearAlgebra.I"。 - phipsgabler
1个回答

8
您链接的文档不是官方文档,官方文档可以在docs.julialang.org找到。您链接的文档是某个开发者网站上的旧版本。这就是它与当前的Julia不一致的原因。

我已经提交了一个问题(https://github.com/MichaelHatherly/julia-docs/issues/1),请求Michael删除这个存储库,以避免将来的混淆。 - Milan Bouchet-Valat

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接