Consider that we have defined the array below in Chapel:
var arr : [1..10] [1..5] int;
How to get the size of the dimensions of this array? In other words, I need a procedure that gets arr as the input and gives (10,5) as the output.
To get its second dimension, I used arr.domain.dim(1).size, but it gave me an error.
A potential misunderstanding here is that your array:
is technically not a multidimensional array in Chapel; rather it is a 1D array whose elements are each 1D arrays. So to get the size of one of its inner arrays, you would need to take the size of an element as follows (ATO):
This solution assumes that the arrays are 1D since we're using
size, which will return the total number of elements in an array.A multidimensional array in Chapel looks like this:
and you could determine its dimensions' sizes using one of these queries (ATO):