in reply to Fast Matrix Load

Tsk, tsk, Evanovich. As a good acolyte you know that you will get a much more generous response if you show us a little code from your own attempt to address this problem.

Failing that, you might share some of your thinking about why the most obvious solutions might not be the optimum you are looking for...

Also, some information about this file would be helpful. Do you have control over its format? If not, what is the form of the data stored there? It's tough to offer a solution when we don't know what the data looks like or how much freedom there may be in determining its form.

Update: /me smiles encouragingly at Evanovich noting that his solution uses the same basic approach as that of the honorable cLive ;-), differing mostly in the use of intermediate temporary values and a couple inadvertant errors.
 

Replies are listed 'Best First'.
Re: Re: Fast Matrix Load
by Evanovich (Scribe) on Feb 17, 2002 at 03:10 UTC
    Yes yes yes. Okay. I'll give you my code; I'm just embarassed that I can't get a faster time for this very simple operation. Here is what I have:
    my @matrix; my @profile; open PROFILES, "profile/profile.db" or die "$!"; while (<PROFILES>) { @profile = split (/\t/, $_); while ($i <= $#profile) { $matrix[$j]->[$i] = $profile[$i]; $j++; } $i++; $j = 0; }
    Okay dvergin? I know it sucks--I'm having to load the data twice essentially, passing it once into a temporary array. Suggestions would be very very appreciated. Apologies for not giving you my code. Sorry sorry sorry. Your good acolyte, Evan

    Moved end-code tag 2002-02-16 dvergin

      #this is going to take a very long time while ($i <= $#profile) { $matrix[$j]->[$i] = $profile[$i]; $j++; }

        Forever and ever and ever and ever and ever and ever and ever and ever and ever and ever and ever and ever and ever and ever and ever and ever and ever and ever and ever and ever and ever and.........

        cheers

        tachyon

        s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print