Skip to content

Commit

Permalink
Fix multi-column _small_filt_fir! for ndims(x)>2
Browse files Browse the repository at this point in the history
Missed in #600.
  • Loading branch information
martinholters committed Dec 2, 2024
1 parent 1be88b5 commit 431f91e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/dspbase.jl
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ function _small_filt_fir!(
bs < 2 && throw(ArgumentError("invalid tuple size"))
length(h) != bs && throw(ArgumentError("length(h) does not match bs"))
b = ntuple(j -> h[j], Val(bs))
for col in axes(x, 2)
for col in CartesianIndices(axes(x)[2:end])
v_si = N > 1 ? view(si, :, col) : si
_filt_fir!(out, b, x, v_si, col)
end
Expand Down
8 changes: 8 additions & 0 deletions test/filt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ end
@test all(col -> col y_ref, eachslice(filt(PolynomialRatio(b, a), x); dims=ntuple(n -> n+1, Val(D))))
@test all(col -> col y_ref, eachslice(filt(Biquad(PolynomialRatio(b, a)), x); dims=ntuple(n -> n+1, Val(D))))
@test all(col -> col y_ref, eachslice(filt(SecondOrderSections(PolynomialRatio(b, a)), x); dims=ntuple(n -> n+1, Val(D))))
# use _small_filt_fir!
b = [0.1, 0.1]
a = [1.0]
sz = (10, ntuple(n -> n+1, Val(D))...)
y_ref = filt(b, a, ones(sz[1]))
x = ones(sz)
@test all(col -> col y_ref, eachslice(filt(b, a, x); dims=ntuple(n -> n+1, Val(D))))
@test all(col -> col y_ref, eachslice(filt(PolynomialRatio(b, a), x); dims=ntuple(n -> n+1, Val(D))))
end

#
Expand Down

0 comments on commit 431f91e

Please sign in to comment.