DSPRelated.com
Forums

Search for Convolution method in JAVA

Started by Walker May 1, 2006
Hello!

I'm searching for a method/class/package in JAVA that implements a linear
convolution algorithm between two signals. For example 
"public convolution(double[] signal1, double[] signal2)" that convolves
signal 1 with 2. I've searched in many webpages, but I've found nothing. 

I think, I'm serching for any easy method, but I don't know why I can't
find it. Somebody can help me? 

Me e-mail is: fositin@hotmail.com

I'm sorry if my english isn't perfect. 




Walker wrote:

> Hello! > > I'm searching for a method/class/package in JAVA that implements a linear > convolution algorithm between two signals. For example > "public convolution(double[] signal1, double[] signal2)" that convolves > signal 1 with 2. I've searched in many webpages, but I've found nothing. > > I think, I'm serching for any easy method, but I don't know why I can't > find it. Somebody can help me?
Convolution is easy to code yourself. If s1 and s2 are two causal signals (ie. s1(n) = 0 for n < 0), then the convolution y = s1 * s2 can be calculated as y(n) = sum_k^n s1(k) s2(n-k) If the lengths L1 of s1 and L2 of s2 are finite, then the length of y is equal to L1 + L2 - 1. Regards, Andor
>Convolution is easy to code yourself. If s1 and s2 are two causal >signals (ie. s1(n) = 0 for n < 0), then the convolution y = s1 * s2 can >be calculated as > >y(n) = sum_k^n s1(k) s2(n-k) > >If the lengths L1 of s1 and L2 of s2 are finite, then the length of y >is equal to L1 + L2 - 1. > >Regards, >Andor > >
Thank you, I know it, but it would be easyer when somebody would have this class/method. I can programm it, but: what happens when the signals aren't causals? Thanks
Walker wrote:

> >Convolution is easy to code yourself. If s1 and s2 are two causal > >signals (ie. s1(n) = 0 for n < 0), then the convolution y = s1 * s2 can > >be calculated as > > > >y(n) = sum_k^n s1(k) s2(n-k) > > > >If the lengths L1 of s1 and L2 of s2 are finite, then the length of y > >is equal to L1 + L2 - 1. > > > >Regards, > >Andor > > > > > > Thank you, > I know it, but it would be easyer when somebody would have this > class/method. I can programm it, but: what happens when the signals aren't > causals?
In that case the sum either comes from or goes to infinity (or both) ... not something you want to calculate with Java :-). Usually, either s1 and s2 or at least one of them can be considered finite in duration. In that case, each entry in y(n) can be computed using a finite sum.
"Walker" <fositin@hotmail.com> wrote in message 
news:BOOdneDcHYbg6srZnZ2dnUVZ_uWdnZ2d@giganews.com...
> >Convolution is easy to code yourself. If s1 and s2 are two causal >>signals (ie. s1(n) = 0 for n < 0), then the convolution y = s1 * s2 can >>be calculated as >> >>y(n) = sum_k^n s1(k) s2(n-k) >> >>If the lengths L1 of s1 and L2 of s2 are finite, then the length of y >>is equal to L1 + L2 - 1. >> >>Regards, >>Andor >> >> > > Thank you, > I know it, but it would be easyer when somebody would have this > class/method. I can programm it, but: what happens when the signals aren't > causals?
Actually the formulation above doesn't rely on either sequence representing anything "causal". You get to define the indices relative to time. Fred