描述
MathVM exposes a simple framework (both C++ and Blueprint) for running user-defined math expressions:
y = sin(x) * 2
This expression will compute the sin of x and multiply it by 2. The result will be put in y.
The two symbols (x and y), can be local variables or globals (more on this below) and, in the case of x, it can be a constant.
There is a very important difference between local and global: MathVM supports running expressions in parallel (read: on multiple threads) but while accessing local variables is fully thread-safe and lock-free (each thread works on a different copy of them), global variables are shared between parallel evaluations.
For global variables a locking is required to avoid race conditions (see below). Constants are shared and lock-free (but obviously you cannot change them).
The native data type is double and multiple statements can be specified by using the ; separator:
y = tan(x * 2); y = y + (3 * sin(z)); final = y + x;
If there are parts of your expressions that works over global variables (or resources, see below), and you want to avoid race conditions you can "surround" critical sections with curly brackets (braces):
y = sin(z); {x = x + 1;}
Here the x increment (assuming x is a global variable) will be under lock.
Note: the compiler will automatically detect deadlocks
A plotter is included for drawing simple lines/points based graphs.
The plugin is open source under the MIT license. This marketplace version is meant for supporting the development of the project.
包含格式
- versions