slow file loading



On 8/27/2011 12:32 PM, Robert Dodier wrote:
> On 8/22/11, ladida vllt<ladida.vllt at gmail.com>  wrote:
>
>> i have a huge matrix (saved in a file), and i want to load this file, but
>> with the standard load-command this takes nearly 10 min; if i load it from a
>> program (C#) it only takes a few seconds.
>> how can i make the load-command faster?
> If the matrix in question contains only floating point numbers,
> you are probably better off using R or Octave or something like
> that, which are stronger than Maxima for many numerical problems.
>
> If you still want to use Maxima, you could load it once and
> then save it as file of binary floats via write_binary_data.
>
> If you are prepared to do some preprocessing to get the
> original data to load faster, you could reformat (via awk or
> sed or perl or whatever) the original data into Lisp
> and then load that; it would be faster since the Lisp
> parser is probably a lot faster than the Maxima parser.
> I can help with that if you choose to go down that road.
>
> What, exactly, is the content of the data file?
> Perhaps you can show the first few lines.
> And what command, exactly, are you using to load it?
>
> best,
>
> Robert Dodier
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
It's unclear from the original message if the file being loaded was one that
was saved from a previous Maxima, in which case the load process would be
reading LISP,
   or if this was some kind of "batch" file consisting of Maxima language
commands like m[1,1]: 1.223$ m[1,2]: 4.56$  etc.

If it is the latter, then perhaps the file can be edited to consist of lisp,
e.g.

(setq $m (make-array '(2 2) :initial-contents '((1 2)(3 4))))

in which case it would read in at lisp speed.  depending on the lisp,
it could be similar in speed to c# etc.

(this would not be exactly a normal maxima array -- it is zero- based.
that is, m[0,0] is 1.  m[1,1] is 4.

)

It may be the case that what you are computing could be done faster
in a purely-numerical setting, but that is orthogonal to the question
of the speed of reading numbers from a file.