Sam Steingold asked:
>can you optimize this code in clisp/modules/matlab/matlab.lisp?
There's one thing that I noticed there:
low-level transformation: use MEMORY-AS
(defun matfile-content (mf)
"return the vector of strings naming variables in MATfile"
(multiple-value-bind (buf num) (matGetDir mf)
(memory-as buf (parse-c-type `(c-array c-string ,num)))
(with-c-var (names `(c-ptr (c-array c-string ,num)))
(setf (cast names 'c-pointer) buf)
Benefit: with-c-var has overhead similar to foreign-funcall + callback,
memory-as is more lightweight.
Before the addition of MEMORY-AS, the WITH-C-VAR+CAST trick was indeed one I recommended.
Beside that, since matlab seems to use Fortran-style ordering of arrays, and CL follows C usage, I see little opportunity for block operations.
Well, maybe there are fast transpositions tricks, so that (memory-as `(c-array double-flaot ,x ,y)) can still be used? That might be faster than a nested loop, depending on matrix size and speed of the 2 transpositions.