Building dynamically functions to compile
| Newsgroups | gmane.lisp.lush.devel |
|---|---|
| Message-ID | <8D1414482878D4119AEE00508B6C90740E3D8AFD@seacex02.eib.electrabel.be> |
Hi lushers,
As there is not lush-user@mailing lists, I post my question to this list.
For a numerical simulation I need to update a vector at each step with a
formula of the type:
x[t] = A . x[t-1] + B . e[t]
where x[t] is a vector of size n, e[t] a vector of size m, A a matrix of
size (n x n) and B a matrix of size (n x m)
with m,n < 10.
But as A and B may be quite sparse (only 10 % different of 0), I want to
avoid to make the multiplications by 0.
My strategy was to give to a function the known matrix A and B (i.e. list of
list) that will build the C expansion of
x[t] = A . x[t-1] + B . e[t]
with all zeros written explicitlty and let the C compiler optimize and get
rid of all 0.
Hence, something like
(setq stepper (build-stepper A B))
(dhc-make "stepper_code" stepper)
;; loop
(repeat (setq x (stepper x e))
Now, how can I build easely the build-stepper high order function ?
I can't use the #{ #} construct with references to A and B as it will give
an awful code.
I want to use cinline directly but there is no documentation about it. I was
thinking to something like
(de build-stepper (A B)
;; build string of C code with sprintf and code
(let ((c-code (sprintf "bla %s bla %i" ...)))
(cinline c-code)))
Well, has anybody used lush with this kind of goal in mind (sorta
specialisation of important code) ?
Any hint ?
Any documentation on cinline ?
TX
-------------------------------------------------------
This SF.net email is sponsored by: Get the new Palm Tungsten T
handheld. Power & Color in a compact size!
http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0002en