c# application calling Scipy

D

dongarbage

Hi,

Novice here. :)

I'm building a c# application and I want to call functions in SciPy
from that application.

What's the best way to call SciPy methods from a C# program?

Is there a best Python implementation for this? Ironython? Python for
..NET? Enthought?

Thanks in advance,
Don
 
R

Robert Kern

Hi,

Novice here. :)

I'm building a c# application and I want to call functions in SciPy
from that application.

What's the best way to call SciPy methods from a C# program?

Is there a best Python implementation for this? Ironython? Python for
.NET? Enthought?

scipy is a package with many C and FORTRAN extensions, so IronPython won't work
unless someone has figured out a magic way to compile them. The Enthought
distribution (disclosure: I work for Enthought) is just a bundling of the normal
python.org distribution of Python with a bunch of packages; it knows nothing
about C#. I know little about Python for .NET beyond its README, but it does
seem to be able to embed CPython into a C# application and with some elbow
grease, that might work for you.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
 
S

sturlamolden

Hi,

Novice here. :)

I'm building a c# application and I want to call functions in SciPy
from that application.

What's the best way to call SciPy methods from a C# program?

You need to:

1. Embed a Python interpreter in your C# app. That is, importing from a
DLL with a Python interpreter and defining a few structs.

2. Define a NumPy ndarray as a C# struct.

Or:

1. Write a proxy DLL in C and embed Python in that. This is the
preferred way, as I see it. You are relieved of having to redefine
Python and NumPy's C structs in C#.

2. Import your proxy in C# and marshal a C# array to a IntPtr. That
will allow you to map a C# array to a NumPy ndarray C struct in your
proxy.

The latter method is less hassle.

In any case you also need to make sure you are using a .NET runtime
that are linked to the same CRT as Python (.NET 1.1 should work).

Using IronPython will not work, as neither NumPy nor SciPy is ported to
IronPython (and porting is not trivial either; but if you take the task
upon yourself, many will be happy if you succeeed.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top