tomwalters@0: .TH OP 1 "14 September 1993" tomwalters@0: tomwalters@0: .SH NAME tomwalters@0: op \- Ordered sequence of operations on input stream. tomwalters@0: tomwalters@0: .SH SYNTAX tomwalters@0: op [options] [file] tomwalters@0: tomwalters@0: .SH DESCRIPTION tomwalters@0: tomwalters@0: A sequence of operations is done on each item in the input stream. tomwalters@0: The operations are done in the order they appear on the tomwalters@0: command line. Operations can be repeated as many times as needed on the tomwalters@0: command line. tomwalters@0: tomwalters@0: Input items may be binary numbers (short or float) or ascii lines tomwalters@0: (terminated by CR) according to the type option. tomwalters@0: tomwalters@0: .SH OPTIONS tomwalters@0: tomwalters@0: 1. Operations. tomwalters@0: tomwalters@0: The list of operations is as follows. Some operations take valued tomwalters@0: arguments (which are real numbers), others are flags, as indicated: tomwalters@0: tomwalters@0: .nf tomwalters@0: operation result for each input item x tomwalters@0: tomwalters@0: add= x+ tomwalters@0: negate=on -x tomwalters@0: multiply= x* tomwalters@0: divide= x/ tomwalters@0: remainder= real remainder of x/ tomwalters@0: inverse=on 1/x tomwalters@0: round=on x rounded to nearest integer tomwalters@0: absolute=on |x| tomwalters@0: power= x^ tomwalters@0: exponent= ^x tomwalters@0: e-exponent=on e^x tomwalters@0: log= log(x) to base tomwalters@0: e-log=on log(x) to base e. tomwalters@0: sin=on sin(x) tomwalters@0: cos=on cos(x) tomwalters@0: tan=on tan(x) tomwalters@0: threshold= if ( x ) 0 else if ( x = ) 1 tomwalters@0: diff1=on first difference tomwalters@0: diff2=on second difference tomwalters@0: diff3=on third difference tomwalters@0: cusum=on cumulative sum tomwalters@0: cumean=on cumulative (recursive) mean an tomwalters@0: cumin=on cumulative min tomwalters@0: cumax=on cumulative max tomwalters@0: .fi tomwalters@0: tomwalters@0: tomwalters@0: 2. type. tomwalters@0: tomwalters@0: The `type' option sets the data type for all input and output items. tomwalters@0: Recognised data types are: short, float, ascii. tomwalters@0: tomwalters@0: Ascii data is read in line-by-line, and comment lines are allowed. tomwalters@0: The following operation apply only to ascii input items, enabling tomwalters@0: comment lines to be stripped or echoed directly to the output. tomwalters@0: tomwalters@0: .nf tomwalters@0: strip= ignore lines beginning with string tomwalters@0: echo= echo lines beginning with string tomwalters@0: number=on number output lines tomwalters@0: .fi tomwalters@0: tomwalters@0: If number=on then stripped lines are not numbered; they simply dissappear. tomwalters@0: If there are no operations, (other than comment stripping/echoing or line tomwalters@0: numbering), then ascii lines are echoed. tomwalters@0: tomwalters@0: tomwalters@0: .SH EXAMPLES tomwalters@0: tomwalters@0: 1. Specify the following ordered sequence of operations on each binary tomwalters@0: float in the input stream: invert (take reciprocal), scale up by 100, tomwalters@0: square (raise to power 2), invert (take reciprocal), square root (raise to tomwalters@0: power 0.5). tomwalters@0: tomwalters@0: op type=float inverse=on multiply=100 power=2 inverse=on power=.5 file tomwalters@0: tomwalters@0: 2. Increase dynamic range by powering up and scaling down. tomwalters@0: (Note that internal calculating is done in floating point; the short datatype tomwalters@0: applies only to input and output). tomwalters@0: tomwalters@0: op type=short power=4 divide=3e8 file tomwalters@0: tomwalters@0: 3. Print out the result of log2(17/16). tomwalters@0: tomwalters@0: echo 17 | op type=ascii -div16 -log2 tomwalters@0: tomwalters@0: 4. For each input number x output exp(-0.2x) tomwalters@0: tomwalters@0: op mult=-0.2 e-exp=on tomwalters@0: tomwalters@0: 5. Read ascii data ignoring any comment lines defined as beginning with the tomwalters@0: string "**". Read one ascii number per line and for each number x output 149-x. tomwalters@0: tomwalters@0: op type=ascii strip="**" neg=on add=149 file tomwalters@0: tomwalters@0: .SH "SEE ALSO" tomwalters@0: tomwalters@0: options merge tomwalters@0: .SH COPYRIGHT tomwalters@0: .LP tomwalters@0: Copyright (c) Applied Psychology Unit, Medical Research Council, 1995 tomwalters@0: .LP tomwalters@0: Permission to use, copy, modify, and distribute this software without fee tomwalters@0: is hereby granted for research purposes, provided that this copyright tomwalters@0: notice appears in all copies and in all supporting documentation, and that tomwalters@0: the software is not redistributed for any fee (except for a nominal tomwalters@0: shipping charge). Anyone wanting to incorporate all or part of this tomwalters@0: software in a commercial product must obtain a license from the Medical tomwalters@0: Research Council. tomwalters@0: .LP tomwalters@0: The MRC makes no representations about the suitability of this tomwalters@0: software for any purpose. It is provided "as is" without express or tomwalters@0: implied warranty. tomwalters@0: .LP tomwalters@0: THE MRC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING tomwalters@0: ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL tomwalters@0: THE A.P.U. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES tomwalters@0: OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, tomwalters@0: WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, tomwalters@0: ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS tomwalters@0: SOFTWARE. tomwalters@0: