On Wed, 6 Jan 2016, Jan Tille wrote:
Hello to all and a (maybe late) Happy New Year.
I have a problem saving the contents of matrix into a file .
Sven pointed to the mwrite() function, which is the right tool for
the job here, but I thought it was worth investigating the other
options you tried.
I used the tiny script:
outfile "matrix_test.txt" --write
printf "%#24.10g", test
outfile --close
While the matrix in Gretl is 497 x 1317 the printed matrix
contains the first 133 rows only.
Using gretl from current git on Linux I'm not able to replicate
this. Here's my test script:
<hansl>
matrix M = mnormal(497, 1317)
scalar n1 = onenorm(M)
scalar i1 = infnorm(M)
outfile "matrix_test.txt" --write
printf "%#24.10g", M
outfile --close
open matrix_test.txt --quiet
matrix M2 = {dataset}
scalar n2 = onenorm(M2)
scalar i2 = infnorm(M2)
</hansl>
I create a random matrix (M) of the size you specified, write it out
to a text file using "outfile" and "printf", then read it back in as
a dataset, convert it back to a matrix (M2), and compare the 1- and
infinity-norms of the two matrices. These values agree (and the txt
file has 497 lines).
I have alternatively tried a right click on the matrix and use the
"save as csv" option (with decimal separator set to ","). Pasting
this into Excel, gives me 406 rows.
This is more problematic. The results may differ by platform, and
also by the application into which one attempts to paste the data.
I again created a 497 x 1317 random matrix, chose "Copy as CSV" in
the gretl icon view, then tried pasting into:
1) Libreoffice calc: 90 rows were imported, after which Libreoffice
said "The contents of the clipboard could not be pasted".
2) Gnumeric: recognized that the clipboard data offered 497 rows,
then proceeded to use 100% CPU for about 5 minutes, eventually
saying "Invalid Pasting: is beyond sheet boundaries".
3) Nedit text editor: pasted 11 rows, no error message.
4) Gedit text editor: pasted all 497 rows quite quickly.
When I scaled down to a 32 x 32 matrix all the above applications
pasted all the data without complaint or delay.
The moral here seems to be: don't try copy-and-paste on big matrices
unless you're sure the target application is able to handle the
incoming data. In my testing only Gedit worked correctly.
All the tests above were carried out several times, and while the
differences across applications seem "random", nonetheless the
results appear to be deterministic: each application behaved in
exactly the same way on each trial.
Allin Cottrell