I'm puzzled why no one has used the basic matrix multiplication expression
in J.

   matmul3
([: +/ *)"1 _
   mat1=. <.0.5+10*<:+:1000 1000?@$0
   mat0=. <.0.5+10*<:+:1000 1000?@$0
   (10) 6!:2 'mat0 matmul3 mat1'
0.737084
   (10) 6!:2 'mat0 +/ . * mat1'
0.0499271
   (mat0 matmul3 mat1) -: mat0 +/ . * mat1
1



On Tue, Jul 19, 2022 at 12:49 PM Thomas McGuire <[email protected]>
wrote:

> My late night laziness and I got bitten by the 13 : definition doesn’t
> always work
> correctly with both x and y variables. Which I just assumed was working
> correctly.
>
> Now when I fix the definition of matmul3 so it works correctly (as Elijah
> pointed out) the variable
> representation does not incur a worrisome time penalty:
>
>    (1+i. 4 3) ([: +/ *)"1 _ (1+i. 3 4)
>  38  44  50  56
>  83  98 113 128
> 128 152 176 200
> 173 206 239 272
>    matmul3 =: ([: +/ *)"1 _
>    (1+i. 4 3) matmul3 (1+i. 3 4)
>  38  44  50  56
>  83  98 113 128
> 128 152 176 200
> 173 206 239 272
>
>    10 timex 'bmat1 ([: +/ *)"1 _ bmat2’
> 0.0464441
>    10 timex 'bmat1 matmul3 bmat2’
> 0.0471224
>
>    (bmat1 matmul3 bmat2) -: bmat1 ([: +/ *)"1 _ bmat2
> 1
>
>
> Thanks for showing me the error
>
> > On Jul 19, 2022, at 5:15 AM, Elijah Stone <[email protected]> wrote:
> >
> > You are measuring two completely different things.
> >
> >   10 timex'bmat1 ([: +/ *)"1 _ bmat2'
> > 0.0482293
> >   10 timex'bmat1 ([: +/ *"1 _) bmat2'
> > 0.115583
> >   (bmat1 ([: +/ *)"1 _ bmat2) -: (bmat1 ([: +/ *"1 _) bmat2)
> > 0
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>


-- 

Devon McCormick, CFA

Quantitative Consultant
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to