/*============================================================================== | | NAME | | Primpoly.h | | DESCRIPTION | | Global header file for primitive polynomial routines. | Constants, message strings, data types and algorithm control parameters. | | LEGAL | | Primpoly Version 9.1 - A Program for Computing Primitive Polynomials. | Copyright (C) 1999-2008 by Sean Erik O'Connor. All Rights Reserved. | | 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; version 2 | of the License. | | 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. | | The author's address is artifex@seanerikoconnor.freeservers.com | ==============================================================================*/ #ifndef PP_H /* Wrap this header file. */ #define PP_H /*============================================================================= | | NAME | | Miscellaneous constants. | | DESCRIPTION | | +============================================================================*/ typedef unsigned int uint ; // For convenience. const uint minModulus = 2 ; const uint minDegree = 2 ; // Return status fed back to Unix shell. enum ReturnStatus { Success = 0, AskForHelp = 1, PNotPrime = 2, RangeError = 3, InternalError = 4, Reserved = 5 } ; /*============================================================================= | | NAME | | PrimpolyError | | DESCRIPTION | | Top level error class for main. | +============================================================================*/ class PrimpolyError : public runtime_error { public: // Throw with an error message. PrimpolyError( const string & description ) : runtime_error( description ) { } ; // Default throw with no error message. PrimpolyError() : runtime_error( "Polynomial error: " ) { } ; } ; // end class PrimpolyError /*============================================================================= | | NAME | | Message strings. | | DESCRIPTION | | +============================================================================*/ static string legalNotice ( "\n" "Primpoly Version 9.1 - A Program for Computing Primitive Polynomials.\n" "Copyright (C) 1999-2008 by Sean Erik O'Connor. All Rights Reserved.\n" "\n" "Primpoly comes with ABSOLUTELY NO WARRANTY; for details see the\n" "GNU General Public License. This is free software, and you are welcome\n" "to redistribute it under certain conditions; see the GNU General Public License\n" "for details.\n\n" ) ; static string helpText ( "This program generates a primitive polynomial of degree n modulo p.\n" "\n" "Usage: Primpoly p n\n" " where p is a prime >= 2 and n is an integer >= 2\n" "\n" " Primpoly -t "", p""\n" " If you leave off the ,p we assume p = 2\n" "\n" "Example: \n" " Primpoly 2 4 \n" " Self-check passes...\n" " Primitive polynomial modulo 2 of degree 4\n" "\n" " x ^ 4 + x + 1, 2\n" "\n" "\n" " Primpoly -t ""x^4+x+1,2""\n" " Self-check passes...\n" " x ^ 4 + x + 1, 2 is primitive!\n" "\n" "\n" "Primitive polynomials find many uses in mathematics and communications\n" "engineering:\n" " * Generation of pseudonoise (PN) sequences for spread spectrum\n" " communications and chip fault testing.\n" " * Generation of CRC and Hamming codes.\n" " * Generation of Galois (finite) fields for use in decoding Reed-Solomon\n" " and BCH error correcting codes.\n" "\n" "For detailed technical information, see my web page\n" " http://seanerikoconnor.freeservers.com/Mathematics/AbstractAlgebra/PrimitivePolynomials/overview.html\n" ) ; static string writeToAuthorMessage ( "Please email the author at \n" " artifex@seanerikoconnor.freeservers.com\n" "and attach the unitTest.log file which should be located\n" "in the current directory and all console output from this program.\n" "Thanks for your help,\n" " Artifex.\n" ) ; #endif // End of wrapper for header.