On Sun, 13 Oct 2019, Marcin Błażejowski wrote:
On 12.10.2019 22:01, Allin Cottrell wrote:
> First, gretl matrices are in column-major order: column elements are
> adjacent in memory, row elements are separated by the number of rows
> in the matrix. So go by columns whenever possible.
Ok, Does it mean that if I have a matrix which I expand by adding new
"tuples" I should append these tuples as new columns instead of new rows?
If you have the choice then Yes, it should be cheaper to add columns
rather than rows.
> Second, one should uses ranges rather than single-element
indices
> whenever possible. If the data in the given range are contiguous in
> memory, libgretl will use the C library's memcpy() to copy a chunk of
> data in one call.
I know. I just wanted to replicate an example I mentioned at the
beggining of my email, because people discovered that gcc was able to
'vectorize' only "a[i,j] = b[i,j]" copying (i.e. load the chunks of
matrixes into YMM/XMM registers and call specific AVX functions on it).
OK, but hansl is not C ;-). I mean, gcc doesn't get to see your hansl
script, it only gets to look at the libgretl code -- and libgretl uses
the faster memcpy only for contiguous chunks of data in a matrix copy
operation.
Allin