num-utils-0.5/0040775000076400007640000000000010147276463012107 5ustar susosusonum-utils-0.5/CHANGELOG0100664000076400007640000000541410147276245013320 0ustar susosuso Nov. 19th, 2004 04:53 GMT ---------------------------- Fifth Beta Release v0.5 - Cleaned up a few bits of code in numsum. - Adjusted copyright years to 2004. Aug. 28th, 2004 06:40 GMT ---------------------------- - Added -c,-r,-x,-y options to numsum to allow it to sum columns and rows and specify which rows and columns you want. * Special thanks to the folks on #perl on irc.freenode.org for helping me out with the regex for this one. - Added - number hack to numsum to quickly specify the column number that you want to sum. For now it only does columns 1 through 9 because I need to figure out how to get past Getopt::Std to get the whole number specified. Since this is such a hack, I might just leave it as is or drop it. Aug. 25th, 2004 19:56 GMT ---------------------------- - Made some changes to the GOALS file in regards to what options are being planned. Sept. 23rd, 2003 22:23 GMT ---------------------------- Fourth Beta Release v0.4 - Added -R option to normalize - updated utils to include man page reference to normalize - updated range program to include man page reference to seq(1) - Added feedback directory and files to CVS. Sept. 22nd, 2003 22:24 GMT ---------------------------- - Added normalize program and documentation. Sept. 21st, 2003 20:51 GMT --------------------------- - Added median function and -M option - Added -l option for using the lower median number on even sets. Sept. 19th, 2003 15:50 GMT ---------------------------- - Added find_mode subroutine to average program and respective documentation. June 9th, 2003 14:48 GMT --------------------------- Third Beta Release v0.3 - Added -q option to interval and updated documentation. June 3rd, 2003 23:26 GMT --------------------------- - Added interval program with initial functionality - Changed man page listing on other programs to include interval - Updated GOALS file to include 'interval' goals and also added the -t option to numsum's goals. - Updated spec file with interval file entries. - Updated README file. May 29th, 2003 20:12 GMT -------------------------- Second Beta Release v0.2 - Fixed formatting in GOALS document. - Added some of the features submitted by areiner@tph.tuwien.ac.at to the GOALS file. - Added helpful information for the 'bound' program to explain that the default is to find the maximum number. - Added code to 'numgrep' to handle factors and multiples. - Added expression info and examples to 'numgrep' man page/pod and help output. - Added code and documentation for -e (exclude) option for 'range'. - Fixed a few things in the README. - Made the sqrt function in numprocess process negative numbers as imaginary. June 17th, 2002 13:00 GMT -------------------------- Initial Beta Release v0.1 num-utils-0.5/COPYING0100664000076400007640000004312707401755122013137 0ustar susosuso GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. num-utils-0.5/GOALS0100664000076400007640000004657310147276245012711 0ustar susosuso num-utils - Goals for this project ----------------------------------- (NOTE: This document does not represent a currrent feature set, please read the README file and man pages instead.) This document outlines certain criteria that the num-utils should eventually meet. It outlines a general interface that each utility should follow and guides the project to bring the num-utils to version 1.0 The initial releases of the num-utils will be small and much less featured than what is shown below. I originally wrote the num-utils with many of the features shown below, but everything was rather unorganized and some of the programs simply processed the data incorrectly. I decided that I would go back to the beginning, write down all the features that I would like to have and think are useful, and create a development cycle. I'll release each version to the public for review, comments and contribution. Anyone who is interested in helping out in any way, please contact me at suso@suso.org. Any contributions are welcome. I've put an 'X' at the begining of the line for features that have been completeled. -= All numeric utilities =- 1. All num utils should process data on either STDIN or from a file or files specified from command line arguments. Examples of STDIN usage: cat file | num-util num-util < file num-util [Program will wait for data on STDIN until Ctrl-D is pressed] Examples of file argument usage: num-util file num-util file1 file2 file3 ... fileN num-util -[options] file1 file2 file3 2. All num utils should use the following options that are standard among all the utilities: X -h -- provide helpful usage information X -V -- Be verbose. Send verbose information to STDERR. X -d -- Debug information for developers. This implies verbose and more. -q -- Quiet mode, Don't print out any warnings about file read errors. -i -- Output numeric values as their integer only. -I -- Output numeric values as their decimal portion only. -a -- Don't treat '-' characters as negative signs. Think of -a as 'absolute value'. -d -- Don't treat the '.' character as a decimal point. -N -- Don't process complete numbers, process each numeric character individually. -C -- Commify numbers in output. Instead of printing out '1000000', it should print out '1,000,000'. -b -- Use the following base when dealing with numbers. -- -- Don't process any more arguments as options. 3. All num utils should provide user documentation in the form of man pages. - While the programs are written in perl I plan on using POD information in the programs themselves and then that documentation can be exported to man pages, info docs or HTML format. - Eventually I would like to write the documentation in SGML so that it can be easily converted into many different formats. 4. All num utils should provide summarized help with the -h option simular to the following: ---------------------------------------------- numutil: process numbers in such a way...... ---------------------------------------------- Usage: numutil [options] [file args] STDIN | numutil [options] numutil [options] < file Options: -h Help: You're looking at it. -V Increase verbosity. -d Don't treat the '.' character as a decimal point. 5. All numeric utilities should abstract their functionality as much as possible so that a numeric processing module can be written to make things consistent among all numeric utility programs. 6. The num-utils set of utilities should be available in the following forms for download: o tar format, both gz and bz2 o rpm package o gentoo ebuild tree o deb package 7. The Makefile should be setup to be able to create the different package formats listed above as well as the man pages from the perldoc information in each utility's source code. 8. Numeric expressions (regular expressions, plus operations for numbers) .. -- range operator i -- increment operator f -- factor operator m -- multiple operator , -- expression seperation separator [] -- character grouping + -- quantifier (1 or more) * -- quantifier (0 or more) ? -- Match the preceding character 0 or 1 times. {} -- for matching specific number of times. -- Some goals sent in by areiner@tph.tuwien.ac.at (thanks) -- - Support for locale changes between . and , usage. In other parts of the world they use a period in the place of a decimal point (ie. 1.000.000,50 means one million and 5 tenths). - Some of the utilities should be able to recurse through subdirectories, where appropriate. - Support for output and input of numbers in scientific noation. (ie. 1.3e-7 for 0.0000013) - A utility for sorting numbers in mixed notations. For instance, it is hard to sort numbers that are in scientific notation or commified along side ones that aren't. Maybe this is a call for a numsort utility. -= Individual program goals =- -- numsum -- This program adds up all numbers encountered. In it's basic operation, it will simply add up all the numbers that it encounters. The numbers can be one per line, multiple per line separated by space or multiple numbers separated by anything. Eventually, it would be nice if numsum could do things like sum up individual rows or columns of input separately. There might be other types of summing functions that would be useful when dealing with textual input. Examples $ cat numbers 1 2 3 4 $ cat numbers | numsum 10 $ numsum numbers 10 Advanced Examples $ cat columns 1 6 11 16 21 2 7 12 17 22 3 8 13 18 23 4 9 14 19 24 5 10 15 20 25 $ cat columns | numsum -c 15 40 65 90 115 $ cat columns | numsum -r (add up the rows) 55 60 65 70 75 $ Usage options (in addition to the standard options) -a -- Add all numbers in the file, not just the first ones found on each line. X -c -- Treat each line as a set of columns separated by white space, or a string if the -s option is used. Sum up the values in each column and print out the result of each column seperated by the seperation character. This is shown above in the advanced examples section. X -s [for columns] -- Use as the separator between each column. This is allowed to be more than one character and possibly even a number. X -r -- Treat each line (by default) as a row of numbers to sum up. The results of the sums of each row will be printed on seperate lines. -s [for rows] -- When used with the -r flag, this will specify the seperator for rows. By default it is the new line character. It could be a character, set of characters or even a number. -t -- When used, it will add up every th number and at the end print out rows showing the sums of each th number. This would be useful for example if you had data from each day of the month and you wanted to sum up the date for each week day. So you might do something like this $ cat monthly-data | numsum -t 7 Options that might be included eventually. X -x -- Where is some number. This would be a shortcut for adding up all the numbers in the th column of the input. By default, the columns would be determined by white space, but could also be determined by the -s flag. This must be used with the -c or -r flag. So you can do something like: $ numsum -c -x 10 access_log To get the total bytes transfered in an access_log. Maybe this could also be able to handle comma seperated values, so 1,5,10 would sum up the 1st, 5th and 10th columns. -- numgrep -- This program is the numeric equivilent of the unix grep utility. numgrep will search textual input for numbers matching the expression specified from the command line. The main power of numgrep is in being able to search for ranges of numbers. Such as searching for all numbers between 1 and 100. Normal unix grep and regular expressions would not allow you to do this simple task, but with numgrep's numeric matching expressions it is possible to match numbers in ways not previously possible. A few examples of numgrep's usage: X o Search for all numbers between 1 and 100 in the file data.txt. numgrep /1..100/ data.txt X o search for numbers between 1 and 37,even numbers between 50 and 58 as well as the numbers 79, 86 and 94. numgrep /1..37,5[2468],79,86,94/ data.txt X o search for numbers from -10 to 10. numgrep /-10..10/ data.txt X o search for numbers that are multiples of 7 numgrep /m7/ data.txt o search for numbers that are multiples of 7, 12 and 22 numgrep /m7m12m22/ data.txt o search for numbers that are factors of 1024 and multiples of 12 or numbers that are factors of 2333 and multiples of 9 numgrep /f1024m12,f2333m9/ data.txt o seach for numbers that are in the set 1, 4, 7, 10, 13 and 16 numgrep /1..16i3/ data.txt Usage options (in addition to the standard options) -l -- Instead of keeping the numbers in their textual context, print them out one number per line. -R -- Inverse the sense of matching. To match non-matching numbers -r -- Recurse subdirectories. -p -- Obtain the patterns from file -f -- Suppress normal output and just print the names of the files that contain a match one per line. -F -- Suppress normal output and print the names of the files for which no output would have been printed. -n -- Print the line number in front of each line that contains a match. -c -- Don't save non-numeric context. This will cause numgrep to dump all non-matching/non-numeric values around the numbers that match. Eventual options -A [n] -- Print [n] lines of context out after the matching line. The default is 2. -B [n] -- Print [n] lines of context out before the matching line. The default is 2. Feature submitted by areiner@tph.tuwien.ac.at: - Intervals: I may be biased due to my work, but usually when you determine a quantity with only finite precision, people write something like 1.234 +/- 0.056 or 1.234(56) (the last form is more common, at least in physics journals; the interpretation is that the digits in brackets are taken to line up with the last digit shown, left-padded with zeroes and a decimal point in the correct place). The natural representation of both of these is as intervals, i.e. as sets of two numbers representing lower and upper bounds. Thus, the given number should be turned into something like 1.178..1.290, and there should be a conversion function that turns it back into either of the other two. -- average -- This program finds the average of all numbers encountered. By default it will find the mean average of all the numbers. Meaning (;-) that it will add up all the values and divide that sum by the number of values encountered. It should eventually offer more sophisticated calculations like finding the median and mode values. Examples of usage: $ cat numbers 4 8 9 20 99 $ average numbers 28 Usage options: X -m -- Print out the mode value of all the numbers entered. The mode is the most frequently occuring value in the set. X -M -- Print out the median of the set of numbers entered. The median is the middle value all all numbers encountered. So if the numbers 88, 12, 2, 1, 9, 100 and 1000 are encountered, the median of that set is 12. Illustrated: 1 2 9 12 88 100 1000 ^^ X -l -- Use the lower number of the median on even counted sets. -a -- average all numbers in the file, not just the first ones found on each line. -c -- Treat each line as a set of columns separated by white space, or a string if the -s option is used. Average the values in each column and print out the result of each column seperated by the seperation character. This is shown above in the advanced examples section. -s [for columns] -- Use as the separator between each column. This is allowed to be more than one character and possibly even a number. -r -- Treat each line (by default) as a row of numbers to sum up. The results of the averages of each row will be printed on seperate lines. -s [for rows] -- When used with the -r flag, this will specify the seperator for rows. By default it is the new line character. It could be a character, set of characters or even a number. Options that might be included eventually. -n -- Where is some number. This would be a shortcut for averaging all the numbers in the th column of the input. By default, the columns would be determined by white space, but could also be determined by the -s flag. This must be used with the -c or -r flags. Usage options (in addition to the standard options) -- normalize -- This program will distribute a group of numbers between 0 and 1 by default according to their initial value. You can change the range using the -R option. Usage options: X -R -- This is for specifying a range to normalize for instead of 0..1 -- round -- This utility will round each number encountered up or down depending on it's decimal value or it's relation to a number. It will probably also deal with finding the floor or ceiling values of numbers. It should also be able to round to factors of certain numbers. Options: X -n -- Round to the nearest factor of . Instead of just rounding all decimal numbers, you can also round to a factor of any number. So if you set to 1000 and you encounter the number 6777, it will round that number to 7000. If you set to 3 and encounter the number 7, it will round it to 6. X -c -- Find the ceiling of each number encountered. Round up. X -f -- Find the floor of each number. Round down. -- range -- Print out a range of numbers for use in for loops and such. o Do zero or character padding with the -p option. So 1 becomes 001 if the range has an upper limit of 3 digits. o Accept ranges in the following formats: n1..n2 (ex. 1..100 ; All integers from 1 to 100) n1..n2,n3..n4 (ex. 1..10,50..100 ; All integers from 1 to 10 and from 50 to 100) n1..n2i2 (ex. 2..20i2 ; All even numbers from 2 to 20) (ex. 1..19i2 ; All odd numbers from 1 to 19) (ex. 3..21i3 ; 3, 6, 9, 12, 15, 18, 21) n1.d..n2.di0.1 (ex. 1.1..2.0i0.1 ; 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0) Or any combination of the above. Usage options (in addition to the standard options) -p -- Put the following prefix before each number. -s -- Put the following suffix after each number. X -n -- Use as a character to separate each number. By default, a space is used. Use the sequence \n to specify a newline. X -N -- Shortcut for using a newline separator. X -e -- Exclude the numbers in from the output. This is so that if you want to do a complex range without including certain numbers. is a list of numbers seperated by a ','. -- random -- Print out a random number or numbers. This program will take a range of numbers much like the range command does. Except that instead of printing out all the numbers in that range, it will print out a random number from that range. Ex: $ random 1..100 37 $ random 1.0..100.0 56.9 $ random 1.000..100.000 42.397 $ random 2..100i2 [only pick among the even integers from 2 to 100] 68 Usage options (in addition to the standard options) -n -- Generate random numbers seperated by a space. -s -- Use as the seperation character. -N -- Shortcut for using a newline separation character. Feature submitted by areiner@tph.tuwien.ac.at: - You should specify the distribution you are generating; probably, this is just an equal distribution. What would come in handy quite often is to have a way of producing pseudo-random numbers that realize a chosen distribution with a given set of parameters. But that should probably be a different program than random, e.g. distribution, as the name is already taken. So, e.g., ``distribution --gaussian 3.0 4.0 100'' should produce 100 numbers distributed according to a gauss distribution with mean 3 and variance 4. -- bound -- This program is for finding the maximum, minimum and surrounding numbers in a set. You can use different options to specify how many numbers are returned as to show top maximum and minimum lists. Also you can show the numbers that occur around the context of the boundary numbers. Ex: $ cat numbers 1 10 8 100 15 1000 2 9 5 15 27 12 136 $ bound -u numbers (upper) 1000 $ bound -l numbers (lower) 1 Top 4 upper numbers sorted $ bound -u -n 4 numbers 1000 136 100 27 Bottom 4 lower numbers sorted) $ bound -l -n 4 numbers 1 2 5 8 Context around lowest number. Show 2 numbers of context. $ bound -l -c 2 numbers 1 10 8 Find the 5 closet numbers to the number 75. They will print out in closeness order. $ bound -f 75 -n 6 100 27 15 15 136 10 Usage options (in addition to the standard options) -u -- Return the upper bound number in the set (the maximum number) -l -- Return the lower bound number in the set (the minimum number) -n -- Return the top or bottom numbers or numbers around a number. -c -- In addition to the number returned, show numbers on both sides of the number. -f -- Find the number or the closest number to . -- numprocess -- (maybe a name like mutate, alter, or process would be better) This program mutates numbers as it encounters them. It should do the following operations: o Add/Subtract a value to a number o Multiply/Divide a number by a factor o Raise a number to a power (includes the concept of roots) o Round a number up or down o Do any mathematical function to a number. o Quantify a number. So 1024 bytes is 1KB and so on. Ex: Add 1 to each number $ numprocess /+1/ Multiply each number by 8 and then divide by 5 $ numprocess /*8,%5/ Convert from Farenheit to Celcius $ numprocess /-32,*5,%9/ Usage options (in addition to the standard options) -- interval -- This program calculates and displays the interval between one number and the next. num-utils-0.5/LICENSE0100664000076400007640000000165407665476706013134 0ustar susosuso--------------------------------------------------------------------------- num-utils - A set of programs that deals with numbers. Copyright (C) 2002-2003 Suso Banderas --------------------------------------------------------------------------- This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. num-utils-0.5/MANIFEST0100664000076400007640000000027007734144204013227 0ustar susosusoCHANGELOG COPYING GOALS LICENSE MANIFEST Makefile README VERSION WARNING num-utils.spec.in template numsum numgrep average round range random bound numprocess tests interval normalize num-utils-0.5/Makefile0100664000076400007640000000762307734144204013547 0ustar susosuso# $Id: Makefile,v 1.12 2003/09/23 22:26:12 suso Exp $ # num-utils A set of programs for doing operations on numbers # Copyright (C) 2002-2003 Suso Banderas # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # You may contact the author at . VERSION = $(shell cat VERSION) PROJECT = num-utils DIST = $(PROJECT)-$(VERSION) FILES = $(shell cat MANIFEST) UTILS = average bound interval normalize numgrep numprocess numsum random range round DOCS = CHANGELOG COPYING LICENSE MANIFEST template README GOALS WARNING TESTS = file fractionalnums numbers numbers2 README zeros # rpm --showrc is gettin to be hard to parse anymore. #RPMDIR = /usr/src/redhat RPMDIR = $(shell rpm --showrc | grep " _topdir" | \ perl -n -e \ '/_topdir(?:\s+|\s+:\s+)(\/.*|%{_usrsrc}.*$$)/; \ $$dir = $$1; $$dir =~ s|%{_usrsrc}|/usr/src|; print "$$1\n";') # Modify these as nessecary PERL = /usr/bin/perl BINDIR = /usr/bin TOPDIR = $(ROOT)/usr MANDIR = $(TOPDIR)/share/man/man1 DOCDIR = $(TOPDIR)/share/doc/$(DIST) BINDIR = $(TOPDIR)/bin TARFILE = $(DIST).tar.gz RPMFILE = $(RPMDIR) SPECFILE= $(PROJECT).spec RPMFILE = $(RPMDIR)/RPMS/noarch/$(DIST)-1.noarch.rpm SRPMFILE= $(RPMDIR)/SRPMS/$(DIST)-1.src.rpm all: manpages for file in $(UTILS) ; do \ cat $$file | sed 's|^#!/usr/bin/perl|#!$(PERL)|' > $$file.out ; \ mv $$file.out $$file ; chmod a+x $$file ; done install: install -m 0755 -o 0 -g 0 -d $(BINDIR) for util in $(UTILS) ; do \ install -m 0755 -o 0 -g 0 $$util $(BINDIR) ; done install -m 0755 -o 0 -g 0 -d $(DOCDIR) for doc in $(DOCS) ; do \ install -m 0644 -o 0 -g 0 $$doc $(DOCDIR) ; done install -m 0755 -o 0 -g 0 -d $(MANDIR) for man in $(UTILS) ; do \ install -m 0644 -o 0 -g 0 $$man.1.gz $(MANDIR) ; done uninstall: for util in $(UTILS) ; do \ rm -f $(BINDIR)/$$util ; done rmdir $(BINDIR) for doc in $(DOCS) ; do \ rm -f $(DOCDIR)/$$doc ; done rmdir $(DOCDIR) for man in $(UTILS) ; do \ rm -f $(MANDIR)/$$man.1.gz ; done rmdir $(MANDIR) manpages: for doc in $(UTILS) ; do \ pod2man $$doc > $$doc.1 ; \ gzip $$doc.1 ; chmod 644 $$doc.1.gz \ ; done rpminstall: install -m 0755 -d $(BINDIR) for util in $(UTILS) ; do \ install -m 0755 $$util $(BINDIR) ; done install -m 0755 -d $(DOCDIR) for doc in $(DOCS) ; do \ install -m 0644 $$doc $(DOCDIR) ; done install -m 0755 -d $(MANDIR) for man in $(UTILS) ; do \ install -m 0644 $$man.1.gz $(MANDIR) ; done clean: rm -f $(PROJECT).spec rm -f $(TARFILE) for file in $(UTILS) ; do \ rm -f $$file.1 ; done for file in $(UTILS) ; do \ cat $$file | sed 's|^#!$(PERL)|#!/usr/bin/perl|' > $$file.out ; \ mv $$file.out $$file ; chmod a+x $$file ; done dist: $(TARFILE) test: for file in $(UTILS) ; do $(PERL) -Tcw $$file ; done $(TARFILE): $(FILES) rm -fr $(DIST) rm -f $(TARFILE) mkdir $(DIST) perl -pe 'chomp; symlink "../$$_", "$(DIST)/$$_" or die $$!' MANIFEST tar zchf $(DIST).tar.gz $(DIST) --exclude CVS rm -r $(DIST) rpm: $(RPMFILE) $(SRPMFILE) $(RPMFILE): do-rpm $(SRPMFILE): do-rpm do-rpm: $(TARFILE) $(SPECFILE) cp $(SPECFILE) $(RPMDIR)/SPECS/ cp $(TARFILE) $(RPMDIR)/SOURCES/ rpmbuild -ba $(RPMDIR)/SPECS/$(SPECFILE) $(SPECFILE): $(SPECFILE).in VERSION perl -pe 's[\@(\S+)\@] \ [open F, $$1 or die; $$x = join "", ; chomp $$x; $$x]ge' \ < $< > $@ num-utils-0.5/README0100664000076400007640000000573107667227206012776 0ustar susosuso num-utils is Copyright 2002-2003 Suso Banderas ====================---------------------------- **PLEASE ALSO READ THE WARNING FILE THAT** **COMES WITH THIS PROGRAM.** Description - num-utils are a set of utilities that aim to provide the numeric equivilent of the GNU text-utils. These programs do operations on numbers such as filtering, adding, averaging and so on. They help expand and complete the shell vocabulary. Right now these programs are in the beta stage. If you have any bug fixes or suggestions to improve this program, please see the "Contact" section of this document . An extensive list of planned features is in the 'GOALS' file included with this program. Installation ------------ For now please use the Makefile to install the programs. By default this will install them in /usr/bin. Standard 'make' and 'make install' commands will build and install the programs. You can also make an RPM source and binary package from the Makefile using 'make rpm'. How to use ---------- These programs are useful when you want to deal with numbers on stdin or from files. There are different programs for different functions: numsum - Adding a set of numbers from stdin is simply a matter of passing just the numbers themselves to numsum. $ cat test/numbers | numsum 21937.74 $ You can use other programs like numgrep, awk or sed to get just the numbers that you want from a file: $ cat access_log | awk {'print $10'} | numsum numgrep - Simular to grep, but specific to numbers. This program will let you search for ranges of numbers and sequences. $ numgrep /-5..5,100..200/ tests/numbers 5 135 135 1 1.5 4.5351 3 3 -1 -2.543 -1 3 random - Generates random numbers based on range expressions. $ randnum /0..100/ 47 $ range - This program will spit out a sequence of numbers for use in stuff like shell for loops. The syntax for this program will most likely change in the next version. $ range /5..10/ 5 6 7 8 9 10 $ $ for i in `range /1..5,10..15/` ; do mv track$i.mp3 song$i.mp3 ; done 1 2 3 4 5 10 11 12 13 14 15 $ interval - This program will calculate and display the interval between every two seqeuntial numbers on the input stream: $ cat numbers 1 2 3 5 10 45 35 2 1 $ cat numbers | interval 1 1 2 5 35 -10 -33 -1 $ Contact ------- Please send bug reports, suggestions, requests or correspondence to Suso Banderas at 'suso@suso.org'. You can visit the homepage for this program at: http://suso.suso.org/programs/num-utils/ num-utils-0.5/VERSION0100664000076400007640000000000410147276245013144 0ustar susosuso0.5 num-utils-0.5/WARNING0100664000076400007640000000133207502661631013127 0ustar susosusonum-utils - WARNING ----------------------------------- The num-utils are not nearly tested as much as they should be and does not have all the functionality that you may expect it to have. I'm releasing them now so that I can get a little bit of input from potential users of the programs and also so that I could reach a checkpoint in their development. If you have a problem with num-utils please notify me at 'suso@suso.org' and I will take note of the bug or your comments. It should also be noted that options and expected behavior are likely to change before the release of version 1.0. Right now I'm trying to find the best interface for these programs. Thanks for being patient, Suso Banderas suso@suso.org num-utils-0.5/num-utils.spec.in0100664000076400007640000000400010147276245015312 0ustar susosuso# $Id: num-utils.spec.in,v 1.12 2004/11/19 04:55:01 suso Exp $ Summary: num-utils are a set of programs for dealing with numbers. Name: num-utils Version: @VERSION@ Release: 1 Copyright: GPL Group: Utilities Source: num-utils-@VERSION@.tar.gz BuildArch: noarch BuildRoot: /var/tmp/num-utils-build-@VERSION@ Packager: Suso Banderas Vendor: suso.org %description The num-utils, short for numeric utilities are a set of programs designed to work together from the unix shell to do numeric operations on input. They are basically the numeric equivilent of common unix text utilities and aim to help complete the unix shell vocabulary. %prep %setup %build make %install make ROOT="$RPM_BUILD_ROOT" rpminstall %files %attr(0755 root root) /usr/bin/average %attr(0755 root root) /usr/bin/bound %attr(0755 root root) /usr/bin/interval %attr(0755 root root) /usr/bin/normalize %attr(0755 root root) /usr/bin/numgrep %attr(0755 root root) /usr/bin/numprocess %attr(0755 root root) /usr/bin/numsum %attr(0755 root root) /usr/bin/random %attr(0755 root root) /usr/bin/range %attr(0755 root root) /usr/bin/round %doc %attr(- root root) CHANGELOG COPYING GOALS LICENSE README WARNING template #%attr(0755 root root) tests %doc %attr(- root root) tests/ %{_mandir}/man1/average.1.gz %{_mandir}/man1/bound.1.gz %{_mandir}/man1/interval.1.gz %{_mandir}/man1/normalize.1.gz %{_mandir}/man1/numgrep.1.gz %{_mandir}/man1/numprocess.1.gz %{_mandir}/man1/numsum.1.gz %{_mandir}/man1/random.1.gz %{_mandir}/man1/range.1.gz %{_mandir}/man1/round.1.gz %changelog * Fri Nov 19 2004 Suso Banderas - 0.5 release * Tue Sep 23 2003 Suso Banderas - 0.4 release - added file entries for normalize program. * Mon Jun 9 2003 Suso Banderas - 0.3 beta release * Tue Jun 3 2003 Suso Banderas - Added file entries for interval program. * Thu May 29 2003 Suso Banderas - 0.2 beta release. * Mon Jun 17 2002 Suso Banderas - Initial 0.1 release of the num-utils num-utils-0.5/template0100775000076400007640000000715410147276246013653 0ustar susosuso#!/usr/bin/perl -w # template: This is the default template file used to create # new files. # # Copyright (C) 2002-2004 Suso Banderas # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # You may contact the author at . ####################### # VARIABLES AND SETUP # ####################### use Getopt::Std; use strict; use vars qw/ %opts $verbose /; getopts('hdV', \%opts); if ($opts{'h'}) { &help(); exit(0); } if ($opts{'d'}) { $verbose = 3; print STDERR "Debug mode\n"; } elsif ($opts{'V'}) { $verbose = 2; print STDERR "Verbose mode\n"; } elsif ($opts{'q'}) { $verbose = 0; # Nothing except the final answer } else { $verbose = 1; # Normal warnings and such. } ################ # MAIN PROGRAM # ################ # For file args if (@ARGV) { foreach $file (@ARGV) { print STDERR "Reading from file $file.\n" if ($verbose >= 2); open (ARGFILE, "$file") && process_filehandle(\*ARGFILE, \@number_array) || $verbose && warn "Couldn't open file $file for reading: $!\n"; close (ARGFILE); } # For STDIN } else { print STDERR "Reading from STDIN.\n" if ($verbose >= 2); process_filehandle(\*STDIN, \@number_array); } exit(0); ############### # SUBROUTINES # ############### sub help { print <<"EOF"; ---------------------------------------------- template : ---------------------------------------------- Usage: template [options] | template [options] template [options] Options: -d Debug. For developers only. -h Help: You're looking at it. -V Increase verbosity. EOF } sub process_filehandle { my $filehandle = shift; my $number_array_ref = shift; while (<$filehandle>) { if (m/^\s*(\-?[0-9]*\.?[0-9]+)/) { print STDERR "found number: $1\n" if ($verbose >= 3); push(@$number_array_ref, $1); } } return 1; } # Lay down some of that perl pod action. =pod =head1 NAME template - template program file =head1 SYNOPSIS B