[Jprogramming] NYCJUG: Thinking in an Array Language

Hauke Rehr hauke.rehr at uni-jena.de
Tue Jul 19 18:13:03 UTC 2022


Tom did, in the very post starting this thread:

    (1+i. 4 3) +/ . * 1+i. 3 4
  38  44  50  56
  83  98 113 128
128 152 176 200
173 206 239 272

Am 19.07.22 um 20:10 schrieb Devon McCormick:
> 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 <tmcguirefl at gmail.com>
> 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 <elronnd at elronnd.net> 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
>>
> 
> 

-- 
----------------------
mail written using NEO
neo-layout.org


More information about the Programming mailing list