首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Julia MethodError数组Int64

Julia MethodError数组Int64
EN

Stack Overflow用户
提问于 2019-06-07 03:16:43
回答 1查看 314关注 0票数 0

在我试图调试和解决的一些代码中,我遇到了我的下一个障碍。

代码语言:javascript
复制
ERROR: LoadError: MethodError: no method matching Array(::Type{Int64}, ::Int64)
Closest candidates are:
  Array(::LinearAlgebra.UniformScaling, ::Integer, ::Integer) at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.1\LinearAlgebra\src\uniformscaling.jl:345

我查看了提供的材料,它看起来数组定义可能已经更改为使用arrArray{Int64,0} ...但这些似乎对我也不起作用。有什么建议吗?提前谢谢你!

代码语言:javascript
复制
    # Puts the output of one lineup into a format that will be used later
    if status==:Optimal
        data_lineup_copy = Array(Int64, 0)
        for i=1:num_data
            if getValue(data_lineup[i]) >= 0.9 && getValue(data_lineup[i]) <= 1.1
                data_lineup_copy = vcat(data_lineup_copy, fill(1,1))
            else
                data_lineup_copy = vcat(data_lineup_copy, fill(0,1))
            end
        end
        for i=1:num_shot
            if getValue(shot_lineup[i]) >= 0.9 && getValue(shot_lineup[i]) <= 1.1
                data_lineup_copy = vcat(data_lineup_copy, fill(1,1))
            else
                data_lineup_copy = vcat(data_lineup_copy, fill(0,1))
            end
        end
        return(data_lineup_copy)
    end
end
    data1 = Array(Int64, 0)
    data2 = Array(Int64, 0)
    data3 = Array(Int64, 0)
EN

回答 1

Stack Overflow用户

发布于 2019-06-07 03:48:52

Array(Int64, 0)会在旧版本(可能是0.6版本之前)上创建一个空的Int64 1D数组(即Vector)。

现在,要创建一个空的Int64 1D数组,您可以使用以下任一命令

代码语言:javascript
复制
data1 = Array{Int64, 1}(undef, 0) # where `1`, the second type parameter is for the dimension
data1 = Array{Int64}(undef, 0)
data1 = Vector{Int64}(undef, 0)
data1 = Vector{Int64}()
data1 = Int64[]

您可以随时参考官方文档,了解Julia中array construction的不同方式。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56483786

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档