rajaguha has asked for the wisdom of the Perl Monks concerning the following question:
Hello,
I need an implementation of a sparse array. If the searched key/index does not exist, it needs to return the immediately higher and immediately lower keys/indexes. I also need it to be able to nest to any depth.
I am trying to implement this using a hash coupled with an array containing the keys in sorted order. This can then be packaged as a tied array. I also want to get clever with the search on the hash keys stored in the array. Provision for a user-defined subroutine to return interpolated values is also possible.
But I am wondering if someone has not written something like it already. CPAN searches have failed so far.
Any comments on ways to improve my implementation will also be greatly appreciated.
Thanks
----
(Please YELL if updating the original post is not the done thing.)
Thanks everyone - much food for thought and some very interesting modules.
I will take GrandFather's advice and post the code when ready. For now, I am updating just to state the motivation for the effort.
The original thought was to create a structure for storage and querying of large data sets from experiments having multiple input variables and a single result from each run. The input variables could be reals, integers or even strings(to accommodate categories). For now, I am presuming the output to be a real.
Not only should we be able to return results for the previously loaded combinations(like any db can) but, once 'enough' data is fed in, we should also return approximate results for combinations with intermediate values (for numeric variables) through interpolation.
One can use simple linear interpolation, allow the user to supply some subroutine based on her/his knowledge of the data or get fancy w/ non-linear regression, even try to derive an equation from the data.
But fancy for later. Just the data structure for now.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Sparse Array
by Your Mother (Archbishop) on Jul 24, 2011 at 06:03 UTC | |
|
Re: Sparse Array
by GrandFather (Saint) on Jul 24, 2011 at 05:19 UTC | |
|
Re: Sparse Array
by AnomalousMonk (Archbishop) on Jul 24, 2011 at 05:30 UTC | |
|
Re: Sparse Array
by Anonymous Monk on Jul 24, 2011 at 06:06 UTC | |
|
Re: Sparse Array
by etj (Priest) on May 26, 2022 at 14:03 UTC | |
|
Re: Sparse Array
by Khen1950fx (Canon) on Jul 24, 2011 at 07:00 UTC | |
|
Re: Sparse Array
by jdporter (Paladin) on Jul 25, 2011 at 17:09 UTC | |
|
Re: Sparse Array
by JavaFan (Canon) on Jul 25, 2011 at 14:29 UTC | |
by BrowserUk (Patriarch) on Jul 25, 2011 at 15:32 UTC |