Question: Indexing and storage of higher dimensional structured arrays


As an example, the two-dimensional Array created by

A := Array(triangular[upper], 1..100, 1..100);

has both indexing function and storage "triangular[upper]", which is fine. However, the attempt

B := Array(triangular[upper], 1..100, 1..100, 1..100);

to make a three-dimensional analogue did not work: It returns "Error, triangular[upper] indexing is only valid with 2 dimensions". A similar error message is returned when I replace "triangular[upper]" by "symmetric".

(For definiteness, by a higher-dimensional symmetric Array I would like to understand an Array with entries that are invariant under every permutation of their indices. Similarly, I would call the Array upper-triangular if only its entries with non-decreasing indices can be non-zero.)


For a first solution attempt, I mimic a higher dimensional upper-triangular Array by instead creating a multiply nested one-dimensional Array, where the one-dimensional subarrays become shorter and shorter. I did some preliminary testing with CodeTools[Usage] and the memory and timing results seem to compare favorably to naively using standard rectangular Arrays.

It seems more natural to write my own indexing function. However, I am not sure how to write a suitable corresponding storage function, as the documentation on that latter subject mentions only Vectors and Matrices. Is it possible and advisable to write my own storage function, or is there yet another more natural and memory-efficient way to store higher-dimensional structured Arrays (with symbolic data) in Maple? 

Thank you very much for any insights, particularly documentation pointers.

Sebastiaan Janssens.


Please Wait...