Author |
Topic  |
|
Frank_H
Germany
Posts |
Posted - 12/15/2005 : 2:06:51 PM
|
Origin Version (Select Help-->About Origin): 7.5 SR5 Operating System: XP
Hi!
I just want to give a warning to all future users of fft_convolute and fft_deconvolute. As a reminder, the function definition is:
int fft_convolute(vector& vecSignal, vector& vecResponse, vector& vecResult, bool bNormalize = true, bool bWrap = true)
The function computes the convolution of vecSignal and vecResponse and the result is written into vecResult. But attention: vecSignal and vecResponse are both altered in this process, as some operations (FFT) are performed within these vectors! Same is true for fft_deconvolute. Therefore these functions should be used only with a copy of any vector or dataset that you might want to use later!
It would be nice to see a warning or hint onto this effect in the help files!
Regards, Frank |
|
Mike Buess
USA
3037 Posts |
Posted - 12/15/2005 : 4:53:35 PM
|
The fact that vecSignal and vecResponse are declared as vector& is a pretty strong clue that they will be changed by the function. It's called passing variables (in this case vectors) by reference.
Mike Buess Origin WebRing Member |
 |
|
Frank_H
Germany
Posts |
Posted - 12/16/2005 : 05:09:08 AM
|
Hi Mike
When working on large vectors (or matrices), it makes pretty much sense to pass vectors by reference to avoid allocating new memory, copying data around, and deallocating it at the end. Therefore when writing time efficient code its everything but obvious that a call by reference implies necessarily a change of the data - I always use references and not a call by value for matrix and vector data. You are of cause right, that it could give a hint, but it is still far from obvious - 2 lines in the help file would be nice.
Best regards, Frank
P.S.: No offence meant, but I learned the distinction between call by reference and by value 20 years ago. But I have to admit, that I am still living too much in pre-object era of C (without ++) and Pascal, and my use of IDL in recent years threw me back (at least concerning syntax) into the Fortran 77 era :-) |
 |
|
|
Topic  |
|
|
|