scalanlp/breeze — pull request #137 by ktakagaki (2014-01-24 15:51:59+00:00)
Title: convolve/correlate first versions done

Hi David,

I've finished my first pass at convolve/correlate. I'm interested to hear what you think of the syntax, especially for option passing with case classes. The options are all placed in breeze.signal/options.scala

These are some examples of how one would use convolve/correlate, as I have it now...

val kernel = DenseVector(1.0, 2.0)
val data = DenseVector(2.0, 3.0, 4.0, 5.0)

//default has no overhangs
convolve(data, kernel) => DenseVector(7.0, 10.0, 13.0)

//this is the MatLab default, with zero padding on both ends (i.e. padding = OptPadding.Value(0d) )
convolve(data, kernel, overhang = OptOverhang.Full() ) => DenseVector(2.0, 7.0, 10.0, 13.0, 10)

//one can also specify padding with the boundary values (first and last element of the data)
//which is sometimes done in DSP, especially image processing.... padding = OptPadding.Boundary()

//one can also specify cyclical padding, which is also common in DSP...
//padding = OptPadding.Cyclical()

I'll edit if you have any comments, and then I plan to document it all with scaladoc and in the Wiki.
At some point, I'd like to put in fft convolution for longish floating-point DV's
convolve( data, kernel, ..., method = OptMethod.FFT() )

Kenta