You have seen me escape from Simple J when the going got rough!  But for 
matrix multiplication you can do

     mv =: ([: +/ *)"1  NB. matrix times vector

     mm =: [: |: (mv"2 1 |:)   NB. matrix time matrix

     ]a =: i. 2 3
  0 1 2
  3 4 5

     ]v =: i. 3
  0 1 2

     a mv v
  5 14

     ]b =: i. 3 3
  0 1 2
  3 4 5
  6 7 8

     a mm b
  15 18 21
  42 54 66

     a +/ . * b
  15 18 21
  42 54 66

To me it is always a pleasure to see how simply J can do complicated 
things.  And I am glad we have +/ . *  .


On 12/7/2011 8:02 AM, Raul Miller wrote:
> Yes, that was intended to be a simple, meaningful example of f@g@h -- and a
> concise example of how the "Simple J" rules can make some things awkward.
>
> (But it's hardly the only thing made awkward -- consider inner product as
> another concise example.)
...

(THE EXAMPLE:)

 >   require 'strings' NB. require needed for j6, irrelevant for j7
 >
 >   <@toupper@> 'this';'is';'a';'test'
 > +----+--+-+----+
 > |THIS|IS|A|TEST|
 > +----+--+-+----+
 >
 > Here's an explicit equivalent that does not require rank and does not 
use @
 >   a=: toupper 0 {:: 'this';'is';'a';'test'
 >   b=: toupper 1 {:: 'this';'is';'a';'test'
 >   c=: toupper 2 {:: 'this';'is';'a';'test'
 >   d=: toupper 3 {:: 'this';'is';'a';'test'
 >   a;b;c;d
 > +----+--+-+----+
 > |THIS|IS|A|TEST|
 > +----+--+-+----+
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to