--- title: "Operators and axis" author: "Jeremy Howard" date: "2022-07-05" categories: [Dyalog, APL, Glyphs] --- ]box on -style=max -trains=tree -fns=on 3 2⍴⍳6 1 4 5 =[1] 3 2⍴⍳6 ⎕←mat ← 2 3 ⍴ 10 20 30 40 50 60 mat+[1]1 2 ⍝ add along first axis ⎕ ← cube ← 2 2 2 ⍴ ⍳8 , cube , (1 2)(1 2) 'ABC' ,[0.5]'ABC' ⍴'ABC' ⍴,[0.5]'ABC' ⍴,[⍬]'ABC' 2 2 2⍴⍳8 ⎕←M ← 2 3 4 ⍴ ⍳24 ,[1 2]M ⍴,[1 2]M ,[2 3]M ⍴,[2 3]M 1 2 3 , 4 5 6 cube ← 2 2 2 ⍴ ⍳8 cube , 99 rect←3 2⍴⍳6 rect ⍴rect rect,10 rect,[1]10 rect,[0.5]10 'HEADING',[0.5]'-' ⍪1 ⎕←,5⍴⎕A ⎕←⍪5⍴⎕A 2 3 4⍴⎕A ⍴⍪2 3 4⍴⎕A ⍪2 3 4⍴⎕A 1 2 3 ⍪ 4 5 6 cube ← 2 2 2 ⍴ ⍳8 cube ⍪ 99 ⎕ ← a ← ⍳5 +/a a ← ⍳5 ×/a a ← ⍳3 ÷/a a ← 4 6 2 ⌈/ a a ← 4 6 2 ⌊/ a ×/⍳5 !5 3+/⍳4 ⍝ (1+2+3) (2+3+4) 2+/⍳4 ⍝ (1+2) (2+3) (3+4) 3÷⍨3+/⍳4 0+/⍳4 ⍝ Identity element for + 0×/⍳4 ⍝ Identity element for × ¯2,/⍳4⍝ (2,1) (3,2) (4,3) mat←2 3⍴⍳6 +/[1]mat mat←2 3⍴⍳6 +/[2]mat mat←2 3⍴⍳6 +/mat a ← ⍳5 +\a a ← ⍳5 ×\a ⎕ ← a ← ⍳3 ÷\a ⎕←mat ← 2 3 ⍴ ⍳6 +/mat ⎕←mat ← 2 3 ⍴ ⍳6 +/[1]mat +⌿mat ⎕ ← mat ← 2 3 ⍴ ⍳6 +⍀mat trace←{⍺←⊢⋄⎕←'⍺: '⍺ '⍵: '⍵⋄ ⍺ ⍺⍺ ⍵} ⍝ explainer function ⎕←cube ← 2 3 4 ⍴ ⍳24 (+⌿⍤1)cube (+⌿trace⍤1)cube ⍝ show the input to pluse reduce first ⎕←mat ← 3 4 ⍴ ⍳12 +⌿mat ⎕←cube (+⌿⍤2)cube ⎕←mat 1 2 3 (+trace⍤0 1) mat f ← *⍤÷ ⎕←*(÷3) ⎕←f 3 ⎕←*2÷3 ⎕←2 f 3 sqr ← *∘2 sqr 3 pow2 ← 2∘* pow2 3 f ← *∘÷ *(÷3) f 3 2 f 3 2 * (÷3) 2*÷3 f ← *⍥÷ *(÷3) f 3 2 f 3 (÷2)*÷3 10 (÷⍥!) 6 ⍝ P(10,4) (!10)÷!(10-4) ⍝ P(10,4) S ← +∘1 S 0 (S⍣3) 0 add ← {(S⍣⍺) ⍵} 2 add 3 mult ← {⍺ (add⍣⍵) 0} 3 mult 4 P ← S⍣¯1 P 3 (S⍣¯3) 5 sqr ← *∘2 (sqr⍣¯1)9 pow ← {⍺ (mult⍣⍵) 1} 2 pow 3 1 +∘÷⍣= 1 f ← +∘÷ 1 f 1 1 f 2 1 f 1.5 1 (f⍣15) 1 1 (f⍣=) 1 1 2 3 +.× 4 5 6 ⍝ Dot product 3 ∧.= 3 3 3 3 ⍝ All-equal ⎕←mat←2 2⍴⍳4 mat +.× mat ⍝ matrix product 1 2 3 ∘.× 4 5 6 7 ⍝ Special case: outer prodct mat←2 2⍴⍳4 ⎕←inv←⌹ mat inv +.× mat ⍝ Identity ⎕←div←5 6 ⌹ mat mat +.× div f ← *∘2 d ← 0.01 x ← 3 ((f (x+d)) - f x) ÷ d d ← 0.0001 ((f (x+d)) - f x) ÷ d grad ← {((⍺⍺ ⍺+⍵) - ⍺⍺ ⍺) ÷ ⍵} 3 f grad 0.01 3-2 2-3 3-⍨2 v←22 10 22 22 21 10 5 10 v/⍨≠v grad ← {⍵ ÷⍨ (⍺⍺ ⍺+⍵) - ⍺⍺ ⍺} 3 f grad 0.01 pow ← ×⍨ pow 3 zero ← 0⍨ 2 zero 5 ⎕ ← a ← (1 2 3 4)(5 6 7) +/¨a ⎕ ← b ← (1 2 3)(4 5 6) 2 3 +¨ b