| 1 | 
greg | 
1.7 | 
.\" RCSid "$Id: total.1,v 1.6 2005/07/13 15:21:28 greg Exp $" | 
| 2 | 
greg | 
1.1 | 
.TH TOTAL 1 2/3/95 RADIANCE | 
| 3 | 
  | 
  | 
.SH NAME | 
| 4 | 
  | 
  | 
total - sum up columns | 
| 5 | 
  | 
  | 
.SH SYNOPSIS | 
| 6 | 
  | 
  | 
.B total | 
| 7 | 
  | 
  | 
[ | 
| 8 | 
  | 
  | 
.B \-m | 
| 9 | 
  | 
  | 
][ | 
| 10 | 
  | 
  | 
.B \-sE | 
| 11 | 
  | 
  | 
| | 
| 12 | 
  | 
  | 
.B \-p | 
| 13 | 
  | 
  | 
| | 
| 14 | 
  | 
  | 
.B \-u | 
| 15 | 
  | 
  | 
| | 
| 16 | 
  | 
  | 
.B \-l | 
| 17 | 
  | 
  | 
][ | 
| 18 | 
greg | 
1.4 | 
.B \-i{f|d}[N] | 
| 19 | 
  | 
  | 
][ | 
| 20 | 
  | 
  | 
.B \-o{f|d} | 
| 21 | 
  | 
  | 
][ | 
| 22 | 
greg | 
1.1 | 
.B \-tC | 
| 23 | 
  | 
  | 
][ | 
| 24 | 
  | 
  | 
.B \-N | 
| 25 | 
  | 
  | 
[ | 
| 26 | 
  | 
  | 
.B \-r | 
| 27 | 
  | 
  | 
]] | 
| 28 | 
  | 
  | 
[ | 
| 29 | 
  | 
  | 
file .. | 
| 30 | 
  | 
  | 
] | 
| 31 | 
  | 
  | 
.SH DESCRIPTION | 
| 32 | 
  | 
  | 
.I Total | 
| 33 | 
  | 
  | 
sums up columns of real numbers from one or more files | 
| 34 | 
  | 
  | 
and prints out the result on its standard output. | 
| 35 | 
  | 
  | 
.PP | 
| 36 | 
  | 
  | 
By default, | 
| 37 | 
  | 
  | 
.I total | 
| 38 | 
  | 
  | 
computes the straigt sum of each input column, but multiplication | 
| 39 | 
  | 
  | 
can be specified instead with the | 
| 40 | 
  | 
  | 
.I \-p | 
| 41 | 
  | 
  | 
option. | 
| 42 | 
  | 
  | 
Likewise, the | 
| 43 | 
  | 
  | 
.I \-u | 
| 44 | 
  | 
  | 
option means find the upper limit (maximum), and | 
| 45 | 
  | 
  | 
.I \-l | 
| 46 | 
  | 
  | 
means find the lower limit (minimum). | 
| 47 | 
  | 
  | 
.PP | 
| 48 | 
  | 
  | 
Sums of powers can be computed by giving an exponent with the | 
| 49 | 
  | 
  | 
.I \-s | 
| 50 | 
  | 
  | 
option. | 
| 51 | 
  | 
  | 
(Note that there is no space between the  | 
| 52 | 
  | 
  | 
.I \-s | 
| 53 | 
  | 
  | 
and the exponent.) | 
| 54 | 
  | 
  | 
This exponent can be any real number, positive or negative. | 
| 55 | 
  | 
  | 
The absolute value of the input is always taken before the | 
| 56 | 
  | 
  | 
power is computed in order to avoid complex results. | 
| 57 | 
  | 
  | 
Thus, | 
| 58 | 
  | 
  | 
.I \-s1 | 
| 59 | 
  | 
  | 
will produce a sum of absolute values. | 
| 60 | 
  | 
  | 
The default power (zero) is interpreted as a straight sum without | 
| 61 | 
  | 
  | 
taking absolute values. | 
| 62 | 
  | 
  | 
.PP | 
| 63 | 
  | 
  | 
The | 
| 64 | 
  | 
  | 
.I \-m | 
| 65 | 
  | 
  | 
option can be used to compute the mean rather than the total. | 
| 66 | 
  | 
  | 
For sums, the arithmetic mean is computed. | 
| 67 | 
  | 
  | 
For products, the geometric mean is computed. | 
| 68 | 
  | 
  | 
(A logarithmic sum of absolute values is used to avoid overflow, and  | 
| 69 | 
  | 
  | 
zero values are silently ignored.) | 
| 70 | 
  | 
  | 
.PP | 
| 71 | 
greg | 
1.4 | 
If the input data is binary, the | 
| 72 | 
  | 
  | 
.I \-id | 
| 73 | 
  | 
  | 
or | 
| 74 | 
  | 
  | 
.I \-if | 
| 75 | 
  | 
  | 
option may be given for 64-bit double or 32-bit float values, respectively. | 
| 76 | 
  | 
  | 
Either option may be followed immediately by an optional | 
| 77 | 
  | 
  | 
count, which defaults to 1, indicating the number of double or float | 
| 78 | 
  | 
  | 
binary values to read per record on the input file. | 
| 79 | 
  | 
  | 
(There can be no space between the option and this count.)\0 | 
| 80 | 
  | 
  | 
Similarly, the | 
| 81 | 
  | 
  | 
.I \-od | 
| 82 | 
  | 
  | 
and | 
| 83 | 
  | 
  | 
.I \-of | 
| 84 | 
  | 
  | 
options specify binary double or float output, respectively. | 
| 85 | 
  | 
  | 
These options do not need a count, as this will be determined by the | 
| 86 | 
  | 
  | 
number of input channels. | 
| 87 | 
  | 
  | 
.PP | 
| 88 | 
greg | 
1.1 | 
A count can be given as the number of lines to read before | 
| 89 | 
  | 
  | 
computing a result. | 
| 90 | 
greg | 
1.6 | 
Normally, | 
| 91 | 
greg | 
1.1 | 
.I total | 
| 92 | 
greg | 
1.6 | 
reads each file to its end before producing its result,  | 
| 93 | 
  | 
  | 
but this behavior may be overridden by inserting blank lines in | 
| 94 | 
  | 
  | 
the input. | 
| 95 | 
  | 
  | 
For each blank input line, total produces a result as if the | 
| 96 | 
  | 
  | 
end-of-file had been reached. | 
| 97 | 
  | 
  | 
If two blank lines immediately follow each other, total closes | 
| 98 | 
  | 
  | 
the file and proceeds to the next one (after reporting the result). | 
| 99 | 
  | 
  | 
The | 
| 100 | 
greg | 
1.1 | 
.I \-N | 
| 101 | 
  | 
  | 
option (where N is a decimal integer) tells | 
| 102 | 
  | 
  | 
.I total | 
| 103 | 
  | 
  | 
to produce a result and reset the calculation after | 
| 104 | 
  | 
  | 
every N input lines. | 
| 105 | 
  | 
  | 
In addition, the | 
| 106 | 
  | 
  | 
.I \-r | 
| 107 | 
  | 
  | 
option can be specified to override reinitialization and thus | 
| 108 | 
greg | 
1.6 | 
give a running total every N lines (or every blank line). | 
| 109 | 
greg | 
1.1 | 
If the end of file is reached, the current total is printed | 
| 110 | 
  | 
  | 
and the calculation is reset before the next file (with or without the | 
| 111 | 
  | 
  | 
.I \-r | 
| 112 | 
  | 
  | 
option). | 
| 113 | 
  | 
  | 
.PP | 
| 114 | 
  | 
  | 
The | 
| 115 | 
  | 
  | 
.I \-tC | 
| 116 | 
  | 
  | 
option can be used to specify the input and output tab character. | 
| 117 | 
  | 
  | 
The default tab character is TAB. | 
| 118 | 
  | 
  | 
.PP | 
| 119 | 
  | 
  | 
If no files are given, the standard input is read. | 
| 120 | 
  | 
  | 
.SH EXAMPLE | 
| 121 | 
  | 
  | 
To compute the RMS value of colon-separated columns in a file: | 
| 122 | 
  | 
  | 
.IP "" .2i | 
| 123 | 
greg | 
1.7 | 
total \-t: \-m \-s2 input | 
| 124 | 
greg | 
1.1 | 
.PP | 
| 125 | 
  | 
  | 
To produce a running product of values from a file: | 
| 126 | 
  | 
  | 
.IP "" .2i | 
| 127 | 
greg | 
1.7 | 
total \-p \-1 \-r input | 
| 128 | 
greg | 
1.1 | 
.SH BUGS | 
| 129 | 
  | 
  | 
If the input files have varying numbers of columns, mean values | 
| 130 | 
  | 
  | 
will certainly be off. | 
| 131 | 
  | 
  | 
.I Total | 
| 132 | 
  | 
  | 
will ignore missing column entries if the tab separator is a non-white | 
| 133 | 
  | 
  | 
character, but cannot tell where a missing column should have been if | 
| 134 | 
  | 
  | 
the tab character is white. | 
| 135 | 
  | 
  | 
.SH AUTHOR | 
| 136 | 
  | 
  | 
Greg Ward | 
| 137 | 
  | 
  | 
.SH "SEE ALSO" | 
| 138 | 
greg | 
1.3 | 
cnt(1), neaten(1), rcalc(1), rlam(1), tabfunc(1) |