如何设置DArray元素的值?

时间:2014-04-22 13:36:38

标签: julia

我正在探索朱莉娅的并行计算,并尝试了这个:

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

但是出现了这个错误:

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

好吧,我认为手册说setindex!完全由DArray实施。我错过了什么?

我正在使用v0.2.1 for Windows 32位。

1 个答案:

答案 0 :(得分:4)

我也只是一名探险家,但在阅读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> 

似乎分布式阵列不是本地的"直到你制作它们"本地"。