Commit 41356ea9 authored by ulrich_y's avatar ulrich_y

128-bit for mathlink

parent 7c9d6ade
......@@ -523,6 +523,7 @@ _EOF_
echo "no" 1>&3
exit 1
}
$HAVE_MCC && eval addflag CFLAGS -DHAVE_QUAD
fi
......@@ -694,7 +695,7 @@ EOF
$HAVE_MCC && cat >> makefile <<EOF
build/%.tm.c: src/%.tm
@echo "MPREP \$@"
@\$(MPREP) \$< -o \$@
@cat \$< | sed '/:Begin:/,/:End:/ s/Real/Real$($CONF_QUAD && echo 128)/g' | \$(MPREP) > \$@
build/mathlink.o: build/mathlink.tm.c
@echo "CC \$<"
......
......@@ -46,33 +46,46 @@
#include <string.h>
#include <assert.h>
typedef struct {double r,i;} complex;
#ifdef HAVE_QUAD
typedef __float128 real;
#define PUTREAL MLPutReal128
#else
typedef double real;
#define PUTREAL MLPutReal
#endif
typedef struct {real r,i;} complex;
typedef struct {complex c; signed char i0;} inum;
extern complex __gpl_module_MOD_g_superflatn(inum*,long*);
#ifdef HAVE_QUAD
void gpl(mlextended_double * re, int nr, mlextended_double * im, int ni, int*ieps, long ne)
#else
void gpl(double * re, long nr, double * im, long ni, int*ieps, long ne)
#endif
{
assert(nr==ni);
assert(nr==ne);
inum input[nr];
complex ans;
long nnr = nr;
for(long i=0;i<nr;i++)
{
input[i].c.r = *(re+i);
input[i].c.i = *(im+i);
input[i].i0 = *(ieps+i);
}
ans = __gpl_module_MOD_g_superflatn(&input[0],&nr);
ans = __gpl_module_MOD_g_superflatn(&input[0],&nnr);
if(ans.i == 0)
MLPutReal(stdlink, ans.r);
PUTREAL(stdlink, ans.r);
else
{
MLPutFunction(stdlink, "Complex", 2);
MLPutReal(stdlink, ans.r);
MLPutReal(stdlink, ans.i);
PUTREAL(stdlink, ans.r);
PUTREAL(stdlink, ans.i);
}
}
......@@ -84,10 +97,16 @@ void wipecache(void)
MLPutSymbol(stdlink, "Null");
}
double __globals_MOD_hoeldercircle;
double __globals_MOD_mpldel;
real __globals_MOD_hoeldercircle;
real __globals_MOD_mpldel;
int __globals_MOD_polyloginfinity;
#ifdef HAVE_QUAD
void setopts(mlextended_double del, int inf, mlextended_double circ)
#else
void setopts(double del, int inf, double circ)
#endif
{
if(del > 0)
__globals_MOD_mpldel = del;
......@@ -99,13 +118,13 @@ void setopts(double del, int inf, double circ)
MLPutFunction(stdlink, "List", 3);
MLPutFunction(stdlink, "Rule", 2);
MLPutSymbol(stdlink, "MPLdel");
MLPutReal(stdlink, __globals_MOD_mpldel);
PUTREAL(stdlink, __globals_MOD_mpldel);
MLPutFunction(stdlink, "Rule", 2);
MLPutSymbol(stdlink, "LiInf");
MLPutInteger32(stdlink, __globals_MOD_polyloginfinity);
MLPutFunction(stdlink, "Rule", 2);
MLPutSymbol(stdlink, "hCircle");
MLPutReal(stdlink, __globals_MOD_hoeldercircle);
PUTREAL(stdlink, __globals_MOD_hoeldercircle);
}
int main(int argc, char **argv)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment