in reply to upper or lower triangular matrix to full

With a matrix 460000x460000 and 32bytes per element(scalar+pointer), you would need need over 6.15TB of memory to hold it in Perl.

Even if you used C, and all your values were less than 256, you'd still need 197GB of memory.

Do you have such a machine?


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
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". The enemy of (IT) success is complexity.
In the absence of evidence, opinion is indistinguishable from prejudice. Suck that fhit
  • Comment on Re: upper or lower triangular matrix to full

Replies are listed 'Best First'.
Re^2: upper or lower triangular matrix to full
by savita (Novice) on Sep 04, 2017 at 14:18 UTC
    Unfortunately not! I have a 256GB machine. Thanks for your response, I will check to see if C is an option!

      If you accumulate and discard as you go, you can substantially reduce the memory requirement.

      Ie. (Using 10x10 as an example) After reading the first row, and duplicating the 9 elements to the lower triangle you need storage for 19 elements:

      +---+---+---+---+---+---+---+---+---+---+ | a | b | c | d | e | f | g | h | i | j | +---+---+---+---+---+---+---+---+---+---+ | b'| +---+ | c'| +---+ | d'| +---+ | e'| +---+ | f'| +---+ | g'| +---+ | h'| +---+ | i'| +---+ | j'| +---+

      But then you can print out the first row to the new file and free up that memory leaving only 9 elements in ram.

      You then read the second row, duplicate the 8 elements, and print out the second row to the new file and discard it. And you now have 8x2=16 in memory.

      The peak memory requirement comes when you have read the 5th row, at which point you will have 5x5 =25 elements in the lower triangle cache, and (breifly) the 10 elements of the 5 row before writing it out and discarding it. So rather than 10x10=100 you have a maximum requirement of (n/2)2 + n = (10/2)2+10 = 35.

      Or for your example (460000/2)2 + 460000 = 52,900,460,000 rather than 4600002 = 211,600,000,000 or ~60% less. Still needs a lot of memory, but it might help if your numbers are small enough to allow a C solution.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      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". The enemy of (IT) success is complexity.
      In the absence of evidence, opinion is indistinguishable from prejudice. Suck that fhit