A Small Software Repository

This page contains code that, for some reason or another, I have made public. Unless otherwise noted, all the code is original. The use and redistribution of this code is governed by the GNU General Public License, a copy of which I keep locally for reference. In short, feel free to use this code as your needs require, but my primary concern is that you may not charge others for the use of my work. I know this sounds self-evident, but believe me, there are people out there who still don't understand this (I've worked with a few)...

Documentation

Hist doc A simple class for creating histograms.
RandTools doc A package of random number generators. Many come from NRC.


I tend to break programing down into very small increments. If there is some aspect of the code that I do not fully understand, I like to create a “toy” program dedicated solely to understanding the issue at hand. These toys are then quite simple, and make an excellent reference (in my opinion) for later work. Over the years, I have developed quite a library of these toys, and so I though I'd share them with the world at large---in case there are others out there with the same questions I had. The following is a list of toys that have been “sanitized for your protection.”

toy_formatprint  
A demonstration of how to get formatted output using C++ calls. The temptation is to use printf() because it is more compact. But there are times when strict adherence to the C++ printing conventions is important.
toy_c++printing  
A little toy to demonstrate how to get C++ style printing into a class. We make a little class with a Print function. Then, we overload the ≪ operator to call that function. This setup allows us to print to standard out. One cute trick is demonstrated in the second overload of the ≪ operator. This move lets us print the object to a file without having to go through all the business of creating and setting up the output stream. We just need to pick a name and effectively pipe the object into that file name.
toy_input  
An example of three ways to input data into a C++ program. The first section demonstrates basic interactive entry. The second handles command line input. And the third is a sketch of how to read data from an ASCII text file. Each of the three segments is independent of the other, and may thus be commented out to simplify the program.
toy_fileIO  
This program demonstrates the writing to, and reading from both binary and ASCII files via C++ conventions. Both sections are “self sufficient,” so the removal of one will not affect the performance of the other. Note that the reading and writing of the binary file requires the intermediate step of reading from (or writing to) a buffer array. This array must be long enough to contain the data that are being transferred. Note also that the first open() command is coupled with an optional invocation that has been commented out. The extra flag in the optional invocation means that the data file will be opened in “append” mode instead of “clobber” mode.
toy_random  
This example demonstrates how to incorporate a random number generator into your program. Also addresses some issues involved in insuring that the sequence of numbers you generate are, in fact, random.
toy_vector  
A quick little demo on how to implement a vector from the standard template library. For a complete list of vector functions, try googling STL and vector.
toy_structure  
A quick demo to show how to use structures.