Debian Codegraph @

GOALS

raw ◀ ▶
Source reconstructed at patch state 0 of 2 — not the installed (fully patched) source.
2 Debian patches touch this file
1
2 num-utils - Goals for this project
3 -----------------------------------
4
5 (NOTE: This document does not represent a currrent feature set, please read
6 the README file and man pages instead.)
7
8 This document outlines certain criteria that the num-utils should eventually
9 meet. It outlines a general interface that each utility should follow and
10 guides the project to bring the num-utils to version 1.0
11
12 The initial releases of the num-utils will be small and much less featured
13 than what is shown below. I originally wrote the num-utils with many of
14 the features shown below, but everything was rather unorganized and some of
15 the programs simply processed the data incorrectly. I decided that I would
16 go back to the beginning, write down all the features that I would like to
17 have and think are useful, and create a development cycle. I'll release
18 each version to the public for review, comments and contribution. Anyone who
19 is interested in helping out in any way, please contact me at [email protected].
20 Any contributions are welcome.
21
22 I've put an 'X' at the begining of the line for features that have been
23 completeled.
24
25 -= All numeric utilities =-
26
27 1. All num utils should process data on either STDIN or from a file or files
28 specified from command line arguments.
29
30 Examples of STDIN usage:
31
32 cat file | num-util
33 num-util < file
34 num-util
35 [Program will wait for data on STDIN until Ctrl-D is pressed]
36
37 Examples of file argument usage:
38
39 num-util file
40 num-util file1 file2 file3 ... fileN
41 num-util -[options] file1 file2 file3
42
43
44 2. All num utils should use the following options that are standard among
45 all the utilities:
46
47 X -h -- provide helpful usage information
48 X -V -- Be verbose. Send verbose information to STDERR.
49 X -d -- Debug information for developers. This implies verbose and more.
50 -q -- Quiet mode, Don't print out any warnings about file read errors.
51
52 -i -- Output numeric values as their integer only.
53 -I -- Output numeric values as their decimal portion only.
54 -a -- Don't treat '-' characters as negative signs.
55 Think of -a as 'absolute value'.
56 -d -- Don't treat the '.' character as a decimal point.
57 -N -- Don't process complete numbers, process each numeric character
58 individually.
59 -C -- Commify numbers in output. Instead of printing out '1000000', it
60 should print out '1,000,000'.
61 -b <n>
62 -- Use the following base <n> when dealing with numbers.
63 -- -- Don't process any more arguments as options.
64
65
66 3. All num utils should provide user documentation in the form of man pages.
67
68 - While the programs are written in perl I plan on using POD information in
69 the programs themselves and then that documentation can be exported to man
70 pages, info docs or HTML format.
71
72 - Eventually I would like to write the documentation in SGML so that it can
73 be easily converted into many different formats.
74
75 4. All num utils should provide summarized help with the -h option simular to
76 the following:
77
78 ----------------------------------------------
79 numutil: process numbers in such a way......
80 ----------------------------------------------
81
82 Usage: numutil [options] [file args]
83 STDIN | numutil [options]
84 numutil [options] < file
85
86 Options:
87 -h Help: You're looking at it.
88 -V Increase verbosity.
89 -d Don't treat the '.' character as a decimal point.
90
91 5. All numeric utilities should abstract their functionality as much as
92 possible so that a numeric processing module can be written to make things
93 consistent among all numeric utility programs.
94
95 6. The num-utils set of utilities should be available in the following forms
96 for download:
97
98 o tar format, both gz and bz2
99 o rpm package
100 o gentoo ebuild tree
101 o deb package
102
103 7. The Makefile should be setup to be able to create the different package
104 formats listed above as well as the man pages from the perldoc information
105 in each utility's source code.
106
107 8. Numeric expressions (regular expressions, plus operations for numbers)
108
109 .. -- range operator
110 i -- increment operator
111 f -- factor operator
112 m -- multiple operator
113 , -- expression seperation separator
114
115 [] -- character grouping
116 + -- quantifier (1 or more)
117 * -- quantifier (0 or more)
118 ? -- Match the preceding character 0 or 1 times.
119 {} -- for matching specific number of times.
120
121 -- Some goals sent in by [email protected] (thanks) --
122
123 - Support for locale changes between . and , usage. In other parts of
124 the world they use a period in the place of a decimal point
125 (ie. 1.000.000,50 means one million and 5 tenths).
126
127 - Some of the utilities should be able to recurse through subdirectories,
128 where appropriate.
129
130 - Support for output and input of numbers in scientific noation.
131 (ie. 1.3e-7 for 0.0000013)
132
133 - A utility for sorting numbers in mixed notations. For instance, it
134 is hard to sort numbers that are in scientific notation or commified
135 along side ones that aren't. Maybe this is a call for a numsort utility.
136
137
138 -= Individual program goals =-
139
140 -- numsum --
141
142 This program adds up all numbers encountered. In it's basic operation, it
143 will simply add up all the numbers that it encounters. The numbers can be one
144 per line, multiple per line separated by space or multiple numbers separated
145 by anything.
146
147 Eventually, it would be nice if numsum could do things like sum up individual
148 rows or columns of input separately. There might be other types of summing
149 functions that would be useful when dealing with textual input.
150
151
152 Examples
153 $ cat numbers
154 1
155 2
156 3
157 4
158 $ cat numbers | numsum
159 10
160 $ numsum numbers
161 10
162
163 Advanced Examples
164 $ cat columns
165 1 6 11 16 21
166 2 7 12 17 22
167 3 8 13 18 23
168 4 9 14 19 24
169 5 10 15 20 25
170 $ cat columns | numsum -c
171 15 40 65 90 115
172 $ cat columns | numsum -r (add up the rows)
173 55
174 60
175 65
176 70
177 75
178 $
179
180 Usage options (in addition to the standard options)
181
182 -a -- Add all numbers in the file, not just the first ones found on each
183 line.
184 X -c -- Treat each line as a set of columns separated by white space, or a
185 string if the -s option is used. Sum up the values in each column
186 and print out the result of each column seperated by the seperation
187 character. This is shown above in the advanced examples section.
188 X -s <string> [for columns]
189 -- Use <string> as the separator between each column. This is allowed
190 to be more than one character and possibly even a number.
191 X -r -- Treat each line (by default) as a row of numbers to sum up. The
192 results of the sums of each row will be printed on seperate lines.
193 -s <string> [for rows]
194 -- When used with the -r flag, this will specify the seperator for
195 rows. By default it is the new line character. It could be a
196 character, set of characters or even a number.
197
198 -t <x>
199 -- When used, it will add up every <x>th number and at the end
200 print out <x> rows showing the sums of each <x>th number. This
201 would be useful for example if you had data from each day of the
202 month and you wanted to sum up the date for each week day.
203 So you might do something like this
204
205 $ cat monthly-data | numsum -t 7
206
207
208
209 Options that might be included eventually.
210
211 X -x <n> -- Where <n> is some number. This would be a shortcut for adding up
212 all the numbers in the <n>th column of the input. By default, the
213 columns would be determined by white space, but could also be
214 determined by the -s flag. This must be used with the -c or -r flag.
215 So you can do something like:
216
217 $ numsum -c -x 10 access_log
218
219 To get the total bytes transfered in an access_log.
220
221 Maybe this could also be able to handle comma seperated values, so
222 1,5,10 would sum up the 1st, 5th and 10th columns.
223
224
225 -- numgrep --
226
227 This program is the numeric equivilent of the unix grep utility. numgrep
228 will search textual input for numbers matching the expression specified from
229 the command line. The main power of numgrep is in being able to search for
230 ranges of numbers. Such as searching for all numbers between 1 and 100.
231 Normal unix grep and regular expressions would not allow you to do this simple
232 task, but with numgrep's numeric matching expressions it is possible to match
233 numbers in ways not previously possible.
234
235 A few examples of numgrep's usage:
236
237 X o Search for all numbers between 1 and 100 in the file data.txt.
238
239 numgrep /1..100/ data.txt
240
241 X o search for numbers between 1 and 37,even numbers between 50 and 58 as
242 well as the numbers 79, 86 and 94.
243
244 numgrep /1..37,5[2468],79,86,94/ data.txt
245
246 X o search for numbers from -10 to 10.
247
248 numgrep /-10..10/ data.txt
249
250 X o search for numbers that are multiples of 7
251
252 numgrep /m7/ data.txt
253
254 o search for numbers that are multiples of 7, 12 and 22
255
256 numgrep /m7m12m22/ data.txt
257
258 o search for numbers that are factors of 1024 and multiples of 12 or numbers
259 that are factors of 2333 and multiples of 9
260
261 numgrep /f1024m12,f2333m9/ data.txt
262
263 o seach for numbers that are in the set 1, 4, 7, 10, 13 and 16
264
265 numgrep /1..16i3/ data.txt
266
267 Usage options (in addition to the standard options)
268
269 -l -- Instead of keeping the numbers in their textual context, print
270 them out one number per line.
271 -R -- Inverse the sense of matching. To match non-matching numbers
272 -r -- Recurse subdirectories.
273 -p <file>
274 -- Obtain the patterns from file <file>
275 -f -- Suppress normal output and just print the names of the files
276 that contain a match one per line.
277 -F -- Suppress normal output and print the names of the files for which
278 no output would have been printed.
279 -n -- Print the line number in front of each line that contains a match.
280
281 -c -- Don't save non-numeric context. This will cause numgrep to dump all
282 non-matching/non-numeric values around the numbers that match.
283
284 Eventual options
285
286 -A [n] -- Print [n] lines of context out after the matching line.
287 The default is 2.
288 -B [n] -- Print [n] lines of context out before the matching line.
289 The default is 2.
290
291 Feature submitted by [email protected]:
292
293 - Intervals: I may be biased due to my work, but usually when you
294 determine a quantity with only finite precision, people write
295 something like 1.234 +/- 0.056 or 1.234(56) (the last form is more
296 common, at least in physics journals; the interpretation is that the
297 digits in brackets are taken to line up with the last digit shown,
298 left-padded with zeroes and a decimal point in the correct place). The
299 natural representation of both of these is as intervals, i.e. as sets
300 of two numbers representing lower and upper bounds. Thus, the given
301 number should be turned into something like 1.178..1.290, and there
302 should be a conversion function that turns it back into either of the
303 other two.
304
305
306
307
308 -- average --
309
310 This program finds the average of all numbers encountered. By default it will
311 find the mean average of all the numbers. Meaning (;-) that it will add up all
312 the values and divide that sum by the number of values encountered. It should
313 eventually offer more sophisticated calculations like finding the median and
314 mode values.
315
316 Examples of usage:
317
318 $ cat numbers
319 4
320 8
321 9
322 20
323 99
324 $ average numbers
325 28
326
327 Usage options:
328
329 X -m -- Print out the mode value of all the numbers entered. The mode is
330 the most frequently occuring value in the set.
331
332 X -M -- Print out the median of the set of numbers entered. The median is
333 the middle value all all numbers encountered. So if the numbers
334 88, 12, 2, 1, 9, 100 and 1000 are encountered, the median of that
335 set is 12. Illustrated:
336
337 1 2 9 12 88 100 1000
338 ^^
339 X -l -- Use the lower number of the median on even counted sets.
340
341 -a -- average all numbers in the file, not just the first ones found on
342 each line.
343 -c -- Treat each line as a set of columns separated by white space, or a
344 string if the -s option is used. Average the values in each column
345 and print out the result of each column seperated by the seperation
346 character. This is shown above in the advanced examples section.
347 -s <string> [for columns]
348 -- Use <string> as the separator between each column. This is allowed
349 to be more than one character and possibly even a number.
350 -r -- Treat each line (by default) as a row of numbers to sum up. The
351 results of the averages of each row will be printed on seperate
352 lines.
353 -s <string> [for rows]
354 -- When used with the -r flag, this will specify the seperator for
355 rows. By default it is the new line character. It could be a
356 character, set of characters or even a number.
357
358
359 Options that might be included eventually.
360
361 -n <n> -- Where <n> is some number. This would be a shortcut for averaging
362 all the numbers in the <n>th column of the input. By default, the
363 columns would be determined by white space, but could also be
364 determined by the -s flag. This must be used with the -c or -r flags.
365
366
367
368 Usage options (in addition to the standard options)
369
370
371 -- normalize --
372
373 This program will distribute a group of numbers between 0 and 1 by default according
374 to their initial value. You can change the range using the -R option.
375
376 Usage options:
377
378 X -R <range> -- This is for specifying a range to normalize for instead of 0..1
379
380
381
382 -- round --
383
384 This utility will round each number encountered up or down depending on it's
385 decimal value or it's relation to a number. It will probably also deal with
386 finding the floor or ceiling values of numbers. It should also be able to
387 round to factors of certain numbers.
388
389 Options:
390
391 X -n <n> -- Round to the nearest factor of <n>. Instead of just rounding all
392 decimal numbers, you can also round to a factor of any number. So
393 if you set <n> to 1000 and you encounter the number 6777, it will
394 round that number to 7000. If you set <n> to 3 and encounter the
395 number 7, it will round it to 6.
396
397 X -c -- Find the ceiling of each number encountered. Round up.
398 X -f -- Find the floor of each number. Round down.
399
400
401 -- range --
402
403 Print out a range of numbers for use in for loops and such.
404
405 o Do zero or character padding with the -p option. So 1 becomes 001 if the
406 range has an upper limit of 3 digits.
407
408 o Accept ranges in the following formats:
409
410 n1..n2 (ex. 1..100 ; All integers from 1 to 100)
411 n1..n2,n3..n4 (ex. 1..10,50..100 ; All integers from 1 to 10 and
412 from 50 to 100)
413 n1..n2i2 (ex. 2..20i2 ; All even numbers from 2 to 20)
414 (ex. 1..19i2 ; All odd numbers from 1 to 19)
415 (ex. 3..21i3 ; 3, 6, 9, 12, 15, 18, 21)
416 n1.d..n2.di0.1
417 (ex. 1.1..2.0i0.1 ; 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8,
418 1.9, 2.0)
419 Or any combination of the above.
420
421 Usage options (in addition to the standard options)
422
423 -p <prefix> -- Put the following prefix before each number.
424 -s <suffix> -- Put the following suffix after each number.
425 X -n <separator> -- Use <separator> as a character to separate each number.
426 By default, a space is used. Use the sequence \n to specify
427 a newline.
428 X -N -- Shortcut for using a newline separator.
429 X -e <set>
430 -- Exclude the numbers in <set> from the output. This is so that if
431 you want to do a complex range without including certain numbers.
432 <set> is a list of numbers seperated by a ','.
433
434 -- random --
435
436 Print out a random number or numbers. This program will take a range of
437 numbers much like the range command does. Except that instead of printing out
438 all the numbers in that range, it will print out a random number from that
439 range.
440
441 Ex:
442 $ random 1..100
443 37
444 $ random 1.0..100.0
445 56.9
446 $ random 1.000..100.000
447 42.397
448 $ random 2..100i2 [only pick among the even integers from 2 to 100]
449 68
450
451 Usage options (in addition to the standard options)
452
453 -n <n> -- Generate <n> random numbers seperated by a space.
454 -s <c> -- Use <c> as the seperation character.
455 -N -- Shortcut for using a newline separation character.
456
457
458 Feature submitted by [email protected]:
459
460 - You should specify the distribution you are generating;
461 probably, this is just an equal distribution. What would come in handy
462 quite often is to have a way of producing pseudo-random numbers that
463 realize a chosen distribution with a given set of parameters. But that
464 should probably be a different program than random, e.g. distribution,
465 as the name is already taken. So, e.g., ``distribution --gaussian 3.0
466 4.0 100'' should produce 100 numbers distributed according to a gauss
467 distribution with mean 3 and variance 4.
468
469
470 -- bound --
471
472 This program is for finding the maximum, minimum and surrounding numbers in a
473 set. You can use different options to specify how many numbers are returned as
474 to show top maximum and minimum lists. Also you can show the numbers that
475 occur around the context of the boundary numbers.
476
477 Ex:
478 $ cat numbers
479 1 10 8 100 15 1000
480 2 9 5 15 27 12 136
481 $ bound -u numbers (upper)
482 1000
483 $ bound -l numbers (lower)
484 1
485
486 Top 4 upper numbers sorted
487 $ bound -u -n 4 numbers
488 1000
489 136
490 100
491 27
492
493 Bottom 4 lower numbers sorted)
494 $ bound -l -n 4 numbers
495 1
496 2
497 5
498 8
499
500 Context around lowest number. Show 2 numbers of context.
501 $ bound -l -c 2 numbers
502 1 10 8
503
504 Find the 5 closet numbers to the number 75. They will print out
505 in closeness order.
506
507 $ bound -f 75 -n 6
508 100
509 27
510 15
511 15
512 136
513 10
514
515 Usage options (in addition to the standard options)
516
517 -u -- Return the upper bound number in the set (the maximum number)
518 -l -- Return the lower bound number in the set (the minimum number)
519 -n <n> -- Return the top or bottom <n> numbers or <n> numbers around
520 a number.
521 -c <n> -- In addition to the number returned, show <n> numbers on both sides
522 of the number.
523 -f <n> -- Find the number <n> or the closest number to <n>.
524
525 -- numprocess -- (maybe a name like mutate, alter, or process would be better)
526
527 This program mutates numbers as it encounters them. It should do the
528 following operations:
529
530 o Add/Subtract a value to a number
531 o Multiply/Divide a number by a factor
532 o Raise a number to a power (includes the concept of roots)
533 o Round a number up or down
534 o Do any mathematical function to a number.
535 o Quantify a number. So 1024 bytes is 1KB and so on.
536
537 Ex:
538
539 Add 1 to each number
540 $ numprocess /+1/
541
542 Multiply each number by 8 and then divide by 5
543 $ numprocess /*8,%5/
544
545 Convert from Farenheit to Celcius
546 $ numprocess /-32,*5,%9/
547
548 Usage options (in addition to the standard options)
549
550
551
552 -- interval --
553
554 This program calculates and displays the interval between one number
555 and the next.
556
557