> On 28 Jan 2019, at 18:00, [email protected] wrote:

> From: Matt Wette <[email protected]>
> Subject: Re: Matrix or array operations library
> Date: 27 January 2019 at 19:41:57 CET
> To: [email protected] <mailto:[email protected]>

> …

> Also, is it possible to get a pointer to the first element of an array
> (i.e., it's #f64() root vector), for the purpose of using with FFI?

Yes, you'd do

(bytevector->pointer (shared-array-root ARRAY) (* (shared-array-offset ARRAY) 
(sizeof TYPE)))

you can get the type with (array-type ARRAY), only that returns a symbol that 
has to be translated to the values that sizeof accepts (int double float etc), 
those are in (system foreign). Maybe it would be a good idea to have sizeof 
accept 'f32 'f64 etc directly.

Here's an full example for FFTW.

https://github.com/lloda/guile-ffi-fftw/blob/master/mod/ffi/fftw.scm 
<https://github.com/lloda/guile-ffi-fftw/blob/master/mod/ffi/fftw.scm>

Regards

        Daniel

Reply via email to