Exercise 15 | Index << >> |
Let x and y be vectors of floating point numbers. Compare the times for x⍳y and x{⎕ct←0 ⋄ ⍺⍳⍵}y . Compare their results. I0←{⎕ct←0 ⋄ ⍺⍳⍵} x ← ?1e6⍴0 y ← ?1e6⍴0 cmpx 'x⍳y' 'x I0 y' x⍳y → 2.05e¯1 | 0% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕ x I0 y → 1.22e¯1 | -41% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕ x ← 0.1 , ?1e6⍴9e5 y ← 100 × 100 ÷⍨ x cmpx 'x⍳y' 'x{⎕ct←0 ⋄ ⍺⍳⍵}y' x⍳y → 1.79e¯1 | 0% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕ * x I0 y → 1.11e¯1 | -39% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕ |