Beginner's J question
Author Message
Beginner's J question

J Version 6.2.

Trying to do a simple dot-product, I write

0 1 4

(i. 3) ((+/) . *) (i. 3)
5

Shouldn't these results be the same?

Henry Rich

Sun, 23 Mar 1997 00:14:19 GMT
Beginner's J question

0 1 4
(i. 3) ((+/) . *) (i. 3)
5

Shouldn't these results be the same?

No.  inner product is nothing like preprocess.

Here's the above rephrased in terms of partial results

((+/0), (+/1), (+/4))
0 1 4

(i. 3) ((+/) . *) (i. 3)
(0 1 2) (+/ . *) (0 1 2)
+/0 1 4
5

Hmm... dot product is much more meaningful if you're working with
arrays with more dimensions than 1.  Basically, the operation to the
right of the dot is used to combine elements of the left argument with
items of the right argument.  Then, the operation on the left of the
dot is used to combine the arguments corresponding to the rank 1
subarrays of the left argument.

--
Raul D. Miller           n =: p*q             NB. 9<##:##:n [.large prime p, q

NB.  public e, n, y
x -: n&|&(*&y)^:d 1  NB. 1=(d*e)+.p*&<:q

Sun, 23 Mar 1997 10:02:57 GMT
Beginner's J question
: J Version 6.2.
: Trying to do a simple dot-product, I write

: 0 1 4
:    (i. 3) ((+/) . *) (i. 3)
: 5
: Shouldn't these results be the same?
: Henry Rich

The ranks are different, the first has rank 0; compare:
(+/ . *)~ i.3
5

0 1 4

5

5
Cliff
--
Clifford A. Reiter
Mathematics Department, Lafayette College
Easton, PA 18042 USA,   610-250-5277

Sun, 23 Mar 1997 19:57:10 GMT
Beginner's J question

Quote:

> 0 1 4

So the arguments get broken down into the three 0-0-cell-pairs
(0 with 0), (1 with 1), and (2 with 2).  Each pair gets fed through

are re-combined to the common result array.

The arguments will be passed in their entirety (ie., as vectors)

0-0-cell-pairs, but also the re-combinition, so the +/-stage
operates again on a vector.

I guess everybody beginning with J is puzzled by that.  You're
welcome to continue with your questions.

Martin Neitzel

PS:  So you know now that it is important to Watch Ranks!
The adverb b. allows you to inquire the ranks of both primitive
and programmed verbs:

_ 0 0

Interestingly, this use of "base" b. was described in the "Programming
in J" but not the the Dictionary at the time of version 5.  I know that
some people have put much effort into devising such an adverb on their
own.
J has some primitives reflecting on the language, such as word formation,
name class enquiries, and pretty printing.  b. falls into this set, too.
Which reminds me that I'm still not done with my "J by topic" classification.

Sun, 23 Mar 1997 23:39:40 GMT
Beginner's J question
Martin Neitzel:
.

. > 0 1 4
.
. That's kind of a FAQ.  ...

I think the problem is that the dictionary uses notations like mv lu
rv to indicate the rank of verbs derived by adverbs and conjunctions.
And, while the meanings are obvious once you understand them (modadic
rank of v, left rank of u, right rank of v), this correspondence isn't
explicitly stated in the dictionary.  [Or, if it has, could somebody
point out to me where?]

--
Raul D. Miller           n =: p*q             NB. 9<##:##:n [.large prime p, q

NB.  public e, n, y
x -: n&|&(*&y)^:d 1  NB. 1=(d*e)+.p*&<:q

Mon, 24 Mar 1997 09:34:50 GMT
Beginner's J question

Quote:
> [Or, if it has, could somebody point out to me where?]

The small introductory paragraph of "part III, Definitions" has
the hints.

Yeah, the Dictionary is a Gordian Knot, mostly due to its numerous
self-references.  Problem is:  once I understood it, I couldn't express
the rules any clearer and simpler than they already are.  I tried and
failed.

Martin Neitzel

Mon, 24 Mar 1997 19:53:37 GMT
Beginner's J question
Raul Miller:
. > [Or, if it has, could somebody point out to me where?]

Martin Neitzel:
. The small introductory paragraph of "part III, Definitions" has the
. hints.

Well, there's a couple paragraphs there that point out a lot of the
significance of the rank notation of the dictionary.  However, it does
not appear to indicate the significance of the leading letters in (to
use the example presented there) mu, lv, rv, etc.

--
Raul D. Miller           n =: p*q             NB. 9<##:##:n [.large prime p, q

NB.  public e, n, y
x -: n&|&(*&y)^:d 1  NB. 1=(d*e)+.p*&<:q

Mon, 24 Mar 1997 20:53:37 GMT

 Page 1 of 1 [ 7 post ]

Relevant Pages