[rrd-users] Re: RPN Tutorial with logical operators (AND/OR)?

Hugo van der Kooij hvdkooij at vanderkooij.org
Sun May 2 17:25:36 MEST 2004


On Sun, 2 May 2004, Laurent LEVIER wrote:

> When I read this:
>    "CDEF:C2=in,$L2,LT,in,$L1,GE,*,in,$L1,-,0,IF,in,$L2,GT,$L1,0,IF,+" \
> I understand there is some sort of AND in the first IF: in LT $L2 AND in GE
> $L1.
> But I dont understand how is managed the 2nd IF after the 1st one, as well
> as I dont understand what's the use of the star '*' (is this the AND
> operator?) and the plus '+' at the end of the line. Does it add the result
> of the 2nd IF to the result of the 1st one? or it is another logical operator?

All of them are maths. The first * does work as the AND operator but the
+ does not at all. I am not a RPN expert however.

You need to play the stack game and rewrite it part by part to a more
common notation to figure this one out.

C2=in,$L2,LT,in,$L1,GE,*,in,$L1,-,0,IF,in,$L2,GT,$L1,0,IF,+

	Compare L2:
C2 = (in < $L2) ,in,$L1,GE,*,in,$L1,-,0,IF,in,$L2,GT,$L1,0,IF,+
	Compare L1:
C2 = (in < $L2) (in >= $L1) ,*,in,$L1,-,0,IF,in,$L2,GT,$L1,0,IF,+
	Multiply these results (which equals to AND):
C2 = ((in < $L2) * (in >= $L1)) ,in,$L1,-,0,IF,in,$L2,GT,$L1,0,IF,+
	Lower with L1:
C2 = ((in < $L2) * (in >= $L1)) (in - $L1) ,0,IF,in,$L2,GT,$L1,0,IF,+

	Now rewrite in more common format:

IF ((in < $L2) * (in >= $L1))
THEN C2a = (in - $L1)
ELSE C2a = 0

	So where did C2a come from? Well, I needed a place holder as we
	haven't finished yet.

C2b = in,$L2,GT,$L1,0,IF
C2b = (in > $L2) ,$L1,0,IF

	In more common format:
IF (in > $L2)
THEN C2b = $L1
ELSE C2b = 0

	And finaly:

C2 = C2a + C2b

The problem here lies that it only works if you use even spaced color
intervals. But if these intervals are not equaly divided you should not
use $L1 but ($L2 - $L1). Which would in the end result in:

CDEF:C2=in,$L2,LT,in,$L1,GE,*,in,$L1,-,0,IF,in,$L2,GT,$L2,$L1,-,0,IF,+

BTW: I assume here that $Lx stands for the color seperation levels.

Hugo.

-- 
 All email sent to me is bound to the rules described on my homepage.
    hvdkooij at vanderkooij.org		http://hvdkooij.xs4all.nl/
	    Don't meddle in the affairs of sysadmins,
	    for they are subtle and quick to anger.

--
Unsubscribe mailto:rrd-users-request at list.ee.ethz.ch?subject=unsubscribe
Help        mailto:rrd-users-request at list.ee.ethz.ch?subject=help
Archive     http://www.ee.ethz.ch/~slist/rrd-users
WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi



More information about the rrd-users mailing list