Skip to content

1D Convolution - always a 0 element #852

Closed
@jiegillet

Description

@jiegillet

This is possibly talked about in #202 but I'm pretty sure the chapter on convolution came after that issue...

Bug Report

Description

There is always a 0 element in the linear convolution.

Steps to Reproduce

The code says

# full convolution, output will be the size of x + y
full_linear_output = convolve_linear(x, y, length(x) + length(y))

for example,

julia> convolve_linear([1,2], [7, 8], 4)
4-element Array{Float64,1}:
  7.0
 22.0
 16.0
  0.0

The last element is always 0 because it corresponds to a situation when the signal and filter functions don't overlap at all.

  1 2  1 2  1 2    1 2
  |    | |    |
8 7    8 7    8 7     8 7
  7    22     16    0

Expected behavior

# full convolution, output will be the size of x + y - 1
full_linear_output = convolve_linear(x, y, length(x) + length(y) - 1)
julia> convolve_linear([1,2], [7, 8], 3)
4-element Array{Float64,1}:
  7.0
 22.0
 16.0

For Algorithm Archive Developers

  • The bug can be reproduced
  • The bug can be fixed (if not, please explain why not in a comment below)
  • There is a timeline to fix the bug
  • The bug has been fixed (Please link the PR)

Metadata

Metadata

Assignees

No one assigned

    Labels

    ProblemThis is a problem in the archive or an implementation.lang: juliaJulia programming language

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions