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

Home » Public Forums » archive » help with stopping criterion - use of BREAK
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
help with stopping criterion - use of BREAK [message #90116] Wed, 28 January 2015 09:09 Go to next message
g.nacarts is currently offline  g.nacarts
Messages: 148
Registered: November 2013
Senior Member
Hi

I am using an iterative method and I want to add a stopping criterion in which the iterating will stop when there is no change in 3 consecutive iterations. I did the following but I am getting syntax error but I am not sure whether the use of BREAK it's correct. My code is as follows:

COUNTER = 0
IF ABS(OLD_VALUE-NEW_VALUE) EQ 0 THEN COUNTER = COUNTER + 1 $
ELSE COUNTER = 0

IF COUNTER EQ 3 THEN
BREAK
ENDIF
Re: help with stopping criterion - use of BREAK [message #90118 is a reply to message #90116] Wed, 28 January 2015 09:46 Go to previous messageGo to next message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
On Wednesday, January 28, 2015 at 12:09:52 PM UTC-5, g.na...@gmail.com wrote:
> Hi
>
> I am using an iterative method and I want to add a stopping criterion in which the iterating will stop when there is no change in 3 consecutive iterations. I did the following but I am getting syntax error but I am not sure whether the use of BREAK it's correct. My code is as follows:
>
> COUNTER = 0
> IF ABS(OLD_VALUE-NEW_VALUE) EQ 0 THEN COUNTER = COUNTER + 1 $
> ELSE COUNTER = 0
>
> IF COUNTER EQ 3 THEN
> BREAK
> ENDIF

IDL is line oriented. You can extend lines with $ like you did in the first part of your code.

This statement:
> IF COUNTER EQ 3 THEN
is a syntax error.

This statement:
> IF COUNTER EQ 3 THEN BREAK
is not a syntax error. Nor is this,
> IF COUNTER EQ 3 THEN $
> BREAK

Craig
Re: help with stopping criterion - use of BREAK [message #90176 is a reply to message #90116] Thu, 05 February 2015 13:26 Go to previous message
mick.mitanirc3 is currently offline  mick.mitanirc3
Messages: 16
Registered: August 2015
Junior Member
Why are you using the abs() function in your comparison? Since you are comparing your result to 0 the sign doesn't matter. Mathematically -0 is possible but unless you are doing some crazy stuff you won't get it and that's even providing that IDL allows integer 0 to have a sign.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: triangulation tribulation: alpha shape for raster-to-vector shape extraction (sort of a concave hull)
Next Topic: Sun symbol appears in plot window but not in pdf output

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

Current Time: Wed Oct 08 15:07:08 PDT 2025

Total time taken to generate the page: 0.00535 seconds