beginner's J question 
Author Message
 beginner's J question

I am trying to learn J from the somewhat terse "J Introduction and
Dictionary", by K. Iverson.  I am new to J, and have no background in
APL, so the following may seem naive.

Is it possible to save J results in some form other than a workspace?
Say some computations results in a large matrix and I want to export that
matrix to Mathematica.   How can I do it?   If I could write the matrix
as to a text file, great.  But what can I do with a workspace to make it
accessible to anything but J?

                thank you,
                David Cabana



Sun, 14 Jan 1996 22:26:37 GMT  
 beginner's J question

Quote:
 David Cabana writes:
>Is it possible to save J results in some form other than a workspace?

 You can maintain your programs in regular textfiles and load them into
 J via 0!:2 and 0!:3. And you can write output to textfiles.

   For example to write a noun from J you could use the following verb :


   Then ( x write <'b' ) writes x to filename b.

   And FYR, here is the counterpart to read which reads a textfile into J:


   So (z =. read 'textfile') makes z a character table in J (use ". to
   turn it into numbers).

 Most J programmers I know to don't use workspaces at all.
 However, a fellow name Mr. Frey wrote an article in VECTOR
 where he explains how workspaces can be used to provide
 object-oriented capabilities.

 If you have a lot of output and you want
 to organize your it so that it can be found with a key
 then you should check out MikePowell J programs for
 doing this or my C translation of his programs.

Quote:
>Say some computations results in a large matrix and I want to export that
>matrix to Mathematica.   How can I do it?

 The first step is to get familiar with the basic structs Ma uses
 to store its matrices.

 Then you would want to write wrappers which convert Ma data
 structure into J's A struct, for when you are calling J from Ma, and visa
 versa, for when you are calling Ma from J. (Generally I would think it
 would be much more helpful to call Ma from J than visa versa.)  As far
 as learning the J structs is concerned, j.h and jt.h are about all you
 have to study.  If you want the names of the C programs which implement
 the primitive J verbs, then examine t.c.

 As to how do you do it. I recommend looking at the J-lapack interface
 at watserv1.waterloo.edu in languages/apl/j/workspaces (and there
 is an interface to vfftpack in the 1993.q2 archive).

Quote:
>  If I could write the matrix as to a text file, great.

 I just gave you that, but any respectable interface will have
 to have the interface in C. This way there is no duplication
 of memory allocation and no reading&writting textfiles which
 will make your applications with large n crawl.

Quote:
>  But what can I do with a workspace to make it accessible to anything but J?

 I think you've got that.

 I recommend that you ftp to ftp.cs.ualberta.ca and get
 pub/smillie/intj.ps and intj.doc. This is paper provides a well
 written introduction to J for beginners.

 If you will be hacking the J source I suggest purchasing
 An Implementation of J.

 -emmett



Mon, 15 Jan 1996 01:11:24 GMT  
 beginner's J question

Quote:
>I am trying to learn J from the somewhat terse "J Introduction and
>Dictionary", by K. Iverson.  I am new to J, and have no background in
>APL, so the following may seem naive.
>Is it possible to save J results in some form other than a workspace?
>Say some computations results in a large matrix and I want to export that
>matrix to Mathematica.   How can I do it?   If I could write the matrix
>as to a text file, great.  But what can I do with a workspace to make it
>accessible to anything but J?
>            thank you,
>            David Cabana


I have had been able to send j-created matrices to spreadsheets and
statistical packages and Theorist (an alternative to Mma) using the
following steps.

tab=. 9{a.
lf=. 10{a.

cs=.{&('-',a.)&(('_',a.)&i.)

'cs' (I got from this newsgroup) converts j's '_' to '-'.
'clean' puts a tab after each numerical value in the array and
linefeeds at the beginning of each row.

Then I issue the following command "out =. }. , clean arrayname" to create
an output which can be written to a file. Then I use file write
"out (1!:2)  <'filename'" to actually write the file.

Maybe this will give you ideas.

--

College of Business Administration                         404-651-4070
Georgia State University                  interests: approx. reasoning,
Atlanta, Georgia USA 30303-3083     (B=)       decision support systems



Mon, 15 Jan 1996 02:05:35 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Beginner's 'enum' question

2. JS-EAI with *JS*-callback

3. Sorry it's beginner's question..

4. TK beginners question - how to 'beep'

5. js.exception 3279.js

6. Beginner's J question #12 - locales

7. Beginner's J question

8. Beginner's J questions, vol. 3

9. Beginner's J questions, vol. 4

10. Beginner's J question

11. Data Type Problem - COM Beginner's question

12. Beginner's question

 

 
Powered by phpBB® Forum Software