comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Convert Function to Procedure
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Convert Function to Procedure [message #93237] Tue, 17 May 2016 09:33 Go to next message
dmfl0590 is currently offline  dmfl0590
Messages: 17
Registered: December 2015
Junior Member
Hi

I have the following function:

FUNCTION CREATE_NEW, Im1, Im2, B, step=step, itmax=itmax
Bnew = B
ffd_precompute,Im1,size(REFORM(B[0,*,*]), /dimensions)
ffd_grad_precompute, size(REFORM(B[0,*,*]), /dimensions)
for it=1L, itmax do begin
FIRST_FUN, Im1, Im2, Bnew, G=G
Bnew = SECOND_FUN(Im1, Im2, Bnew, G, conv=converged,step=step)
if converged then return, Bnew
endfor
return, Bnew
END

Then I changed this Function to Procedure like this:

PRO CREATE_NEW, Im1, Im2, B, step=step, itmax=itmax
Breg = B
ffd_precompute,Im1,size(REFORM(B[0,*,*]), /dimensions)
ffd_grad_precompute, size(REFORM(B[0,*,*]), /dimensions)
for it=1L, itmax do begin
FIRST_FUN, Im1, Im2, Bnew, G=G
Bnew = SECOND_FUN(Im1, Im2, Bnew, G, conv=converged,step=step)
if converged then begin
B=Bnew
return
endif
endfor
B=Bnew
END


I don't get the same results for some reason. I thought that I can put the output variables in the calling statement. The output variable in this case is the B. However, I don't get the output variable. Can anyone help with this?
Re: Convert Function to Procedure [message #93238 is a reply to message #93237] Tue, 17 May 2016 10:57 Go to previous messageGo to next message
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
On Tuesday, May 17, 2016 at 12:33:52 PM UTC-4, dmfl...@gmail.com wrote:
> Hi
>
> I have the following function:
>
> FUNCTION CREATE_NEW, Im1, Im2, B, step=step, itmax=itmax
> Bnew = B
> ffd_precompute,Im1,size(REFORM(B[0,*,*]), /dimensions)
> ffd_grad_precompute, size(REFORM(B[0,*,*]), /dimensions)
> for it=1L, itmax do begin
> FIRST_FUN, Im1, Im2, Bnew, G=G
> Bnew = SECOND_FUN(Im1, Im2, Bnew, G, conv=converged,step=step)
> if converged then return, Bnew
> endfor
> return, Bnew
> END
>
> Then I changed this Function to Procedure like this:
>
> PRO CREATE_NEW, Im1, Im2, B, step=step, itmax=itmax
> Breg = B
> ffd_precompute,Im1,size(REFORM(B[0,*,*]), /dimensions)
> ffd_grad_precompute, size(REFORM(B[0,*,*]), /dimensions)
> for it=1L, itmax do begin
> FIRST_FUN, Im1, Im2, Bnew, G=G
> Bnew = SECOND_FUN(Im1, Im2, Bnew, G, conv=converged,step=step)
> if converged then begin
> B=Bnew
> return
> endif
> endfor
> B=Bnew
> END
>
>
> I don't get the same results for some reason. I thought that I can put the output variables in the calling statement. The output variable in this case is the B. However, I don't get the output variable. Can anyone help with this?

What do you mean you "don't get the output variable" Do you mean that the variable B is undefined? or that the values are not the same as the output of CREATE_NEW()?

> PRO CREATE_NEW, Im1, Im2, B, step=step, itmax=itmax
> Breg = B

What is the variable Breg ? Why didn't you set this to Bnew like in the function?

I would put stop statements (or breakpoints) in your procedure, and make sure that values are what you expect (or the same as the function) at each step.
Re: Convert Function to Procedure [message #93239 is a reply to message #93238] Wed, 18 May 2016 00:46 Go to previous message
dmfl0590 is currently offline  dmfl0590
Messages: 17
Registered: December 2015
Junior Member
Yes, I meant that the values are not the same as the output of CREAT_NEW().
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: How to label a time axes on an image?
Next Topic: issues appending roi from IDLanROI to IDLanROIGroup

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 09:15:05 PDT 2025

Total time taken to generate the page: 0.00514 seconds