Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r73797 - sandbox/SOC/2011/checks/boost/checks
From: pierre.talbot.6114_at_[hidden]
Date: 2011-08-15 15:33:03


Author: trademark
Date: 2011-08-15 15:33:02 EDT (Mon, 15 Aug 2011)
New Revision: 73797
URL: http://svn.boost.org/trac/boost/changeset/73797

Log:
Delete parasites files used for algorithm idea. BTW Thanks to them.
Removed:
   sandbox/SOC/2011/checks/boost/checks/EANcheck.cpp
   sandbox/SOC/2011/checks/boost/checks/EANcheck.hpp
   sandbox/SOC/2011/checks/boost/checks/IBMCheck.hpp
   sandbox/SOC/2011/checks/boost/checks/ISBN_PAB.hpp
   sandbox/SOC/2011/checks/boost/checks/ISSN_PAB.hpp
   sandbox/SOC/2011/checks/boost/checks/UPCcheck.cpp
   sandbox/SOC/2011/checks/boost/checks/UPCcheck.hpp
   sandbox/SOC/2011/checks/boost/checks/VISACheck.hpp
   sandbox/SOC/2011/checks/boost/checks/isbn_Vasconcelos.hpp

Deleted: sandbox/SOC/2011/checks/boost/checks/EANcheck.cpp
==============================================================================
--- sandbox/SOC/2011/checks/boost/checks/EANcheck.cpp 2011-08-15 15:33:02 EDT (Mon, 15 Aug 2011)
+++ (empty file)
@@ -1,170 +0,0 @@
-//! \file EANcheck.cpp
-
-// Copyright Paul A. Bristow 2011.
-
-// Use, modification and distribution are subject to the
-// Boost Software License, Version 1.0.
-// (See accompanying file LICENSE_1_0.txt
-// or copy at http://www.boost.org/LICENSE_1_0.txt)
-// European Article numbering
-
-// EAN check
-
-// EAN Symbol Specification Manual,
-// Universal Product Code, Uniform Code Council, Dayton, Ohio, USA.
-// M. Blocksma, Reading the Numbers, Penguin, New York 1989.
-// Joseph A Gallian, ACM Computing Surveys, 28(3), 504-517 (Sep 1996)
-// Section 2, page 505 example of Kelloggs Low fat Granola 03800013710 & check digit 5.
-// EAN-13 check is (
-// Example is 7 012345 678908
-// EAN-8 check is -(1, 2, 3, 4, 5, 6, 7) * (3,1,3,1,3,1,3,1,3) mod 10 == 0
-// eg -(1 * 3 + 2 * 1 * 3 * 3 + 4 * 1 + %* 3 + 6 * 1 + 7 * 3) mod 10
-//
-// Stephen Barnett, Discrete Mathematics, Numbers and Beyond, Addison-Wesley.
-// ISBN 0201342928 EAN 978 201 342925
-// EAN for books is based on the ISBN and begins with the digits 978,
-// and the next nine digits being the first nine digits of the ISBN,
-// finally an EAN-13 check decimal digit.
-
-#include <iostream> // For testing only.
-//using std::cout; // For testing only.
-//using std::endl; // For testing only.
-
-#include <string>
-//using std::string;
-#include <vector>
-//using std::vector;
-
-#include <cassert>
-
-#include "EANcheck.hpp" // Declarations of bool EANcheck(string s); & char EANcompute(string s);
-
-bool EANcheck(std::string s)
-{ // Check that a EAN 13 includes the correct check end digit.
- if (s.size() != 13)
- { // Must be exactly 12 decimal digits + one decimal check digit.
- std::cout << "length is " << unsigned int(s.size()) << std::endl;
- return false;
- }
- std::vector<int> v(13); // Exactly 13 requirement.
- assert(v.size() == 13);
- for (int i = 0; i < 13; i++)
- {
- if (isdigit(s[i]))
- {
- v[i] = s[i] - '0';
- }
- else
- { // Unexpected character in string!
- std::cout << " unexpected char " << s[i] << std::endl;
- return false;
- }
- }
- int check = (v[0] * 1 + v[1] * 3 + v[2] * 1 + v[3] * 3 + v[4] * 1 + v[5] * 3
- + v[6] * 1 + v[7] * 3 + v[8] * 1 + v[9] * 3 + v[10] * 1 + v[11] * 3
- + v[12] * 1); // the 13th decimal check digit.
- //std::cout << check << std::endl;
- check %= 10; // modulus 10 because must be a decimal check digit,
- // (not X as ISBN system).
- //std::cout << check << std::endl;
- return (check == 0);
-} // bool EANcheck(string s)
-
-char EANcompute(std::string s)
-{ // Compute EAN check digit.
- if (s.size() != 12)
- { // Must be exactly 12 decimal digits.
- std::cout << "EAN length is " << unsigned int(s.size()) << std::endl;
- return false;
- }
- std::vector<int> v(13); // Exactly 12 digits required,
- // but leave space for check digit too?
- assert(v.size() == 13);
-
- for (int i = 0; i < 12; i++)
- {
- if (isdigit(s[i]))
- { // Convert ACSII digit chars to int.
- v[i] = s[i] - '0';
- }
- else
- { // Unexpected character in string!
- std::cout << " unexpected char " << s[i] << std::endl;
- return false;
- }
- }
- int check = (v[0] * 1 + v[1] * 3 + v[2] * 1 + v[3] * 3 + v[4] * 1 + v[5] * 3
- + v[6] * 1 + v[7] * 3 + v[8] * 1 + v[9] * 3 + v[10] * 1 + v[11] * 3
- ); // decimal check digit.
-
- //cout << check << endl;
- check %= 10; // modulus 10 so can be a decimal digit.
- check = (check != 0) ? 10 - check : 0;
- //std::cout << check << std::endl;
- return char(check + '0'); // ASCII '0' to '9'
-} // bool EANcompute(string s)
-
-bool EAN8check(std::string s)
-{ // Check that a EAN-8 string includes the correct check digit.
- // Examples: EAN8check("12345670")
- // EAN8check("00511728")
- if (s.size() != 8)
- { // Must be exactly 7 decimal digits & one decimal check digit.
- std::cout << "length is " << unsigned int(s.size()) << "!" << std::endl;
- return false;
- }
- std::vector<int> v(8); // Exactly 8 decimal digits required.
- assert(v.size() == 8);
- for (int i = 0; i < 8; i++)
- {
- if (isdigit(s[i]))
- { // Convert ascii digit chars to int.
- v[i] = s[i] - '0'; // Convert ascii digit chars to int.
- }
- else
- { // Unexpected character in string!
- std::cout << " unexpected char " << s[i] << std::endl;
- return false;
- }
- }
- int check = (v[0] * 3 + v[1] * 1 + v[2] * 3 + v[3] * 1 + v[4] * 3 + v[5] * 1 + v[6] * 3
- + v[7] * 1 // the 8th decimal check digit.
- );
- //std::cout << check << std::endl;
- check %= 10; // modulus 10 because must be a decimal check digit (not X as ISBN system).
- //std::cout << check << std::endl;
- return (check == 0);
-} // bool EANcheck(string s)
-
-char EAN8compute(std::string s)
-{ // Compute EAN-8 check digit.
- if (s.size() != 7)
- { // Must be exactly 7 decimal digits, because 8th will be the check digit.
- std::cout << "EAN length is " << unsigned int(s.size()) << std::endl;
- return false;
- }
- std::vector<int> v(7);// Exactly 7 digits required,
- assert(v.size() == 7);
- for (int i = 0; i < 7; i++)
- {
- if (isdigit(s[i]))
- {
- v[i] = s[i] - '0';
- }
- else
- { // Unexpected character in string!
- std::cout << " unexpected char " << s[i] << std::endl;
- return false;
- }
- }
- int check = - (
- v[0] * 3 + v[1] * 1 + v[2] * 3 + v[3] * 1 + v[4] * 3 + v[5] * 1 + v[6] * 3
- ); // decimal check digit.
-
- //std::cout << check << std::endl;
- check %= 10; // modulus 10 as must be be a decimal digit (not X as ISBN system).
- //std::cout << check << std::endl;
- return char(check + '0'); // ASCII '0' to '9'
-} // bool EANcompute(string s)
-
-// and bar code 2 in 5...

Deleted: sandbox/SOC/2011/checks/boost/checks/EANcheck.hpp
==============================================================================
--- sandbox/SOC/2011/checks/boost/checks/EANcheck.hpp 2011-08-15 15:33:02 EDT (Mon, 15 Aug 2011)
+++ (empty file)
@@ -1,18 +0,0 @@
-// EAN.hpp
-
-// European Article Numbering
-// similar to
-// UPC Symbol Specification Manual, Uniform Code Council, Dayton, Ohio, USA.
-// M. Blocksma, Reading the Numbers, Penguin, New York 1989.
-// Joseph A Gallian, ACM Computing Surveys, 28(3), 504-517 (Sep 1996)
-// Section 2, 506
-// 13 decimal digit code, like UPC
-// uses a two digits that identify the country in which the item was produced.
-// C Harmon & R Adams, Reading between the Lines, Helmers publishing NH (1989)
-// Stephen Barnett, discrete Mathematics, Numbers and Beyond, Addison-Wesley.
-// ISBN 0201342928 EAN 9 78201 342925
-
-#include <string>
-
-bool EANcheck(std::string s);
-char EANcompute(std::string s);

Deleted: sandbox/SOC/2011/checks/boost/checks/IBMCheck.hpp
==============================================================================
--- sandbox/SOC/2011/checks/boost/checks/IBMCheck.hpp 2011-08-15 15:33:02 EDT (Mon, 15 Aug 2011)
+++ (empty file)
@@ -1,104 +0,0 @@
-// IBM check used by MAstercard, VISA, and most other credit card companies.
-
-// Is an even/odd weighted code.
-
-// Digits in the even positions (numbering from the right) are multiplied by 2,
-// then reduced to a single digit (if > 9) by "casting out nines"
-// (subtracting 9, which is equivalent to adding the digits).
-// All digits are them summed
-// and a check digit added to make the result evenly divisble by 10.
-
-// EAN for books is based on the ISBN and begins with the digits 978,
-// and the next nine digits being the first nine digits of the ISBN,
-// finally an EAN-13 check decimal digit.
-
-#include <string>
-#include <vector>
-#include <cctype> // isdigit, isspace, tolower
-
-using std::string;
-using std::vector;
-
-using std::cout;
-using std::endl;
-
-bool IBMcheck(string s)
-{ // Check an existing IBM check string s
- // which includes a check digit 0 to 9.
- vector<int> v(16);
- for (int i = 0; i < 16; i++)
- { // Convert decimal digit characters in string to integers in vector.
- if (isdigit(s[i]))
- {
- v[i] = s[i] - '0';
- }
- else if (toupper(s[i] == 'X'))
- {
- v[i] = 10;
- }
- else
- { // give up! (assumes no whitespace or punctuation).
- return false;
- }
- // cout << v[i] << ' ';
- }
- int check = 0;
- for (int i = 0; i < 16; i++)
- {
- if ((i % 2) == 0)
- { // even
- v[i] *= 2;
- if (v[i] > 9)
- {
- v[i] -= 9; // "casting out nines"
- }
- }
- // else unchanged if odd.
- check += v[i]; //
- }
- //cout << '\n' << check << endl;
- check %= 10; // modulus 10
- // cout << ' ' << check << endl;
- return (check == 0); // true if check digit is correct.
-} // bool IBMcheck(string s)
-
-char IBMcompute(string s)
-{ // Compute check digit 0 to 9 for the string provided.
- // Might allow other size if remove whitespace and punctutation?
- vector<int> v(15); // To hold numeric values from character values in string s.
- for (int i = 0; i < 15; i++)
- {
- if (isdigit(s[i]))
- {
- v[i] = s[i] - '0';
- }
- else
- { // throw?
- //return '?';
- // ignore
- }
- // cout << v[i] << ' ';
- }
- int check = 0;
- for (int i = 0; i < 15; i++)
- {
- if ((i % 2) == 0)
- { // even
- v[i] *= 2;
- if (v[i] > 9)
- {
- v[i] -= 9; // "casting out nines"
- }
- }
- // else unchanged if odd.
- check += v[i]; //
- }
- // cout << '\n' << check << endl;
-
- check %= 10; // modulus 10
- // cout << ' ' << check << endl;
- if (check == 0) return '0';
- check = 10 - check;
- return char(check + '0');
-} // char IBMcompute(string s)
-

Deleted: sandbox/SOC/2011/checks/boost/checks/ISBN_PAB.hpp
==============================================================================
--- sandbox/SOC/2011/checks/boost/checks/ISBN_PAB.hpp 2011-08-15 15:33:02 EDT (Mon, 15 Aug 2011)
+++ (empty file)
@@ -1,113 +0,0 @@
-// ISBN_PAB.hpp obselete version
-
-//! \file
-//! \brief Obselete versio of ISBN check and compute.
-
-// Boost checks/isbn_pab.hpp header file ------------------------------------//
-
-// (C) Copyright Paul A. Bristow, 2002, 2011
-
-// Distributed under the Boost Software License, Version 1.0.
-// (See accompanying file LICENSE_1_0.txt
-// or copy at http://www.boost.org/LICENSE_1_0.txt
-
-// The Standard Book Numbering Agency Ltd, London.
-// ISBN.org
-// Philip M. Tuchinsky, International Standard Book Numbers,
-// UMAP Journal 5(1985) 41-45, ISSN 0197-3622
-// ISO Standard International Standard Book Number 2108:1992.
-// http://www.isbn.org/standards/home/isbn/digitalworld.asp
-// Length of the ISBN String/Check Digit
-
-// In January 2005, the ISBN standard will expand the current 10-digit string of numbers to 13.
-// This action is being taken to increase the availability of new numbers
-// and to make the ISBN standard compatible with European standard numbering systems EAN13.
-// All ISBNs in the original pool of numbers will be prefaced
-// by the prefix "978" to accomplish this increase in digits.
-// All new ISBNs will be given a prefix "979",
-// allowing the agency to effectively "reuse" the current pool of ISBNs.
-
-
-//#include <iostream> // test only.
-//using std::cout;
-//using std::endl;
-
-#include <string>
-//using std::string;
-
-#include <vector>
-//using std::vector;
-
-#include <cctype>
-// using std::isdigit and std::tolower
-
-// Defines:
-bool ISBNcheck(string s);
-char ISBNcompute(string s);
-
-
-bool ISBNcheck(std::string s)
-{ // Check an existing ISBN string s
- // which includes a check digit 0 to 9 or X (=11)
- std::vector<int> v(10);
- for (int i = 0; i < 10; i++)
- {
- if (std::isdigit(s[i]))
- {
- v[i] = s[i] - '0';
- }
- else if (toupper(s[i] == 'X'))
- {
- v[i] = 10;
- }
- else
- { // give up! (assumes no whitespace or punctuation).
- return false;
- }
- // cout << v[i] << ' ';
- }
- int check = 10 * v[0] + 9 * v[1] + 8 * v[2] + 7 * v[3] + 6 * v[4]
- + 5 * v[5] + 4 * v[6] + 3 * v[7] + 2 * v[8]
- + 1 * v[9]; // check digit
- // std::cout << ' ' << check << std::endl;
- check %= 11; // modulus 11
- // std::cout << ' ' << check << std::endl;
- return (check == 0); // true if check digit is correct.
-} // bool ISBNcheck(std::string s)
-
-char ISBNcompute(std::string s)
-{ // Compute check digit 0 to 9 or X (=11) for the string provided.
- if (s.size() != 9)
- {
- return -1; // Must be exactly 9 digits (to be a 10 digit ISBN)
- }
- // Might allow other size if remove whitespace and punctutation?
- std::vector<int> v(9);
- for (int i = 0; i < 9; i++)
- {
- if (std::isdigit(s[i]))
- {
- v[i] = s[i] - '0';
- }
- else if (std::toupper(s[i] == 'X'))
- {
- v[i] = 10;
- }
- else
- { // throw?
- return '?';
- }
- // cout << v[i] << ' ';
- }
- int check = 10 * v[0] + 9 * v[1] + 8 * v[2] + 7 * v[3] + 6 * v[4]
- + 5 * v[5] + 4 * v[6] + 3 * v[7] + 2 * v[8];
-
- // std::cout << '\n' << check << std::endl;
-
- check %= 11; // modulus 11
- // std::cout << ' ' << check << std::endl;
- if (check == 0) return '0';
- check = 11 - check;
- return (check == 10) ? 'X' : char(check + '0');
-} // char ISBNcomputer(std::string s)
-

Deleted: sandbox/SOC/2011/checks/boost/checks/ISSN_PAB.hpp
==============================================================================
--- sandbox/SOC/2011/checks/boost/checks/ISSN_PAB.hpp 2011-08-15 15:33:02 EDT (Mon, 15 Aug 2011)
+++ (empty file)
@@ -1,94 +0,0 @@
-// ISSN.hpp
-
-// The Standard Book Numbering Agency Ltd, London.
-// Philip M. Tuchinsky, International Standard Book Numbers, UMAP Journal 5(1985) 41-45, ISSN 0197-3622
-// ISO Standard, International Standard Book Number 2108:1992.
-// http://www.issn.org:8080/English/pub/faqs/barcodes
-// EAN-13 codes start with 977, "land of serial publications"
-// for example ISSN 1144-875X GENCOD informations(Paris)
-// EAN-13 bar code is 9 771144 875007
-// ISSN Check digit, in this case X is removed from the ISSN,
-// 00 is price code (usually 00), 7 is EAN-13 check digit
-// and finally issue number 03 for March, for example.
-
-// Defines:
-bool ISSNcheck(string s);
-char ISSNcompute(string s);
-
-#include <iostream>
-#include <string>
-#include <vector>
-#include <cctype> // for isdigit and tolower
-
-using std::string;
-using std::vector;
-
-using std::cout; // test only.
-using std::endl;
-
-bool ISSNcheck(string s)
-{ // Check an existing ISSN string s
- // which includes a check digit 0 to 9 or X (=11)
- vector<int> v(8);
- for (int i = 0; i < 8; i++)
- {
- if (isdigit(s[i]))
- {
- v[i] = s[i] - '0';
- }
- else if (toupper(s[i] == 'X'))
- {
- v[i] = 10;
- }
- else
- { // give up! (assumes no whitespace or punctuation).
- return false;
- }
- // cout << v[i] << ' ';
- }
- int check = 8 * v[0] + 7 * v[1] + 6 * v[2] + 5 * v[3] + 4 * v[4]
- + 3 * v[5] + 2 * v[6] + 1 * v[7];
- //cout << ' ' << check << endl;
- check %= 11; // modulus 11
- //cout << ' ' << check << endl;
- return (check == 0); // true if check digit is correct.
-} // bool ISSNcheck(string s)
-
-char ISSNcompute(string s)
-{ // Compute check digit 0 to 9 or X (=11) for the string provided.
- if (s.size() != 7)
- {
- return '?' ; // Must be exactly 7 digits (to be a 8 digit ISSN)
- }
- // Might allow other sizes if remove whitespace and punctutation?
- vector<int> v(7);
- for (int i = 0; i < 7; i++)
- {
- if (isdigit(s[i]))
- {
- v[i] = s[i] - '0';
- }
- else if (toupper(s[i] == 'X'))
- {
- v[i] = 10;
- }
- else
- { // throw?
- return '?';
- }
- // cout << v[i] << ' ';
- }
- int check = 8 * v[0] + 7 * v[1] + 6 * v[2] + 5 * v[3] + 4 * v[4] + 3 * v[5] + 2 * v[6];
-
- check %= 11; // modulus 11
- if (check == 0) return '0';
- check = 11 - check;
- return (check == 10) ? 'X' : char(check + '0');
- // return 3 * v[0] + 4 * v[1] + 5 * v[2] + 6 * v[3] + 7 * v[4] + 8 * v[5] + 9 * v[6];
- // L. Egghe & R. Rousseau, Mathmetical and Computer Modelling,
- // 33 (2001), 943-955 ISSN 0895-7177 page 944,
- // equation 5 - simpler version of equation 4, the ISO standard.
-} // char ISSNcomputer(string s)
-
-
-

Deleted: sandbox/SOC/2011/checks/boost/checks/UPCcheck.cpp
==============================================================================
--- sandbox/SOC/2011/checks/boost/checks/UPCcheck.cpp 2011-08-15 15:33:02 EDT (Mon, 15 Aug 2011)
+++ (empty file)
@@ -1,96 +0,0 @@
-//! \file UPCcheck.cpp
-
-// Copyright Paul A. Bristow 2011.
-
-// Use, modification and distribution are subject to the
-// Boost Software License, Version 1.0.
-// (See accompanying file LICENSE_1_0.txt
-// or copy at http://www.boost.org/LICENSE_1_0.txt)
-
-// UPC check
-
-// Universal Product Code
-// UPC Symbol Specification Manual, Uniform Code Council, Dayton, Ohio, USA.
-// M. Blocksma, Reading the Numbers, Penguin, New York 1989.
-// Joseph A Gallian, ACM Computing Surveys, 28(3), 504-517 (Sep 1996)
-// Section 2, page 505 example of Kellogs Low fat Granola 03800013710 & check digit 5.
-
-// Shipping code adds a second using modulo 103 arithmetic.
-// USS-128 Uniform Symbology Specification, p5,
-// Uniform Code Couuncil, Ohio, USA. (1986)
-
-#include <iostream> // For testing only.
-using std::cout; // For testing only.
-using std::endl; // For testing only.
-#include <string>
-// using std::string;
-#include <vector>
-//using std::vector;
-#include <cassert>
-
-#include <boost/checks/UPCcheck.hpp> // Declarations of bool UPCcheck(string s);
-// & char UPCcompute(string s);
-
-bool UPCcheck(std::string s)
-{ // Check that a UPC includes the correct check digit.
- if (s.size() != 12)
- { // Must be exactly 11 decimal digits + one decimal check digit.
- cout << "length is " << unsigned int(s.size()) << " ! but must be exactly 12."<< endl;
- return false;
- }
- std::vector<int> v (12);
- assert(v.size() == 12);
- for (int i = 0; i < 12; i++)
- {
- char d = s[i];
- if (isdigit(d))
- {
- int c = d - int('0');
- //v.push_back(c);
- v[i] = c;
- }
- else
- { // Unexpected character in string!
- cout << " Unexpected char " << s[i] << endl;
- return false;
- }
- }
- int check = (v[0] * 3 + v[1] * 1 + v[2] * 3 + v[3] * 1 + v[4] * 3 + v[5] * 1
- + v[6] * 3 + v[7] * 1 + v[8] * 3 + v[9] * 1 + v[10] * 3
- + v[11] * 1); // the 12th decimal check digit.
- // cout << check << endl;
- check %= 10; // modulus 10 because a decimal check digit.
- //cout << check << endl;
- return bool(check == 0);
-} // bool UPCcheck(string s)
-
-char UPCcompute(std::string s)
-{ // Compute UPC check digit.
- if (s.size() != 11)
- { // Must be exactly 11 decimal digits.
- cout << "UPC length is " << unsigned int(s.size()) << "! but should be exactly 11." << endl;
- return false;
- }
- std::vector<int> v (12);
- assert(v.size() == 12); // Exactly 11 digits required,
- // but leave one space for check digit too.
- for (int i = 0; i < 10; i++)
- {
- if (isdigit(s[i]))
- {
- v[i] = s[i] - int('0');
- }
- else
- { // Unexpected character in string!
- cout << " unexpected char " << s[i] << endl;
- return false;
- }
- }
- int check = (v[0] * 3 + v[1] * 1 + v[2] * 3 + v[3] * 1 + v[4] * 3 + v[5] * 1
- + v[6] * 3 + v[7] * 1 + v[8] * 3 + v[9] * 1 + v[10] * 3);
- // cout <<"check int before mod " << check << endl;
- check %= 10; // modulus 10 so can be a decimal digit.
- check = (check != 0) ? 10 - check : 0;
- // cout << check << endl;
- return char(check + '0'); // ASCII '0' to '9'
-} // bool UPCcompute(string s)

Deleted: sandbox/SOC/2011/checks/boost/checks/UPCcheck.hpp
==============================================================================
--- sandbox/SOC/2011/checks/boost/checks/UPCcheck.hpp 2011-08-15 15:33:02 EDT (Mon, 15 Aug 2011)
+++ (empty file)
@@ -1,21 +0,0 @@
-//! \file UPCcheck.hpp
-
-// Copyright Paul A. Bristow 2011.
-
-// Use, modification and distribution are subject to the
-// Boost Software License, Version 1.0.
-// (See accompanying file LICENSE_1_0.txt
-// or copy at http://www.boost.org/LICENSE_1_0.txt)
-
-// UPCcheck.hpp
-
-// Universal Product Code UPC check
-// UPC Symbol Specification Manual, Uniform Code Council, Dayton, Ohio, USA.
-// M. Blocksma, Reading the Numbers, Penguin, New York 1989.
-// Joseph A Gallian, ACM Computing Surveys, 28(3), 504-517 (Sep 1996)
-// Section 2
-
-#include <string>
-
-bool UPCcheck(std::string s);
-char UPCcompute(std::string s);

Deleted: sandbox/SOC/2011/checks/boost/checks/VISACheck.hpp
==============================================================================
--- sandbox/SOC/2011/checks/boost/checks/VISACheck.hpp 2011-08-15 15:33:02 EDT (Mon, 15 Aug 2011)
+++ (empty file)
@@ -1,269 +0,0 @@
-// IBM check used by Mastercard, VISA, and most other credit card companies.
-// Version using Joseph A. Gallian permutations, rather than 'casting out nines'
-// See Error Detection Methods, Joseph A. Gallian,
-// ACM computing Surveys, 28(3) 504-517 (Sep 1996)
-// ISSN 0360-0300
-
-// Is an even/odd weighted code.
-
-// Digits in the even positions (numbering from the right) are multiplied by 2,
-// then reduced to a single digit (if > 9) by "casting out nines"
-// (subtracting 9, which is equivalent to adding the digits).
-// All digits are them summed
-// and a check digit added to make the result evenly divisble by 10.
-
-#include <string>
-#include <vector>
-#include <cctype> // isdigit, isspace, tolower
-
-using std::string;
-using std::vector;
-
-using std::cout;
-using std::endl;
-
-int perm[10] =
-{ // J A Gallian & S Winters, (1988), Amer. Math. Monthly 95, 548-551.
- // A. Ecker & G. Poch, Check Characeter system, Computing, 37, 277-301 (1986)
- // if digit == 0, add 0, if digit is 1, add 2 to check.
- 0, // s(0) = 0 page 506 section 3, Credit card scheme.
- 2, // s(1) = 2
- 4, // s(2) = 4
- 6, // s(3) = 6
- 8, // s(4) = 8
- 1, // s(5) = 1
- 3, // s(6) = 3
- 5, // s(7) = 5
- 7, // s(8) = 7
- 9, // s(9) = 9
-};
-
-bool VISAcheck(string s)
-{ // Check an existing IBM check string s
- // which includes a check digit 0 to 9.
- // const int n = 8; // n-1 digits, plus 1 nth check digit.
- const int n = int(s.size()); // including check digit, so do all n digits.
- // cout << "Check n = " << n << endl;
- // 16 for credit card numbers.
- vector<int> v(n);
- for (int i = 0; i < n; i++)
- { // Convert decimal digit characters in string to integers in vector.
- if (isdigit(s[i]))
- {
- v[i] = s[i] - '0';
- }
- else if (toupper(s[i] == 'X'))
- {
- v[i] = 10;
- }
- else
- { // give up! (assumes no whitespace or punctuation).
- return false;
- }
- //cout << v[i] << ' ';
- }
- //cout << endl;
- int check = 0;
- for (int i = 0; i < n; i++)
- { // Assumes n (total including check digit) is even.
- // Permute the even numbered digits instead if n is odd.
- if ((i % 2) == 0)
- { // i is even, odd numbered digits (counting 1, 2, 3 ... n) are permuted.
- // cout << v[i] << ' ' << perm[v[i]] << endl;
- check += perm[v[i]];
- }
- else
- { // even numbered digits (counting 1, 2, 3 ... n) are unchanged.
- // cout << v[i] << endl;
- check += v[i]; //
- }
- }
- // cout << '\n' << check << endl;
- check %= 10; // modulus 10
- // cout << ' ' << check << endl;
- return (check == 0); // true if check digit is correct.
-} // bool IBMcheck(string s)
-
-char VISAcompute(string s)
-{ // Compute check digit 0 to 9 for the string provided.
- // Might allow other size if remove whitespace and punctutation?
-// const int n = 8; // including check digit, so only do n-1 digits.
- const int n = int(s.size() +1); // including check digit, so only do n-1 digits.
- // cout << "compute n = " << n << endl;
-
- vector<int> v(n-1); // To hold numeric values from character values in string s.
- for (int i = 0; i < n-1; i++)
- {
- if (isdigit(s[i]))
- {
- v[i] = s[i] - '0';
- }
- else
- { // throw?
- //return '?';
- // ignore
- }
- // cout << v[i] << ' ';
- }
- int check = 0;
- for (int i = 0; i < n-1; i++)
- { // Assumes n (total including check digit) is even.
- // Permute the even numbered digits instead if n is odd.
- if ((i % 2) == 0)
- { // i is even, odd numbered digits (counting 1, 2, 3 ... n) are permuted.
- // cout << v[i] << ' ' << perm[v[i]] << endl;
- check += perm[v[i]]; // permutated.
- }
- else
- { // even numbered digits (counting 1, 2, 3 ... n) are unchanged.
- // cout << v[i] << endl;
- check += v[i]; // unchanged.
- }
- }
- // cout << "\nComputed check " << check << endl;
- // cout << '\n' << check << endl;
- check %= 10; // modulus 10
- // cout << ' ' << check << endl;
- if (check == 0) return '0';
- check = 10 - check;
- return char(check + '0');
-} // char IBMcompute(string s)
-
-/*
-
-
-Test j:\cpp\isbn\testisbn.cpp Thu Nov 28 09:46:29 2002
-VISAcheck("76592146")
-Check n = 8
-7 6 5 9 2 1 4 6
-7 5
-6
-5 1
-9
-2 4
-1
-4 8
-6
-
-40
- 0
-true
-VISAcompute("7659214")
-compute n = 8
-7 5
-6
-5 1
-9
-2 4
-1
-4 8
-
-Computed check 34
-VISAcompute("7659214") 6
-Check n = 16
-5 8 1 8 0 0 6 1 9 1 1 4 0 0 2 7
-5 1
-8
-1 2
-8
-0 0
-0
-6 3
-1
-9 9
-1
-1 2
-4
-0 0
-0
-2 4
-7
-
-50
- 0
-VISAcheck("5818006191140027") true
-compute n = 16
-5 1
-8
-1 2
-8
-0 0
-0
-6 3
-1
-9 9
-1
-1 2
-4
-0 0
-0
-2 4
-
-Computed check 43
-VISAcompute("581800619114002") 7
-Check n = 16
-4 4 1 7 1 2 3 4 5 6 7 8 9 1 1 2
-4 8
-4
-1 2
-7
-1 2
-2
-3 6
-4
-5 1
-6
-7 5
-8
-9 9
-1
-1 2
-2
-
-69
- 9
-VISAcheck("4417123456789112") false
-compute n = 16
-4 8
-4
-1 2
-7
-1 2
-2
-3 6
-4
-5 1
-6
-7 5
-8
-9 9
-1
-1 2
-
-Computed check 67
-VISAcompute("441712345678911") 3
-Check n = 16
-4 4 1 7 1 2 3 4 5 6 7 8 9 1 1 3
-4 8
-4
-1 2
-7
-1 2
-2
-3 6
-4
-5 1
-6
-7 5
-8
-9 9
-1
-1 2
-3
-
-70
- 0
-VISAcheck("4417123456789113") true
-Press any key to continue
-
-*/
\ No newline at end of file

Deleted: sandbox/SOC/2011/checks/boost/checks/isbn_Vasconcelos.hpp
==============================================================================
--- sandbox/SOC/2011/checks/boost/checks/isbn_Vasconcelos.hpp 2011-08-15 15:33:02 EDT (Mon, 15 Aug 2011)
+++ (empty file)
@@ -1,63 +0,0 @@
-// Boost checks/isbn.hpp header file ------------------------------------//
-// (C) Copyright Murilo Adriano Vasconcelos 2011.
-// Distributed under the Boost Software License, Version 1.0. (See
-// accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt
-// See http://www.boost.org for updates, documentation, and revision history.
-
-#ifndef BOOST_ISBN_INCLUDED
-#define BOOST_ISBN_INCLUDED
-
-#include <string>
-
-namespace boost {
-
-/**
- * This function checks if a `isbn' is a valid ISBN
- */
-bool is_isbn(const std::string& isbn)
-{
- if (isbn.size() != 10) return false;
-
- int check = 0;
- for (int i = 0; i < 9; ++i) {
- if (!isdigit(isbn[i])) {
- return false;
- }
-
- check += (10 - i) * isbn[i];
- }
-
- check += (isbn[9] == 'x' || isbn[9] == 'X') ? 10 : isbn[9];
-
- return (check % 11 == 0);
-}
-
-/**
- * This function computes the check digit for a given ISBN in `isbn'
- */
-char isbn_check_digit(const std::string& isbn)
-{
- int check = 0;
- for (int i = 0; i < 9; ++i) {
- if (!isdigit(isbn[i])) {
- return false;
- }
-
- check += (10 - i) * isbn[i];
- }
-
- check += (isbn[9] == 'x' || isbn[9] == 'X') ? 10 : isbn[9];
- check %= 11;
-
- if (check == 0) {
- return '0';
- }
- check = 11 - check;
-
- return (check == 10) ? 'X' : (check + '0');
-}
-
-} // namespace boost
-
-#endif
\ No newline at end of file


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk