The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 fft_convolute and fft_deconvolute
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Frank_H

Germany
Posts

Posted - 12/15/2005 :  2:06:51 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

Frank_H

Germany
Posts

Posted - 12/16/2005 :  05:09:08 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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 :-)
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000