From r.lucchetti@univpm.it Thu Nov 26 15:55:14 2009 From: Riccardo (Jack) Lucchetti To: gretl-devel@gretlml.univpm.it Subject: Re: [Gretl-devel] store or mwrite solution Date: Thu, 26 Nov 2009 21:55:10 +0100 Message-ID: In-Reply-To: Pine.A41.4.58.0911261157300.250078@f1n11.sp2net.wfu.edu MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============6719081769850858131==" --===============6719081769850858131== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit On Thu, 26 Nov 2009, Allin Cottrell wrote: > > On Thu, 26 Nov 2009, Ignacio Diaz-Emparanza wrote: > >> I need to save in each iteration of a long loop an, in principle, >> unknown number of scalars. I tried saving all them in a matrix and >> writing it to disk with 'mwrite', but this is very time consuming >> because the matrix is very big... > > You could try something like: > > set messages off > set echo off > outfile scalars.txt --write > loop i=1..n -q > printf "%.15g\n", some_scalar > endloop > outfile --close or perhaps It's possible to implement the "append" solution, but IMO there are a few disadvantages: first, the format we use for storing matrices is such that the first row of the file contains the muber of rows and columns, so we'd have to read that, update it and then do the actual append. Doable, but ugly. Second, what's supposed to happen if you try to append a matrix with n columns to a matrix with m columns when m!=n? Riccardo (Jack) Lucchetti Dipartimento di Economia Università Politecnica delle Marche r.lucchetti(a)univpm.it http://www.econ.univpm.it/lucchetti --===============6719081769850858131==--