Comment has asked for the wisdom of the Perl Monks concerning the following question:
Thank you all in advance for your help!
It seems that I have setup an overly complicated multidimensional associated array and I was wondering if I could get some suggestions on how to simplify my data structure. If it turns out that I cannot simplify my multidimensional array, than I was hoping to get a few tips on how to work with this data. Here is a bit of background on the situation:
BACKGROUND- I have multiple data sets each containing points in 3D space. I have gone ahead and calculated all of the possible distances between any two points between and within each data set. For example (using set notation), let's say I have Set1 = {a,b,c}, Set2 = {d,e,f,g}, and Set3 = {h,i} (unfortunately, in real life the points do not have unique identifiers relative to other sets; for example, the identifier for "a","d", and "h" would all be "1" and the identifier for "b","e", and "i" would all be "2"). I believe I have setup a hash of hashes of hashes of hashes to hold my data. Therefore, the distance between "a" and "d" would be held in $matrix{set1}{a}{set2}{d}, the distance between "h" and "i" would be held in $matrix{set3}{h}{set3}{i}, and so on. I should also note that distances are not redundant. Therefore, I have stored the distance from "a" to "b" but not from "b" to "a". I have also not calculated the distance between a point and itself (i.e. from "a" to "a" or "b" to "b"). This was done to save memory and calculation time.
GOAL- I would like to print out an Excel file that contains all of the distances between the points of any two sets. Therefore, I would like to have a file containing Set1 vs. Set2. Using set notation, the Set1vSet2.xls would contain {AD,AE,AF,AG,BD,BE,BF,BG,CD,CE,CF,CG} where AD represented the distance between point "a" and point "d". Ultimately, I would like to have every combination of sets: Set1vSet1.xls, Set1vSet2.xls, Set1vSet3.xls, Set2vSet2.xls, Set2vSet3.xls, and Set3vSet3.xls.
WHERE I AM NOW- Here is some pseudocode on how I think this could work:
I think this code would loop through the entire matrix and print out the necessary point in the correct files. Unfortunately, I'm not sure how to implement this with my current data structure setup.foreach firstSet { foreach firstPoint { foreach secondSet { foreach secondPoint { print distance to firstSetVsecondSet.xls } } } }
I hope I have made this as clear as possible. Please let me know if I can explain anything further. Many many thanks for your help!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Hash of Hashes of Hashes of Hashes
by BrowserUk (Patriarch) on Sep 30, 2010 at 20:28 UTC | |
|
Re: Hash of Hashes of Hashes of Hashes
by muba (Priest) on Oct 01, 2010 at 01:18 UTC | |
by Comment (Novice) on Oct 01, 2010 at 12:50 UTC |