Newsgroups: comp.lang.apl
Path: watmath!watserv2.uwaterloo.ca!mach1!torn!howland.reston.ans.net!bogus.sura.net!news-feed-1.peachnet.edu!umn.edu!csus.edu!sfsuvax1.sfsu.edu!vpcsc4
From: vpcsc4@sfsuvax1.sfsu.edu (Emmett McLean)
Subject: Re: MathLink to J?
Message-ID: <1993Apr22.034459.16422@csus.edu>
Sender: news@csus.edu
Organization: San Francisco State University
References: <1993Apr21.173949.13762@ll.mit.edu>
Date: Thu, 22 Apr 1993 03:44:59 GMT
Lines: 66

In article wgilson@ll.mit.edu (William Gilson) writes:

>This suggests (to me, anyway) that many problems could be solved
>efficiently with a MathLink from Mathematica to J, allowing Mathematica
>routines to pass J code and numerical values to the J interpreter and 
>to receive return values.
>
>Has anyone attempted this?

 I haven't heard of it.

>  Is there something I don't know that makes this foolhardy?

 I don't thinks so.

One can easily call J from C. I am not familar with calling ma from C,
but if it can be called from C then yes, I imagine you could do this.

You may find it of interest to study the example in the distribution
of the J source where J is called from C.  This example is in the
file main.c and also shows how C can be called from J, although
the specifics of that require that you get up to speed on how
J represents data internally (not really easy for me).

To compile the example program :

1. change SYS_* to fit your system in js.h
2. change SYS_LILENDIAN to 1 and SYS_SEM to 0 if you are compiling on the PC.
3. Use a make file similar to the one below.

   (replace the -g's with -O's
   one you know you will nolonger to debug your programs and you just
   need an executable. And also, you might stick a "strip j " command
   in there when you do this too.)

# J Makefile for Unix

CC     = gcc
CFLAGS = -g 
HDR    = a.h io.h j.h jc.h je.h js.h jt.h p.h v.h x.h lj.h
OBJ    = main.o a.o ai.o ap.o au.o \
	c.o cc.o cd.o cf.o cg.o cp.o cr.o ct.o cx.o \
	f.o i.o io.o j.o k.o lj.o m.o  p.o pc.o pv.o \
	r.o rl.o rt.o s.o t.o ta.o u.o ut.o \
	v.o ve.o vg.o vi.o vm.o vp.o vs.o vx.o vz.o \
	w.o wn.o x.o xa.o xf.o xl.o

OB2    = vh.o vb.o xs.o

j      : $(OBJ) $(OB2)
	$(CC) -g $(OBJ) $(OB2) -lm -o j

$(OBJ) : $(HDR)

$(OB2): $(@:.o=.c) $(HDR)
	$(CC) -g -c $<




I've been working on a more elaborate example than the one found in
main.c , where I calculate
the Legendre, Hermite, and Laguerre polynomials and their zeros in J
but print the results in C. I hope to post it some time next week.

Emmett
