[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master a3278e2b 10/11: Expunge 'stl_extensions.hpp'
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master a3278e2b 10/11: Expunge 'stl_extensions.hpp' |
Date: |
Tue, 31 May 2022 17:52:06 -0400 (EDT) |
branch: master
commit a3278e2bc11bc7f5c8a5c180007fbf76b8259f39
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Expunge 'stl_extensions.hpp'
---
Makefile.am | 1 -
currency_test.cpp | 1 -
stl_extensions.hpp | 156 -----------------------------------------------------
3 files changed, 158 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 0e74f16b..e476a9a3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1320,7 +1320,6 @@ noinst_HEADERS = \
skeleton.hpp \
so_attributes.hpp \
ssize_lmi.hpp \
- stl_extensions.hpp \
stratified_algorithms.hpp \
stratified_charges.hpp \
stratified_charges.xpp \
diff --git a/currency_test.cpp b/currency_test.cpp
index 5cd28cb9..ef91b5af 100644
--- a/currency_test.cpp
+++ b/currency_test.cpp
@@ -391,7 +391,6 @@ void currency_test::test_quodlibet()
// CURRENCY !! Ideas for testing overflow or underflow.
#if 0
-// double big_num = nonstd::power(2.0, 53);
double big_num = 1.0e100;
currency::data_type big_int1 = 1.0 * big_num;
LMI_TEST_EQUAL(1.0e100, big_int1);
diff --git a/stl_extensions.hpp b/stl_extensions.hpp
deleted file mode 100644
index a360c792..00000000
--- a/stl_extensions.hpp
+++ /dev/null
@@ -1,156 +0,0 @@
-// SGI extensions to STL.
-//
-// Copyright (C) 2001, 2002, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012,
2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022 Gregory W. Chicares.
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License version 2 as
-// published by the Free Software Foundation.
-//
-// 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
-//
-// https://savannah.nongnu.org/projects/lmi
-// email: <gchicares@sbcglobal.net>
-// snail: Chicares, 186 Belle Woods Drive, Glastonbury CT 06033, USA
-
-// Copyright (C) 1994
-// Hewlett-Packard Company
-//
-// Permission to use, copy, modify, distribute and sell this software
-// and its documentation for any purpose is hereby granted without fee,
-// provided that the above copyright notice appear in all copies and
-// that both that copyright notice and this permission notice appear
-// in supporting documentation. Hewlett-Packard Company makes no
-// representations about the suitability of this software for any
-// purpose. It is provided "as is" without express or implied warranty.
-//
-// Copyright (C) 1996-1998
-// Silicon Graphics Computer Systems, Inc.
-//
-// Permission to use, copy, modify, distribute and sell this software
-// and its documentation for any purpose is hereby granted without fee,
-// provided that the above copyright notice appear in all copies and
-// that both that copyright notice and this permission notice appear
-// in supporting documentation. Silicon Graphics makes no
-// representations about the suitability of this software for any
-// purpose. It is provided "as is" without express or implied warranty.
-
-// This implementation is a derived work based on code SGI released
-// with the above disclaimers.
-//
-// Gregory W. Chicares modified it trivially in 2002 and 2005, and in
-// later years as indicated in 'ChangeLog' or in `git log`. Any defect
-// in it should not reflect on SGI's or HP's reputation.
-
-#ifndef stl_extensions_hpp
-#define stl_extensions_hpp
-
-#include "config.hpp"
-
-#include "assert_lmi.hpp"
-#include "bin_exp.hpp"
-#include "bourn_cast.hpp"
-#include "miscellany.hpp" // scoped_ios_format
-
-#include <functional> // multiplies, plus
-#include <iostream>
-#include <stdexcept> // logic_error
-#include <type_traits> // is_integral_v
-
-namespace hidden
-{
-/// Identity element.
-
-template <typename T> inline T identity_element(std::plus<T>)
-{
- return T(0);
-}
-
-template <typename T> inline T identity_element(std::multiplies<T>)
-{
- return T(1);
-}
-
-/// Returns x ** n, where 0 <= n, by right-to-left binary exponentiation.
-///
-/// See Knuth, TAOCP volume 2, section 4.6.3 (p. 442 in 2nd ed.).
-///
-/// Note that "multiplication" is required to be associative, but not
-/// necessarily commutative.
-///
-/// GWC modification: throw on negative exponent--otherwise, the loop
-/// may never terminate, because the bitwise operators don't work as
-/// intended with negative values. Alternative not used: assert that
-/// type Integer is unsigned, as the author evidently assumed--but
-/// imposing that requirement now breaks too much existing lmi code.
-
-template <typename T, typename Integer, typename MonoidOperation>
-T power(T x, Integer n, MonoidOperation opr)
-{
- static_assert(std::is_integral_v<Integer>);
- if(n < 0)
- {
- throw std::logic_error("power() called with negative exponent.");
- }
- if(n == 0)
- {
- return identity_element(opr);
- }
- else
- {
- while ((n & 1) == 0)
- {
- n >>= 1;
- x = opr(x, x);
- }
- T result = x;
- n >>= 1;
- while (n != 0)
- {
- x = opr(x, x);
- if((n & 1) != 0)
- result = opr(result, x);
- n >>= 1;
- }
- return result;
- }
-}
-} // namespace hidden
-
-namespace nonstd
-{
-template <typename T, typename Integer>
-inline T power(T x, Integer n)
-{
- using F = std::conditional_t<std::is_floating_point_v<T>, T, double>;
-
- T const r = hidden::power(x, n, std::multiplies<T>());
- F const a = bourn_cast<F>(r);
- F const b = bin_exp(bourn_cast<F>(x), bourn_cast<int>(n));
- if(a != b)
- {
- scoped_ios_format meaningless_name(std::cout);
- std::cout.precision(32);
- std::cout
- << "power <> bin_exp:\n"
- << x << " x\n"
- << n << " n\n"
- << a << " a\n"
- << b << " b\n"
- << a - b << " a - b\n"
- << (a - b) / a << " (a - b) / a\n"
- << std::endl
- ;
- }
- LMI_ASSERT(a == b);
- return r;
-}
-} // namespace nonstd
-
-#endif // stl_extensions_hpp
- [lmi-commits] [lmi] master updated (44ea8a5b -> fd325f5e), Greg Chicares, 2022/05/31
- [lmi-commits] [lmi] master d36e5145 03/11: Suppress undefined behavior; add a test with defined behavior, Greg Chicares, 2022/05/31
- [lmi-commits] [lmi] master 28055a62 02/11: Realize the actual intention of a comparison, Greg Chicares, 2022/05/31
- [lmi-commits] [lmi] master a3278e2b 10/11: Expunge 'stl_extensions.hpp',
Greg Chicares <=
- [lmi-commits] [lmi] master c6dc35ea 05/11: Demonstrate equivalence of bin_exp() to SGI's power(), Greg Chicares, 2022/05/31
- [lmi-commits] [lmi] master 8922e7a1 06/11: Explain restrictions on bin_exp() argument types, Greg Chicares, 2022/05/31
- [lmi-commits] [lmi] master 8cbc3001 07/11: Make a value definitely exact and definitely constexpr, Greg Chicares, 2022/05/31
- [lmi-commits] [lmi] master 2c8cc917 04/11: Don't bother calculating 2^64 - 1, Greg Chicares, 2022/05/31
- [lmi-commits] [lmi] master 7727d36d 08/11: Prefer bin_exp() to SGI's power(), Greg Chicares, 2022/05/31
- [lmi-commits] [lmi] master d9655b77 01/11: Refactor: rename local variables, Greg Chicares, 2022/05/31
- [lmi-commits] [lmi] master 2576d70c 09/11: Prefer bin_exp() to SGI's power(), Greg Chicares, 2022/05/31
- [lmi-commits] [lmi] master fd325f5e 11/11: Record speed measurements, Greg Chicares, 2022/05/31