mathlink

Possible to use Mathematica from other programming languages (python/C#)?

♀尐吖头ヾ 提交于 2020-01-24 04:23:46
问题 Is it possible to use Mathematica's computing capabilities from other languages? I need to do some complex operations (not necessarily symbolic, btw), and it'd be pretty sweet to be able to just call Mathematica's functions or running Mathematica's code right from my python/c#'s program. Is it possible? 回答1: Looks like there is a MathLink API you can use from C#, c or Java, have you checked this out? http://reference.wolfram.com/mathematica/guide/MathLinkAPI.html 回答2: To links about usage of

Mathematica: MathLink error messages

折月煮酒 提交于 2020-01-12 17:42:32
问题 I think I am starting to understand how to link functions written in C/C++ to Mathematica . The problem I'm facing is that I don't know how to send error messages from my C wrapper to Mathematica. After searching in google I found this MathLink Tutorial. Section 1.7 gave me an insight as to how to send error messages but I am getting weird results. Here is the code I am working with. //File cppFunctions.h #ifndef CPPFUNCTIONS_H #define CPPFUNCTIONS_H class Point { public: double x, y; Point()

Mathematica: MathLink error messages

…衆ロ難τιáo~ 提交于 2020-01-12 17:42:30
问题 I think I am starting to understand how to link functions written in C/C++ to Mathematica . The problem I'm facing is that I don't know how to send error messages from my C wrapper to Mathematica. After searching in google I found this MathLink Tutorial. Section 1.7 gave me an insight as to how to send error messages but I am getting weird results. Here is the code I am working with. //File cppFunctions.h #ifndef CPPFUNCTIONS_H #define CPPFUNCTIONS_H class Point { public: double x, y; Point()

Understanding Kernel-FrontEnd communication — Why does my Front End freeze?

霸气de小男生 提交于 2019-12-22 04:46:17
问题 EDIT: Just a confirmation whether you can reproduce this or not would be useful. Only a single computer is needed to try this (no remote connection necessary). Update It seems other can't reproduce this on Mac or Win7, so it's either WinXP-specific or specific to my machine. At this point I'm giving up. It would be good to have a tutorial on how the Front End and the Kernel communicate, so we can debug remote kernel issues. Any such general answers (or links to tutorials elsewhere) are most

How to make an analog of InString[]?

风格不统一 提交于 2019-12-20 02:42:50
问题 I have discovered that InString[] does not work in MathLink mode when sending input with EnterExpressionPacket header. So I need to define my own function that returns previous input line. One way I have developed here does not work in some cases: In[1]:= Unevaluated[2 + 2] With[{line = $Line - 1}, HoldForm[In[line]]] /. (DownValues[In]) Out[1]= Unevaluated[2 + 2] Out[2]= 2 + 2 This is because RuleDelayed has no HoldAllComplete attribute. Adding this attribute makes this OK: In[1]:= Unprotect

CheckAbort inside MathLink functions?

醉酒当歌 提交于 2019-12-08 15:11:03
问题 I just found that such MathLink functions as LinkWrite and LinkRead have something like its own internal CheckAbort that absorbs any aborts, and does not propagate them further. This can be easily shown with LinkRead : link = LinkLaunch[First[$CommandLine] <> " -mathlink"]; LinkRead[link]; LinkWrite[link, Unevaluated[Pause[10]]]; {LinkRead[link], Print["!!"]} After evaluating the above code press Alt + . and you will get the following output: During evaluation of In[6]:= !! Out[9]=

How to kill slave kernel securely?

梦想与她 提交于 2019-12-07 09:51:51
问题 LinkClose[link] "does not necessarily terminate the program at the other end of the connection" as it is said in the Documentation. Is there a way to kill the process of the slave kernel securely? EDIT: In really I need a function in Mathematica that returns only when the process of the slave kernel has already killed and its memory has already released. Both LinkInterrupt[link, 1] and LinkClose[link] do not wait while the slave kernel exits. At this moment the only such function is seemed to

How to kill slave kernel securely?

前提是你 提交于 2019-12-05 14:41:00
LinkClose[link] "does not necessarily terminate the program at the other end of the connection" as it is said in the Documentation. Is there a way to kill the process of the slave kernel securely? EDIT: In really I need a function in Mathematica that returns only when the process of the slave kernel has already killed and its memory has already released. Both LinkInterrupt[link, 1] and LinkClose[link] do not wait while the slave kernel exits. At this moment the only such function is seemed to be killProc[procID] function I had showed in one of answers at this page. But is there a built-in

Mathematica: MathLink error messages

♀尐吖头ヾ 提交于 2019-12-05 04:27:17
I think I am starting to understand how to link functions written in C/C++ to Mathematica . The problem I'm facing is that I don't know how to send error messages from my C wrapper to Mathematica. After searching in google I found this MathLink Tutorial . Section 1.7 gave me an insight as to how to send error messages but I am getting weird results. Here is the code I am working with. //File cppFunctions.h #ifndef CPPFUNCTIONS_H #define CPPFUNCTIONS_H class Point { public: double x, y; Point(){ x=y=0.0;} Point(double a, double b): x(a), y(b) {} }; class Line { public: Point p1, p2; Line(void)

How to make an analog of InString[]?

旧时模样 提交于 2019-12-01 22:07:18
I have discovered that InString[] does not work in MathLink mode when sending input with EnterExpressionPacket header. So I need to define my own function that returns previous input line. One way I have developed here does not work in some cases: In[1]:= Unevaluated[2 + 2] With[{line = $Line - 1}, HoldForm[In[line]]] /. (DownValues[In]) Out[1]= Unevaluated[2 + 2] Out[2]= 2 + 2 This is because RuleDelayed has no HoldAllComplete attribute. Adding this attribute makes this OK: In[1]:= Unprotect[RuleDelayed]; SetAttributes[RuleDelayed, HoldAllComplete]; Protect[RuleDelayed]; Unevaluated[2 + 2]