diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-02-10 17:04:06 -0500 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-02-10 17:04:06 -0500 |
| commit | 4f3b2a488cbd63936266117008cfa560fa42a1c2 (patch) | |
| tree | c67214f60f66b90a19d441a59b7b56753c0c2f10 /filter.bqn | |
| parent | 77ad395ae37ba96048edc17d3a51d472d5102a52 (diff) | |
Specialize filtering function to common lengths
Diffstat (limited to 'filter.bqn')
| -rw-r--r-- | filter.bqn | 24 |
1 files changed, 17 insertions, 7 deletions
@@ -37,13 +37,23 @@ o ← ≠◶⟨•Import∘"options.bqn", ⊑⟩ •args # 𝕩 is the signal to filter # 𝕨 is ⟨result coefficients , 𝕩 coefficients⟩. Filter ← { - a‿b ← 0×coeff←𝕨 # accumulators and coefficients for input and result - { - a«˜↩𝕩 - r←+´coeff+´∘רa‿b - b«˜↩r - r - }¨ 𝕩 + ⟨i0⟩‿⟨o0⟩ 𝕊𝕩: + b0←a0←0 + { b0↩(o0×b0)+i0×a0↩𝕩 }¨ 𝕩 + ;⟨i0,i1⟩‿⟨o0⟩ 𝕊𝕩: + b0←a1←a0←0 + { b0↩(o0×b0)+(i1×a1↩𝕩)+i0×a0↩a1 }¨ 𝕩 + ;⟨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 }¨ 𝕩 + ;coeff 𝕊𝕩: + a‿b ← 0×coeff # accumulators for input and result + { + a«˜↩𝕩 + r←+´coeff+´∘רa‿b + b«˜↩r + r + }¨ 𝕩 }⎉1 _f ← { !∘0⊘(𝔽⊸Filter) } |
