Code: Select all
float trainingData[4][2] = { {501, 10}, {255, 10}, {501, 255}, {10, 501} };
Code: Select all
(defun foreign-array-alloc (array array-type)
"Allocate a foreign array containing the elements of lisp array.
The foreign array must be freed with foreign-array-free."
(check-type array array)
(let* ((type (follow-typedefs (parse-type array-type)))
(ptr (foreign-alloc (element-type type)
:count (reduce #'* (dimensions type)))))
(lisp-array-to-foreign array ptr array-type)
ptr))