
December 29th, 2007, 02:10 AM
|
 | Grand Panjandrum | | Join Date: Nov 2005 Location: South of England
Posts: 11,379
Country: Thanks: 667
Thanked 3,619 Times in 2,916 Posts
| |
Quote:
Originally Posted by SoftwareTester As i think my problem is a mathematical one I post it here, if I should be somewhere else please tell me where.
I have a multiple array (5 or 6 dimensions each being of same size) where only elements with different indexcombinations are being filled (i.e. if element [1,2,3,4,5,6] being filled element [6,5,4,3,2,1] will NOT be filled) so I want to store all elements of such a multiple array in a lineairarray and compute the indexes for each element as it saves a lot of memory.
in code
N = 20; // maximum number of an element in each dimension
MaxIndex= N * ((N+1)/2) * ((N+2)/3) * ((N+3)/4) * ((N+4)/5) * ((N+5)/6);
long[] Array = new long [MaxIndex];
[snip]
| Why do you think MaxIndex is this (  ), rather than say:  ?
(I would consider using some other type of structure for this data, maybe a linked list
with each record holding the indices and the value)
RonL
__________________ Truth does not change because it is, or is not, believed by a majority of the people.
Giordano Bruno |