Makefile.am (std_headers): Remove cXXX from list.
2002-01-04 Benjamin Kosnik <bkoz@redhat.com>
* include/Makefile.am (std_headers): Remove cXXX from list.
(c_base_srcdir): No bits subdirectory.
(c_base_builddir): Same.
(c_base_headers): Adjust names, add ciso646.
(bits_headers): Remove std_xxx.h headers.
* include/Makefile.in: Regenerate.
* include/ext/iterator: Adjust includes.
* include/ext/ropeimpl.h: Same.
* include/ext/stl_hash_fun.h: Same.
* include/ext/algorithm: Same.
* include/backward/bvector.h: Adjust includes.
* include/backward/vector.h: Same.
* include/backward/strstream: Same.
* include/backward/streambuf.h: Same.
* include/backward/stack.h: Same.
* include/backward/set.h: Same.
* include/backward/queue.h: Same.
* include/backward/multiset.h: Same.
* include/backward/multimap.h: Same.
* include/backward/map.h: Same.
* include/backward/list.h: Same.
* include/backward/iterator.h: Same.
* include/backward/iostream.h: Same.
* include/backward/iomanip.h: Same.
* include/backward/fstream.h: Same.
* include/backward/deque.h: Same.
* include/backward/complex.h: Same.
* include/bits/std_algorithm.h: Move to...
* include/std/algorithm: ...here.
* include/bits/std_iosfwd.h, std_locale.h, std_stack.h,
std_bitset.h, std_ios.h, std_map.h, std_stdexcept.h,
std_complex.h, std_iostream.h, std_memory.h, std_streambuf.h,
std_deque.h, std_istream.h, std_numeric.h, std_string.h,
std_fstream.h, std_ostream.h, std_utility.h, std_iterator.h,
std_queue.h, std_valarray.h, std_functional.h, std_limits.h,
std_set.h, std_vector.h, std_iomanip.h, std_list.h, std_sstream.h:
Same.
* include/c_std/bits/std_cassert.h: Move to...
* include/c_std/cassert: Here.
* include/c_std/std_cctype.h, std_cerrno.h, std_cfloat.h,
std_climits.h, std_clocale.h, std_cmath.h, std_csetjmp.h,
std_csignal.h, std_cstdarg.h, std_cstddef.h, std_cstdio.h,
std_cstdlib.h, std_cstring.h, std_ctime.h, std_cwchar.h,
std_cwctype.h: Same.
* include/c_std/cmath: Adjust cmath.tcc include.
* include/c_std/cstdlib: Adjust includes.
* include/c_std/cwchar: Same.
* include/c_std/ctime: Same.
* include/c_std/cstring: Same.
* include/c_std/cstdio: Same.
* include/c_std/bits: Remove directory.
* include/c/bits/std_cassert.h: Move to...
* include/c/cassert: Here.
* include/c/std_cctype.h, std_cerrno.h, std_cfloat.h,
std_climits.h, std_clocale.h, std_cmath.h, std_csetjmp.h,
std_csignal.h, std_cstdarg.h, std_cstddef.h, std_cstdio.h,
std_cstdlib.h, std_cstring.h, std_ctime.h, std_cwchar.h,
std_cwctype.h: Same.
* include/c/bits: Remove directory.
* include/std/cwctype: Remove.
* include/std/cwchar: Remove.
* include/std/ctime: Remove.
* include/std/cstring: Remove.
* include/std/cstdlib: Remove.
* include/std/cstdio: Remove.
* include/std/cstddef: Remove.
* include/std/cstdarg: Remove.
* include/std/csignal: Remove.
* include/std/csetjmp: Remove.
* include/std/cmath: Remove.
* include/std/clocale: Remove.
* include/std/climits: Remove.
* include/std/ciso646: Remove.
* include/std/cfloat: Remove.
* include/std/cerrno: Remove.
* include/std/cctype: Remove.
* include/std/cassert: Remove.
* include/bits/fpos.h: Adjust includes, removing <bits/std_xxx.h>
files and subsituting <.xxx>
* include/bits/valarray_array.h: Same.
* include/bits/stl_uninitialized.h: Same.
* include/bits/stl_alloc.h: Same.
* include/bits/stl_algobase.h: Same.
* include/bits/sstream.tcc: Same.
* include/bits/pthread_allocimpl.h: Same.
* include/bits/ostream.tcc: Same.
* include/bits/localefwd.h: Same.
* include/bits/locale_facets.tcc: Same.
* include/bits/locale_facets.h: Same.
* include/bits/istream.tcc: Same.
* include/bits/char_traits.h: Same.
* include/bits/boost_concept_check.h: Same.
* include/bits/basic_file.h: Same.
* include/std/bitset: Same.
* include/std/complex: Same.
* include/std/fstream: Same.
* include/std/functional: Same.
* include/std/ios: Same.
* include/std/iostream: Same.
* include/std/ostream: Same.
* include/std/sstream: Same.
* include/std/streambuf: Same.
* include/std/string: Same.
* include/std/iterator: Same.
* include/std/valarray: Same.
* src/ios.cc: Adjust includes.
* src/valarray-inst.cc: Same.
* src/string-inst.cc: Same.
* src/stl-inst.cc: Same.
* src/stdexcept.cc: Same.
* src/misc-inst.cc: Same.
* src/localename.cc: Same.
* src/locale-inst.cc: Same.
* src/locale.cc: Same.
* src/limits.cc: Same.
* src/concept-inst.cc: Same.
* src/complex_io.cc: Same.
* src/codecvt.cc: Same.
* src/bitset.cc: Same.
* src/cmath.cc: Same.
From-SVN: r48544
2002-01-04 22:27:36 +01:00
|
|
|
// <numeric> -*- C++ -*-
|
2001-06-09 01:22:26 +02:00
|
|
|
|
2020-01-01 12:51:42 +01:00
|
|
|
// Copyright (C) 2001-2020 Free Software Foundation, Inc.
|
2001-06-09 01:22:26 +02:00
|
|
|
//
|
|
|
|
// This file is part of the GNU ISO C++ Library. This library is free
|
|
|
|
// software; you can redistribute it and/or modify it under the
|
|
|
|
// terms of the GNU General Public License as published by the
|
2009-04-09 17:00:19 +02:00
|
|
|
// Free Software Foundation; either version 3, or (at your option)
|
2001-06-09 01:22:26 +02:00
|
|
|
// any later version.
|
|
|
|
|
|
|
|
// This library 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.
|
|
|
|
|
2009-04-09 17:00:19 +02:00
|
|
|
// Under Section 7 of GPL version 3, you are granted additional
|
|
|
|
// permissions described in the GCC Runtime Library Exception, version
|
|
|
|
// 3.1, as published by the Free Software Foundation.
|
2001-06-09 01:22:26 +02:00
|
|
|
|
2009-04-09 17:00:19 +02:00
|
|
|
// You should have received a copy of the GNU General Public License and
|
|
|
|
// a copy of the GCC Runtime Library Exception along with this program;
|
|
|
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
|
|
|
// <http://www.gnu.org/licenses/>.
|
2001-06-09 01:22:26 +02:00
|
|
|
|
Makefile.am (std_headers): Remove cXXX from list.
2002-01-04 Benjamin Kosnik <bkoz@redhat.com>
* include/Makefile.am (std_headers): Remove cXXX from list.
(c_base_srcdir): No bits subdirectory.
(c_base_builddir): Same.
(c_base_headers): Adjust names, add ciso646.
(bits_headers): Remove std_xxx.h headers.
* include/Makefile.in: Regenerate.
* include/ext/iterator: Adjust includes.
* include/ext/ropeimpl.h: Same.
* include/ext/stl_hash_fun.h: Same.
* include/ext/algorithm: Same.
* include/backward/bvector.h: Adjust includes.
* include/backward/vector.h: Same.
* include/backward/strstream: Same.
* include/backward/streambuf.h: Same.
* include/backward/stack.h: Same.
* include/backward/set.h: Same.
* include/backward/queue.h: Same.
* include/backward/multiset.h: Same.
* include/backward/multimap.h: Same.
* include/backward/map.h: Same.
* include/backward/list.h: Same.
* include/backward/iterator.h: Same.
* include/backward/iostream.h: Same.
* include/backward/iomanip.h: Same.
* include/backward/fstream.h: Same.
* include/backward/deque.h: Same.
* include/backward/complex.h: Same.
* include/bits/std_algorithm.h: Move to...
* include/std/algorithm: ...here.
* include/bits/std_iosfwd.h, std_locale.h, std_stack.h,
std_bitset.h, std_ios.h, std_map.h, std_stdexcept.h,
std_complex.h, std_iostream.h, std_memory.h, std_streambuf.h,
std_deque.h, std_istream.h, std_numeric.h, std_string.h,
std_fstream.h, std_ostream.h, std_utility.h, std_iterator.h,
std_queue.h, std_valarray.h, std_functional.h, std_limits.h,
std_set.h, std_vector.h, std_iomanip.h, std_list.h, std_sstream.h:
Same.
* include/c_std/bits/std_cassert.h: Move to...
* include/c_std/cassert: Here.
* include/c_std/std_cctype.h, std_cerrno.h, std_cfloat.h,
std_climits.h, std_clocale.h, std_cmath.h, std_csetjmp.h,
std_csignal.h, std_cstdarg.h, std_cstddef.h, std_cstdio.h,
std_cstdlib.h, std_cstring.h, std_ctime.h, std_cwchar.h,
std_cwctype.h: Same.
* include/c_std/cmath: Adjust cmath.tcc include.
* include/c_std/cstdlib: Adjust includes.
* include/c_std/cwchar: Same.
* include/c_std/ctime: Same.
* include/c_std/cstring: Same.
* include/c_std/cstdio: Same.
* include/c_std/bits: Remove directory.
* include/c/bits/std_cassert.h: Move to...
* include/c/cassert: Here.
* include/c/std_cctype.h, std_cerrno.h, std_cfloat.h,
std_climits.h, std_clocale.h, std_cmath.h, std_csetjmp.h,
std_csignal.h, std_cstdarg.h, std_cstddef.h, std_cstdio.h,
std_cstdlib.h, std_cstring.h, std_ctime.h, std_cwchar.h,
std_cwctype.h: Same.
* include/c/bits: Remove directory.
* include/std/cwctype: Remove.
* include/std/cwchar: Remove.
* include/std/ctime: Remove.
* include/std/cstring: Remove.
* include/std/cstdlib: Remove.
* include/std/cstdio: Remove.
* include/std/cstddef: Remove.
* include/std/cstdarg: Remove.
* include/std/csignal: Remove.
* include/std/csetjmp: Remove.
* include/std/cmath: Remove.
* include/std/clocale: Remove.
* include/std/climits: Remove.
* include/std/ciso646: Remove.
* include/std/cfloat: Remove.
* include/std/cerrno: Remove.
* include/std/cctype: Remove.
* include/std/cassert: Remove.
* include/bits/fpos.h: Adjust includes, removing <bits/std_xxx.h>
files and subsituting <.xxx>
* include/bits/valarray_array.h: Same.
* include/bits/stl_uninitialized.h: Same.
* include/bits/stl_alloc.h: Same.
* include/bits/stl_algobase.h: Same.
* include/bits/sstream.tcc: Same.
* include/bits/pthread_allocimpl.h: Same.
* include/bits/ostream.tcc: Same.
* include/bits/localefwd.h: Same.
* include/bits/locale_facets.tcc: Same.
* include/bits/locale_facets.h: Same.
* include/bits/istream.tcc: Same.
* include/bits/char_traits.h: Same.
* include/bits/boost_concept_check.h: Same.
* include/bits/basic_file.h: Same.
* include/std/bitset: Same.
* include/std/complex: Same.
* include/std/fstream: Same.
* include/std/functional: Same.
* include/std/ios: Same.
* include/std/iostream: Same.
* include/std/ostream: Same.
* include/std/sstream: Same.
* include/std/streambuf: Same.
* include/std/string: Same.
* include/std/iterator: Same.
* include/std/valarray: Same.
* src/ios.cc: Adjust includes.
* src/valarray-inst.cc: Same.
* src/string-inst.cc: Same.
* src/stl-inst.cc: Same.
* src/stdexcept.cc: Same.
* src/misc-inst.cc: Same.
* src/localename.cc: Same.
* src/locale-inst.cc: Same.
* src/locale.cc: Same.
* src/limits.cc: Same.
* src/concept-inst.cc: Same.
* src/complex_io.cc: Same.
* src/codecvt.cc: Same.
* src/bitset.cc: Same.
* src/cmath.cc: Same.
From-SVN: r48544
2002-01-04 22:27:36 +01:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* 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,1997
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2006-12-06 00:24:07 +01:00
|
|
|
/** @file include/numeric
|
2004-11-24 05:11:23 +01:00
|
|
|
* This is a Standard C++ Library header.
|
2001-09-28 00:44:24 +02:00
|
|
|
*/
|
|
|
|
|
2003-07-23 17:28:44 +02:00
|
|
|
#ifndef _GLIBCXX_NUMERIC
|
|
|
|
#define _GLIBCXX_NUMERIC 1
|
Makefile.am (std_headers): Remove cXXX from list.
2002-01-04 Benjamin Kosnik <bkoz@redhat.com>
* include/Makefile.am (std_headers): Remove cXXX from list.
(c_base_srcdir): No bits subdirectory.
(c_base_builddir): Same.
(c_base_headers): Adjust names, add ciso646.
(bits_headers): Remove std_xxx.h headers.
* include/Makefile.in: Regenerate.
* include/ext/iterator: Adjust includes.
* include/ext/ropeimpl.h: Same.
* include/ext/stl_hash_fun.h: Same.
* include/ext/algorithm: Same.
* include/backward/bvector.h: Adjust includes.
* include/backward/vector.h: Same.
* include/backward/strstream: Same.
* include/backward/streambuf.h: Same.
* include/backward/stack.h: Same.
* include/backward/set.h: Same.
* include/backward/queue.h: Same.
* include/backward/multiset.h: Same.
* include/backward/multimap.h: Same.
* include/backward/map.h: Same.
* include/backward/list.h: Same.
* include/backward/iterator.h: Same.
* include/backward/iostream.h: Same.
* include/backward/iomanip.h: Same.
* include/backward/fstream.h: Same.
* include/backward/deque.h: Same.
* include/backward/complex.h: Same.
* include/bits/std_algorithm.h: Move to...
* include/std/algorithm: ...here.
* include/bits/std_iosfwd.h, std_locale.h, std_stack.h,
std_bitset.h, std_ios.h, std_map.h, std_stdexcept.h,
std_complex.h, std_iostream.h, std_memory.h, std_streambuf.h,
std_deque.h, std_istream.h, std_numeric.h, std_string.h,
std_fstream.h, std_ostream.h, std_utility.h, std_iterator.h,
std_queue.h, std_valarray.h, std_functional.h, std_limits.h,
std_set.h, std_vector.h, std_iomanip.h, std_list.h, std_sstream.h:
Same.
* include/c_std/bits/std_cassert.h: Move to...
* include/c_std/cassert: Here.
* include/c_std/std_cctype.h, std_cerrno.h, std_cfloat.h,
std_climits.h, std_clocale.h, std_cmath.h, std_csetjmp.h,
std_csignal.h, std_cstdarg.h, std_cstddef.h, std_cstdio.h,
std_cstdlib.h, std_cstring.h, std_ctime.h, std_cwchar.h,
std_cwctype.h: Same.
* include/c_std/cmath: Adjust cmath.tcc include.
* include/c_std/cstdlib: Adjust includes.
* include/c_std/cwchar: Same.
* include/c_std/ctime: Same.
* include/c_std/cstring: Same.
* include/c_std/cstdio: Same.
* include/c_std/bits: Remove directory.
* include/c/bits/std_cassert.h: Move to...
* include/c/cassert: Here.
* include/c/std_cctype.h, std_cerrno.h, std_cfloat.h,
std_climits.h, std_clocale.h, std_cmath.h, std_csetjmp.h,
std_csignal.h, std_cstdarg.h, std_cstddef.h, std_cstdio.h,
std_cstdlib.h, std_cstring.h, std_ctime.h, std_cwchar.h,
std_cwctype.h: Same.
* include/c/bits: Remove directory.
* include/std/cwctype: Remove.
* include/std/cwchar: Remove.
* include/std/ctime: Remove.
* include/std/cstring: Remove.
* include/std/cstdlib: Remove.
* include/std/cstdio: Remove.
* include/std/cstddef: Remove.
* include/std/cstdarg: Remove.
* include/std/csignal: Remove.
* include/std/csetjmp: Remove.
* include/std/cmath: Remove.
* include/std/clocale: Remove.
* include/std/climits: Remove.
* include/std/ciso646: Remove.
* include/std/cfloat: Remove.
* include/std/cerrno: Remove.
* include/std/cctype: Remove.
* include/std/cassert: Remove.
* include/bits/fpos.h: Adjust includes, removing <bits/std_xxx.h>
files and subsituting <.xxx>
* include/bits/valarray_array.h: Same.
* include/bits/stl_uninitialized.h: Same.
* include/bits/stl_alloc.h: Same.
* include/bits/stl_algobase.h: Same.
* include/bits/sstream.tcc: Same.
* include/bits/pthread_allocimpl.h: Same.
* include/bits/ostream.tcc: Same.
* include/bits/localefwd.h: Same.
* include/bits/locale_facets.tcc: Same.
* include/bits/locale_facets.h: Same.
* include/bits/istream.tcc: Same.
* include/bits/char_traits.h: Same.
* include/bits/boost_concept_check.h: Same.
* include/bits/basic_file.h: Same.
* include/std/bitset: Same.
* include/std/complex: Same.
* include/std/fstream: Same.
* include/std/functional: Same.
* include/std/ios: Same.
* include/std/iostream: Same.
* include/std/ostream: Same.
* include/std/sstream: Same.
* include/std/streambuf: Same.
* include/std/string: Same.
* include/std/iterator: Same.
* include/std/valarray: Same.
* src/ios.cc: Adjust includes.
* src/valarray-inst.cc: Same.
* src/string-inst.cc: Same.
* src/stl-inst.cc: Same.
* src/stdexcept.cc: Same.
* src/misc-inst.cc: Same.
* src/localename.cc: Same.
* src/locale-inst.cc: Same.
* src/locale.cc: Same.
* src/limits.cc: Same.
* src/concept-inst.cc: Same.
* src/complex_io.cc: Same.
* src/codecvt.cc: Same.
* src/bitset.cc: Same.
* src/cmath.cc: Same.
From-SVN: r48544
2002-01-04 22:27:36 +01:00
|
|
|
|
|
|
|
#pragma GCC system_header
|
2003-11-11 21:09:16 +01:00
|
|
|
|
Makefile.am (std_headers): Remove cXXX from list.
2002-01-04 Benjamin Kosnik <bkoz@redhat.com>
* include/Makefile.am (std_headers): Remove cXXX from list.
(c_base_srcdir): No bits subdirectory.
(c_base_builddir): Same.
(c_base_headers): Adjust names, add ciso646.
(bits_headers): Remove std_xxx.h headers.
* include/Makefile.in: Regenerate.
* include/ext/iterator: Adjust includes.
* include/ext/ropeimpl.h: Same.
* include/ext/stl_hash_fun.h: Same.
* include/ext/algorithm: Same.
* include/backward/bvector.h: Adjust includes.
* include/backward/vector.h: Same.
* include/backward/strstream: Same.
* include/backward/streambuf.h: Same.
* include/backward/stack.h: Same.
* include/backward/set.h: Same.
* include/backward/queue.h: Same.
* include/backward/multiset.h: Same.
* include/backward/multimap.h: Same.
* include/backward/map.h: Same.
* include/backward/list.h: Same.
* include/backward/iterator.h: Same.
* include/backward/iostream.h: Same.
* include/backward/iomanip.h: Same.
* include/backward/fstream.h: Same.
* include/backward/deque.h: Same.
* include/backward/complex.h: Same.
* include/bits/std_algorithm.h: Move to...
* include/std/algorithm: ...here.
* include/bits/std_iosfwd.h, std_locale.h, std_stack.h,
std_bitset.h, std_ios.h, std_map.h, std_stdexcept.h,
std_complex.h, std_iostream.h, std_memory.h, std_streambuf.h,
std_deque.h, std_istream.h, std_numeric.h, std_string.h,
std_fstream.h, std_ostream.h, std_utility.h, std_iterator.h,
std_queue.h, std_valarray.h, std_functional.h, std_limits.h,
std_set.h, std_vector.h, std_iomanip.h, std_list.h, std_sstream.h:
Same.
* include/c_std/bits/std_cassert.h: Move to...
* include/c_std/cassert: Here.
* include/c_std/std_cctype.h, std_cerrno.h, std_cfloat.h,
std_climits.h, std_clocale.h, std_cmath.h, std_csetjmp.h,
std_csignal.h, std_cstdarg.h, std_cstddef.h, std_cstdio.h,
std_cstdlib.h, std_cstring.h, std_ctime.h, std_cwchar.h,
std_cwctype.h: Same.
* include/c_std/cmath: Adjust cmath.tcc include.
* include/c_std/cstdlib: Adjust includes.
* include/c_std/cwchar: Same.
* include/c_std/ctime: Same.
* include/c_std/cstring: Same.
* include/c_std/cstdio: Same.
* include/c_std/bits: Remove directory.
* include/c/bits/std_cassert.h: Move to...
* include/c/cassert: Here.
* include/c/std_cctype.h, std_cerrno.h, std_cfloat.h,
std_climits.h, std_clocale.h, std_cmath.h, std_csetjmp.h,
std_csignal.h, std_cstdarg.h, std_cstddef.h, std_cstdio.h,
std_cstdlib.h, std_cstring.h, std_ctime.h, std_cwchar.h,
std_cwctype.h: Same.
* include/c/bits: Remove directory.
* include/std/cwctype: Remove.
* include/std/cwchar: Remove.
* include/std/ctime: Remove.
* include/std/cstring: Remove.
* include/std/cstdlib: Remove.
* include/std/cstdio: Remove.
* include/std/cstddef: Remove.
* include/std/cstdarg: Remove.
* include/std/csignal: Remove.
* include/std/csetjmp: Remove.
* include/std/cmath: Remove.
* include/std/clocale: Remove.
* include/std/climits: Remove.
* include/std/ciso646: Remove.
* include/std/cfloat: Remove.
* include/std/cerrno: Remove.
* include/std/cctype: Remove.
* include/std/cassert: Remove.
* include/bits/fpos.h: Adjust includes, removing <bits/std_xxx.h>
files and subsituting <.xxx>
* include/bits/valarray_array.h: Same.
* include/bits/stl_uninitialized.h: Same.
* include/bits/stl_alloc.h: Same.
* include/bits/stl_algobase.h: Same.
* include/bits/sstream.tcc: Same.
* include/bits/pthread_allocimpl.h: Same.
* include/bits/ostream.tcc: Same.
* include/bits/localefwd.h: Same.
* include/bits/locale_facets.tcc: Same.
* include/bits/locale_facets.h: Same.
* include/bits/istream.tcc: Same.
* include/bits/char_traits.h: Same.
* include/bits/boost_concept_check.h: Same.
* include/bits/basic_file.h: Same.
* include/std/bitset: Same.
* include/std/complex: Same.
* include/std/fstream: Same.
* include/std/functional: Same.
* include/std/ios: Same.
* include/std/iostream: Same.
* include/std/ostream: Same.
* include/std/sstream: Same.
* include/std/streambuf: Same.
* include/std/string: Same.
* include/std/iterator: Same.
* include/std/valarray: Same.
* src/ios.cc: Adjust includes.
* src/valarray-inst.cc: Same.
* src/string-inst.cc: Same.
* src/stl-inst.cc: Same.
* src/stdexcept.cc: Same.
* src/misc-inst.cc: Same.
* src/localename.cc: Same.
* src/locale-inst.cc: Same.
* src/locale.cc: Same.
* src/limits.cc: Same.
* src/concept-inst.cc: Same.
* src/complex_io.cc: Same.
* src/codecvt.cc: Same.
* src/bitset.cc: Same.
* src/cmath.cc: Same.
From-SVN: r48544
2002-01-04 22:27:36 +01:00
|
|
|
#include <bits/c++config.h>
|
PR libstdc++/28080 (partial)
2007-02-26 Paolo Carlini <pcarlini@suse.de>
PR libstdc++/28080 (partial)
* include/std/bitset: Do not include <istream> and <ostream>,
<ios> is enough.
* include/std/iomanip: Do not include the whole <istream>,
<ios> is enough; do not include <functional>; reformat.
* include/std/functional: Do not include <cstddef>.
* include/std/list: Do not include <bits/stl_uninitialized.h>.
* include/std/numeric: Do not include the whole <iterator> and
<bits/stl_function.h>.
* include/std/valarray: Do not include <numeric>.
* include/bits/stl_numeric.h: Include <bits/concept_check.h>.
* src/iostream-inst.cc: Include <istream>.
* include/ext/functional: Include <cstddef>.
* testsuite/util/testsuite_hooks.h: Do not include <locale>,
<ctime> is enough; qualify tm.
* testsuite/util/testsuite_hooks.cc: Qualify tm.
2007-02-26 Paolo Carlini <pcarlini@suse.de>
* include/bits/locale_facets.h (class ctype_byname<char>,
class ctype_byname<wchar_t>): Declare.
* src/ctype.cc (ctype_byname<wchar_t>::ctype_byname(const char*,
size_t), ctype_byname<wchar_t>::~ctype_byname): Define.
* config/locale/generic/ctype_members.cc (ctype_byname<char>::
ctype_byname(const char*, size_t), ctype_byname<char>::~ctype_byname):
Likewise.
* config/locale/gnu/ctype_members.cc (ctype_byname<char>::
ctype_byname(const char*, size_t), ctype_byname<char>::~ctype_byname):
Likewise.
* config/locale/darwin/ctype_members.cc (ctype_byname<char>::
ctype_byname(const char*, size_t), ctype_byname<char>::~ctype_byname):
Likewise.
* testsuite/22_locale/headers/locale/synopsis.cc: Remove xfail.
From-SVN: r122329
2007-02-26 10:36:39 +01:00
|
|
|
#include <bits/stl_iterator_base_types.h>
|
Makefile.am (std_headers): Remove cXXX from list.
2002-01-04 Benjamin Kosnik <bkoz@redhat.com>
* include/Makefile.am (std_headers): Remove cXXX from list.
(c_base_srcdir): No bits subdirectory.
(c_base_builddir): Same.
(c_base_headers): Adjust names, add ciso646.
(bits_headers): Remove std_xxx.h headers.
* include/Makefile.in: Regenerate.
* include/ext/iterator: Adjust includes.
* include/ext/ropeimpl.h: Same.
* include/ext/stl_hash_fun.h: Same.
* include/ext/algorithm: Same.
* include/backward/bvector.h: Adjust includes.
* include/backward/vector.h: Same.
* include/backward/strstream: Same.
* include/backward/streambuf.h: Same.
* include/backward/stack.h: Same.
* include/backward/set.h: Same.
* include/backward/queue.h: Same.
* include/backward/multiset.h: Same.
* include/backward/multimap.h: Same.
* include/backward/map.h: Same.
* include/backward/list.h: Same.
* include/backward/iterator.h: Same.
* include/backward/iostream.h: Same.
* include/backward/iomanip.h: Same.
* include/backward/fstream.h: Same.
* include/backward/deque.h: Same.
* include/backward/complex.h: Same.
* include/bits/std_algorithm.h: Move to...
* include/std/algorithm: ...here.
* include/bits/std_iosfwd.h, std_locale.h, std_stack.h,
std_bitset.h, std_ios.h, std_map.h, std_stdexcept.h,
std_complex.h, std_iostream.h, std_memory.h, std_streambuf.h,
std_deque.h, std_istream.h, std_numeric.h, std_string.h,
std_fstream.h, std_ostream.h, std_utility.h, std_iterator.h,
std_queue.h, std_valarray.h, std_functional.h, std_limits.h,
std_set.h, std_vector.h, std_iomanip.h, std_list.h, std_sstream.h:
Same.
* include/c_std/bits/std_cassert.h: Move to...
* include/c_std/cassert: Here.
* include/c_std/std_cctype.h, std_cerrno.h, std_cfloat.h,
std_climits.h, std_clocale.h, std_cmath.h, std_csetjmp.h,
std_csignal.h, std_cstdarg.h, std_cstddef.h, std_cstdio.h,
std_cstdlib.h, std_cstring.h, std_ctime.h, std_cwchar.h,
std_cwctype.h: Same.
* include/c_std/cmath: Adjust cmath.tcc include.
* include/c_std/cstdlib: Adjust includes.
* include/c_std/cwchar: Same.
* include/c_std/ctime: Same.
* include/c_std/cstring: Same.
* include/c_std/cstdio: Same.
* include/c_std/bits: Remove directory.
* include/c/bits/std_cassert.h: Move to...
* include/c/cassert: Here.
* include/c/std_cctype.h, std_cerrno.h, std_cfloat.h,
std_climits.h, std_clocale.h, std_cmath.h, std_csetjmp.h,
std_csignal.h, std_cstdarg.h, std_cstddef.h, std_cstdio.h,
std_cstdlib.h, std_cstring.h, std_ctime.h, std_cwchar.h,
std_cwctype.h: Same.
* include/c/bits: Remove directory.
* include/std/cwctype: Remove.
* include/std/cwchar: Remove.
* include/std/ctime: Remove.
* include/std/cstring: Remove.
* include/std/cstdlib: Remove.
* include/std/cstdio: Remove.
* include/std/cstddef: Remove.
* include/std/cstdarg: Remove.
* include/std/csignal: Remove.
* include/std/csetjmp: Remove.
* include/std/cmath: Remove.
* include/std/clocale: Remove.
* include/std/climits: Remove.
* include/std/ciso646: Remove.
* include/std/cfloat: Remove.
* include/std/cerrno: Remove.
* include/std/cctype: Remove.
* include/std/cassert: Remove.
* include/bits/fpos.h: Adjust includes, removing <bits/std_xxx.h>
files and subsituting <.xxx>
* include/bits/valarray_array.h: Same.
* include/bits/stl_uninitialized.h: Same.
* include/bits/stl_alloc.h: Same.
* include/bits/stl_algobase.h: Same.
* include/bits/sstream.tcc: Same.
* include/bits/pthread_allocimpl.h: Same.
* include/bits/ostream.tcc: Same.
* include/bits/localefwd.h: Same.
* include/bits/locale_facets.tcc: Same.
* include/bits/locale_facets.h: Same.
* include/bits/istream.tcc: Same.
* include/bits/char_traits.h: Same.
* include/bits/boost_concept_check.h: Same.
* include/bits/basic_file.h: Same.
* include/std/bitset: Same.
* include/std/complex: Same.
* include/std/fstream: Same.
* include/std/functional: Same.
* include/std/ios: Same.
* include/std/iostream: Same.
* include/std/ostream: Same.
* include/std/sstream: Same.
* include/std/streambuf: Same.
* include/std/string: Same.
* include/std/iterator: Same.
* include/std/valarray: Same.
* src/ios.cc: Adjust includes.
* src/valarray-inst.cc: Same.
* src/string-inst.cc: Same.
* src/stl-inst.cc: Same.
* src/stdexcept.cc: Same.
* src/misc-inst.cc: Same.
* src/localename.cc: Same.
* src/locale-inst.cc: Same.
* src/locale.cc: Same.
* src/limits.cc: Same.
* src/concept-inst.cc: Same.
* src/complex_io.cc: Same.
* src/codecvt.cc: Same.
* src/bitset.cc: Same.
* src/cmath.cc: Same.
From-SVN: r48544
2002-01-04 22:27:36 +01:00
|
|
|
#include <bits/stl_numeric.h>
|
|
|
|
|
2007-09-12 00:32:51 +02:00
|
|
|
#ifdef _GLIBCXX_PARALLEL
|
|
|
|
# include <parallel/numeric>
|
|
|
|
#endif
|
|
|
|
|
2009-02-19 09:15:15 +01:00
|
|
|
/**
|
|
|
|
* @defgroup numerics Numerics
|
|
|
|
*
|
|
|
|
* Components for performing numeric operations. Includes support for
|
2019-06-24 14:09:51 +02:00
|
|
|
* complex number types, random number generation, numeric (n-at-a-time)
|
|
|
|
* arrays, generalized numeric algorithms, and mathematical special functions.
|
2009-02-19 09:15:15 +01:00
|
|
|
*/
|
|
|
|
|
2016-10-03 19:01:10 +02:00
|
|
|
#if __cplusplus >= 201402L
|
|
|
|
#include <type_traits>
|
|
|
|
|
|
|
|
namespace std _GLIBCXX_VISIBILITY(default)
|
|
|
|
{
|
|
|
|
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|
|
|
|
2017-07-23 10:41:35 +02:00
|
|
|
namespace __detail
|
|
|
|
{
|
2016-10-03 19:01:10 +02:00
|
|
|
// std::abs is not constexpr and doesn't support unsigned integers.
|
|
|
|
template<typename _Tp>
|
|
|
|
constexpr
|
|
|
|
enable_if_t<__and_<is_integral<_Tp>, is_signed<_Tp>>::value, _Tp>
|
|
|
|
__abs_integral(_Tp __val)
|
|
|
|
{ return __val < 0 ? -__val : __val; }
|
|
|
|
|
|
|
|
template<typename _Tp>
|
|
|
|
constexpr
|
|
|
|
enable_if_t<__and_<is_integral<_Tp>, is_unsigned<_Tp>>::value, _Tp>
|
|
|
|
__abs_integral(_Tp __val)
|
|
|
|
{ return __val; }
|
|
|
|
|
2016-10-10 14:17:34 +02:00
|
|
|
void __abs_integral(bool) = delete;
|
|
|
|
|
2016-10-03 19:01:10 +02:00
|
|
|
template<typename _Mn, typename _Nn>
|
|
|
|
constexpr common_type_t<_Mn, _Nn>
|
|
|
|
__gcd(_Mn __m, _Nn __n)
|
|
|
|
{
|
|
|
|
return __m == 0 ? __detail::__abs_integral(__n)
|
|
|
|
: __n == 0 ? __detail::__abs_integral(__m)
|
|
|
|
: __detail::__gcd(__n, __m % __n);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Least common multiple
|
|
|
|
template<typename _Mn, typename _Nn>
|
|
|
|
constexpr common_type_t<_Mn, _Nn>
|
|
|
|
__lcm(_Mn __m, _Nn __n)
|
|
|
|
{
|
|
|
|
return (__m != 0 && __n != 0)
|
|
|
|
? (__detail::__abs_integral(__m) / __detail::__gcd(__m, __n))
|
|
|
|
* __detail::__abs_integral(__n)
|
|
|
|
: 0;
|
|
|
|
}
|
2017-07-23 10:41:35 +02:00
|
|
|
} // namespace __detail
|
2016-10-03 19:01:10 +02:00
|
|
|
|
Define midpoint and lerp functions for C++20 (P0811R3)
The implementation of midpoint used for integral types is due to Howard
Hinnant and avoids a branch for int and larger types (but not for chars
and shorts).
The midpoint and lerp functions for floating point types come straight
from the P0811R3 proposal, with no attempt at optimization.
* include/c_compatibility/math.h [C++20] (lerp): Add using
declaration.
* include/c_global/cmath [C++20] (__cpp_lib_interpolate): Define.
(__lerp): Define function template to implement lerp.
(lerp(float, float, float), lerp(double, double, double))
(lerp(long double, long double, long double)): Define for C++20.
* include/std/numeric [C++20] (__cpp_lib_interpolate): Define.
(midpoint(T, T), midpoint(T*, T*)): Define.
* include/std::version [C++20] (__cpp_lib_interpolate): Define.
* testsuite/26_numerics/lerp.cc: New test.
* testsuite/26_numerics/midpoint/floating.cc: New test.
* testsuite/26_numerics/midpoint/integral.cc: New test.
* testsuite/26_numerics/midpoint/pointer.cc: New test.
From-SVN: r269398
2019-03-05 19:37:24 +01:00
|
|
|
#if __cplusplus >= 201703L
|
2016-10-03 19:01:10 +02:00
|
|
|
|
2017-09-12 16:02:59 +02:00
|
|
|
#define __cpp_lib_gcd_lcm 201606
|
|
|
|
// These were used in drafts of SD-6:
|
2016-10-03 19:01:10 +02:00
|
|
|
#define __cpp_lib_gcd 201606
|
2017-09-12 16:02:59 +02:00
|
|
|
#define __cpp_lib_lcm 201606
|
|
|
|
|
2016-10-03 19:01:10 +02:00
|
|
|
/// Greatest common divisor
|
|
|
|
template<typename _Mn, typename _Nn>
|
|
|
|
constexpr common_type_t<_Mn, _Nn>
|
|
|
|
gcd(_Mn __m, _Nn __n)
|
|
|
|
{
|
2017-11-14 19:11:33 +01:00
|
|
|
static_assert(is_integral_v<_Mn>, "gcd arguments are integers");
|
|
|
|
static_assert(is_integral_v<_Nn>, "gcd arguments are integers");
|
|
|
|
static_assert(!is_same_v<remove_cv_t<_Mn>, bool>,
|
|
|
|
"gcd arguments are not bools");
|
2017-11-15 21:42:58 +01:00
|
|
|
static_assert(!is_same_v<remove_cv_t<_Nn>, bool>,
|
2017-11-14 19:11:33 +01:00
|
|
|
"gcd arguments are not bools");
|
2016-10-03 19:01:10 +02:00
|
|
|
return __detail::__gcd(__m, __n);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Least common multiple
|
|
|
|
template<typename _Mn, typename _Nn>
|
|
|
|
constexpr common_type_t<_Mn, _Nn>
|
|
|
|
lcm(_Mn __m, _Nn __n)
|
|
|
|
{
|
2017-11-14 19:11:33 +01:00
|
|
|
static_assert(is_integral_v<_Mn>, "lcm arguments are integers");
|
|
|
|
static_assert(is_integral_v<_Nn>, "lcm arguments are integers");
|
|
|
|
static_assert(!is_same_v<remove_cv_t<_Mn>, bool>,
|
|
|
|
"lcm arguments are not bools");
|
|
|
|
static_assert(!is_same_v<remove_cv_t<_Nn>, bool>,
|
|
|
|
"lcm arguments are not bools");
|
2016-10-03 19:01:10 +02:00
|
|
|
return __detail::__lcm(__m, __n);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // C++17
|
|
|
|
|
2019-06-24 14:09:51 +02:00
|
|
|
_GLIBCXX_END_NAMESPACE_VERSION
|
|
|
|
} // namespace std
|
|
|
|
|
|
|
|
#endif // C++14
|
|
|
|
|
Define midpoint and lerp functions for C++20 (P0811R3)
The implementation of midpoint used for integral types is due to Howard
Hinnant and avoids a branch for int and larger types (but not for chars
and shorts).
The midpoint and lerp functions for floating point types come straight
from the P0811R3 proposal, with no attempt at optimization.
* include/c_compatibility/math.h [C++20] (lerp): Add using
declaration.
* include/c_global/cmath [C++20] (__cpp_lib_interpolate): Define.
(__lerp): Define function template to implement lerp.
(lerp(float, float, float), lerp(double, double, double))
(lerp(long double, long double, long double)): Define for C++20.
* include/std/numeric [C++20] (__cpp_lib_interpolate): Define.
(midpoint(T, T), midpoint(T*, T*)): Define.
* include/std::version [C++20] (__cpp_lib_interpolate): Define.
* testsuite/26_numerics/lerp.cc: New test.
* testsuite/26_numerics/midpoint/floating.cc: New test.
* testsuite/26_numerics/midpoint/integral.cc: New test.
* testsuite/26_numerics/midpoint/pointer.cc: New test.
From-SVN: r269398
2019-03-05 19:37:24 +01:00
|
|
|
#if __cplusplus > 201703L
|
2019-06-24 14:09:51 +02:00
|
|
|
#include <limits>
|
|
|
|
|
|
|
|
namespace std _GLIBCXX_VISIBILITY(default)
|
|
|
|
{
|
|
|
|
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
Define midpoint and lerp functions for C++20 (P0811R3)
The implementation of midpoint used for integral types is due to Howard
Hinnant and avoids a branch for int and larger types (but not for chars
and shorts).
The midpoint and lerp functions for floating point types come straight
from the P0811R3 proposal, with no attempt at optimization.
* include/c_compatibility/math.h [C++20] (lerp): Add using
declaration.
* include/c_global/cmath [C++20] (__cpp_lib_interpolate): Define.
(__lerp): Define function template to implement lerp.
(lerp(float, float, float), lerp(double, double, double))
(lerp(long double, long double, long double)): Define for C++20.
* include/std/numeric [C++20] (__cpp_lib_interpolate): Define.
(midpoint(T, T), midpoint(T*, T*)): Define.
* include/std::version [C++20] (__cpp_lib_interpolate): Define.
* testsuite/26_numerics/lerp.cc: New test.
* testsuite/26_numerics/midpoint/floating.cc: New test.
* testsuite/26_numerics/midpoint/integral.cc: New test.
* testsuite/26_numerics/midpoint/pointer.cc: New test.
From-SVN: r269398
2019-03-05 19:37:24 +01:00
|
|
|
// midpoint
|
|
|
|
# define __cpp_lib_interpolate 201902L
|
|
|
|
|
2019-06-24 14:09:51 +02:00
|
|
|
template<typename _Tp>
|
Define midpoint and lerp functions for C++20 (P0811R3)
The implementation of midpoint used for integral types is due to Howard
Hinnant and avoids a branch for int and larger types (but not for chars
and shorts).
The midpoint and lerp functions for floating point types come straight
from the P0811R3 proposal, with no attempt at optimization.
* include/c_compatibility/math.h [C++20] (lerp): Add using
declaration.
* include/c_global/cmath [C++20] (__cpp_lib_interpolate): Define.
(__lerp): Define function template to implement lerp.
(lerp(float, float, float), lerp(double, double, double))
(lerp(long double, long double, long double)): Define for C++20.
* include/std/numeric [C++20] (__cpp_lib_interpolate): Define.
(midpoint(T, T), midpoint(T*, T*)): Define.
* include/std::version [C++20] (__cpp_lib_interpolate): Define.
* testsuite/26_numerics/lerp.cc: New test.
* testsuite/26_numerics/midpoint/floating.cc: New test.
* testsuite/26_numerics/midpoint/integral.cc: New test.
* testsuite/26_numerics/midpoint/pointer.cc: New test.
From-SVN: r269398
2019-03-05 19:37:24 +01:00
|
|
|
constexpr
|
2019-04-24 18:25:21 +02:00
|
|
|
enable_if_t<__and_v<is_arithmetic<_Tp>, is_same<remove_cv_t<_Tp>, _Tp>,
|
|
|
|
__not_<is_same<_Tp, bool>>>,
|
Define midpoint and lerp functions for C++20 (P0811R3)
The implementation of midpoint used for integral types is due to Howard
Hinnant and avoids a branch for int and larger types (but not for chars
and shorts).
The midpoint and lerp functions for floating point types come straight
from the P0811R3 proposal, with no attempt at optimization.
* include/c_compatibility/math.h [C++20] (lerp): Add using
declaration.
* include/c_global/cmath [C++20] (__cpp_lib_interpolate): Define.
(__lerp): Define function template to implement lerp.
(lerp(float, float, float), lerp(double, double, double))
(lerp(long double, long double, long double)): Define for C++20.
* include/std/numeric [C++20] (__cpp_lib_interpolate): Define.
(midpoint(T, T), midpoint(T*, T*)): Define.
* include/std::version [C++20] (__cpp_lib_interpolate): Define.
* testsuite/26_numerics/lerp.cc: New test.
* testsuite/26_numerics/midpoint/floating.cc: New test.
* testsuite/26_numerics/midpoint/integral.cc: New test.
* testsuite/26_numerics/midpoint/pointer.cc: New test.
From-SVN: r269398
2019-03-05 19:37:24 +01:00
|
|
|
_Tp>
|
|
|
|
midpoint(_Tp __a, _Tp __b) noexcept
|
|
|
|
{
|
|
|
|
if constexpr (is_integral_v<_Tp>)
|
|
|
|
{
|
|
|
|
using _Up = make_unsigned_t<_Tp>;
|
|
|
|
|
|
|
|
int __k = 1;
|
|
|
|
_Up __m = __a;
|
|
|
|
_Up __M = __b;
|
|
|
|
if (__a > __b)
|
|
|
|
{
|
|
|
|
__k = -1;
|
|
|
|
__m = __b;
|
|
|
|
__M = __a;
|
|
|
|
}
|
|
|
|
return __a + __k * _Tp(_Up(__M - __m) / 2);
|
|
|
|
}
|
2019-06-24 14:09:51 +02:00
|
|
|
else // is_floating
|
Define midpoint and lerp functions for C++20 (P0811R3)
The implementation of midpoint used for integral types is due to Howard
Hinnant and avoids a branch for int and larger types (but not for chars
and shorts).
The midpoint and lerp functions for floating point types come straight
from the P0811R3 proposal, with no attempt at optimization.
* include/c_compatibility/math.h [C++20] (lerp): Add using
declaration.
* include/c_global/cmath [C++20] (__cpp_lib_interpolate): Define.
(__lerp): Define function template to implement lerp.
(lerp(float, float, float), lerp(double, double, double))
(lerp(long double, long double, long double)): Define for C++20.
* include/std/numeric [C++20] (__cpp_lib_interpolate): Define.
(midpoint(T, T), midpoint(T*, T*)): Define.
* include/std::version [C++20] (__cpp_lib_interpolate): Define.
* testsuite/26_numerics/lerp.cc: New test.
* testsuite/26_numerics/midpoint/floating.cc: New test.
* testsuite/26_numerics/midpoint/integral.cc: New test.
* testsuite/26_numerics/midpoint/pointer.cc: New test.
From-SVN: r269398
2019-03-05 19:37:24 +01:00
|
|
|
{
|
2019-06-24 14:09:51 +02:00
|
|
|
constexpr _Tp __lo = numeric_limits<_Tp>::min() * 2;
|
|
|
|
constexpr _Tp __hi = numeric_limits<_Tp>::max() / 2;
|
2019-06-25 15:18:36 +02:00
|
|
|
const _Tp __abs_a = __a < 0 ? -__a : __a;
|
|
|
|
const _Tp __abs_b = __b < 0 ? -__b : __b;
|
|
|
|
if (__abs_a <= __hi && __abs_b <= __hi) [[likely]]
|
2019-06-24 14:09:51 +02:00
|
|
|
return (__a + __b) / 2; // always correctly rounded
|
2019-06-25 15:18:36 +02:00
|
|
|
if (__abs_a < __lo) // not safe to halve __a
|
2019-06-24 14:09:51 +02:00
|
|
|
return __a + __b/2;
|
2019-06-25 15:18:36 +02:00
|
|
|
if (__abs_b < __lo) // not safe to halve __b
|
2019-06-24 14:09:51 +02:00
|
|
|
return __a/2 + __b;
|
|
|
|
return __a/2 + __b/2; // otherwise correctly rounded
|
Define midpoint and lerp functions for C++20 (P0811R3)
The implementation of midpoint used for integral types is due to Howard
Hinnant and avoids a branch for int and larger types (but not for chars
and shorts).
The midpoint and lerp functions for floating point types come straight
from the P0811R3 proposal, with no attempt at optimization.
* include/c_compatibility/math.h [C++20] (lerp): Add using
declaration.
* include/c_global/cmath [C++20] (__cpp_lib_interpolate): Define.
(__lerp): Define function template to implement lerp.
(lerp(float, float, float), lerp(double, double, double))
(lerp(long double, long double, long double)): Define for C++20.
* include/std/numeric [C++20] (__cpp_lib_interpolate): Define.
(midpoint(T, T), midpoint(T*, T*)): Define.
* include/std::version [C++20] (__cpp_lib_interpolate): Define.
* testsuite/26_numerics/lerp.cc: New test.
* testsuite/26_numerics/midpoint/floating.cc: New test.
* testsuite/26_numerics/midpoint/integral.cc: New test.
* testsuite/26_numerics/midpoint/pointer.cc: New test.
From-SVN: r269398
2019-03-05 19:37:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename _Tp>
|
2020-02-19 16:01:41 +01:00
|
|
|
constexpr enable_if_t<is_object_v<_Tp>, _Tp*>
|
Define midpoint and lerp functions for C++20 (P0811R3)
The implementation of midpoint used for integral types is due to Howard
Hinnant and avoids a branch for int and larger types (but not for chars
and shorts).
The midpoint and lerp functions for floating point types come straight
from the P0811R3 proposal, with no attempt at optimization.
* include/c_compatibility/math.h [C++20] (lerp): Add using
declaration.
* include/c_global/cmath [C++20] (__cpp_lib_interpolate): Define.
(__lerp): Define function template to implement lerp.
(lerp(float, float, float), lerp(double, double, double))
(lerp(long double, long double, long double)): Define for C++20.
* include/std/numeric [C++20] (__cpp_lib_interpolate): Define.
(midpoint(T, T), midpoint(T*, T*)): Define.
* include/std::version [C++20] (__cpp_lib_interpolate): Define.
* testsuite/26_numerics/lerp.cc: New test.
* testsuite/26_numerics/midpoint/floating.cc: New test.
* testsuite/26_numerics/midpoint/integral.cc: New test.
* testsuite/26_numerics/midpoint/pointer.cc: New test.
From-SVN: r269398
2019-03-05 19:37:24 +01:00
|
|
|
midpoint(_Tp* __a, _Tp* __b) noexcept
|
|
|
|
{
|
2020-02-19 16:01:41 +01:00
|
|
|
static_assert( sizeof(_Tp) != 0, "type must be complete" );
|
2019-05-24 17:39:35 +02:00
|
|
|
return __a + (__b - __a) / 2;
|
Define midpoint and lerp functions for C++20 (P0811R3)
The implementation of midpoint used for integral types is due to Howard
Hinnant and avoids a branch for int and larger types (but not for chars
and shorts).
The midpoint and lerp functions for floating point types come straight
from the P0811R3 proposal, with no attempt at optimization.
* include/c_compatibility/math.h [C++20] (lerp): Add using
declaration.
* include/c_global/cmath [C++20] (__cpp_lib_interpolate): Define.
(__lerp): Define function template to implement lerp.
(lerp(float, float, float), lerp(double, double, double))
(lerp(long double, long double, long double)): Define for C++20.
* include/std/numeric [C++20] (__cpp_lib_interpolate): Define.
(midpoint(T, T), midpoint(T*, T*)): Define.
* include/std::version [C++20] (__cpp_lib_interpolate): Define.
* testsuite/26_numerics/lerp.cc: New test.
* testsuite/26_numerics/midpoint/floating.cc: New test.
* testsuite/26_numerics/midpoint/integral.cc: New test.
* testsuite/26_numerics/midpoint/pointer.cc: New test.
From-SVN: r269398
2019-03-05 19:37:24 +01:00
|
|
|
}
|
2016-10-03 19:01:10 +02:00
|
|
|
_GLIBCXX_END_NAMESPACE_VERSION
|
|
|
|
} // namespace std
|
|
|
|
|
2019-06-24 14:09:51 +02:00
|
|
|
#endif // C++20
|
2016-10-03 19:01:10 +02:00
|
|
|
|
2019-03-22 00:48:49 +01:00
|
|
|
#if __cplusplus > 201402L
|
2019-06-19 01:01:16 +02:00
|
|
|
#include <bits/stl_function.h>
|
|
|
|
|
|
|
|
namespace std _GLIBCXX_VISIBILITY(default)
|
|
|
|
{
|
|
|
|
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|
|
|
|
2020-02-25 20:40:41 +01:00
|
|
|
#if __cplusplus > 201703L
|
|
|
|
#define __cpp_lib_constexpr_numeric 201911L
|
|
|
|
#endif
|
|
|
|
|
2019-06-19 01:01:16 +02:00
|
|
|
/// @addtogroup numeric_ops
|
|
|
|
/// @{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Calculate reduction of values in a range.
|
|
|
|
*
|
|
|
|
* @param __first Start of range.
|
|
|
|
* @param __last End of range.
|
|
|
|
* @param __init Starting value to add other values to.
|
|
|
|
* @param __binary_op A binary function object.
|
|
|
|
* @return The final sum.
|
|
|
|
*
|
|
|
|
* Reduce the values in the range `[first,last)` using a binary operation.
|
|
|
|
* The initial value is `init`. The values are not necessarily processed
|
|
|
|
* in order.
|
|
|
|
*
|
|
|
|
* This algorithm is similar to `std::accumulate` but is not required to
|
|
|
|
* perform the operations in order from first to last. For operations
|
|
|
|
* that are commutative and associative the result will be the same as
|
|
|
|
* for `std::accumulate`, but for other operations (such as floating point
|
|
|
|
* arithmetic) the result can be different.
|
|
|
|
*/
|
|
|
|
template<typename _InputIterator, typename _Tp, typename _BinaryOperation>
|
2020-02-25 20:40:41 +01:00
|
|
|
_GLIBCXX20_CONSTEXPR
|
2019-06-19 01:01:16 +02:00
|
|
|
_Tp
|
|
|
|
reduce(_InputIterator __first, _InputIterator __last, _Tp __init,
|
|
|
|
_BinaryOperation __binary_op)
|
|
|
|
{
|
|
|
|
using value_type = typename iterator_traits<_InputIterator>::value_type;
|
2019-06-19 17:29:49 +02:00
|
|
|
static_assert(is_invocable_r_v<_Tp, _BinaryOperation&, _Tp&, _Tp&>);
|
2019-06-19 01:01:16 +02:00
|
|
|
static_assert(is_convertible_v<value_type, _Tp>);
|
|
|
|
if constexpr (__is_random_access_iter<_InputIterator>::value)
|
|
|
|
{
|
|
|
|
while ((__last - __first) >= 4)
|
|
|
|
{
|
|
|
|
_Tp __v1 = __binary_op(__first[0], __first[1]);
|
|
|
|
_Tp __v2 = __binary_op(__first[2], __first[3]);
|
|
|
|
_Tp __v3 = __binary_op(__v1, __v2);
|
|
|
|
__init = __binary_op(__init, __v3);
|
|
|
|
__first += 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (; __first != __last; ++__first)
|
|
|
|
__init = __binary_op(__init, *__first);
|
|
|
|
return __init;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Calculate reduction of values in a range.
|
|
|
|
*
|
|
|
|
* @param __first Start of range.
|
|
|
|
* @param __last End of range.
|
|
|
|
* @param __init Starting value to add other values to.
|
|
|
|
* @return The final sum.
|
|
|
|
*
|
|
|
|
* Reduce the values in the range `[first,last)` using addition.
|
2019-08-20 23:34:15 +02:00
|
|
|
* Equivalent to calling `std::reduce(first, last, init, std::plus<>())`.
|
2019-06-19 01:01:16 +02:00
|
|
|
*/
|
|
|
|
template<typename _InputIterator, typename _Tp>
|
2020-02-25 20:40:41 +01:00
|
|
|
_GLIBCXX20_CONSTEXPR
|
2019-06-19 01:01:16 +02:00
|
|
|
inline _Tp
|
|
|
|
reduce(_InputIterator __first, _InputIterator __last, _Tp __init)
|
2019-06-19 17:29:49 +02:00
|
|
|
{ return std::reduce(__first, __last, std::move(__init), plus<>()); }
|
2019-06-19 01:01:16 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Calculate reduction of values in a range.
|
|
|
|
*
|
|
|
|
* @param __first Start of range.
|
|
|
|
* @param __last End of range.
|
|
|
|
* @return The final sum.
|
|
|
|
*
|
|
|
|
* Reduce the values in the range `[first,last)` using addition, with
|
|
|
|
* an initial value of `T{}`, where `T` is the iterator's value type.
|
2019-08-20 23:34:15 +02:00
|
|
|
* Equivalent to calling `std::reduce(first, last, T{}, std::plus<>())`.
|
2019-06-19 01:01:16 +02:00
|
|
|
*/
|
|
|
|
template<typename _InputIterator>
|
2020-02-25 20:40:41 +01:00
|
|
|
_GLIBCXX20_CONSTEXPR
|
2019-06-19 01:01:16 +02:00
|
|
|
inline typename iterator_traits<_InputIterator>::value_type
|
|
|
|
reduce(_InputIterator __first, _InputIterator __last)
|
|
|
|
{
|
|
|
|
using value_type = typename iterator_traits<_InputIterator>::value_type;
|
|
|
|
return std::reduce(__first, __last, value_type{}, plus<>());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Combine elements from two ranges and reduce
|
|
|
|
*
|
|
|
|
* @param __first1 Start of first range.
|
|
|
|
* @param __last1 End of first range.
|
|
|
|
* @param __first2 Start of second range.
|
|
|
|
* @param __init Starting value to add other values to.
|
|
|
|
* @param __binary_op1 The function used to perform reduction.
|
|
|
|
* @param __binary_op2 The function used to combine values from the ranges.
|
|
|
|
* @return The final sum.
|
|
|
|
*
|
|
|
|
* Call `binary_op2(first1[n],first2[n])` for each `n` in `[0,last1-first1)`
|
|
|
|
* and then use `binary_op1` to reduce the values returned by `binary_op2`
|
|
|
|
* to a single value of type `T`.
|
|
|
|
*
|
|
|
|
* The range beginning at `first2` must contain at least `last1-first1`
|
|
|
|
* elements.
|
|
|
|
*/
|
|
|
|
template<typename _InputIterator1, typename _InputIterator2, typename _Tp,
|
|
|
|
typename _BinaryOperation1, typename _BinaryOperation2>
|
2020-02-25 20:40:41 +01:00
|
|
|
_GLIBCXX20_CONSTEXPR
|
2019-06-19 01:01:16 +02:00
|
|
|
_Tp
|
|
|
|
transform_reduce(_InputIterator1 __first1, _InputIterator1 __last1,
|
|
|
|
_InputIterator2 __first2, _Tp __init,
|
|
|
|
_BinaryOperation1 __binary_op1,
|
|
|
|
_BinaryOperation2 __binary_op2)
|
|
|
|
{
|
|
|
|
if constexpr (__and_v<__is_random_access_iter<_InputIterator1>,
|
|
|
|
__is_random_access_iter<_InputIterator2>>)
|
|
|
|
{
|
|
|
|
while ((__last1 - __first1) >= 4)
|
|
|
|
{
|
|
|
|
_Tp __v1 = __binary_op1(__binary_op2(__first1[0], __first2[0]),
|
|
|
|
__binary_op2(__first1[1], __first2[1]));
|
|
|
|
_Tp __v2 = __binary_op1(__binary_op2(__first1[2], __first2[2]),
|
|
|
|
__binary_op2(__first1[3], __first2[3]));
|
|
|
|
_Tp __v3 = __binary_op1(__v1, __v2);
|
|
|
|
__init = __binary_op1(__init, __v3);
|
|
|
|
__first1 += 4;
|
|
|
|
__first2 += 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (; __first1 != __last1; ++__first1, (void) ++__first2)
|
|
|
|
__init = __binary_op1(__init, __binary_op2(*__first1, *__first2));
|
|
|
|
return __init;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Combine elements from two ranges and reduce
|
|
|
|
*
|
|
|
|
* @param __first1 Start of first range.
|
|
|
|
* @param __last1 End of first range.
|
|
|
|
* @param __first2 Start of second range.
|
|
|
|
* @param __init Starting value to add other values to.
|
|
|
|
* @return The final sum.
|
|
|
|
*
|
|
|
|
* Call `first1[n]*first2[n]` for each `n` in `[0,last1-first1)` and then
|
|
|
|
* use addition to sum those products to a single value of type `T`.
|
|
|
|
*
|
|
|
|
* The range beginning at `first2` must contain at least `last1-first1`
|
|
|
|
* elements.
|
|
|
|
*/
|
|
|
|
template<typename _InputIterator1, typename _InputIterator2, typename _Tp>
|
2020-02-25 20:40:41 +01:00
|
|
|
_GLIBCXX20_CONSTEXPR
|
2019-06-19 01:01:16 +02:00
|
|
|
inline _Tp
|
|
|
|
transform_reduce(_InputIterator1 __first1, _InputIterator1 __last1,
|
|
|
|
_InputIterator2 __first2, _Tp __init)
|
|
|
|
{
|
|
|
|
return std::transform_reduce(__first1, __last1, __first2,
|
|
|
|
std::move(__init),
|
|
|
|
plus<>(), multiplies<>());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Transform the elements of a range and reduce
|
|
|
|
*
|
|
|
|
* @param __first Start of range.
|
|
|
|
* @param __last End of range.
|
|
|
|
* @param __init Starting value to add other values to.
|
|
|
|
* @param __binary_op The function used to perform reduction.
|
|
|
|
* @param __unary_op The function used to transform values from the range.
|
|
|
|
* @return The final sum.
|
|
|
|
*
|
|
|
|
* Call `unary_op(first[n])` for each `n` in `[0,last-first)` and then
|
|
|
|
* use `binary_op` to reduce the values returned by `unary_op`
|
|
|
|
* to a single value of type `T`.
|
|
|
|
*/
|
|
|
|
template<typename _InputIterator, typename _Tp,
|
|
|
|
typename _BinaryOperation, typename _UnaryOperation>
|
2020-02-25 20:40:41 +01:00
|
|
|
_GLIBCXX20_CONSTEXPR
|
2019-06-19 01:01:16 +02:00
|
|
|
_Tp
|
|
|
|
transform_reduce(_InputIterator __first, _InputIterator __last, _Tp __init,
|
|
|
|
_BinaryOperation __binary_op, _UnaryOperation __unary_op)
|
|
|
|
{
|
|
|
|
if constexpr (__is_random_access_iter<_InputIterator>::value)
|
|
|
|
{
|
|
|
|
while ((__last - __first) >= 4)
|
|
|
|
{
|
|
|
|
_Tp __v1 = __binary_op(__unary_op(__first[0]),
|
|
|
|
__unary_op(__first[1]));
|
|
|
|
_Tp __v2 = __binary_op(__unary_op(__first[2]),
|
|
|
|
__unary_op(__first[3]));
|
|
|
|
_Tp __v3 = __binary_op(__v1, __v2);
|
|
|
|
__init = __binary_op(__init, __v3);
|
|
|
|
__first += 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (; __first != __last; ++__first)
|
|
|
|
__init = __binary_op(__init, __unary_op(*__first));
|
|
|
|
return __init;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @brief Output the cumulative sum of one range to a second range
|
|
|
|
*
|
|
|
|
* @param __first Start of input range.
|
|
|
|
* @param __last End of input range.
|
|
|
|
* @param __result Start of output range.
|
|
|
|
* @param __init Initial value.
|
|
|
|
* @param __binary_op Function to perform summation.
|
|
|
|
* @return The end of the output range.
|
|
|
|
*
|
|
|
|
* Write the cumulative sum (aka prefix sum, aka scan) of the input range
|
|
|
|
* to the output range. Each element of the output range contains the
|
|
|
|
* running total of all earlier elements (and the initial value),
|
|
|
|
* using `binary_op` for summation.
|
|
|
|
*
|
|
|
|
* This function generates an "exclusive" scan, meaning the Nth element
|
|
|
|
* of the output range is the sum of the first N-1 input elements,
|
|
|
|
* so the Nth input element is not included.
|
|
|
|
*/
|
|
|
|
template<typename _InputIterator, typename _OutputIterator, typename _Tp,
|
|
|
|
typename _BinaryOperation>
|
2020-02-25 20:40:41 +01:00
|
|
|
_GLIBCXX20_CONSTEXPR
|
2019-06-19 01:01:16 +02:00
|
|
|
_OutputIterator
|
|
|
|
exclusive_scan(_InputIterator __first, _InputIterator __last,
|
|
|
|
_OutputIterator __result, _Tp __init,
|
|
|
|
_BinaryOperation __binary_op)
|
|
|
|
{
|
|
|
|
while (__first != __last)
|
|
|
|
{
|
|
|
|
auto __v = __init;
|
|
|
|
__init = __binary_op(__init, *__first);
|
|
|
|
++__first;
|
|
|
|
*__result++ = std::move(__v);
|
|
|
|
}
|
|
|
|
return __result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @brief Output the cumulative sum of one range to a second range
|
|
|
|
*
|
|
|
|
* @param __first Start of input range.
|
|
|
|
* @param __last End of input range.
|
|
|
|
* @param __result Start of output range.
|
|
|
|
* @param __init Initial value.
|
|
|
|
* @return The end of the output range.
|
|
|
|
*
|
|
|
|
* Write the cumulative sum (aka prefix sum, aka scan) of the input range
|
|
|
|
* to the output range. Each element of the output range contains the
|
|
|
|
* running total of all earlier elements (and the initial value),
|
|
|
|
* using `std::plus<>` for summation.
|
|
|
|
*
|
|
|
|
* This function generates an "exclusive" scan, meaning the Nth element
|
|
|
|
* of the output range is the sum of the first N-1 input elements,
|
|
|
|
* so the Nth input element is not included.
|
|
|
|
*/
|
|
|
|
template<typename _InputIterator, typename _OutputIterator, typename _Tp>
|
2020-02-25 20:40:41 +01:00
|
|
|
_GLIBCXX20_CONSTEXPR
|
2019-06-19 01:01:16 +02:00
|
|
|
inline _OutputIterator
|
|
|
|
exclusive_scan(_InputIterator __first, _InputIterator __last,
|
|
|
|
_OutputIterator __result, _Tp __init)
|
|
|
|
{
|
|
|
|
return std::exclusive_scan(__first, __last, __result, std::move(__init),
|
|
|
|
plus<>());
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @brief Output the cumulative sum of one range to a second range
|
|
|
|
*
|
|
|
|
* @param __first Start of input range.
|
|
|
|
* @param __last End of input range.
|
|
|
|
* @param __result Start of output range.
|
|
|
|
* @param __binary_op Function to perform summation.
|
|
|
|
* @param __init Initial value.
|
|
|
|
* @return The end of the output range.
|
|
|
|
*
|
|
|
|
* Write the cumulative sum (aka prefix sum, aka scan) of the input range
|
|
|
|
* to the output range. Each element of the output range contains the
|
|
|
|
* running total of all earlier elements (and the initial value),
|
|
|
|
* using `binary_op` for summation.
|
|
|
|
*
|
|
|
|
* This function generates an "inclusive" scan, meaning the Nth element
|
|
|
|
* of the output range is the sum of the first N input elements,
|
|
|
|
* so the Nth input element is included.
|
|
|
|
*/
|
|
|
|
template<typename _InputIterator, typename _OutputIterator,
|
|
|
|
typename _BinaryOperation, typename _Tp>
|
2020-02-25 20:40:41 +01:00
|
|
|
_GLIBCXX20_CONSTEXPR
|
2019-06-19 01:01:16 +02:00
|
|
|
_OutputIterator
|
|
|
|
inclusive_scan(_InputIterator __first, _InputIterator __last,
|
|
|
|
_OutputIterator __result, _BinaryOperation __binary_op,
|
|
|
|
_Tp __init)
|
|
|
|
{
|
|
|
|
for (; __first != __last; ++__first)
|
|
|
|
*__result++ = __init = __binary_op(__init, *__first);
|
|
|
|
return __result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @brief Output the cumulative sum of one range to a second range
|
|
|
|
*
|
|
|
|
* @param __first Start of input range.
|
|
|
|
* @param __last End of input range.
|
|
|
|
* @param __result Start of output range.
|
|
|
|
* @param __binary_op Function to perform summation.
|
|
|
|
* @return The end of the output range.
|
|
|
|
*
|
|
|
|
* Write the cumulative sum (aka prefix sum, aka scan) of the input range
|
|
|
|
* to the output range. Each element of the output range contains the
|
|
|
|
* running total of all earlier elements, using `binary_op` for summation.
|
|
|
|
*
|
|
|
|
* This function generates an "inclusive" scan, meaning the Nth element
|
|
|
|
* of the output range is the sum of the first N input elements,
|
|
|
|
* so the Nth input element is included.
|
|
|
|
*/
|
|
|
|
template<typename _InputIterator, typename _OutputIterator,
|
|
|
|
typename _BinaryOperation>
|
2020-02-25 20:40:41 +01:00
|
|
|
_GLIBCXX20_CONSTEXPR
|
2019-06-19 01:01:16 +02:00
|
|
|
_OutputIterator
|
|
|
|
inclusive_scan(_InputIterator __first, _InputIterator __last,
|
|
|
|
_OutputIterator __result, _BinaryOperation __binary_op)
|
|
|
|
{
|
|
|
|
if (__first != __last)
|
|
|
|
{
|
|
|
|
auto __init = *__first;
|
|
|
|
*__result++ = __init;
|
|
|
|
++__first;
|
|
|
|
if (__first != __last)
|
|
|
|
__result = std::inclusive_scan(__first, __last, __result,
|
|
|
|
__binary_op, std::move(__init));
|
|
|
|
}
|
|
|
|
return __result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @brief Output the cumulative sum of one range to a second range
|
|
|
|
*
|
|
|
|
* @param __first Start of input range.
|
|
|
|
* @param __last End of input range.
|
|
|
|
* @param __result Start of output range.
|
|
|
|
* @return The end of the output range.
|
|
|
|
*
|
|
|
|
* Write the cumulative sum (aka prefix sum, aka scan) of the input range
|
|
|
|
* to the output range. Each element of the output range contains the
|
|
|
|
* running total of all earlier elements, using `std::plus<>` for summation.
|
|
|
|
*
|
|
|
|
* This function generates an "inclusive" scan, meaning the Nth element
|
|
|
|
* of the output range is the sum of the first N input elements,
|
|
|
|
* so the Nth input element is included.
|
|
|
|
*/
|
|
|
|
template<typename _InputIterator, typename _OutputIterator>
|
2020-02-25 20:40:41 +01:00
|
|
|
_GLIBCXX20_CONSTEXPR
|
2019-06-19 01:01:16 +02:00
|
|
|
inline _OutputIterator
|
|
|
|
inclusive_scan(_InputIterator __first, _InputIterator __last,
|
|
|
|
_OutputIterator __result)
|
|
|
|
{ return std::inclusive_scan(__first, __last, __result, plus<>()); }
|
|
|
|
|
|
|
|
/** @brief Output the cumulative sum of one range to a second range
|
|
|
|
*
|
|
|
|
* @param __first Start of input range.
|
|
|
|
* @param __last End of input range.
|
|
|
|
* @param __result Start of output range.
|
|
|
|
* @param __init Initial value.
|
|
|
|
* @param __binary_op Function to perform summation.
|
|
|
|
* @param __unary_op Function to transform elements of the input range.
|
|
|
|
* @return The end of the output range.
|
|
|
|
*
|
|
|
|
* Write the cumulative sum (aka prefix sum, aka scan) of the input range
|
|
|
|
* to the output range. Each element of the output range contains the
|
|
|
|
* running total of all earlier elements (and the initial value),
|
|
|
|
* using `__unary_op` to transform the input elements
|
|
|
|
* and using `__binary_op` for summation.
|
|
|
|
*
|
|
|
|
* This function generates an "exclusive" scan, meaning the Nth element
|
|
|
|
* of the output range is the sum of the first N-1 input elements,
|
|
|
|
* so the Nth input element is not included.
|
|
|
|
*/
|
|
|
|
template<typename _InputIterator, typename _OutputIterator, typename _Tp,
|
|
|
|
typename _BinaryOperation, typename _UnaryOperation>
|
2020-02-25 20:40:41 +01:00
|
|
|
_GLIBCXX20_CONSTEXPR
|
2019-06-19 01:01:16 +02:00
|
|
|
_OutputIterator
|
|
|
|
transform_exclusive_scan(_InputIterator __first, _InputIterator __last,
|
|
|
|
_OutputIterator __result, _Tp __init,
|
|
|
|
_BinaryOperation __binary_op,
|
|
|
|
_UnaryOperation __unary_op)
|
|
|
|
{
|
|
|
|
while (__first != __last)
|
|
|
|
{
|
|
|
|
auto __v = __init;
|
|
|
|
__init = __binary_op(__init, __unary_op(*__first));
|
|
|
|
++__first;
|
|
|
|
*__result++ = std::move(__v);
|
|
|
|
}
|
|
|
|
return __result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @brief Output the cumulative sum of one range to a second range
|
|
|
|
*
|
|
|
|
* @param __first Start of input range.
|
|
|
|
* @param __last End of input range.
|
|
|
|
* @param __result Start of output range.
|
|
|
|
* @param __binary_op Function to perform summation.
|
|
|
|
* @param __unary_op Function to transform elements of the input range.
|
|
|
|
* @param __init Initial value.
|
|
|
|
* @return The end of the output range.
|
|
|
|
*
|
|
|
|
* Write the cumulative sum (aka prefix sum, aka scan) of the input range
|
|
|
|
* to the output range. Each element of the output range contains the
|
|
|
|
* running total of all earlier elements (and the initial value),
|
|
|
|
* using `__unary_op` to transform the input elements
|
|
|
|
* and using `__binary_op` for summation.
|
|
|
|
*
|
|
|
|
* This function generates an "inclusive" scan, meaning the Nth element
|
|
|
|
* of the output range is the sum of the first N input elements,
|
|
|
|
* so the Nth input element is included.
|
|
|
|
*/
|
|
|
|
template<typename _InputIterator, typename _OutputIterator,
|
|
|
|
typename _BinaryOperation, typename _UnaryOperation, typename _Tp>
|
2020-02-25 20:40:41 +01:00
|
|
|
_GLIBCXX20_CONSTEXPR
|
2019-06-19 01:01:16 +02:00
|
|
|
_OutputIterator
|
|
|
|
transform_inclusive_scan(_InputIterator __first, _InputIterator __last,
|
|
|
|
_OutputIterator __result,
|
|
|
|
_BinaryOperation __binary_op,
|
|
|
|
_UnaryOperation __unary_op,
|
|
|
|
_Tp __init)
|
|
|
|
{
|
|
|
|
for (; __first != __last; ++__first)
|
|
|
|
*__result++ = __init = __binary_op(__init, __unary_op(*__first));
|
|
|
|
return __result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @brief Output the cumulative sum of one range to a second range
|
|
|
|
*
|
|
|
|
* @param __first Start of input range.
|
|
|
|
* @param __last End of input range.
|
|
|
|
* @param __result Start of output range.
|
|
|
|
* @param __binary_op Function to perform summation.
|
|
|
|
* @param __unary_op Function to transform elements of the input range.
|
|
|
|
* @return The end of the output range.
|
|
|
|
*
|
|
|
|
* Write the cumulative sum (aka prefix sum, aka scan) of the input range
|
|
|
|
* to the output range. Each element of the output range contains the
|
|
|
|
* running total of all earlier elements,
|
|
|
|
* using `__unary_op` to transform the input elements
|
|
|
|
* and using `__binary_op` for summation.
|
|
|
|
*
|
|
|
|
* This function generates an "inclusive" scan, meaning the Nth element
|
|
|
|
* of the output range is the sum of the first N input elements,
|
|
|
|
* so the Nth input element is included.
|
|
|
|
*/
|
|
|
|
template<typename _InputIterator, typename _OutputIterator,
|
|
|
|
typename _BinaryOperation, typename _UnaryOperation>
|
2020-02-25 20:40:41 +01:00
|
|
|
_GLIBCXX20_CONSTEXPR
|
2019-06-19 01:01:16 +02:00
|
|
|
_OutputIterator
|
|
|
|
transform_inclusive_scan(_InputIterator __first, _InputIterator __last,
|
|
|
|
_OutputIterator __result,
|
|
|
|
_BinaryOperation __binary_op,
|
|
|
|
_UnaryOperation __unary_op)
|
|
|
|
{
|
|
|
|
if (__first != __last)
|
|
|
|
{
|
|
|
|
auto __init = __unary_op(*__first);
|
|
|
|
*__result++ = __init;
|
|
|
|
++__first;
|
|
|
|
if (__first != __last)
|
|
|
|
__result = std::transform_inclusive_scan(__first, __last, __result,
|
|
|
|
__binary_op, __unary_op,
|
|
|
|
std::move(__init));
|
|
|
|
}
|
|
|
|
return __result;
|
|
|
|
}
|
|
|
|
|
|
|
|
// @} group numeric_ops
|
|
|
|
|
|
|
|
_GLIBCXX_END_NAMESPACE_VERSION
|
|
|
|
} // namespace std
|
|
|
|
|
2019-03-22 00:48:49 +01:00
|
|
|
// Parallel STL algorithms
|
2019-06-08 00:01:16 +02:00
|
|
|
# if _PSTL_EXECUTION_POLICIES_DEFINED
|
2019-03-22 00:48:49 +01:00
|
|
|
// If <execution> has already been included, pull in implementations
|
|
|
|
# include <pstl/glue_numeric_impl.h>
|
|
|
|
# else
|
|
|
|
// Otherwise just pull in forward declarations
|
|
|
|
# include <pstl/glue_numeric_defs.h>
|
2019-06-08 00:01:16 +02:00
|
|
|
# define _PSTL_NUMERIC_FORWARD_DECLARED 1
|
2019-03-22 00:48:49 +01:00
|
|
|
# endif
|
|
|
|
|
|
|
|
// Feature test macro for parallel algorithms
|
2019-06-12 22:16:03 +02:00
|
|
|
# define __cpp_lib_parallel_algorithm 201603L
|
2019-03-22 00:48:49 +01:00
|
|
|
#endif // C++17
|
2016-10-03 19:01:10 +02:00
|
|
|
|
2003-07-23 17:28:44 +02:00
|
|
|
#endif /* _GLIBCXX_NUMERIC */
|