From: hui@yrloc.ipsa.reuter.COM (Roger Hui)
Subject: Re: Two questions regarding J's syntax and semantics
Organization: Iverson Software Inc.
Date: Thu, 9 Apr 92 03:59:19 GMT

Eythan Weg writes:
 
> While using u;.0 I often find myself in need to specify intervals for
> a selection in an array which requires calculations (on my part) involving
> the dimensions of the array.  For example in (1 3,:3 2) ];.0 i. 4 5
> the selection is done to the end of the matrix.  I would have liked to
> say equivalently (1 3,: _ _) ];.0 i. 4 5.   Similarly using __ to
> reverse direction of the elements.  Does it make some sense?
 
This is a sensible proposal because it replaces what is currently an
error with a useful result.  For now, I see no compelling reason
for changing the definition, for two reasons:
 
a) The proposal introduces a discontinuity in the interpretation of the
second row of the left argument.  For example, the dictionary entry for
the primitive would have to say something like "The dimension is |1{x,
_unless_ x is infinite, whence ...".  The case for this special
interpretation of infinity would be stronger, if the same or similar
interpretations can be shown to apply in other primitives.
 
Moreover, the would-be discontinuous interpretation is for a primitive
which is already quite comprehensive.
 
b) The computation can be easily stated in other terms.  For example,
(x,:_) u;.0 y  is  x u@{.y if x is positive, and (x,:t) u;.0 y for infinite-
valued t is (x v y) u;.0 y for a verb v which is not too complicated.
Even with the proposed change to ;.0, this form (x v y) u;.0 y would be
required for other selections mentioned in the opening sentence quoted above.
 
> I am following on R. Bernecky idea that what may be left to the system
> could advantageously be removed from the programmer's concern.
 
I don't think Bob's statement is applicable in this case.  The statement
addressed the issue of "what to compute" vs. "how to compute it"; here,
we are considering the design of language primitives (how to say what to
compute ...).
 
> My other query concerns the qr decomposition.  I find the requirement
> that the rank of the matrix to be the same as the second dimension a
> limitation.  In the same vein the requirement that the monadic %.  is
> useful only for a regular matrices.  A similar comment applies to the
> dyadic case.  Is it inconsistent with J to provide the Penrose
> inverse?  I must have missed an essential point here, for otherwise I
> would not have asked.  What is it?
 
The pseudo-inverse may be useful and more general, but there is merit in
the current definition of %. :  non-singular matrices are a significant
subdomain of the universe of all numeric matrices; that is, often one
_wants_ %. to signal error if the right argument is singular.  %. is
exactly domino in APL, and QR follows %. .  Anyway, there is an alternative
to displacing the current %. .  For example:
 
   128!:0  QR Decomposition
   128!:1  R Inverse
   128!:2  SVD Decomposition   (Not Yet Specified)
   128!:3  Pseudo-Inverse      (Not Yet Specified)

------------------------------------
Roger Hui, Iverson Software Inc., 33 Major Street, Toronto, Ontario  M5S 2K9
Phone: (416) 925 6096;  Fax: (416) 488 7559
Newsgroups: comp.lang.apl