I am also a big fan of dot product (.); however, I have noticed that when
the following assertion holds:

assert (X u/ .v Y) -: (X u/@:v Y)

often the form u/@:v reportedly requires less space.  For example,

   stp=. ([ ((<;._1 '|Sentence|Space|Time|Space * Time') , (, */&.:>@:(1
2&{))@:(] ; 7!:2@:] ; 6!:2)&>) (10{a.) -.&a:@:(<;._2@,~) ]) ".@:('0 : 0'"_)

   $A=:(;:'b c') (0 0;2 2)}3 3$a:
3 3

   stp 666
a: */ .= A
a: */@:= A
)
┌──────────┬─────┬─────────────┬────────────┐
│Sentence  │Space│Time         │Space * Time│
├──────────┼─────┼─────────────┼────────────┤
│a: */ .= A│3328 │5.24466421e_6│0.0174542425│
├──────────┼─────┼─────────────┼────────────┤
│a: */@:= A│2688 │4.38226586e_6│0.0117795306│
└──────────┴─────┴─────────────┴────────────┘

   $B=. ,~^:6 ,.~^:4 A
192 48

   stp 666
a: */ .= B
a: */@:= B
)
┌──────────┬─────┬─────────────┬────────────┐
│Sentence  │Space│Time         │Space * Time│
├──────────┼─────┼─────────────┼────────────┤
│a: */ .= B│19712│9.839355e_5  │1.93953366  │
├──────────┼─────┼─────────────┼────────────┤
│a: */@:= B│3072 │9.72654664e_5│0.298799513 │
└──────────┴─────┴─────────────┴────────────┘

   $B=. ,~^:4 ,.~^:6 A
48 192

   stp 666
a: */ .= B
a: */@:= B
)
┌──────────┬─────┬─────────────┬────────────┐
│Sentence  │Space│Time         │Space * Time│
├──────────┼─────┼─────────────┼────────────┤
│a: */ .= B│19968│9.48200523e_5│1.8933668   │
├──────────┼─────┼─────────────┼────────────┤
│a: */@:= B│3840 │9.18216923e_5│0.352595298 │
└──────────┴─────┴─────────────┴────────────┘

Nevertheless, when efficiency is not critical I keep the dot product form
for clarity (in my mind anyway).  Fortunately, then again I suspect this is
no accident, the common form of linear combinations is not at a
disadvantage.

   C=. ?.99$0
   D=. ?.99 55$0

   stp 666
C +/ .* D
C +/@:* D
)
┌─────────┬─────┬─────────────┬────────────┐
│Sentence │Space│Time         │Space * Time│
├─────────┼─────┼─────────────┼────────────┤
│C +/ .* D│3456 │1.14990557e_5│0.0397407366│
├─────────┼─────┼─────────────┼────────────┤
│C +/@:* D│3456 │1.73971454e_5│0.0601245347│
└─────────┴─────┴─────────────┴────────────┘




On Wed, Jun 1, 2016 at 11:51 AM, Brian Schott <[email protected]>
wrote:

> Raul,
>
> a: */ . = A is very impressive to me especially because it seems to avoid
> the transpose.
> I want to remember it because I  have occasionally thought a special case
> in J for &.|: would be very effective, but perhaps next time that occurs to
> me I'll remember your answer here.
>
> On Wed, Jun 1, 2016 at 10:07 AM, Raul Miller <[email protected]>
> wrote:
>
> > Or, there's a general pattern leading in the direction of (the
> > incredibly useful) linear algebra:
> >
> >       A=:(;:'b c') (0 0;2 2)}3 3$a:
> >       */"1 a: = A
> > 0 1 0
> >       a: */ .= A
> > 0 1 0
> >
> > --
> > Raul
> >
> >
> >
> >
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to