Hello again,

I have an algorithm implemented in both Fricas (Spad) and in C++. The
C++ code turns out to be 13 to 14 times faster than Spad, and a single
call can last arbitrarily many minutes, depending on the parameters.
Thus I would prefer to use the C++ implementation in the rest of my
Fricas Spad code.

It's actually the case that in Spad I'm using bigints (type Integer),
while the C++ code just uses machine arithmetic, which is one reason
for the speed difference. I guess the Fricas code would be greatly
sped up if I converted it to use SingleInteger, but nonetheless I
think my time would be better spent making an interface to the C++
code. At least I know I have SIngleIntegers as an option if this
fails.

I'd prefer the interfacing to be fast, so I don't like the idea of
converting my integers to ASCII text and back again. Thus I'd like to
interface my C/C++ code with Fricas by building the C++ code as a
shared library and interfacing between Fricas and the library with
SBCL (I hope that makes sense ;)

I searched the mailing lists a bit, so I'm sure that what I want to do
is possible, but there seem to be multiple possible approaches, none
too documented AFAIK.

For example, I know that Fricas has a Lisp function called
fricas-foreign-call, and it seems like maybe it would be useful to me,
but I'm not sure how to use it to achieve what I want. Also, there are
multiple options for switching to the Lisp shell from Fricas, and
there's also the option (if I'm correct) of running Fricas from the
Lisp shell. So I feel kind of lost, I can't tell what direction should
I go.

Could someone give a suggestion as to what could be the best approach
here? I'd prefer writing as little Lisp code as possible (is it
perhaps possible to do everything from Fricas/Spad?).

This is the type signature of my C++ function:
extern "C" long f(int, long, long)

This is the type signature of my Spad function:
f: (Integer, Integer, Integer) -> Integer

My system configuration is:

Hardware: 64-bit Intel
OS: Linux, glibc
Lisp: SBCL 2.1.11


Thanks,
Neven

-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/fricas-devel/CAL%2BbK4MMrB8nOYQ4%3D3ytgHhAEZ3zaQJun8T-6YBo5jBu5vvcyQ%40mail.gmail.com.

Reply via email to