with-dynamic-lisp-array-pointer question
Hi lispers,
Is it OK to pass an array of single-floats to with-dynamic-lisp-array-pointer?
The docs only mention strings or byte arrays, however the following works:
(let ((lisp-array (make-array 4 :element-type 'single-float
:initial-contents '(4.0 9.0 1.0 0.5)
:allocation :static)))
(fli:with-dynamic-lisp-array-pointer (ptr lisp-array :type :unsigned-byte)
(loop for i below 16
collect (fli:dereference ptr :index i))))
I use something similar to the above to write floating-point data to an Sqlite
blob. I am relying on this for speed - it would be a pain to have to convert my
floats to their byte representation in Lisp each time I have to write them out to
the database. So is it OK to do this?
Best,
Christopher
Is it OK to pass an array of single-floats to with-dynamic-lisp-array-pointer?
The docs only mention strings or byte arrays, however the following works:
(let ((lisp-array (make-array 4 :element-type 'single-float
:initial-contents '(4.0 9.0 1.0 0.5)
:allocation :static)))
(fli:with-dynamic-lisp-array-pointer (ptr lisp-array :type :unsigned-byte)
(loop for i below 16
collect (fli:dereference ptr :index i))))
I use something similar to the above to write floating-point data to an Sqlite
blob. I am relying on this for speed - it would be a pain to have to convert my
floats to their byte representation in Lisp each time I have to write them out to
the database. So is it OK to do this?
Best,
Christopher