summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaron Kent-Dobias <jaron@kent-dobias.com>2018-07-10 12:36:54 -0400
committerJaron Kent-Dobias <jaron@kent-dobias.com>2018-07-10 12:36:54 -0400
commit609fb52b670d8ed74584a988b8c63da82d8d523b (patch)
treecdc6b0ce89a7ac6e4f08dbdd3e3891fceb1e0da3
parent25781a4041fa75a3394949d111be3abbefc97c26 (diff)
downloadc++-609fb52b670d8ed74584a988b8c63da82d8d523b.tar.gz
c++-609fb52b670d8ed74584a988b8c63da82d8d523b.tar.bz2
c++-609fb52b670d8ed74584a988b8c63da82d8d523b.zip
added wolfram link code
-rw-r--r--.gitignore3
-rw-r--r--wolfram_link/Makefile13
-rw-r--r--wolfram_link/convexminorant.tm33
3 files changed, 49 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index a007fea..bf5bfbe 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,4 @@
build/*
+wolfram_link/*.o
+wolfram_link/*.c
+wolfram_link/convexminorant
diff --git a/wolfram_link/Makefile b/wolfram_link/Makefile
new file mode 100644
index 0000000..9d65623
--- /dev/null
+++ b/wolfram_link/Makefile
@@ -0,0 +1,13 @@
+
+CC = clang
+WSPREP = /opt/Mathematica/SystemFiles/Links/WSTP/DeveloperKit/Linux-x86-64/CompilerAdditions/wsprep
+CFLAGS = -g -Os -O3 -Wall -fno-strict-aliasing -Wstrict-overflow -Wno-missing-field-initializers -flto -fopenmp=libiomp5 -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include/ -march=native -I/opt/Mathematica/SystemFiles/Links/WSTP/DeveloperKit/Linux-x86-64/CompilerAdditions/ -I../lib/
+LDFLAGS = -L/opt/Mathematica/SystemFiles/Links/WSTP/DeveloperKit/Linux-x86-64/CompilerAdditions -lm -lpthread -lrt -lstdc++ -ldl -luuid -l WSTP64i4
+
+convex.o: ../lib/convex.c
+ @${CC} -c -o $@ $< ${CFLAGS}
+
+convexminorant: convexminorant.tm convex.o
+ @${WSPREP} $< -o $@.c
+ @${CC} -o $@ convex.o $@.c ${CFLAGS} ${LDFLAGS}
+
diff --git a/wolfram_link/convexminorant.tm b/wolfram_link/convexminorant.tm
new file mode 100644
index 0000000..48f5650
--- /dev/null
+++ b/wolfram_link/convexminorant.tm
@@ -0,0 +1,33 @@
+
+#include <convex.h>
+#include <wstp.h>
+
+extern int WSMain(int, char **);
+
+void convexminorant(double *, int);
+
+:Begin:
+:Function: convexminorant
+:Pattern: GetConvexMinorant[ list:{___Real} ]
+:Arguments: { list }
+:ArgumentTypes: { Real64List }
+:ReturnType: Manual
+:End:
+
+:Evaluate: GetConvexMinorant[ sequence___Float]:= GetConvexMinorant[ {sequence} ]
+
+void convexminorant(double * Gammas, int len) {
+ int i;
+ for (i = 0; i < len; i++) {
+ if (Gammas[i] <= 0) {
+ break;
+ }
+ }
+ double *m = get_convex_minorant(i, Gammas);
+ WSPutReal64List(stdlink, m, i);
+}
+
+int main(int argc, char **argv) {
+ return WSMain(argc, argv);
+}
+