I see that I have to declare function scalar inner(matrix *a) rather than inner(matrix a) in the pointer case. So only the first question remains.

Sorry for that.

Ekkehart

On 02.02.2022 16:24, Ekkehart Schlicht wrote:
Hi,

I am new to Gretl and have two perhaps silly question concerning the use of pointers. In the Hansl guide p.14 it is explained that parameters are passed to functions "by value" but can also be passed by pointers. As I am dealing with very large sparse matrices, I had the idea to pass them by pointer rather than value in order to save time (for not duplicating the matrix for use in a function in each of some thousand iterations) and use less memory space. Does this make sense?

Second, it seems not quite clear to me how to do that. If I run the script

matrix a = seq(1,3)
function scalar inner(matrix a)
    return a * a'
end function
scalar b =inner(a)                # without pointer
scalar b = inner(&a)            # with pointer

I get the correct result  in the first case but

...

? scalar b = inner(&a)
inner: argument 1 is of the wrong type (is matrix *, should be matrix)
Data types not conformable for operation
...

with pointer in the second one which puzzles me.

I am running gretl version 2021d on Windows

Cheers

Ekkehart



-- 
Ekkehart Schlicht
Hurtenstr. 13
82345 Andechs-Frieding
Tel: +49 (0)8152 9149271