Re: Do I need MathLink to run finite-difference fast enough for Manipulate?
- To: mathgroup at smc.vnet.net
- Subject: [mg115753] Re: Do I need MathLink to run finite-difference fast enough for Manipulate?
- From: Albert Retey <awnl at gmx-topmail.de>
- Date: Thu, 20 Jan 2011 06:27:10 -0500 (EST)
- References: <ih6e2q$36r$1@smc.vnet.net>
Hi, > I would like to create a Manipulate for a finite-difference on a system > of PDEs using a 100x100 array that is processed about 10,000 times. Is > it possible to code this in native Mathematica, for example using > Compile, fast enough to be reasonably used by Manipulate (under 3 or 4 > seconds)? The C++ code is below and with the Compiler set to optimize > speed, it runs in approximately 1.5 seconds. However, if I attempt to > just code it in Mathematica using arrays, it takes much too long to > execute. > > Can someone help me decide if the only reasonable option is to use > MathLink or can I even use MathLink in a Manipulate? > If you run Mathematica 8 I think it would not be too difficult to create a dynamically linked library of your C-code that you could use directly with the new functionality which lets you integrate libraries directly in the Kernel. I think that would be less difficult and more efficient than to use MathLink. On the other hand, your code looks like it would also not be too difficult to be translated into Mathematica code that can be compiled. If you choose CompilationTarget -> "C" you would effectively create all the steps necessary to run the function from a dynamically linked library in an automated way. See the documentation for Compile for more details, there is whole lot of information in Version 8. It think the latter probably needs a lot less to learn... I don't think that there are any limitations concerning the use of such external routines in Manipulates, you will just have to make sure they don't run into timeouts... hth, albert