1 |
< |
.\" RCSid "$Id" |
1 |
> |
.\" RCSid "$Id$" |
2 |
|
.TH RCALC 1 4/6/99 RADIANCE |
3 |
|
.SH NAME |
4 |
|
rcalc - record calculator |
9 |
|
][ |
10 |
|
.B \-l |
11 |
|
][ |
12 |
+ |
.B \-p |
13 |
+ |
][ |
14 |
|
.B \-n |
15 |
|
][ |
16 |
|
.B \-w |
56 |
|
option may be followed immediately by a 'd' or an 'f' and an optional |
57 |
|
count, which defaults to 1, indicating the number of double or float |
58 |
|
binary values to read per record on the input file. |
59 |
+ |
If the input is byte-swapped, the |
60 |
+ |
.I \-iD |
61 |
+ |
or |
62 |
+ |
.I \-iF |
63 |
+ |
options may be substituted. |
64 |
|
If binary input is specified, no format string or file is needed. |
65 |
|
.PP |
66 |
|
A |
73 |
|
.I \-of |
74 |
|
options do not require a count, as this will be determined by the |
75 |
|
number of output channels in the given expressions. |
76 |
+ |
If byte-swapped output is desired, the |
77 |
+ |
.I \-oD |
78 |
+ |
or |
79 |
+ |
.I \-oF |
80 |
+ |
options may be substituted. |
81 |
|
.PP |
82 |
+ |
The |
83 |
+ |
.I \-p |
84 |
+ |
option specifies "passive mode," where characters that do not |
85 |
+ |
match the input format are passed unaltered to the output. |
86 |
+ |
This option has no effect unless |
87 |
+ |
.I \-i |
88 |
+ |
is also specified, and does not make much sense unless |
89 |
+ |
.I \-o |
90 |
+ |
is also given. |
91 |
+ |
With both input and output formats, the passive mode can |
92 |
+ |
effectively substitute information in the middle of a file |
93 |
+ |
or stream without affecting the rest of the data. |
94 |
+ |
.PP |
95 |
|
The variable and function definitions in each |
96 |
|
.I \-f source |
97 |
|
file are read and compiled. |
202 |
|
.PP |
203 |
|
+ - * / ^ |
204 |
|
.PP |
205 |
< |
Operators are evaluated left to right. |
205 |
> |
Operators are evaluated left to right, except '^', |
206 |
> |
which is right associative. |
207 |
|
Powers have the highest precedence; multiplication and |
208 |
|
division are evaluated before addition and subtraction. |
209 |
|
Expressions can be grouped with parentheses. |
235 |
|
This provides a convenient method for avoiding inappropriate calculations. |
236 |
|
The following library of pre-defined functions and variables is provided: |
237 |
|
.TP 10n |
238 |
+ |
.BR \$N |
239 |
+ |
Return the value for input column |
240 |
+ |
.I N. |
241 |
+ |
If an input format is given, using a channel number generates an error. |
242 |
+ |
.TP |
243 |
+ |
.BR "in(n)" |
244 |
+ |
Return the value for input column |
245 |
+ |
.I n, |
246 |
+ |
or the number of columns available in this record if |
247 |
+ |
.I n |
248 |
+ |
is 0. |
249 |
+ |
This is an alternate way to get a column value instead of using |
250 |
+ |
the $N notation, and is more flexible since it is programmable. |
251 |
+ |
This function is disabled if an input format is used. |
252 |
+ |
.TP |
253 |
|
.BR "if(cond, then, else)" |
254 |
|
if cond is greater than zero, |
255 |
|
then is evaluated, otherwise else is evaluated. |
299 |
|
inverse trigonometric functions. |
300 |
|
.TP |
301 |
|
.BR "atan2(y, x)" |
302 |
< |
inverse tangent of y/x (range -pi to pi). |
302 |
> |
inverse tangent of y/x (range \-pi to pi). |
303 |
|
.SH EXAMPLE |
304 |
|
To print the square root of column two in column one, |
305 |
|
and column one times column three in column two: |
306 |
|
.IP "" .2i |
307 |
< |
rcalc -e '$1=sqrt($2);$2=$1*$3' inputfile > outputfile |
307 |
> |
rcalc \-e '$1=sqrt($2);$2=$1*$3' inputfile > outputfile |
308 |
|
.SH AUTHOR |
309 |
|
Greg Ward |
310 |
|
.SH BUGS |
314 |
|
.PP |
315 |
|
Tabs count as single spaces inside fields. |
316 |
|
.SH "SEE ALSO" |
317 |
< |
calc(1), cnt(1), ev(1), getinfo(1), lam(1), tabfunc(1), total(1) |
317 |
> |
cnt(1), ev(1), getinfo(1), icalc(1), rcollate(1), rlam(1), tabfunc(1), total(1) |