X-Git-Url: https://git.octo.it/?p=rrdtool.git;a=blobdiff_plain;f=doc%2Frrdgraph_rpn.pod;h=5000d7a1738915277d065318971440624dc65d4d;hp=b79e4e2db3b42d7f7be588aaeee6cf91423beccd;hb=342b22c3e74a10d7049285c2cea7383676bcfc95;hpb=1ed31d581dfed23377a61d4df88bb9c2b9b2c94b diff --git a/doc/rrdgraph_rpn.pod b/doc/rrdgraph_rpn.pod index b79e4e2..5000d7a 100644 --- a/doc/rrdgraph_rpn.pod +++ b/doc/rrdgraph_rpn.pod @@ -1,4 +1,4 @@ -=head1 NAME +=head1 NAME rrdgraph_rpn - About RPN Math in rrdtool graph @@ -12,14 +12,15 @@ If you have ever used a traditional HP calculator you already know B. The idea behind B is that you have a stack and push your data onto this stack. Whenever you execute an operation, it takes as many elements from the stack as needed. Pushing is done -implicit so whenever you specify a number or a variable, it gets -pushed automatically. +implicitly, so whenever you specify a number or a variable, it gets +pushed onto the stack automatically. -At the end of the calculation there should be one and exactly one -value left on the stack. This is the outcome of the function and -this is what is put into the I. For B instructions, -the stack is processed for each data point on the graph. B -instructions work on an entire data set in one run. +At the end of the calculation there should be one and only one value left on +the stack. This is the outcome of the function and this is what is put into +the I. For B instructions, the stack is processed for each +data point on the graph. B instructions work on an entire data set in +one run. Note, that currently B instructions only support a limited +list of functions. Example: C @@ -29,7 +30,7 @@ of your RRD script. Example: C This means: push variable I, push the number 8, execute -the operator I<+>. The operator needs two elements and uses those +the operator I<*>. The operator needs two elements and uses those to return one value. This value is then stored in I. As you may have guessed, this instruction means nothing more than I. The real power of B lies in the @@ -37,7 +38,7 @@ fact that it is always clear in which order to process the input. For expressions like C you need to multiply 3 with 5 first before you add I to get I. However, with parentheses you could change this order: C. In B, you -would do C and need no parentheses. +would do C without the need for parentheses. =head1 OPERATORS @@ -58,10 +59,10 @@ to I. Returns 1 for true or 0 for false. B -Pops three elements from the stack. If the last element is 0 (false), -the first value is pushed back onto the stack, otherwise the second -popped value is pushed back. This does, indeed, mean that any value -other than 0 is considered to be true. +Pops three elements from the stack. If the element popped last is 0 +(false), the value popped first is pushed back onto the stack, +otherwise the value popped second is pushed back. This does, indeed, +mean that any value other than 0 is considered to be true. Example: C should be read as C @@ -69,11 +70,12 @@ Z<> =item Comparing values -B +B -Pops two elements from the stack and returns the lesser or larger. -The two numbers shouldn't be I or I, if they are -that value is pushed back onto the stack as the result. +Pops two elements from the stack and returns the smaller or larger, +respectively. Note that I is larger than anything else. +If one of the input numbers is I then the result of the operation will be +I too. B @@ -99,17 +101,31 @@ Add, subtract, multiply, divide, modulo B -Sine, cosine (input in radians), log, exp (natural logarithm), square root +Sine and cosine (input in radians), log and exp (natural logarithm), +square root. B -Arctangent. Output in radians. +Arctangent (output in radians). + +B + +Arctangent of y,x components (output in radians). +This pops one element from the stack, the x (cosine) component, and then +a second, which is the y (sine) component. +It then pushes the arctangent of their ratio, resolving the ambiguity between +quadrants. + +Example: C will convert C +components into an angle in degrees. B -Round down,up to the nearest integer +Round down or up to the nearest integer. -Z<> +B + +Convert angle in degrees to radians, or radians to degrees. =item Set Operations @@ -120,7 +136,7 @@ Pop one element from the stack. This is the I of items to be sorted (or reversed) in place on the stack. Example: C will -compute the average of the values v1..v6 after removing the smallest and +compute the average of the values v1 to v6 after removing the smallest and largest. B @@ -138,14 +154,14 @@ average is essentially computed as shown here: delay t0 <---------------> delay t1 - <---------------> + <---------------> delay t2 <---------------> - Value at sample (t0) will be the average between (t0-delay) and (t0) - Value at sample (t1) will be the average between (t1-delay) and (t1) - Value at sample (t2) will be the average between (t2-delay) and (t2) + Value at sample (t0) will be the average between (t0-delay) and (t0) + Value at sample (t1) will be the average between (t1-delay) and (t1) + Value at sample (t2) will be the average between (t2-delay) and (t2) =item Special values @@ -169,22 +185,20 @@ function cannot be used in B instructions. B Pushes an I value if this is the first value of a data -set or otherwise the result of vname variable at the previous time -step. This allows you to do calculations across the data. This +set or otherwise the result of the vname variable at the previous time +step. This allows you to do calculations across the data. This function cannot be used in B instructions. B -Pushes the number 1 if this is the first value of the data set, the -number 2 if it is the second, and so on. This special value, allows -you to make calculations based on the position of the value within +Pushes the number 1 if this is the first value of the data set, the +number 2 if it is the second, and so on. This special value allows +you to make calculations based on the position of the value within the data set. This function cannot be used in B instructions. -Z<> - =item Time -Time inside RRDtool is measured in seconds since the epoch. This +Time inside RRDtool is measured in seconds since the epoch. The epoch is defined to be S>. B @@ -193,14 +207,14 @@ Pushes the current time on the stack. B