2014-04-22 53 views
5

我探索朱莉婭的並行計算,並試圖此:如何爲DArray的元素設置值?

a=dzeros(5);a[1]=5 

只是得到這個錯誤:

setindex! not defined for DArray{{Float64, 1, Array{Float64, 1}} 

嗯,我還以爲說明書上說setindex!DArray全面實施。我錯過了什麼?

我在Windows 32位上使用v0.2.1。

+0

方法(setindex!)說什麼? DArray是否列在列表中的任何位置? –

+0

@JeremyWall我在列表中看到了幾個'DArray',但不知道它們是否支持我想要做的事情。 (我還是不太熟悉Julia的語法。) – xzczd

回答

3

我只是一個探險家,但在閱讀Julia's Distributed Arrays Docs後,我嘗試了這似乎工作。

$ ./julia 
       _ 
    _  _ _(_)_  | A fresh approach to technical computing 
    (_)  | (_) (_) | Documentation: http://docs.julialang.org 
    _ _ _| |_ __ _ | Type "help()" to list help topics 
    | | | | | | |/ _` | | 
    | | |_| | | | (_| | | Version 0.3.0-prerelease+2703 (2014-04-22 18:57 UTC) 
_/ |\__'_|_|_|\__'_| | Commit 942ae42* (0 days old master) 
|__/     | i686-redhat-linux 

julia> versioninfo() 
Julia Version 0.3.0-prerelease+2703 
Commit 942ae42* (2014-04-22 18:57 UTC) 
Platform Info: 
    System: Linux (i686-redhat-linux) 
    CPU: Genuine Intel(R) CPU   T2250 @ 1.73GHz 
    WORD_SIZE: 32 
    BLAS: libopenblas (DYNAMIC_ARCH NO_AFFINITY) 
    LAPACK: libopenblas 
    LIBM: libopenlibm 

julia> a=dzeros(5) 
5-element DArray{Float64,1,Array{Float64,1}}: 
0.0 
0.0 
0.0 
0.0 
0.0 

julia> localpart(a)[1]=5 
5 

julia> a 
5-element DArray{Float64,1,Array{Float64,1}}: 
5.0 
0.0 
0.0 
0.0 
0.0 

julia> 

似乎分佈式數組不是「本地」,直到你讓他們「本地」。

+0

N.B .: DArray的'localpart'需要在它存在的'proc/worker'上進行分配。 – rickhg12hs