Hi Kenjiro --

Just to see if it gets the juices flowing, I believe that one suggestion 
(which I don't get any credit for) was to use multiple consecutive 
"dimensional" separators for higher-dimensional cases.  So for example, a 
2x2x2 array might appear as follows:

        [ 1.11, 1.21;
           2.11, 2.21;;
                            // this space is by convention for readability
           1.12, 1.22;
           2.12, 2.22]


Or, at one point, I think I was espousing using backslash -- can't recall 
offhand whether that resulted in an ambiguity with something else:

        [ 1.11, 1.21 \
           2.11, 2.21 \\
                            // this space is by convention for readability
           1.12, 1.22 \
           2.12, 2.22]


A downside of this is that >2D arrays get a bit ugly; but a 
counterargument might be that code probably rarely contains array literals
>2D or perhaps 3D.  And of course, there's always the reshape-based
approach to fall back on.

-Brad


On Fri, 14 Feb 2014, Kenjiro Taura wrote:

>
> My two cents about multidimensional array literals.
>
> I cannot invent anything brilliant.
>
> For general high-dimensional arrays, I cannot
> think of a solution more elegant than what Chapel
> already has.  Chapel already has a reshape
> operation, allowing:
>
>  var A = reshape([ 1.1, 1.2, 1.3, 2.1, 2.2, 2.3, 3.1, 3.2, 3.3 ],
>                  {1..3,1..3});
>
> It will be a simple matter for a compiler to
> optimize away redundant array creation here.  Any
> proposed literal must be more elegant than this,
> but I cannot think of any.
>
> numpy is also designed along this line.  Arrays
> have reshape method which does exactly what
> Chapel's reshape function does.
>
> For 2D arrays, we may use something along Matlab.
> i.e., something like:
>
> [ 1.1, 1.2, 1.3; 2.1, 2.2, 2.3; 3.1, 3.2, 3.3 ]
>
> but arguably, this is redundant and unnecessary.
>
> To summarize, I am proposing not to propose any,
> but I am happy to be enlightened otherwise.
>
>
>>
>> Chapel Developers --
>>
>> While we're talking about array literals, we need a syntax for
>> multidimensional array literals.  That is, how should I write the
>> conceptual 3x3 array of reals:
>>
>>      1.1 1.2 1.3
>>          2.1 2.2 2.3
>>      3.1 3.2 3.3
>>
>> as Chapel source code?
>>
>> Note that the following:
>>
>>      [[1.1, 1.2, 1.3], [2.1, 2.2, 2.3], [3.1, 3.2, 3.3]]
>>
>> is probably not the right solution as it more logically reads as an array
>> of arrays.  I.e., '[1..3] [1..3] real' rather than '[1..3, 1..3] real'
>>
>> Proposed solutions need to scale to arbitrary dimensions.
>>
>> Thanks!
>> -Brad
>>
>>
>> ------------------------------------------------------------------------------
>> Android apps run on BlackBerry 10
>> Introducing the new BlackBerry 10.2.1 Runtime for Android apps.
>> Now with support for Jelly Bean, Bluetooth, Mapview and more.
>> Get your Android app in front of a whole new audience.  Start now.
>> http://pubads.g.doubleclick.net/gampad/clk?id=124407151&iu=/4140/ostg.clktrk
>> _______________________________________________
>> Chapel-developers mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/chapel-developers
>

------------------------------------------------------------------------------
Android apps run on BlackBerry 10
Introducing the new BlackBerry 10.2.1 Runtime for Android apps.
Now with support for Jelly Bean, Bluetooth, Mapview and more.
Get your Android app in front of a whole new audience.  Start now.
http://pubads.g.doubleclick.net/gampad/clk?id=124407151&iu=/4140/ostg.clktrk
_______________________________________________
Chapel-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/chapel-developers

Reply via email to