You might consider using PDL. Piddles use far less space than normal Perl arrays. Also (I think; you'll need to explore it or consult an PDL expert), it would be able to combine the two piddles into a third using it's Dataflow feature, in a way that would not cause them to be copied wholesale and therefore, would use even less space.

In theory, assuming your numbers are 32-bit ints, a piddle would require ~1/3 or 1/4 the space of an equivalent Perl array. And, if the Dataflow aliasing will work to allow you create the 3rd array as an mapping over the other two, it possible the memory requirement for holding all 3 piddles could be close to 1/6 th of the space required by the Perl solutions. PDL is also renowned for doing what it does very quickly.

Sorry for the scant information, but I really don't know much about PDL, so take this suggestion with a huge handful of salt.

With luck lin0 or Zaxo or one of the other monks with PDL expertise will read this and expand further or shoot me down in flames.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

In reply to Re: Expanding Two demensional arrays by BrowserUk
in thread Expanding Two demensional arrays by pigal

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.