On Thu, 8 Sep 2011, Sven Schreiber wrote:
As a general remark, matrix operations are usually faster if you
work
with the entire matrix (or vector) in one go, because the actual
calculations are then handed over to compiled C code in the background.
If you do element-by-element operations, I don't see any reason to
expect higher speed. Plus, in this case you're mixing series (x) and
matrices (example2). My speculation would be that it's slower because
gretl has to figure out what you want to do and if that's really
syntactically correct.
That's right. The operation Artur mentions, namely assigning a
scalar value to a single element of a matrix, is a special
case of assignment to a sub-matrix, which has the general
form:
M[r1:r2,c1:c2] = <expression>
where the r's and c's are expressions that evaluate to row and
column indices. This demands a lot more parsing effort than
assigning a scalar value to a place in a series (where the
only valid specifier on the left is a single observation
number).
We could maybe write a dedicated, faster function for the
special case, but even then we first have to figure out that
we're actually in that special case.
Allin