Re: float array as return value of a foreign C function call
Fabrizio Morbini <[email protected]> Sun, 11 Jul 2004 12:24:04 -0400 (EDT)
| Newsgroups | gmane.lisp.allegro |
|---|---|
| Message-ID | <[email protected]> |
Hi All, sorry for the previous post, I think that I found the solution: ***************************** ;;define in and out variables (setq in (ff:allocate-fobject '(:array :float 2))) (setq out (ff:allocate-fobject '(:array :float 1))) ;;assign the input values (setf (ff:fslot-value-typed '(:array :float) nil in 0) 1.0) (setf (ff:fslot-value-typed '(:array :float) nil in 1) 1.0) ;;run the input in the network (setq out (fann_run ann in)) ;;print the output value (print (ff:fslot-value-typed '(:array :float) nil out 0)) ***************************** it seems to work, let me know if I'm wrong. Thanks, Fabrizio. On Sun, 11 Jul 2004, Fabrizio Morbini wrote: > Hi All, I'm using the foreign interface to call functions of a neural > network library (the fann library, BTW I searched I little bit for a > neural network library written in Lisp, but I haven't found anything good) > and I have a curiosity to which I haven't found an answer in the > documentation: is it possible to return an array of float from a C > function? > > I mean, there is a function that takes as input the neural network and the > float array representing the input values and returns the float array > representing the output values. I can pass correctly the neural network > and the float array but as output I'm only able to see the address of the > float array but not the actual content. As solution I simply modify the > function adding an additional parameter (the output array) and passing it > by reference, but I wonder if it is possible to see the C float array > directly in Lisp.