--- ray/doc/man/man1/rcalc.1 2003/12/09 15:59:06 1.4 +++ ray/doc/man/man1/rcalc.1 2022/03/13 16:11:48 1.17 @@ -1,4 +1,4 @@ -.\" RCSid "$Id: rcalc.1,v 1.4 2003/12/09 15:59:06 greg Exp $" +.\" RCSid "$Id: rcalc.1,v 1.17 2022/03/13 16:11:48 greg Exp $" .TH RCALC 1 4/6/99 RADIANCE .SH NAME rcalc - record calculator @@ -9,6 +9,8 @@ rcalc - record calculator ][ .B \-l ][ +.B "\-p | \-P" +][ .B \-n ][ .B \-w @@ -21,6 +23,10 @@ rcalc - record calculator ][ .B "\-o format" ][ +.B "\-in M" +][ +.B "\-on M" +][ .B "\-f source" ][ .B "\-e expr" @@ -54,6 +60,11 @@ A special form of the option may be followed immediately by a 'd' or an 'f' and an optional count, which defaults to 1, indicating the number of double or float binary values to read per record on the input file. +If the input is byte-swapped, the +.I \-iD +or +.I \-iF +options may be substituted. If binary input is specified, no format string or file is needed. .PP A @@ -66,10 +77,51 @@ or .I \-of options do not require a count, as this will be determined by the number of output channels in the given expressions. +If byte-swapped output is desired, the +.I \-oD +or +.I \-oF +options may be substituted. .PP +The +.I \-p +option specifies "passive mode," where characters that do not +match the input format are passed unaltered to the output. +If the +.I \-P +option is given instead, then valid input records that do not +yield a positive +.I cond +value are similarly passed to the output. +(See paragraph below.)\0 +These options options require that the +.I \-i +input format and +.I \-o +output format also be present. +With both input and output formats, the passive mode can +effectively substitute information in the middle of a file +or stream without affecting the rest of the data. +.PP +If a +.I \-in +option is given with a positive integer argument, +.I rcalc +will stop processing input once it has loaded this number of records. +Similarly, if a +.I \-on +option is present, +.I rcalc +will stop after producing this many records, which may be a smaller +number if the +.I cond +variable is used. +If multiple input files are given, these counts are continuous over +the input and do not reset on each file. +.PP The variable and function definitions in each .I \-f source -file are read and compiled. +file are read and compiled from the RADIANCE library where it is found. The .I \-e expr option can be used to define variables on the command line. @@ -177,7 +229,8 @@ and the following operators: .PP + - * / ^ .PP -Operators are evaluated left to right. +Operators are evaluated left to right, except '^', +which is right associative. Powers have the highest precedence; multiplication and division are evaluated before addition and subtraction. Expressions can be grouped with parentheses. @@ -204,11 +257,19 @@ If is positive, output is produced. If .I cond -is less than or equal to zero, the record is skipped and no other expressions +is less than or equal to zero, the record is skipped (or passed to the +output if +.I \-P +is specified) and no other expressions are evaluated. This provides a convenient method for avoiding inappropriate calculations. The following library of pre-defined functions and variables is provided: .TP 10n +.BR $N +Return the value for input column +.I N. +If an input format is given, using a channel number generates an error. +.TP .BR "in(n)" Return the value for input column .I n, @@ -219,8 +280,8 @@ This is an alternate way to get a column value instead the $N notation, and is more flexible since it is programmable. This function is disabled if an input format is used. .TP -.BR "if(cond, then, else)" -if cond is greater than zero, +.BR "if(test, then, else)" +if test is greater than zero, then is evaluated, otherwise else is evaluated. This function is necessary for recursive definitions. .TP @@ -234,6 +295,12 @@ is zero, the number of available arguments is returned .BR "rand(x)" compute a random number between 0 and 1 based on x. .TP +.BR "min(a1, a2, ..)" +return the minimum value from a list of arguments. +.TP +.BR "max(a1, a2, ..)" +return the maximum value from a list of arguments. +.TP .BR "floor(x)" return largest integer not greater than x. .TP @@ -268,12 +335,14 @@ trigonometric functions. inverse trigonometric functions. .TP .BR "atan2(y, x)" -inverse tangent of y/x (range -pi to pi). +inverse tangent of y/x (range \-pi to pi). .SH EXAMPLE To print the square root of column two in column one, and column one times column three in column two: .IP "" .2i rcalc -e '$1=sqrt($2);$2=$1*$3' inputfile > outputfile +.SH ENVIRONMENT +RAYPATH the directories to check for auxiliary files. .SH AUTHOR Greg Ward .SH BUGS @@ -282,5 +351,17 @@ String variables can only be used in input and output options, not in definitions. .PP Tabs count as single spaces inside fields. +.PP +The +.I \-P +option buffers up to 16 Kbytes of data per record. +Longer records passed because the "cond" variable +evaluates to <= 0 will be partial; a warning will +be generated and the string "*** MISSING DATA ***" +will appear at the break. +The only workaround is to use the +.I \-p +option instead, which does not pass rejected records. .SH "SEE ALSO" -calc(1), cnt(1), ev(1), getinfo(1), lam(1), tabfunc(1), total(1) +cnt(1), ev(1), getinfo(1), icalc(1), rcollate(1), rlam(1), +rsplit(1), tabfunc(1), total(1)