[Ecls-list] RUN-PROGRAM/FFI
Juan Jose Garcia Ripoll
lisp at arrakis.es
Wed Nov 16 07:09:01 UTC 2005
On Wed, 2005-11-16 at 15:38 +0100, Nicolas Neuss wrote:
> (ffi:def-function ("c_superlu" c-superlu)
> ((m :int) (n :int) (nnz :int)
> (colptr (* :int))
> (rowind (* :int))
> (nzval (* :double))
> (nrhs :int)
> (rhs (* :double))
> (sol (* :double)))
> :returning :int)
>
> (defun superlu (m n nnz cs ri store nrhs rhs sol)
> (c-superlu m n nnz (vector-sap cs) (vector-sap ri)
> (vector-sap store) nrhs (vector-sap rhs)
> (vector-sap sol)))
>
> What can I insert for vector-sap here? Or how should I write SUPERLU?
Just define
(defun vector-sap (a)
(ffi:c-inline (a) (:object) :pointer-void
"(#0)->array.self.ch" :one-liner t))
somewhere and probably add a compiler-macro which expands into a
c-inline form. The rest should work similarly.
Just a quick test:
> (compile 'vector-sap (lambda (a)
(ffi:c-inline (a) (:object) :pointer-void
"(#0)->array.self.ch" :one-liner t)))
> (vector-sap (make-array 10 :element-type 'double-float))
#<foreign :VOID 08118540>
> And a further question: How can I change the package at startup? I have
> found that the code
> ecl -eval "(in-package :SI)"
> does not work. (I dimly remember reading something about this question
> recently, but cannot find the mail anymore.)
Hmmm, the problem is that all "-eval" statements are computed before
entering the toplevel and there was a (in-package "cl-user") statement
right after this. I've fixed this in CVS.
> P.S.: I have been bitten earlier by the fact that ECL returns LONG-FLOAT
> when asked for the array-element-type of a uniform DOUBLE-FLOAT array.
> This is allowed by the spec, however I think that the name DOUBLE-FLOAT is
> more meaningful (relating to what is the actual length of the number). It
> is also used by Allegro and CMUCL (as much as I see only GCL uses
> LONG-FLOAT). Probably, a change would be problematic, but nevertheless I
> would be interested in opinions about this issue.
I see no problem in changing this. Looks also a bit more consistent with
the spec, as it specifies that single-float and double-float are the
numeric types, while the others are synonyms.
Juanjo
More information about the ecl-devel
mailing list