This is a small tour of the capabilities MathPiper currently offers. Note that this list of examples is far from complete. MathPiper contains a few hundred commands, of which only a few are shown here.
Additional example calculations including the results can be found here:
The default operation of MathPiper is to run in the interactive console mode. MathPiper accepts several options that modify its operation. Here is a summary of options:
Options can be combined, for example
mathpiper -pc filename |
Here is a more detailed description of the command-line options.
mathpiper -c |
mathpiper -f |
mathpiper -p |
mathpiper -t |
mathpiper [options] {filename} |
mathpiper -v |
mathpiper -d |
mathpiper --patchload |
mathpiper --init [file] |
mathpiper --read-eval-print [expression] |
There is also a fallback read-eval-print loop in the kernel; it can be invoked by passing an empty string to this command line option, as --read-eval-print "".
An alternative way to replace the default read-eval-print loop is to write a custom initialization script that implements the read-eval-print loop function REP() instead of mathpiperinit.pi.
Care has to be taken with this option because a MathPiper session may become unusable if the read-eval-print expression doesn't function correctly.
mathpiper --server <port> |
Commands can be sent to the server by sending a text line as one block of data, and the server will respond back with another text block.
One can test this function by using telnet. First, set up the server by calling
mathpiper --server 9734 |
telnet 127.0.0.1 9734 |
Some security measures and resource management measures have been taken. No more than 10 connections can be alive at any time, a calculation cannot take more than 30 seconds, and MathPiper operates in the secure mode, much like calling an expression by passing it as an argument to the Secure function. This means that no system calls are allowed, and no writing to local files, amongst other things. Something that has not been taken care of yet is memory use. A calculation could take up all memory, but not for longer than 30 seconds.
The server is single-threaded, but has persistent sessions for at most 10 users at a time, from which it can service requests in a sequential order. To make the service multi-threaded, a solution might be to have a proxy in front of the service listening to the port, redirecting it to different processes which get started up for users (this has not been tried yet).
The flag --single-user-server can be passed on to instruct mathpiper to start in single-user mode. In this mode, unsecure operations can be performed (like reading from and writing to files), and the calculation may take more than 30 seconds. The mathpiper process will automatically be shut down when the last session is closed or when "Exit();" is sent.
mathpiper --rootdir [directory] |
mathpiper --archive [file] |
MathPiper has an experimental system where files can be compressed into one file, and accessed through this command line option. The advantages are:
An additional savings is due to the fact that the script files are stripped from white spaces and comments, making them smaller and faster loading.
To prepare the compressed library archive, run ./configure with the command line option --enable-archive.
The result should be the archive file scripts.dat. Then launch MathPiper with the command line option --archive scripts.dat, with the file scripts.dat in the current directory.
The reason that the scripts.dat file is not built automatically is that it is not tested, at this time, that the build process works on all platforms. (Right now it works on Unix, MacOSX, and Win32.)
Alternatively, configure MathPiper with
./configure --enable-archive |
When an archive is present, MathPiper will try to load it before it looks for scripts from the library directories. Typing
make archivetest -f makefile.compressor |
The currently supported compression schemes are uncompressed and compressed with minilzo. Script file stripping (removing whitespace and comments) may be disabled by editing compressor.cpp (variable strip_script).
mathpiper --disable-compiled-plugins |
Disable loading of compiled scripts, in favor of scripts themselves. This is useful when developing the scripts that need to be compiled in the end, or when the scripts have not been compiled yet.
mathpiper --stacksize <size> |
For a function that would take 4 arguments and has one return value, there would be 5 places reserved on this stack, and the function could call itself recursively 10000 steps deep.
This differs from the MaxEvalDepth mechanism. The MaxEvalDepth mechanism allows one to specify the number of separate stack frames (number of calls, nested), instead of the number of arguments pushed on the stack. MaxEvalDepth was introduced to protect the normal C++ stack.
mathpiper --execute <expression> |
user% ./mathpiper -pc --execute '[Echo("answer ",D(x)Sin(x));Exit();]' answer Cos(x) user% |