I want to define a convolution operator for two Array objects.
Unfortunately, * operator has been used for Array class. +,-,/ are not
good candidates for convolution. Is there any other alternatives for
convolution?

I want to define a convolution operator for two Array objects. Unfortunately, * operator has been used for Array class. +,-,/ are not good candidates for convolution. Is there any other alternatives for convolution?

I want to define a convolution operator for two Array objects. Unfortunately, * operator has been used for Array class. +,-,/ are not good candidates for convolution. Is there any other alternatives for convolution?

Thanks, Peng

I'm sure there are a lot of good reasons not to do this but if you insist...

You could define Array::operator*() to return a proxy object ArrayProxy
that acts as a handle to the Array and then define
Array::operator*(const ArrayProxy&) to perform the convolution between
*this and the Array inside the proxy handle.

This lets you write, for example, array1**array2 and use the somewhat
conventional ** syntax for convolution.

But personally, aside from being mildly amusing, I don't think it's
worth the trouble and I would opt for a named function instead.

I want to define a convolution operator for two Array objects. Unfortunately, * operator has been used for Array class. +,-,/ are not good candidates for convolution. Is there any other alternatives for convolution?

Thanks, Peng

I'm sure there are a lot of good reasons not to do this but if you insist...

You could define Array::operator*() to return a proxy object ArrayProxy that acts as a handle to the Array and then define Array::operator*(const ArrayProxy&) to perform the convolution between *this and the Array inside the proxy handle.

This lets you write, for example, array1**array2 and use the somewhat conventional ** syntax for convolution.

But personally, aside from being mildly amusing, I don't think it's worth the trouble and I would opt for a named function instead.

Mark

Just for fun, here's a little sample of this idea: (I've used ** for
exponentiation rather than convolution, but the idea is the same)