Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Efficient way of reading matrices

  • To: mathgroup at smc.vnet.net
  • Subject: [mg85291] Re: Efficient way of reading matrices
  • From: "Szabolcs HorvÃt" <szhorvat at gmail.com>
  • Date: Tue, 5 Feb 2008 06:09:22 -0500 (EST)
  • References: <fo3gad$b3p$1@smc.vnet.net>

In Feb 5, 2008 7:22 AM,  <m.r at inbox.ru> wrote:
>
> Hi Szabolcs,
>
> maybe you can read and pack your matrix row by row:
>
> WriteString["/zzz", Sequence @@ Riffle[#, " "], "\n"]& /@
>   RandomInteger[{-1000, 1000}, {200, 250000}]
> Close["/zzz"]
>  (*a test file*)
>
> (m = Developer`ToPackedArray@ Read["/zzz",
>   Array[Number&, 250000]]& /@ Range[200];) // Timing
> Close["/zzz"]
>

Thanks you Maxim Rytin,

Good and useful suggestion, as always. :-)  I have already written a
MathLink matrix reader program to do the work, but your program
(though slower) uses even less memory as it never needs to store two
copies of the complete matrix in memory.

Szabolcs Horvát



  • Prev by Date: Re: pattern matching against the Dt function?
  • Next by Date: Re: Accessing the contents of the clipboard
  • Previous by thread: Re: Efficient way of reading matrices
  • Next by thread: Re: Efficient way of reading matrices