Hi Chris --
The way the language was designed, this pattern is supported, but that
support has never been implemented. In the STATUS file, this is noted
as:
- Arrays of arrays where the inner arrays vary in size are not supported.
and we often refer to this as lack of support for skyline arrays.
However, there is a workaround.
First, to capture how this is supposed to work in the language, it is:
var stuff: [loc in locdom] [1..f(loc)] thing;
or:
var stuff: [loc in locdom] [D[loc]] thing;
That is: name the index in the outer array declaration (e.g., 'loc') and
then use it in the inner array declaration (here I've either used it to
compute a high bound for a 1D array or to name an element from an array of
domains -- more generally you could do any other expression with it).
The workaround, since this it not working today, is to wrap that inner
array in a record. For example, you should be able to get the first
example above as follows:
record R {
var size;
var data: [1..size] thing;
}
var stuff: [loc in locdom] R(size=loc);
Then, if you add an accessor function to the record (a 'these' function)
that indexes into 'data', you can access the 'stuff' array as though it
were a 2D array, permitting you to write:
stuff[i][j]
rather than:
stuff[i].data[j]
Hope this helps,
-Brad
On Thu, 5 Dec 2013, Chris Doris wrote:
> Hello all,
>
> Sorry if this is a stupid question, but how to I make a distributed array
> of arrays (*not* a 2-dimensional array)? For instance, I want an array for
> each locale (not the same size on each locale), and I want these stored in
> an array which is distributed round-robin. Something like:
>
> var locdom = {1..numLocales} dmapped Cyclic(1);
> var stuff: [locdom][???] thing;
>
> Except that it's not obvious what ??? should be, given that it needs to be
> a different domain for each index in locdom.
>
> Considering that the domain forms part of the type of the array, I'm now
> wondering if it's even syntactically possible?
>
> Of course, you can achieve a similar thing with an array of Vectors instead.
>
> Chris
>
------------------------------------------------------------------------------
Sponsored by Intel(R) XDK
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk
_______________________________________________
Chapel-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/chapel-users