> OK, for the moment, this means multiple dimension arrays cannot really be
> initialized unless one wants the overhead of reshapes which it would seen
"Can't be initialized via an array literal", yes. Personally, I wouldn't
use a reshape() in this context unless I was absolutely desparate.
Multidimensional arrays can be initialized via other means, for example:
const A: [1..m, 1..n] real = [(i,j) in {1..m, 1..n}] f(i,j);
// ^^^ this is a sugared forall expr
or, they can be initialized after their declaration point:
var A: [1..m, 1..n] real;
forall (i,j) in {1..m, 1..n} do
A[i,j] = ...; // or infile.read(A[i,j]) or ...
(where a truly lame form of the previous might be to assign a temporary
array of arrays to a 2D array...).
I don't believe there are many instances where Chapel currently optimizes
a 'const' array better than a 'var' array, so initializing outside of the
declaration context as described here shouldn't result in penalties that
I'm aware of (other than the syntactic overhead/hassle).
> Is there any overhead for an array of arrays compared to multidimensional
> arrays?
Yes, in terms of memory, a multidimensional array will be stored compactly
compared to an array of arrays (which will give you an array of array
descriptors, each of which points off to its own elements).
That said, in terms of loops, our multidimensional loop nests can
sometimes be less efficient than single-dimensional loop nests,
particularly when zippering is used.
I usually recommend using a multidimensional array if the problem space
that it's describing is logically multidimensional.
-Brad
------------------------------------------------------------------------------
BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
Develop your own process in accordance with the BPMN 2 standard
Learn Process modeling best practices with Bonita BPM through live exercises
http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_
source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF
_______________________________________________
Chapel-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/chapel-users