初学Julia,处理一段老程序:
以前在0.3版本中有很多矩阵操作的函数找不到了,不知道如何处理?加了线性代数库也没有找到呢。。。
比如atan2,生成单位矩阵的eye,还有——
indmin(返回集合中最小值的索引号)
unshift!(在集合前端插入元素)
请大拿们帮忙支招,非常感谢!
建议看一遍文档,0.3版本太古老了
下个 0.7 不少函数 0.7 都会提示你废弃后该用哪个。
julia> atan2(1.0,2.0)
┌ Warning: `atan2(y, x)` is deprecated, use `atan(y, x)` instead.
│ caller = top-level scope at none:0
└ @ Core none:0
0.4636476090008061
julia> eye(1)
WARNING: Base.eye is deprecated: it has been moved to the standard library package `LinearAlgebra`.
Add `using LinearAlgebra` to your imports.
in module Main
┌ Warning: `eye(m::Integer)` has been deprecated in favor of `I` and `Matrix` constructors. For a direct replacement, consider `Matrix(1.0I, m, m)` or `Matrix{Float64}(I, m, m)`. If `Float64` element type is not necessary, consider the shorter `Matrix(I, m, m)` (with default `eltype(I)` `Bool`).
│ caller = top-level scope at none:0
└ @ Core none:0
1×1 Array{Float64,2}:
1.0
julia> indmin([1])
┌ Warning: `indmin` is deprecated, use `argmin` instead.
│ caller = top-level scope at none:0
└ @ Core none:0
1
help?> unshift!
search: unshift!
No documentation found.
Base.unshift! is a Function.
# 1 method for generic function "unshift!":
[1] unshift!(args...) in Base at deprecated.jl:29
julia> unshift!(1)
┌ Warning: `unshift!` is deprecated, use `pushfirst!` instead.
│ caller = top-level scope at none:0
└ @ Core none:0
ERROR: MethodError: no method matching pushfirst!(::Int64)
2 个赞
太赞了 版本更新竟然有迹可循,感谢大神还帮忙实践了一下!
确实太古老,调试问题超多,哭了
再次感谢大佬,其他函数替换都OK,刚发现就剩一个shift!,好像是删除操作,在1.0不知道被替换成了什么。请问下您能帮忙看看吗?
┌ Warning: `shift!` is deprecated, use `popfirst!` instead.
│ caller = top-level scope at none:0
└ @ Core none:0
非常感谢,您也是0.7版上找到的吗?