From: Yury Sulsky
Subject: Inline C code
Date: 
Message-ID: <1123290303.557327.95140@g43g2000cwa.googlegroups.com>
Hi everyone,

I don't know if anybody will find this useful, but this is something I
wrote a while ago (damn NYU servers don't allow Google indexing).

It's an idea taken from Lush <http://lush.sf.net>: namely, to allow
integration of C into your LISP* code. Pretty cool if you need to talk
to the real world.


Here's an example of using it to interface with GSL and BLAS to find
the eigenvalues of a symmetric matrix:

(load "cinline")
(defun symm-eigenvals (matrix)
           (let* ((n^2 (length matrix))
                  (n-r (multiple-value-list (floor (sqrt n^2))))
                  (n   (if (zerop (cadr n-r)) (car n-r) (error "matrix
isn't square")))
                  (eivals (make-array n :element-type 'double-float)))
             (cin:cinline ((double* matrix) (uint n) (double* eivals))
                          """
#include <gsl/gsl_math.h>
#include <gsl/gsl_eigen.h>
                          """
                          """
gsl_matrix_view m = gsl_matrix_view_array ($matrix, $n, $n);
gsl_vector_view o = gsl_vector_view_array ($eivals, $n);
gsl_eigen_symm_workspace *w = gsl_eigen_symm_alloc ($n);

gsl_eigen_symm (&m.matrix, &o.vector, w);
gsl_eigen_symm_free (w);
                          """
                          ("gsl" "blas"))
             eivals))
==> SYMM-EIGENVALS

(symm-eigenvals (make-array 4 :initial-contents #(1d0 2d0 2d0 1d0)
                            :element-type 'double-float))
==> #(3.0000000000000004d0 -1.0000000000000002d0)

Check it out under "Inline C" at http://home.nyu.edu/~ys453/

* Currently only CMUCL and SBCL work.


 -Yury

From: Marco Antoniotti
Subject: Re: Inline C code
Date: 
Message-ID: <1123292702.754963.9010@z14g2000cwz.googlegroups.com>
Yury Sulsky wrote:
> Hi everyone,
>
> I don't know if anybody will find this useful, but this is something I
> wrote a while ago (damn NYU servers don't allow Google indexing).
>
> It's an idea taken from Lush <http://lush.sf.net>: namely, to allow
> integration of C into your LISP* code. Pretty cool if you need to talk
> to the real world.
>

It is a cool idea, but it is not a Lush idea.  KCL did it ages ago (and
GCL, and ECLS do it now as well).
Details differ of course.

Cheers
--
Marco
From: Christopher C. Stacy
Subject: Re: Inline C code
Date: 
Message-ID: <uhde3myi8.fsf@news.dtpq.com>
"Marco Antoniotti" <·······@gmail.com> writes:

> Yury Sulsky wrote:
> > Hi everyone,
> >
> > I don't know if anybody will find this useful, but this is something I
> > wrote a while ago (damn NYU servers don't allow Google indexing).
> >
> > It's an idea taken from Lush <http://lush.sf.net>: namely, to allow
> > integration of C into your LISP* code. Pretty cool if you need to talk
> > to the real world.
> >
> 
> It is a cool idea, but it is not a Lush idea.  KCL did it ages ago (and
> GCL, and ECLS do it now as well).
> Details differ of course.

Corman does this, too.
From: Yury Sulsky
Subject: Re: Inline C code
Date: 
Message-ID: <1123308763.324125.104640@g47g2000cwa.googlegroups.com>
> "Marco Antoniotti" <·······@gmail.com> writes:
> > Yury Sulsky wrote:
> > > Hi everyone,

> > > I don't know if anybody will find this useful, but this is something I
> > > wrote a while ago (damn NYU servers don't allow Google indexing).

> > > It's an idea taken from Lush <http://lush.sf.net>: namely, to allow
> > > integration of C into your LISP* code. Pretty cool if you need to talk
> > > to the real world.

> > It is a cool idea, but it is not a Lush idea.  KCL did it ages ago (and
> > GCL, and ECLS do it now as well).
> > Details differ of course.

> Corman does this, too.

Hey, now we can add CMUCL & SBCL to that list.
From: Marco Antoniotti
Subject: Re: Inline C code
Date: 
Message-ID: <1123349603.356720.208560@z14g2000cwz.googlegroups.com>
Well, it'd be nice to have a more standardized way of doing it,

Cheers
--
Marco





Yury Sulsky wrote:
> > "Marco Antoniotti" <·······@gmail.com> writes:
> > > Yury Sulsky wrote:
> > > > Hi everyone,
>
> > > > I don't know if anybody will find this useful, but this is something I
> > > > wrote a while ago (damn NYU servers don't allow Google indexing).
>
> > > > It's an idea taken from Lush <http://lush.sf.net>: namely, to allow
> > > > integration of C into your LISP* code. Pretty cool if you need to talk
> > > > to the real world.
>
> > > It is a cool idea, but it is not a Lush idea.  KCL did it ages ago (and
> > > GCL, and ECLS do it now as well).
> > > Details differ of course.
>
> > Corman does this, too.
> 
> Hey, now we can add CMUCL & SBCL to that list.