In article (DAVIES Harvey) writes:
Quote:
>I am having trouble using the LinkJ interface on an SGI unix system.
>I decided to start by trying the example in main.c as discussed in Appendix C
>of Roger Hui's "An Implementation of J".
>I modified js.h as follows:
>#define LINKJ 1
>The program compiled & linked OK. Then I tried the following test:
> jc=. 10!:0
> 5 jc i. 7
>0 1 2 3 0
> jc i. 7
>7
> 3 jc i. 3 4
>1 2 _1
>Thus the monadic jc seems OK, but the diadic jc fails. ("x jc y" should give
>the first x elements of y.)
>I tried debugging with dbx. The new array was generated correctly, but
>something went wrong in the printing process. I had trouble following
>what was happening.
>I tried modifying the code to retain the normal main but still define
>10!:0 (essentially as Emmett McLean did in J-lapack interface). I got the
>same problem again.
>Has anyone else had similar problems? Any help would be much appreciated.
I suggest running a few programs on your implementation of J. If these
programs run ok then you should be able to use linkj or properj with
out problems. Based on your example, it looks like memory is not
being copied with memcopy.
Here is a hack which implements ntr in properj, say as lapack 30!:k
which worked ok for me: (OTOH ntr worked for me too.)
static F2(ntr){A z;I n;
ASSERT(0==AR(a),EVRANK); /* a must be scalar */
ASSERT(INT&AT(a),EVDOMAIN); /* a must be integral */
ASSERT(INT&AT(w),EVDOMAIN); /* w must be integral */
n=*AV(a); /* value of x */
ASSERT(n<=AN(w),EVLENGTH); /* x<#,y */
GA(z,INT,n,1,n); /* allocate space for result */
*AS(z)=n; /* the shape of z */
memcpy(AV(z),AV(w),4*n); /* copy into result, 4 bytes per element */
R z;
Quote:
}
See if this works.
Quote:
> I had trouble following what was happening.
What do you mean? Can you use jpr in dbx? as in print jpr(w) ?
Quote:
>Should I report the problem to Iverson Software Inc.? If so, can they be
>contacted by email?
To my knowledge not for now. Maybe Eric is available via some
apl93 address but I don't know what it would be. Encourage
hime to netify.
Quote:
>There are two distinct parts to LinkJ, one for calling C from J & the other
>for calling J from C. There should be two preprocessor flags to control
>these separately, rather than just LINKJ which enables/disable both
>together.
>--
Good idea.
As an aside, I suggest never using linkj at all. linkj aps have numeric
error messages, can not be ported to the pc to run under windows, and
results from the functions in Appendix F of IJ have to be cast to A
types (unless you hack lj.h).
-emmett