Newsgroups: comp.lang.apl
Path: watmath!ljdickey
From: ljdickey@watmath.waterloo.edu (L. J. Dickey)
Subject: Answers to Bin Li (Was: Some Questions on J
Message-ID: <1992Jan29.134134.7136@watmath.waterloo.edu>
Organization: University of Waterloo
References: <1992Jan27.024807.877@newstand.syr.edu> <ROCKWELL.92Jan28004530@socrates.umd.edu>
Date: Wed, 29 Jan 1992 13:41:34 GMT
Lines: 77

[BH has requested that I post this for him. LJD]

From: Bob Hendricks <72740.1026@CompuServe.COM>
Date: 29 Jan 92 04:31:57 EST
Subject: Answers to Bin Li
Message-Id: <920129093157_72740.1026_EHE38-1@CompuServe.COM>


This is in answer to some questions on J from Bin Li posted on 1/27/92.

   ] a=. 1 2 3
1 2 3
   ] b=. 4 5 6
4 5 6

   NB. ?1 - Convolution: don't know for sure but try this.

   +/ (-i.3) |."(_1) a*/b    NB. "itemwize" rotate
31 31 28
   +//. a*/b                 NB. also look at /. (oblique)
4 13 28 27 18
   convolute=. +/@((-@i.@#@[) |."_1 */)
   a convolute b
31 31 28
   NB. Rotation is tricky because you actually want to rotate
   NB. the rows (rank 1 cells) in the right argument with the atoms
   NB. (rank 0 cells) in the left.  Besides |."(_1) you could
   NB. also use |."(0 1) (which is probably clearer).

   NB. ?2 - Row products: products along subarrays.
   a,:b                      NB. make two item array
1 2 3
4 5 6
   */a,:b                    NB. multiply items
4 10 18
   */"_1 a,:b                NB. multibly arrays in each item
6 120
   submult=. */"_1
   submult a,:b
6 120
   NB. Same issue as in question 1.  The "insertion" always occurs
   NB. between the items of the argument so the rank conjunction
   NB. (operator) is used to move the whole operation down one
   NB. frame.

   NB. ?3 - Matrix selection.

   1{a,:b                    NB. item 1 is row 1 for rank 2 table
4 5 6
   2{1{a,:b                  NB. item 2 of item 1
6
   (<1 2){a,:b               NB. scalar intersection
6
   (<1;2){a,:b               NB. general intersection
6
   (<(<<0),<<0 1){a,:b       NB. not row 0 and not columns 1 or 2
6

   NB. ?4 - Ordering book.

   NB. The book "PROGRAMMING in J" can be ordered from
   NB.    Iverson Software Inc.
   NB.    33 Major Street
   NB.    Toronto, Ontario, Canada M5S 2K9
   NB.    Phone (416) 925-6096
   NB.    Fax (416) 488-7559

Hope this helps...thanks for the very good questions.

Bob Hendricks


-- 
Leroy J. (Lee) Dickey, Faculty of Mathematics, U of Waterloo, Canada  N2L 3G1
Internet:      ljdickey@watmath.UWaterloo.ca
UUCP:          ljdickey@watmath.UUCP             ...!uunet!watmath!ljdickey
Obsolescent?:  ljdickey@watmath.waterloo.edu     BITNET/EARN: ljdickey@watdcs
