## Re: [clisp-list] ffi & libsvm

 Re: [clisp-list] ffi & libsvm From: Sam Steingold - 2006-09-25 19:45:31 ```Hi, Hoehle, Joerg-Cyril wrote: > (allocate-deep 'problem '(1 #(2.0d0) #( (1 2.0d0) (2 5.6d0)))) ok, here you go: (defun task (num divisor base) (flet ((normalize (x d) (- (/ (* 2 x) (1- d)) 1d0))) (values (normalize (rem num divisor) divisor) (do ((n num) r (ret ()) (index 0 (1+ index))) ((zerop n) (coerce (nreverse (cons (list -1 0d0) ret)) 'vector)) (multiple-value-setq (n r) (floor n base)) (let ((value (normalize r base))) (unless (zerop value) (push (list index value) ret))))))) (defun problem (repeat divisor base) (let ((x (make-array repeat)) (y (make-array repeat))) (dotimes (i repeat) (multiple-value-bind (n v) (task i divisor base) (setf (aref y i) n (aref x i) v))) (libsvm:make-problem :l repeat :x x :y y))) (defparameter f-problem-3-7 (problem 1000 3 7)) (defparameter l-problem-3-7 (ffi:foreign-value f-problem-3-7)) (second l-problem-3-7) #(-1.0d0) it should be a vector of length 1000, but it appears to be a vector of length 1! ```