Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set values to the elements of DArray?

Tags:

julia

I'm exploring the parallel computing of Julia and tried this:

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

but just got this error:

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

Well, I thought the manual said setindex! is fully implemented by DArray. What have I missed?

I was using v0.2.1 for Windows 32-bit.

like image 588
xzczd Avatar asked Sep 30 '22 23:09

xzczd


1 Answers

I'm just an explorer too, but after reading Julia's Distributed Arrays Docs, I tried this which seemed to work.

$ ./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> 

It seems that distributed arrays aren't "local" until you make them "local".

like image 137
rickhg12hs Avatar answered Oct 13 '22 10:10

rickhg12hs