Hi -

I was just about to propose the multiple ; option.

I think that the most important thing is to support
an easy representation of 2D array literals
(because that is a common case with matrices). I don't
see any reason why supporting ;; to allow 3D and ;;; to
allow 4D array literals is a big deal (or supporting
any number of ; for an arbitrary dimension).

I think that supporting a reshape operation makes sense
too, but isn't sufficient on its own.

Lastly, I want to point out that the array literal syntax
is an important format for doing I/O. I would personally
have the default text format for arrays (or any other
language object) be something you could paste into a
program, but even if it's not the default, you should get
that with writef("%ht", something). I'm saying that if
we don't have a multi-dimensional array literal syntax,
writef("%ht", something) will have to make one up... and
that will be confusing if it's not supported in source code.

-michael

On 02/14/2014 01:49 PM, Brad Chamberlain wrote:
>
> 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
>


------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk
_______________________________________________
Chapel-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/chapel-developers

Reply via email to