Convolution with Scaled Waves

Hello,

I'm trying to figure out the best way to get Igor to execute a convolution that takes wave scaling into account, provided that the two waves of interest have the same scaled delta value. So far, I have come up with this:


function SmartConvolve(srcWaveName,destWaveName)
wave srcWaveName, destWaveName
if( dimdelta(srcWaveName,0) != dimdelta(destWaveName,0) ) 
	print "SmartConvolve has failed."
	abort
elseif( dimoffset(srcWaveName,0) == 0 )
	Convolve srcWaveName, destWaveName
	destWaveName *= dimdelta(destWaveName,0)
else	
	variable x0_dest, x0_src, offst
	x0_dest = dimoffset(srcWaveName,0)
	x0_src = dimoffset(destWaveName,0)
	Convolve srcWaveName destWaveName
	offst =  x0_dest + x0_src
	setscale/p x, offst, dimdelta(destWaveName,0), destWaveName 
	destWaveName *= dimdelta(destWaveName,0)
endif
end


Just curious, is this the best I can hope to do? Or is there a smarter (or faster) way to execute some of these commands. I'm thinking of playing around a little bit with the rotate operation...

P.S.: Adding a flag to the convolve operation that makes the operation wave-scaling aware might be a nice thing to add to the Igor Pro Wish list, don't you think?