To answer your exact question pack() and unpack() will let you read and write doubles. Look it up in your favorite Perl book, do a search here, then try testing things in the debugger.

If you are writing binary files you should use binmode() like:

open(BINM,"<:raw"); binmode(BINM); read(BINM,$number,64);

It will not have any effect if you don't need it but will save your bacon if you do.

If your matrix is too big for your system's memory then I would have thought that doing things via files would take way too long. I would suggest that a carefull examination of the problem you are trying to solve is in order.

If you still want to transpose in files remember that there are many ways to do it, for example if you split the matrix into four quarters, transpose each of them and then combine them in the right order you may find that efficiency can be improved. This problem is the same as reflecting a bitmap image around a diagonal, I'll bet that some of the image processing books have some neat tricks you should look at (the last time I did any low level raster stuff was almost 10 years ago).


In reply to Re: Binary file handling by hawtin
in thread Binary file handling by Hena

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.