Skip to content

About

Some examples about how to use WSTP(Wolfram Symbolic Transfer Protocol) provided by WolframResearch.

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Prerequisite

Here are some notes:

  1. For Arch user, install mathematica or mathematica-light.
  2. Check if your shell is zshell.
  3. Change the WOLFRAM and WSTP_PATH variable in run.sh.

Build

wolfram repl

Build it with command:

# build
./run.sh wstp_repl.c

# after building, simply run
./wstp_repl

wolfram server & client

Commands list as follows, take wstp_type=NET as example:

# launch server(wolfram kernel)
wolfram -script wstp_server.wls

# build & run client
./run.sh wstp_client.c

# after building, simply run 
./wstp_client "2^64"
./wstp_client 'num1=2^64; Print["Hello From wstp client"]; num1'
./wstp_client '<< "example.wls"'
./wstp_client 'Integrate[Sin[x]/x^3, x]'
./wstp_client "Integrate[Sin[x], {x, 0, 2/3*Pi}]//TeXForm//ToString"

File example.wls contains just 3 lines:

(* This is file 'example.wls' *)
TeXResult=ToString[TeXForm[LaplaceTransform[t^4 Sin[3*t], t, s]]];
Export["output.txt",TeXResult]

WARN: wstp will only print the last experssion that does not followed by a semicolon in wstp '<< "<file>"' syntax.

image support(experiment)

Currently, wstp_client only has a limited support for image generating(export), check wstp_client_img.c for details.

A simple example:

./wstp_client -i "Plot[Sin[x], {x, 0, 2*Pi}]"
./wstp_client -i "Plot[Sin[x], {x, 0, 2*Pi}]" -o 'test.png'

In the first case, you'll see a figure named output.png appears in current directory.

WARN: do NOT support exporting pictures in vector format, such as PDF, SVG etc.

Usage

This repo provides some scripts(config) to make wstp_client and wstp_server work with other programs:

Reference

Some materials about WSTP:

Deeply appreciate the innovative tools provided by Wolfram Research.

About

Some examples about how to use WSTP(Wolfram Symbolic Transfer Protocol) provided by WolframResearch.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages