public interface IKernelLink : IMathLink
Public Interface IKernelLink
Inherits IMathLink
public interface class IKernelLink : IMathLink
type IKernelLink =
interface
interface IMathLink
end
An example is the WaitAndDiscardAnswer method, which reads and discards the sequence of packets the kernel will send in the course of a single evaluation.
Most programmers will use links that implement this interface. The actual implementation classes are not documented and are of no concern. You will always interact with link objects via an interface type. Use the MathLinkFactory.CreateKernelLink method to create an IKernelLink.
using System;
using Wolfram.NETLink;
public class LinkTest {
public static void Main(String[] args) {
// This launches the Wolfram kernel:
IKernelLink ml = MathLinkFactory.CreateKernelLink();
// Discard the initial InputNamePacket the kernel will send when launched.
ml.WaitAndDiscardAnswer();
// Now compute 2+2 in several different ways.
// The easiest way. Send the computation as a string and get the result in a single call:
string result = ml.EvaluateToOutputForm("2+2", 0);
Console.WriteLine("2 + 2 = " + result);
// Use Evaluate() instead of EvaluateToXXX() if you want to read the result as a native type
// instead of a string.
ml.Evaluate("2+2");
ml.WaitForAnswer();
int intResult = ml.GetInteger();
Console.WriteLine("2 + 2 = " + intResult);
// You can also get down to the metal by using methods from IMathLink:
ml.PutFunction("EvaluatePacket", 1);
ml.PutFunction("Plus", 2);
ml.Put(2);
ml.Put(2);
ml.EndPacket();
ml.WaitForAnswer();
intResult = ml.GetInteger();
Console.WriteLine("2 + 2 = " + intResult);
// Always Close when done:
ml.Close();
}
}
Imports Wolfram.NETLink
Public Class LinkTest
Public Shared Sub Main(ByVal args As String())
' This launches the Wolfram kernel:
Dim ml As IKernelLink = MathLinkFactory.CreateKernelLink()
' Discard the initial InputNamePacket the kernel will send when launched.
ml.WaitAndDiscardAnswer()
' Now compute 2+2 in several different ways.
' The easiest way. Send the computation as a string and get the result in a single call:
Dim result As String = ml.EvaluateToOutputForm("2+2", 0)
Console.WriteLine("2 + 2 = " & result)
' Use Evaluate() instead of EvaluateToXXX() if you want to read the result
' as a native type instead of a string.
ml.Evaluate("2+2")
ml.WaitForAnswer()
Dim intResult As Integer = ml.GetInteger()
Console.WriteLine("2 + 2 = " & intResult)
' You can also get down to the metal by using methods from IMathLink:
ml.PutFunction("EvaluatePacket", 1)
ml.PutFunction("Plus", 2)
ml.Put(2)
ml.Put(2)
ml.EndPacket()
ml.WaitForAnswer()
intResult = ml.GetInteger()
Console.WriteLine("2 + 2 = " & intResult)
'Always Close when done:
ml.Close()
End Sub
End Class
ComplexType |
Sets or gets the class that you want to map to Wolfram Language Complex numbers.
(Inherited from IMathLink) |
Error |
Gets the current error state for the link.
(Inherited from IMathLink) |
ErrorMessage |
Gets a textual message describing the current error state for the link.
(Inherited from IMathLink) |
GraphicsFormat | Gets or sets the format in which Wolfram Language graphics will be rendered. |
LastError | Gets the Exception object that represents any exception detected during the last call of one of the "EvaluateTo" methods (EvaluateToInputForm, EvaluateToOutputForm, EvaluateToImage, EvaluateToImageBytes, EvaluateToTypeset, EvaluateToTypesetBytes). |
Name |
Gets the name of the link.
(Inherited from IMathLink) |
Ready |
Indicates whether the link has data waiting to be read.
(Inherited from IMathLink) |
TypesetStandardForm | Gets or sets whether images created by the EvaluateToTypeset(String, Int32) method should use Wolfram Language StandardForm (vs. TraditionalForm). |
UseFrontEnd | Gets or sets whether the Wolfram notebook front end should be used in the background to assist in rendering graphics. |
WasInterrupted | Tells whether the user has attempted to abort the computation. |
AbandonEvaluation | Causes any method that is blocking waiting for output from the kernel to return immediately and throw a MathLinkException. |
AbortEvaluation | Sends a request to the kernel to abort the current evaluation. |
BeginManual | Informs .NET/Link that your code will be manually sending a result back to the Wolfram Language. |
BytesToGet |
Gives the number of bytes that remain to be read in the element that is currently being read in textual form.
(Inherited from IMathLink) |
BytesToPut |
Gives the number of bytes that remain to be sent in the element that is currently being sent in textual form.
(Inherited from IMathLink) |
CheckFunction |
Reads a function name and argument count and requires that it match the specified function name.
(Inherited from IMathLink) |
CheckFunctionWithArgCount |
Reads a function name and argument count and requires that it match the specified function name and arg count.
(Inherited from IMathLink) |
ClearError |
Clears the link error condition, if possible.
(Inherited from IMathLink) |
Close |
Closes the link.
(Inherited from IMathLink) |
Connect |
Waits for the link to be connected.
(Inherited from IMathLink) |
Connect(Int64) |
Waits for the link to be connected for at most the specified number of milliseconds before throwing a MathLinkException.
(Inherited from IMathLink) |
CreateMark |
Creates a mark at the current point in the incoming MathLink data stream.
(Inherited from IMathLink) |
DestroyMark |
Destroys a mark.
(Inherited from IMathLink) |
DeviceInformation |
A low-level function that retrieves special internal information from the MathLink device.
(Inherited from IMathLink) |
EnableObjectReferences | Call this method to enable the ability to pass .NET objects "by reference" to the Wolfram Language. |
EndPacket |
Call when you are finished writing the contents of a single packet.
(Inherited from IMathLink) |
Evaluate(Expr) | Sends an Expr for evaluation. |
Evaluate(String) | Sends a string of code for evaluation. |
EvaluateToImage(Expr, Int32, Int32) | Sends the code to evaluate as an Expr. |
EvaluateToImage(String, Int32, Int32) | Sends the code to evaluate as a string. |
EvaluateToImageBytes(Expr, Int32, Int32) | Sends the code to evaluate as an Expr. |
EvaluateToImageBytes(String, Int32, Int32) | Sends the code to evaluate as a string. |
EvaluateToInputForm(Expr, Int32) | Sends the code to evaluate as an Expr. |
EvaluateToInputForm(String, Int32) | Sends the code to evaluate as a string. |
EvaluateToOutputForm(Expr, Int32) | Sends the code to evaluate as an Expr. |
EvaluateToOutputForm(String, Int32) | Sends the code to evaluate as a string. |
EvaluateToTypeset(Expr, Int32) | Sends the code to evaluate as an Expr. |
EvaluateToTypeset(String, Int32) | Sends the code to evaluate as a string. |
EvaluateToTypesetBytes(Expr, Int32) | Sends the code to evaluate as an Expr. |
EvaluateToTypesetBytes(String, Int32) | Sends the code to evaluate as a string. |
Flush |
Immediately transmits any data buffered for sending over the link.
(Inherited from IMathLink) |
GetArgCount |
Reads the argument count of an expression being read manually.
(Inherited from IMathLink) |
GetArray(Type, Int32) | Reads an array and discards information about the heads at each level. |
GetArray(Type, Int32, String) | Reads an array and records information about the heads at each level. |
GetBoolean |
Reads the Wolfram Language symbols True or False as a bool.
(Inherited from IMathLink) |
GetBooleanArray |
Reads a list as a one-dimensional array of bools.
(Inherited from IMathLink) |
GetByteArray |
Reads a list as a one-dimensional array of bytes.
(Inherited from IMathLink) |
GetByteString |
Reads a Wolfram Language string as an array of bytes.
(Inherited from IMathLink) |
GetCharArray |
Reads a list as a one-dimensional array of chars.
(Inherited from IMathLink) |
GetComplex |
Reads a complex number. This can be an integer, real, or a Wolfram Language expression with head Complex.
(Inherited from IMathLink) |
GetComplexArray |
Reads a list as a one-dimensional array of complex numbers.
(Inherited from IMathLink) |
GetData |
Gets a specified number of bytes in the textual form of the expression currently being read.
(Inherited from IMathLink) |
GetDecimal |
Reads a Wolfram Language integer or real number or integer as a decimal.
(Inherited from IMathLink) |
GetDecimalArray |
Reads a list as a one-dimensional array of decimals.
(Inherited from IMathLink) |
GetDouble |
Reads a Wolfram Language real number or integer as a double.
(Inherited from IMathLink) |
GetDoubleArray |
Reads a list as a one-dimensional array of doubles.
(Inherited from IMathLink) |
GetExpr |
Reads an arbitrary expression from the link and creates an Expr from it.
(Inherited from IMathLink) |
GetExpressionType | Gives the type of the current element in the expression currently being read. Overrides the IMathLink method by allowing the extra return type ExpressionType.Object. |
GetFunction |
Reads a function name and argument count.
(Inherited from IMathLink) |
GetInt16Array |
Reads a list as a one-dimensional array of shorts.
(Inherited from IMathLink) |
GetInt32Array |
Reads a list as a one-dimensional array of ints.
(Inherited from IMathLink) |
GetInt64Array |
Reads a list as a one-dimensional array of longs.
(Inherited from IMathLink) |
GetInteger |
Reads a Wolfram Language integer as a 32-bit integer.
(Inherited from IMathLink) |
GetNextExpressionType | Gives the type of the next element in the expression currently being read. Overrides the IMathLink method by allowing the extra return type ExpressionType.Object. |
GetObject | Reads any single expression off the link and returns an appropriate object. Overrides the IMathLink version to allow you to read NETObject expressions. |
GetSingleArray |
Reads a list as a one-dimensional array of floats.
(Inherited from IMathLink) |
GetString |
Reads a Wolfram Language character string.
(Inherited from IMathLink) |
GetStringArray |
Reads a list as a one-dimensional array of strings.
(Inherited from IMathLink) |
GetStringCRLF |
Reads a Wolfram Language character string and translates newlines into Windows format.
(Inherited from IMathLink) |
GetSymbol |
Reads a Wolfram Language symbol as a string.
(Inherited from IMathLink) |
HandlePacket | Call this to invoke .NET/Link's internal handling of special packet types. |
InterruptEvaluation | Sends a request to the kernel to interrupt the current evaluation. |
Message | Prints the specified message in the user's Wolfram Language session. |
NewPacket |
Discards the current packet, if it has been partially read. Has no effect if the previous packet was fully read.
(Inherited from IMathLink) |
NextPacket |
"Opens" the next packet arriving on the link.
(Inherited from IMathLink) |
OnPacketArrived | Raises the PacketArrived event. |
PeekExpr |
Creates an Expr from the current expression, but does not drain it off the link.
(Inherited from IMathLink) |
Prints the specified text in the user's Wolfram Language session. | |
Put(Boolean) |
Sends a bool value as the Wolfram Language symbol True or False.
(Inherited from IMathLink) |
Put(Decimal) |
Sends a decimal value as an integer or real.
(Inherited from IMathLink) |
Put(Double) |
Sends a double value.
(Inherited from IMathLink) |
Put(Int32) |
Sends an integer value.
(Inherited from IMathLink) |
Put(Int64) |
Sends a long integer value.
(Inherited from IMathLink) |
Put(Object) | Sends an object, including strings and arrays. Overrides the IMathLink version to allow you to send objects "by reference" that have no meaningful value representation in the Wolfram Language. |
Put(Array, String) |
Sends an array object. Unlike Put(object), this method lets you specify the heads you want for each dimension.
(Inherited from IMathLink) |
PutArgCount |
Specifies the argument count for a composite expression being sent manually.
(Inherited from IMathLink) |
PutData |
Used for sending elements in so-called "textual" form.
(Inherited from IMathLink) |
PutFunction |
Sends a function name and argument count.
(Inherited from IMathLink) |
PutFunctionAndArgs |
Sends a function name and its arguments.
(Inherited from IMathLink) |
PutMessage |
Sends a low-level MathLink message.
(Inherited from IMathLink) |
PutNext |
Identifies the type of data element that is to be sent next.
(Inherited from IMathLink) |
PutReference(Object) | Sends the object as its actual runtime type. |
PutReference(Object, Type) | Sends the object cast as a parent type or interface. |
PutSize |
Specifies the size in bytes of an element being sent in textual form.
(Inherited from IMathLink) |
PutSymbol |
Sends a symbol.
(Inherited from IMathLink) |
SeekMark |
Resets the current position in the incoming MathLink data stream to an earlier point.
(Inherited from IMathLink) |
TerminateKernel | Sends a request to the kernel to shut down. |
TransferExpression |
Reads a complete expression from the named link and writes it to this link.
(Inherited from IMathLink) |
TransferToEndOfLoopbackLink |
Reads the entire contents of a loopback link and writes it to this link.
(Inherited from IMathLink) |
WaitAndDiscardAnswer | Reads and discards all packets from a computation, including the result. |
WaitForAnswer | Reads and discards all packets that arrive up until the packet that contains the result of the computation. |
MessageArrived |
Occurs when a low-level MathLink message arrives.
(Inherited from IMathLink) |
PacketArrived | Occurs when a MathLink packet arrives. |
Yield |
Occurs periodically when the link is blocking in a reading call.
(Inherited from IMathLink) |