From 13b10e45090a5569de994847febcdf71b8f44f88 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Thu, 11 Feb 2021 13:19:52 -0500 Subject: Avoid name lookups in filter code for faster execution in current dzaima/BQN --- filter.bqn | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/filter.bqn b/filter.bqn index effdde4..d532627 100644 --- a/filter.bqn +++ b/filter.bqn @@ -38,19 +38,19 @@ o ← ≠◶⟨•Import∘"options.bqn", ⊑⟩ •args # 𝕨 is ⟨result coefficients , 𝕩 coefficients⟩. Filter ← { ⟨i0⟩‿⟨o0⟩ 𝕊𝕩: - b0←a0←0 - { b0↩(o0×b0)+i0×a0↩𝕩 }¨ 𝕩 + 1↓ (×⟜o0+i0⊸×)` 0∾𝕩 ;⟨i0,i1⟩‿⟨o0⟩ 𝕊𝕩: - b0←a1←a0←0 - { b0↩(o0×b0)+(i1×a1↩𝕩)+i0×a0↩a1 }¨ 𝕩 + b0←a1←a0←0 ⋄ coeff←∾𝕨 + { b0↩+´coeff×⟨a0↩a1,a1↩𝕩,b0⟩ }¨ 𝕩 ;⟨i0,i1,i2⟩‿⟨o0,o1⟩ 𝕊𝕩: - b1←b0←a2←a1←a0←0 - { b1↩(o1×b0↩b1)+(o0×b0)+(i2×a2↩𝕩)+(i1×a1↩a2)+i0×a0↩a1 }¨ 𝕩 + b1←b0←a2←a1←a0←0 ⋄ coeff←∾𝕨 + { b1↩+´coeff×⟨a0↩a1,a1↩a2,a2↩𝕩,b0,b0↩b1⟩ }¨ 𝕩 ;coeff 𝕊𝕩: a‿b ← 0×coeff # accumulators for input and result + c ← ∾coeff { a«˜↩𝕩 - r←+´coeff+´∘רa‿b + r←+´c×a∾b b«˜↩r r }¨ 𝕩 -- cgit v1.2.3