Re: Handling a 450,000x450,000 array with Perl
- From: anno4000@xxxxxxxxxxxxxxxxxxxxxx
- Date: 30 Oct 2006 20:29:03 GMT
bugbear <bugbear@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in comp.lang.perl.misc:
francescomoi@xxxxxxx wrote:
Hi.
Thank you very much for your quick answers. I try to handle data from a
450x450 meter surface.
I've got 100,000 elements distributed on this surface, and each
square millimeter can hold one or more elements. So the array to create
is a sparse one: most of square millimeters holds zero elements, and
the rest, 20 or less.
I'm trying to find the square meter with more elements inside.
"The square meter" as in, divide the surface into meter-squares like
a checkerboard and find the one with the most elements? Or as in,
find the one-meter square that holds the most elements? The first
ones must start on integer meter-coordinates, the other can start
anywhere. The second search space is much larger.
Ah. OK.
Your question should really be "what data structure should
I use to..."
It's not really a perl question at all, it's
really an algorithm and data structure question.
There is, however, a likely Perl answer: Use a hash. It is often
the most straight-forward way to represent a sparse anything.
Here one could use blank-separated integer coordinates (in mm) for
keys and the (nonzero) number of elements for values. Values of
zero are *not* entered. Some care may be needed not to autovivify
these non-entries.
Anno
.
- References:
- Handling a 450,000x450,000 array with Perl
- From: francescomoi
- Re: Handling a 450,000x450,000 array with Perl
- From: Ingo Menger
- Re: Handling a 450,000x450,000 array with Perl
- From: francescomoi
- Re: Handling a 450,000x450,000 array with Perl
- From: bugbear
- Handling a 450,000x450,000 array with Perl
- Prev by Date: Re: Handling a 450,000x450,000 array with Perl
- Next by Date: Re: Interesting behaviour with lexical variable
- Previous by thread: Re: Handling a 450,000x450,000 array with Perl
- Next by thread: Re: Handling a 450,000x450,000 array with Perl
- Index(es):
Relevant Pages
|