On Sun, 11 Jan 2015, Sven Schreiber wrote:
Hello,
this time no bug report but a feature request.
I think there is a pretty obvious feature that's missing and that's
enabling conversion from matrices to lists, to facilitate roundtripping
list - matrix - list. What I have in mind is something like this workaround:
<hansl>
function list mat2list(matrix inmat)
list lout = null # initialize
loop i=1..cols(inmat)
series stemp = inmat[,i]
list lout += stemp
endloop
return lout
end function
</hansl>
For the direction list-to-matrix we have the wonderful {} syntax, and
section 15.9 describes how to do matrix-to-series. So why not
matrix-to-list?
Well, a problem I see with is that list elements are series you ought to
give a name to. I guess you could call the X1, X2 and so forth, or
otherwise you could supply a second "strings" argument.
The thing is that currently lists and matrices in gretl are
complementary; you cannot use matrices in estimation commands for
example, and you cannot apply many calculations to lists.
The good thing about matrices is that you're free from the tyranny of
$nobs. Also, don't forget that we have lincomb(), which I find very
useful, plus a host of other functions for lists, such as nelem(), sum(),
sd(), max(), min() etc.
So I think we need to ensure quick and easy conversion from one type
to
the other. In terms of syntax, I wouldn't mind an explicit function
like mat2list() above, to be built-in. What do you think?
I don't know, I can't see myself using this a lot, but maybe it's just me.
-------------------------------------------------------
Riccardo (Jack) Lucchetti
Dipartimento di Scienze Economiche e Sociali (DiSES)
Università Politecnica delle Marche
(formerly known as Università di Ancona)
r.lucchetti(a)univpm.it
http://www2.econ.univpm.it/servizi/hpp/lucchetti
-------------------------------------------------------