libstdc++
valarray
Go to the documentation of this file.
00001 // The template and inlines for the -*- C++ -*- valarray class.
00002 
00003 // Copyright (C) 1997-2013 Free Software Foundation, Inc.
00004 //
00005 // This file is part of the GNU ISO C++ Library.  This library is free
00006 // software; you can redistribute it and/or modify it under the
00007 // terms of the GNU General Public License as published by the
00008 // Free Software Foundation; either version 3, or (at your option)
00009 // any later version.
00010 
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // GNU General Public License for more details.
00015 
00016 // Under Section 7 of GPL version 3, you are granted additional
00017 // permissions described in the GCC Runtime Library Exception, version
00018 // 3.1, as published by the Free Software Foundation.
00019 
00020 // You should have received a copy of the GNU General Public License and
00021 // a copy of the GCC Runtime Library Exception along with this program;
00022 // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
00023 // <http://www.gnu.org/licenses/>.
00024 
00025 /** @file include/valarray
00026  *  This is a Standard C++ Library header. 
00027  */
00028 
00029 // Written by Gabriel Dos Reis <Gabriel.Dos-Reis@DPTMaths.ENS-Cachan.Fr>
00030 
00031 #ifndef _GLIBCXX_VALARRAY
00032 #define _GLIBCXX_VALARRAY 1
00033 
00034 #pragma GCC system_header
00035 
00036 #include <bits/c++config.h>
00037 #include <cmath>
00038 #include <algorithm>
00039 #include <debug/debug.h>
00040 #if __cplusplus >= 201103L
00041 #include <initializer_list>
00042 #endif
00043 
00044 namespace std _GLIBCXX_VISIBILITY(default)
00045 {
00046 _GLIBCXX_BEGIN_NAMESPACE_VERSION
00047 
00048   template<class _Clos, typename _Tp> 
00049     class _Expr;
00050 
00051   template<typename _Tp1, typename _Tp2> 
00052     class _ValArray;    
00053 
00054   template<class _Oper, template<class, class> class _Meta, class _Dom>
00055     struct _UnClos;
00056 
00057   template<class _Oper,
00058         template<class, class> class _Meta1,
00059         template<class, class> class _Meta2,
00060         class _Dom1, class _Dom2> 
00061     class _BinClos;
00062 
00063   template<template<class, class> class _Meta, class _Dom> 
00064     class _SClos;
00065 
00066   template<template<class, class> class _Meta, class _Dom> 
00067     class _GClos;
00068     
00069   template<template<class, class> class _Meta, class _Dom> 
00070     class _IClos;
00071     
00072   template<template<class, class> class _Meta, class _Dom> 
00073     class _ValFunClos;
00074   
00075   template<template<class, class> class _Meta, class _Dom> 
00076     class _RefFunClos;
00077 
00078   template<class _Tp> class valarray;   // An array of type _Tp
00079   class slice;                          // BLAS-like slice out of an array
00080   template<class _Tp> class slice_array;
00081   class gslice;                         // generalized slice out of an array
00082   template<class _Tp> class gslice_array;
00083   template<class _Tp> class mask_array;     // masked array
00084   template<class _Tp> class indirect_array; // indirected array
00085 
00086 _GLIBCXX_END_NAMESPACE_VERSION
00087 } // namespace
00088 
00089 #include <bits/valarray_array.h>
00090 #include <bits/valarray_before.h>
00091   
00092 namespace std _GLIBCXX_VISIBILITY(default)
00093 {
00094 _GLIBCXX_BEGIN_NAMESPACE_VERSION
00095 
00096   /**
00097    * @defgroup numeric_arrays Numeric Arrays
00098    * @ingroup numerics
00099    *
00100    * Classes and functions for representing and manipulating arrays of elements.
00101    * @{
00102    */
00103 
00104   /**
00105    *  @brief  Smart array designed to support numeric processing.
00106    *
00107    *  A valarray is an array that provides constraints intended to allow for
00108    *  effective optimization of numeric array processing by reducing the
00109    *  aliasing that can result from pointer representations.  It represents a
00110    *  one-dimensional array from which different multidimensional subsets can
00111    *  be accessed and modified.
00112    *  
00113    *  @tparam  _Tp  Type of object in the array.
00114    */
00115   template<class _Tp> 
00116     class valarray
00117     {
00118       template<class _Op>
00119     struct _UnaryOp 
00120     {
00121       typedef typename __fun<_Op, _Tp>::result_type __rt;
00122       typedef _Expr<_UnClos<_Op, _ValArray, _Tp>, __rt> _Rt;
00123     };
00124     public:
00125       typedef _Tp value_type;
00126       
00127     // _lib.valarray.cons_ construct/destroy:
00128       ///  Construct an empty array.
00129       valarray();
00130 
00131       ///  Construct an array with @a n elements.
00132       explicit valarray(size_t);
00133 
00134       ///  Construct an array with @a n elements initialized to @a t.
00135       valarray(const _Tp&, size_t);
00136 
00137       ///  Construct an array initialized to the first @a n elements of @a t.
00138       valarray(const _Tp* __restrict__, size_t);
00139 
00140       ///  Copy constructor.
00141       valarray(const valarray&);
00142 
00143 #if __cplusplus >= 201103L
00144       ///  Move constructor.
00145       valarray(valarray&&) noexcept;
00146 #endif
00147 
00148       ///  Construct an array with the same size and values in @a sa.
00149       valarray(const slice_array<_Tp>&);
00150 
00151       ///  Construct an array with the same size and values in @a ga.
00152       valarray(const gslice_array<_Tp>&);
00153 
00154       ///  Construct an array with the same size and values in @a ma.
00155       valarray(const mask_array<_Tp>&);
00156 
00157       ///  Construct an array with the same size and values in @a ia.
00158       valarray(const indirect_array<_Tp>&);
00159 
00160 #if __cplusplus >= 201103L
00161       ///  Construct an array with an initializer_list of values.
00162       valarray(initializer_list<_Tp>);
00163 #endif
00164 
00165       template<class _Dom>
00166     valarray(const _Expr<_Dom, _Tp>& __e);
00167 
00168       ~valarray() _GLIBCXX_NOEXCEPT;
00169 
00170       // _lib.valarray.assign_ assignment:
00171       /**
00172        *  @brief  Assign elements to an array.
00173        *
00174        *  Assign elements of array to values in @a v.
00175        *
00176        *  @param  __v  Valarray to get values from.
00177        */
00178       valarray<_Tp>& operator=(const valarray<_Tp>& __v);
00179 
00180 #if __cplusplus >= 201103L
00181       /**
00182        *  @brief  Move assign elements to an array.
00183        *
00184        *  Move assign elements of array to values in @a v.
00185        *
00186        *  @param  __v  Valarray to get values from.
00187        */
00188       valarray<_Tp>& operator=(valarray<_Tp>&& __v) noexcept;
00189 #endif
00190 
00191       /**
00192        *  @brief  Assign elements to a value.
00193        *
00194        *  Assign all elements of array to @a t.
00195        *
00196        *  @param  __t  Value for elements.
00197        */
00198       valarray<_Tp>& operator=(const _Tp& __t);
00199 
00200       /**
00201        *  @brief  Assign elements to an array subset.
00202        *
00203        *  Assign elements of array to values in @a sa.  Results are undefined
00204        *  if @a sa does not have the same size as this array.
00205        *
00206        *  @param  __sa  Array slice to get values from.
00207        */
00208       valarray<_Tp>& operator=(const slice_array<_Tp>& __sa);
00209 
00210       /**
00211        *  @brief  Assign elements to an array subset.
00212        *
00213        *  Assign elements of array to values in @a ga.  Results are undefined
00214        *  if @a ga does not have the same size as this array.
00215        *
00216        *  @param  __ga  Array slice to get values from.
00217        */
00218       valarray<_Tp>& operator=(const gslice_array<_Tp>& __ga);
00219 
00220       /**
00221        *  @brief  Assign elements to an array subset.
00222        *
00223        *  Assign elements of array to values in @a ma.  Results are undefined
00224        *  if @a ma does not have the same size as this array.
00225        *
00226        *  @param  __ma  Array slice to get values from.
00227        */
00228       valarray<_Tp>& operator=(const mask_array<_Tp>& __ma);
00229 
00230       /**
00231        *  @brief  Assign elements to an array subset.
00232        *
00233        *  Assign elements of array to values in @a ia.  Results are undefined
00234        *  if @a ia does not have the same size as this array.
00235        *
00236        *  @param  __ia  Array slice to get values from.
00237        */
00238       valarray<_Tp>& operator=(const indirect_array<_Tp>& __ia);
00239 
00240 #if __cplusplus >= 201103L
00241       /**
00242        *  @brief  Assign elements to an initializer_list.
00243        *
00244        *  Assign elements of array to values in @a __l.  Results are undefined
00245        *  if @a __l does not have the same size as this array.
00246        *
00247        *  @param  __l  initializer_list to get values from.
00248        */
00249       valarray& operator=(initializer_list<_Tp> __l);
00250 #endif
00251 
00252       template<class _Dom> valarray<_Tp>&
00253     operator= (const _Expr<_Dom, _Tp>&);
00254 
00255       // _lib.valarray.access_ element access:
00256       /**
00257        *  Return a reference to the i'th array element.  
00258        *
00259        *  @param  __i  Index of element to return.
00260        *  @return  Reference to the i'th element.
00261        */
00262       _Tp&                operator[](size_t __i);
00263 
00264       // _GLIBCXX_RESOLVE_LIB_DEFECTS
00265       // 389. Const overload of valarray::operator[] returns by value.
00266       const _Tp&          operator[](size_t) const;
00267 
00268       // _lib.valarray.sub_ subset operations:
00269       /**
00270        *  @brief  Return an array subset.
00271        *
00272        *  Returns a new valarray containing the elements of the array
00273        *  indicated by the slice argument.  The new valarray has the same size
00274        *  as the input slice.  @see slice.
00275        *
00276        *  @param  __s  The source slice.
00277        *  @return  New valarray containing elements in @a __s.
00278        */
00279       _Expr<_SClos<_ValArray, _Tp>, _Tp> operator[](slice __s) const;
00280 
00281       /**
00282        *  @brief  Return a reference to an array subset.
00283        *
00284        *  Returns a new valarray containing the elements of the array
00285        *  indicated by the slice argument.  The new valarray has the same size
00286        *  as the input slice.  @see slice.
00287        *
00288        *  @param  __s  The source slice.
00289        *  @return  New valarray containing elements in @a __s.
00290        */
00291       slice_array<_Tp>    operator[](slice __s);
00292 
00293       /**
00294        *  @brief  Return an array subset.
00295        *
00296        *  Returns a slice_array referencing the elements of the array
00297        *  indicated by the slice argument.  @see gslice.
00298        *
00299        *  @param  __s  The source slice.
00300        *  @return  Slice_array referencing elements indicated by @a __s.
00301        */
00302       _Expr<_GClos<_ValArray, _Tp>, _Tp> operator[](const gslice& __s) const;
00303 
00304       /**
00305        *  @brief  Return a reference to an array subset.
00306        *
00307        *  Returns a new valarray containing the elements of the array
00308        *  indicated by the gslice argument.  The new valarray has
00309        *  the same size as the input gslice.  @see gslice.
00310        *
00311        *  @param  __s  The source gslice.
00312        *  @return  New valarray containing elements in @a __s.
00313        */
00314       gslice_array<_Tp>   operator[](const gslice& __s);
00315 
00316       /**
00317        *  @brief  Return an array subset.
00318        *
00319        *  Returns a new valarray containing the elements of the array
00320        *  indicated by the argument.  The input is a valarray of bool which
00321        *  represents a bitmask indicating which elements should be copied into
00322        *  the new valarray.  Each element of the array is added to the return
00323        *  valarray if the corresponding element of the argument is true.
00324        *
00325        *  @param  __m  The valarray bitmask.
00326        *  @return  New valarray containing elements indicated by @a __m.
00327        */
00328       valarray<_Tp>       operator[](const valarray<bool>& __m) const;
00329 
00330       /**
00331        *  @brief  Return a reference to an array subset.
00332        *
00333        *  Returns a new mask_array referencing the elements of the array
00334        *  indicated by the argument.  The input is a valarray of bool which
00335        *  represents a bitmask indicating which elements are part of the
00336        *  subset.  Elements of the array are part of the subset if the
00337        *  corresponding element of the argument is true.
00338        *
00339        *  @param  __m  The valarray bitmask.
00340        *  @return  New valarray containing elements indicated by @a __m.
00341        */
00342       mask_array<_Tp>     operator[](const valarray<bool>& __m);
00343 
00344       /**
00345        *  @brief  Return an array subset.
00346        *
00347        *  Returns a new valarray containing the elements of the array
00348        *  indicated by the argument.  The elements in the argument are
00349        *  interpreted as the indices of elements of this valarray to copy to
00350        *  the return valarray.
00351        *
00352        *  @param  __i  The valarray element index list.
00353        *  @return  New valarray containing elements in @a __s.
00354        */
00355       _Expr<_IClos<_ValArray, _Tp>, _Tp>
00356         operator[](const valarray<size_t>& __i) const;
00357 
00358       /**
00359        *  @brief  Return a reference to an array subset.
00360        *
00361        *  Returns an indirect_array referencing the elements of the array
00362        *  indicated by the argument.  The elements in the argument are
00363        *  interpreted as the indices of elements of this valarray to include
00364        *  in the subset.  The returned indirect_array refers to these
00365        *  elements.
00366        *
00367        *  @param  __i  The valarray element index list.
00368        *  @return  Indirect_array referencing elements in @a __i.
00369        */
00370       indirect_array<_Tp> operator[](const valarray<size_t>& __i);
00371 
00372       // _lib.valarray.unary_ unary operators:
00373       ///  Return a new valarray by applying unary + to each element.
00374       typename _UnaryOp<__unary_plus>::_Rt  operator+() const;
00375 
00376       ///  Return a new valarray by applying unary - to each element.
00377       typename _UnaryOp<__negate>::_Rt      operator-() const;
00378 
00379       ///  Return a new valarray by applying unary ~ to each element.
00380       typename _UnaryOp<__bitwise_not>::_Rt operator~() const;
00381 
00382       ///  Return a new valarray by applying unary ! to each element.
00383       typename _UnaryOp<__logical_not>::_Rt operator!() const;
00384 
00385       // _lib.valarray.cassign_ computed assignment:
00386       ///  Multiply each element of array by @a t.
00387       valarray<_Tp>& operator*=(const _Tp&);
00388 
00389       ///  Divide each element of array by @a t.
00390       valarray<_Tp>& operator/=(const _Tp&);
00391 
00392       ///  Set each element e of array to e % @a t.
00393       valarray<_Tp>& operator%=(const _Tp&);
00394 
00395       ///  Add @a t to each element of array.
00396       valarray<_Tp>& operator+=(const _Tp&);
00397 
00398       ///  Subtract @a t to each element of array.
00399       valarray<_Tp>& operator-=(const _Tp&);
00400 
00401       ///  Set each element e of array to e ^ @a t.
00402       valarray<_Tp>& operator^=(const _Tp&);
00403 
00404       ///  Set each element e of array to e & @a t.
00405       valarray<_Tp>& operator&=(const _Tp&);
00406 
00407       ///  Set each element e of array to e | @a t.
00408       valarray<_Tp>& operator|=(const _Tp&);
00409 
00410       ///  Left shift each element e of array by @a t bits.
00411       valarray<_Tp>& operator<<=(const _Tp&);
00412 
00413       ///  Right shift each element e of array by @a t bits.
00414       valarray<_Tp>& operator>>=(const _Tp&);
00415 
00416       ///  Multiply elements of array by corresponding elements of @a v.
00417       valarray<_Tp>& operator*=(const valarray<_Tp>&);
00418 
00419       ///  Divide elements of array by corresponding elements of @a v.
00420       valarray<_Tp>& operator/=(const valarray<_Tp>&);
00421 
00422       ///  Modulo elements of array by corresponding elements of @a v.
00423       valarray<_Tp>& operator%=(const valarray<_Tp>&);
00424 
00425       ///  Add corresponding elements of @a v to elements of array.
00426       valarray<_Tp>& operator+=(const valarray<_Tp>&);
00427 
00428       ///  Subtract corresponding elements of @a v from elements of array.
00429       valarray<_Tp>& operator-=(const valarray<_Tp>&);
00430 
00431       ///  Logical xor corresponding elements of @a v with elements of array.
00432       valarray<_Tp>& operator^=(const valarray<_Tp>&);
00433 
00434       ///  Logical or corresponding elements of @a v with elements of array.
00435       valarray<_Tp>& operator|=(const valarray<_Tp>&);
00436 
00437       ///  Logical and corresponding elements of @a v with elements of array.
00438       valarray<_Tp>& operator&=(const valarray<_Tp>&);
00439 
00440       ///  Left shift elements of array by corresponding elements of @a v.
00441       valarray<_Tp>& operator<<=(const valarray<_Tp>&);
00442 
00443       ///  Right shift elements of array by corresponding elements of @a v.
00444       valarray<_Tp>& operator>>=(const valarray<_Tp>&);
00445 
00446       template<class _Dom>
00447     valarray<_Tp>& operator*=(const _Expr<_Dom, _Tp>&);
00448       template<class _Dom>
00449     valarray<_Tp>& operator/=(const _Expr<_Dom, _Tp>&);
00450       template<class _Dom>
00451     valarray<_Tp>& operator%=(const _Expr<_Dom, _Tp>&);
00452       template<class _Dom>
00453     valarray<_Tp>& operator+=(const _Expr<_Dom, _Tp>&);
00454       template<class _Dom>
00455     valarray<_Tp>& operator-=(const _Expr<_Dom, _Tp>&);
00456       template<class _Dom>
00457     valarray<_Tp>& operator^=(const _Expr<_Dom, _Tp>&);
00458       template<class _Dom>
00459     valarray<_Tp>& operator|=(const _Expr<_Dom, _Tp>&);
00460       template<class _Dom>
00461     valarray<_Tp>& operator&=(const _Expr<_Dom, _Tp>&);
00462       template<class _Dom>
00463         valarray<_Tp>& operator<<=(const _Expr<_Dom, _Tp>&);
00464       template<class _Dom>
00465     valarray<_Tp>& operator>>=(const _Expr<_Dom, _Tp>&);
00466 
00467       // _lib.valarray.members_ member functions:
00468 #if __cplusplus >= 201103L
00469       ///  Swap.
00470       void swap(valarray<_Tp>& __v) noexcept;
00471 #endif
00472 
00473       ///  Return the number of elements in array.
00474       size_t size() const;
00475 
00476       /**
00477        *  @brief  Return the sum of all elements in the array.
00478        *
00479        *  Accumulates the sum of all elements into a Tp using +=.  The order
00480        *  of adding the elements is unspecified.
00481        */
00482       _Tp    sum() const;
00483 
00484       ///  Return the minimum element using operator<().
00485       _Tp    min() const;   
00486 
00487       ///  Return the maximum element using operator<().
00488       _Tp    max() const;   
00489 
00490       /**
00491        *  @brief  Return a shifted array.
00492        *
00493        *  A new valarray is constructed as a copy of this array with elements
00494        *  in shifted positions.  For an element with index i, the new position
00495        *  is i - n.  The new valarray has the same size as the current one.
00496        *  New elements without a value are set to 0.  Elements whose new
00497        *  position is outside the bounds of the array are discarded.
00498        *
00499        *  Positive arguments shift toward index 0, discarding elements [0, n).
00500        *  Negative arguments discard elements from the top of the array.
00501        *
00502        *  @param  __n  Number of element positions to shift.
00503        *  @return  New valarray with elements in shifted positions.
00504        */
00505       valarray<_Tp> shift (int __n) const;
00506 
00507       /**
00508        *  @brief  Return a rotated array.
00509        *
00510        *  A new valarray is constructed as a copy of this array with elements
00511        *  in shifted positions.  For an element with index i, the new position
00512        *  is (i - n) % size().  The new valarray has the same size as the
00513        *  current one.  Elements that are shifted beyond the array bounds are
00514        *  shifted into the other end of the array.  No elements are lost.
00515        *
00516        *  Positive arguments shift toward index 0, wrapping around the top.
00517        *  Negative arguments shift towards the top, wrapping around to 0.
00518        *
00519        *  @param  __n  Number of element positions to rotate.
00520        *  @return  New valarray with elements in shifted positions.
00521        */
00522       valarray<_Tp> cshift(int __n) const;
00523 
00524       /**
00525        *  @brief  Apply a function to the array.
00526        *
00527        *  Returns a new valarray with elements assigned to the result of
00528        *  applying func to the corresponding element of this array.  The new
00529        *  array has the same size as this one.
00530        *
00531        *  @param  func  Function of Tp returning Tp to apply.
00532        *  @return  New valarray with transformed elements.
00533        */
00534       _Expr<_ValFunClos<_ValArray, _Tp>, _Tp> apply(_Tp func(_Tp)) const;
00535 
00536       /**
00537        *  @brief  Apply a function to the array.
00538        *
00539        *  Returns a new valarray with elements assigned to the result of
00540        *  applying func to the corresponding element of this array.  The new
00541        *  array has the same size as this one.
00542        *
00543        *  @param  func  Function of const Tp& returning Tp to apply.
00544        *  @return  New valarray with transformed elements.
00545        */
00546       _Expr<_RefFunClos<_ValArray, _Tp>, _Tp> apply(_Tp func(const _Tp&)) const;
00547 
00548       /**
00549        *  @brief  Resize array.
00550        *
00551        *  Resize this array to @a size and set all elements to @a c.  All
00552        *  references and iterators are invalidated.
00553        *
00554        *  @param  __size  New array size.
00555        *  @param  __c  New value for all elements.
00556        */
00557       void resize(size_t __size, _Tp __c = _Tp());
00558 
00559     private:
00560       size_t _M_size;
00561       _Tp* __restrict__ _M_data;
00562       
00563       friend class _Array<_Tp>;
00564     };
00565   
00566   template<typename _Tp>
00567     inline const _Tp&
00568     valarray<_Tp>::operator[](size_t __i) const
00569     { 
00570       __glibcxx_requires_subscript(__i);
00571       return _M_data[__i];
00572     }
00573 
00574   template<typename _Tp>
00575     inline _Tp&
00576     valarray<_Tp>::operator[](size_t __i)
00577     { 
00578       __glibcxx_requires_subscript(__i);
00579       return _M_data[__i];
00580     }
00581 
00582   // @} group numeric_arrays
00583 
00584 _GLIBCXX_END_NAMESPACE_VERSION
00585 } // namespace
00586 
00587 #include <bits/valarray_after.h>
00588 #include <bits/slice_array.h>
00589 #include <bits/gslice.h>
00590 #include <bits/gslice_array.h>
00591 #include <bits/mask_array.h>
00592 #include <bits/indirect_array.h>
00593 
00594 namespace std _GLIBCXX_VISIBILITY(default)
00595 {
00596 _GLIBCXX_BEGIN_NAMESPACE_VERSION
00597 
00598   /**
00599    * @addtogroup numeric_arrays
00600    * @{
00601    */
00602 
00603   template<typename _Tp>
00604     inline
00605     valarray<_Tp>::valarray() : _M_size(0), _M_data(0) {}
00606 
00607   template<typename _Tp>
00608     inline 
00609     valarray<_Tp>::valarray(size_t __n) 
00610     : _M_size(__n), _M_data(__valarray_get_storage<_Tp>(__n))
00611     { std::__valarray_default_construct(_M_data, _M_data + __n); }
00612 
00613   template<typename _Tp>
00614     inline
00615     valarray<_Tp>::valarray(const _Tp& __t, size_t __n)
00616     : _M_size(__n), _M_data(__valarray_get_storage<_Tp>(__n))
00617     { std::__valarray_fill_construct(_M_data, _M_data + __n, __t); }
00618 
00619   template<typename _Tp>
00620     inline
00621     valarray<_Tp>::valarray(const _Tp* __restrict__ __p, size_t __n)
00622     : _M_size(__n), _M_data(__valarray_get_storage<_Tp>(__n))
00623     { 
00624       _GLIBCXX_DEBUG_ASSERT(__p != 0 || __n == 0);
00625       std::__valarray_copy_construct(__p, __p + __n, _M_data); 
00626     }
00627 
00628   template<typename _Tp>
00629     inline
00630     valarray<_Tp>::valarray(const valarray<_Tp>& __v)
00631     : _M_size(__v._M_size), _M_data(__valarray_get_storage<_Tp>(__v._M_size))
00632     { std::__valarray_copy_construct(__v._M_data, __v._M_data + _M_size,
00633                      _M_data); }
00634 
00635 #if __cplusplus >= 201103L
00636   template<typename _Tp>
00637     inline
00638     valarray<_Tp>::valarray(valarray<_Tp>&& __v) noexcept
00639     : _M_size(__v._M_size), _M_data(__v._M_data)
00640     {
00641       __v._M_size = 0;
00642       __v._M_data = 0;
00643     }
00644 #endif
00645 
00646   template<typename _Tp>
00647     inline
00648     valarray<_Tp>::valarray(const slice_array<_Tp>& __sa)
00649     : _M_size(__sa._M_sz), _M_data(__valarray_get_storage<_Tp>(__sa._M_sz))
00650     {
00651       std::__valarray_copy_construct
00652     (__sa._M_array, __sa._M_sz, __sa._M_stride, _Array<_Tp>(_M_data));
00653     }
00654 
00655   template<typename _Tp>
00656     inline
00657     valarray<_Tp>::valarray(const gslice_array<_Tp>& __ga)
00658     : _M_size(__ga._M_index.size()),
00659       _M_data(__valarray_get_storage<_Tp>(_M_size))
00660     {
00661       std::__valarray_copy_construct
00662     (__ga._M_array, _Array<size_t>(__ga._M_index),
00663      _Array<_Tp>(_M_data), _M_size);
00664     }
00665 
00666   template<typename _Tp>
00667     inline
00668     valarray<_Tp>::valarray(const mask_array<_Tp>& __ma)
00669     : _M_size(__ma._M_sz), _M_data(__valarray_get_storage<_Tp>(__ma._M_sz))
00670     {
00671       std::__valarray_copy_construct
00672     (__ma._M_array, __ma._M_mask, _Array<_Tp>(_M_data), _M_size);
00673     }
00674 
00675   template<typename _Tp>
00676     inline
00677     valarray<_Tp>::valarray(const indirect_array<_Tp>& __ia)
00678     : _M_size(__ia._M_sz), _M_data(__valarray_get_storage<_Tp>(__ia._M_sz))
00679     {
00680       std::__valarray_copy_construct
00681     (__ia._M_array, __ia._M_index, _Array<_Tp>(_M_data), _M_size);
00682     }
00683 
00684 #if __cplusplus >= 201103L
00685   template<typename _Tp>
00686     inline
00687     valarray<_Tp>::valarray(initializer_list<_Tp> __l)
00688     : _M_size(__l.size()), _M_data(__valarray_get_storage<_Tp>(__l.size()))
00689     { std::__valarray_copy_construct(__l.begin(), __l.end(), _M_data); }
00690 #endif
00691 
00692   template<typename _Tp> template<class _Dom>
00693     inline
00694     valarray<_Tp>::valarray(const _Expr<_Dom, _Tp>& __e)
00695     : _M_size(__e.size()), _M_data(__valarray_get_storage<_Tp>(_M_size))
00696     { std::__valarray_copy_construct(__e, _M_size, _Array<_Tp>(_M_data)); }
00697 
00698   template<typename _Tp>
00699     inline
00700     valarray<_Tp>::~valarray() _GLIBCXX_NOEXCEPT
00701     {
00702       std::__valarray_destroy_elements(_M_data, _M_data + _M_size);
00703       std::__valarray_release_memory(_M_data);
00704     }
00705 
00706   template<typename _Tp>
00707     inline valarray<_Tp>&
00708     valarray<_Tp>::operator=(const valarray<_Tp>& __v)
00709     {
00710       // _GLIBCXX_RESOLVE_LIB_DEFECTS
00711       // 630. arrays of valarray.
00712       if (_M_size == __v._M_size)
00713     std::__valarray_copy(__v._M_data, _M_size, _M_data);
00714       else
00715     {
00716       if (_M_data)
00717         {
00718           std::__valarray_destroy_elements(_M_data, _M_data + _M_size);
00719           std::__valarray_release_memory(_M_data);
00720         }
00721       _M_size = __v._M_size;
00722       _M_data = __valarray_get_storage<_Tp>(_M_size);
00723       std::__valarray_copy_construct(__v._M_data, __v._M_data + _M_size,
00724                      _M_data);
00725     }
00726       return *this;
00727     }
00728 
00729 #if __cplusplus >= 201103L
00730   template<typename _Tp>
00731     inline valarray<_Tp>&
00732     valarray<_Tp>::operator=(valarray<_Tp>&& __v) noexcept
00733     {
00734       if (_M_data)
00735     {
00736       std::__valarray_destroy_elements(_M_data, _M_data + _M_size);
00737       std::__valarray_release_memory(_M_data);
00738     }
00739       _M_size = __v._M_size;
00740       _M_data = __v._M_data;
00741       __v._M_size = 0;
00742       __v._M_data = 0;
00743       return *this;
00744     }
00745 
00746   template<typename _Tp>
00747     inline valarray<_Tp>&
00748     valarray<_Tp>::operator=(initializer_list<_Tp> __l)
00749     {
00750       // _GLIBCXX_RESOLVE_LIB_DEFECTS
00751       // 630. arrays of valarray.
00752       if (_M_size == __l.size())
00753     std::__valarray_copy(__l.begin(), __l.size(), _M_data);
00754       else
00755     {
00756       if (_M_data)
00757         {
00758           std::__valarray_destroy_elements(_M_data, _M_data + _M_size);
00759           std::__valarray_release_memory(_M_data);
00760         }
00761       _M_size = __l.size();
00762       _M_data = __valarray_get_storage<_Tp>(_M_size);
00763       std::__valarray_copy_construct(__l.begin(), __l.begin() + _M_size,
00764                      _M_data);
00765     }
00766       return *this;
00767     }
00768 #endif
00769 
00770   template<typename _Tp>
00771     inline valarray<_Tp>&
00772     valarray<_Tp>::operator=(const _Tp& __t)
00773     {
00774       std::__valarray_fill(_M_data, _M_size, __t);
00775       return *this;
00776     }
00777 
00778   template<typename _Tp>
00779     inline valarray<_Tp>&
00780     valarray<_Tp>::operator=(const slice_array<_Tp>& __sa)
00781     {
00782       _GLIBCXX_DEBUG_ASSERT(_M_size == __sa._M_sz);
00783       std::__valarray_copy(__sa._M_array, __sa._M_sz,
00784                __sa._M_stride, _Array<_Tp>(_M_data));
00785       return *this;
00786     }
00787 
00788   template<typename _Tp>
00789     inline valarray<_Tp>&
00790     valarray<_Tp>::operator=(const gslice_array<_Tp>& __ga)
00791     {
00792       _GLIBCXX_DEBUG_ASSERT(_M_size == __ga._M_index.size());
00793       std::__valarray_copy(__ga._M_array, _Array<size_t>(__ga._M_index),
00794                _Array<_Tp>(_M_data), _M_size);
00795       return *this;
00796     }
00797 
00798   template<typename _Tp>
00799     inline valarray<_Tp>&
00800     valarray<_Tp>::operator=(const mask_array<_Tp>& __ma)
00801     {
00802       _GLIBCXX_DEBUG_ASSERT(_M_size == __ma._M_sz);
00803       std::__valarray_copy(__ma._M_array, __ma._M_mask,
00804                _Array<_Tp>(_M_data), _M_size);
00805       return *this;
00806     }
00807 
00808   template<typename _Tp>
00809     inline valarray<_Tp>&
00810     valarray<_Tp>::operator=(const indirect_array<_Tp>& __ia)
00811     {
00812       _GLIBCXX_DEBUG_ASSERT(_M_size == __ia._M_sz);
00813       std::__valarray_copy(__ia._M_array, __ia._M_index,
00814                _Array<_Tp>(_M_data), _M_size);
00815       return *this;
00816     }
00817 
00818   template<typename _Tp> template<class _Dom>
00819     inline valarray<_Tp>&
00820     valarray<_Tp>::operator=(const _Expr<_Dom, _Tp>& __e)
00821     {
00822       _GLIBCXX_DEBUG_ASSERT(_M_size == __e.size());
00823       std::__valarray_copy(__e, _M_size, _Array<_Tp>(_M_data));
00824       return *this;
00825     }
00826 
00827   template<typename _Tp>
00828     inline _Expr<_SClos<_ValArray,_Tp>, _Tp>
00829     valarray<_Tp>::operator[](slice __s) const
00830     {
00831       typedef _SClos<_ValArray,_Tp> _Closure;
00832       return _Expr<_Closure, _Tp>(_Closure (_Array<_Tp>(_M_data), __s));
00833     }
00834 
00835   template<typename _Tp>
00836     inline slice_array<_Tp>
00837     valarray<_Tp>::operator[](slice __s)
00838     { return slice_array<_Tp>(_Array<_Tp>(_M_data), __s); }
00839 
00840   template<typename _Tp>
00841     inline _Expr<_GClos<_ValArray,_Tp>, _Tp>
00842     valarray<_Tp>::operator[](const gslice& __gs) const
00843     {
00844       typedef _GClos<_ValArray,_Tp> _Closure;
00845       return _Expr<_Closure, _Tp>
00846     (_Closure(_Array<_Tp>(_M_data), __gs._M_index->_M_index));
00847     }
00848 
00849   template<typename _Tp>
00850     inline gslice_array<_Tp>
00851     valarray<_Tp>::operator[](const gslice& __gs)
00852     {
00853       return gslice_array<_Tp>
00854     (_Array<_Tp>(_M_data), __gs._M_index->_M_index);
00855     }
00856 
00857   template<typename _Tp>
00858     inline valarray<_Tp>
00859     valarray<_Tp>::operator[](const valarray<bool>& __m) const
00860     {
00861       size_t __s = 0;
00862       size_t __e = __m.size();
00863       for (size_t __i=0; __i<__e; ++__i)
00864     if (__m[__i]) ++__s;
00865       return valarray<_Tp>(mask_array<_Tp>(_Array<_Tp>(_M_data), __s,
00866                        _Array<bool> (__m)));
00867     }
00868 
00869   template<typename _Tp>
00870     inline mask_array<_Tp>
00871     valarray<_Tp>::operator[](const valarray<bool>& __m)
00872     {
00873       size_t __s = 0;
00874       size_t __e = __m.size();
00875       for (size_t __i=0; __i<__e; ++__i)
00876     if (__m[__i]) ++__s;
00877       return mask_array<_Tp>(_Array<_Tp>(_M_data), __s, _Array<bool>(__m));
00878     }
00879 
00880   template<typename _Tp>
00881     inline _Expr<_IClos<_ValArray,_Tp>, _Tp>
00882     valarray<_Tp>::operator[](const valarray<size_t>& __i) const
00883     {
00884       typedef _IClos<_ValArray,_Tp> _Closure;
00885       return _Expr<_Closure, _Tp>(_Closure(*this, __i));
00886     }
00887 
00888   template<typename _Tp>
00889     inline indirect_array<_Tp>
00890     valarray<_Tp>::operator[](const valarray<size_t>& __i)
00891     {
00892       return indirect_array<_Tp>(_Array<_Tp>(_M_data), __i.size(),
00893                  _Array<size_t>(__i));
00894     }
00895 
00896 #if __cplusplus >= 201103L
00897   template<class _Tp>
00898     inline void
00899     valarray<_Tp>::swap(valarray<_Tp>& __v) noexcept
00900     {
00901       std::swap(_M_size, __v._M_size);
00902       std::swap(_M_data, __v._M_data);
00903     }
00904 #endif
00905 
00906   template<class _Tp>
00907     inline size_t 
00908     valarray<_Tp>::size() const
00909     { return _M_size; }
00910 
00911   template<class _Tp>
00912     inline _Tp
00913     valarray<_Tp>::sum() const
00914     {
00915       _GLIBCXX_DEBUG_ASSERT(_M_size > 0);
00916       return std::__valarray_sum(_M_data, _M_data + _M_size);
00917     }
00918 
00919   template<class _Tp>
00920      inline valarray<_Tp>
00921      valarray<_Tp>::shift(int __n) const
00922      {
00923        valarray<_Tp> __ret;
00924 
00925        if (_M_size == 0)
00926      return __ret;
00927 
00928        _Tp* __restrict__ __tmp_M_data =
00929      std::__valarray_get_storage<_Tp>(_M_size);
00930 
00931        if (__n == 0)
00932      std::__valarray_copy_construct(_M_data,
00933                     _M_data + _M_size, __tmp_M_data);
00934        else if (__n > 0)      // shift left
00935      {
00936        if (size_t(__n) > _M_size)
00937          __n = int(_M_size);
00938 
00939        std::__valarray_copy_construct(_M_data + __n,
00940                       _M_data + _M_size, __tmp_M_data);
00941        std::__valarray_default_construct(__tmp_M_data + _M_size - __n,
00942                          __tmp_M_data + _M_size);
00943      }
00944        else                   // shift right
00945      {
00946        if (-size_t(__n) > _M_size)
00947          __n = -int(_M_size);
00948 
00949        std::__valarray_copy_construct(_M_data, _M_data + _M_size + __n,
00950                       __tmp_M_data - __n);
00951        std::__valarray_default_construct(__tmp_M_data,
00952                          __tmp_M_data - __n);
00953      }
00954 
00955        __ret._M_size = _M_size;
00956        __ret._M_data = __tmp_M_data;
00957        return __ret;
00958      }
00959 
00960   template<class _Tp>
00961      inline valarray<_Tp>
00962      valarray<_Tp>::cshift(int __n) const
00963      {
00964        valarray<_Tp> __ret;
00965 
00966        if (_M_size == 0)
00967      return __ret;
00968 
00969        _Tp* __restrict__ __tmp_M_data =
00970      std::__valarray_get_storage<_Tp>(_M_size);
00971 
00972        if (__n == 0)
00973      std::__valarray_copy_construct(_M_data,
00974                     _M_data + _M_size, __tmp_M_data);
00975        else if (__n > 0)      // cshift left
00976      {
00977        if (size_t(__n) > _M_size)
00978          __n = int(__n % _M_size);
00979 
00980        std::__valarray_copy_construct(_M_data, _M_data + __n,
00981                       __tmp_M_data + _M_size - __n);
00982        std::__valarray_copy_construct(_M_data + __n, _M_data + _M_size,
00983                       __tmp_M_data);
00984      }
00985        else                   // cshift right
00986      {
00987        if (-size_t(__n) > _M_size)
00988          __n = -int(-size_t(__n) % _M_size);
00989 
00990        std::__valarray_copy_construct(_M_data + _M_size + __n,
00991                       _M_data + _M_size, __tmp_M_data);
00992        std::__valarray_copy_construct(_M_data, _M_data + _M_size + __n,
00993                       __tmp_M_data - __n);
00994      }
00995 
00996        __ret._M_size = _M_size;
00997        __ret._M_data = __tmp_M_data;
00998        return __ret;
00999      }
01000 
01001   template<class _Tp>
01002     inline void
01003     valarray<_Tp>::resize(size_t __n, _Tp __c)
01004     {
01005       // This complication is so to make valarray<valarray<T> > work
01006       // even though it is not required by the standard.  Nobody should
01007       // be saying valarray<valarray<T> > anyway.  See the specs.
01008       std::__valarray_destroy_elements(_M_data, _M_data + _M_size);
01009       if (_M_size != __n)
01010     {
01011       std::__valarray_release_memory(_M_data);
01012       _M_size = __n;
01013       _M_data = __valarray_get_storage<_Tp>(__n);
01014     }
01015       std::__valarray_fill_construct(_M_data, _M_data + __n, __c);
01016     }
01017     
01018   template<typename _Tp>
01019     inline _Tp
01020     valarray<_Tp>::min() const
01021     {
01022       _GLIBCXX_DEBUG_ASSERT(_M_size > 0);
01023       return *std::min_element(_M_data, _M_data + _M_size);
01024     }
01025 
01026   template<typename _Tp>
01027     inline _Tp
01028     valarray<_Tp>::max() const
01029     {
01030       _GLIBCXX_DEBUG_ASSERT(_M_size > 0);
01031       return *std::max_element(_M_data, _M_data + _M_size);
01032     }
01033   
01034   template<class _Tp>
01035     inline _Expr<_ValFunClos<_ValArray, _Tp>, _Tp>
01036     valarray<_Tp>::apply(_Tp func(_Tp)) const
01037     {
01038       typedef _ValFunClos<_ValArray, _Tp> _Closure;
01039       return _Expr<_Closure, _Tp>(_Closure(*this, func));
01040     }
01041 
01042   template<class _Tp>
01043     inline _Expr<_RefFunClos<_ValArray, _Tp>, _Tp>
01044     valarray<_Tp>::apply(_Tp func(const _Tp &)) const
01045     {
01046       typedef _RefFunClos<_ValArray, _Tp> _Closure;
01047       return _Expr<_Closure, _Tp>(_Closure(*this, func));
01048     }
01049 
01050 #define _DEFINE_VALARRAY_UNARY_OPERATOR(_Op, _Name)                     \
01051   template<typename _Tp>                        \
01052     inline typename valarray<_Tp>::template _UnaryOp<_Name>::_Rt        \
01053     valarray<_Tp>::operator _Op() const                 \
01054     {                                   \
01055       typedef _UnClos<_Name, _ValArray, _Tp> _Closure;                  \
01056       typedef typename __fun<_Name, _Tp>::result_type _Rt;              \
01057       return _Expr<_Closure, _Rt>(_Closure(*this));         \
01058     }
01059 
01060     _DEFINE_VALARRAY_UNARY_OPERATOR(+, __unary_plus)
01061     _DEFINE_VALARRAY_UNARY_OPERATOR(-, __negate)
01062     _DEFINE_VALARRAY_UNARY_OPERATOR(~, __bitwise_not)
01063     _DEFINE_VALARRAY_UNARY_OPERATOR (!, __logical_not)
01064 
01065 #undef _DEFINE_VALARRAY_UNARY_OPERATOR
01066 
01067 #define _DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(_Op, _Name)               \
01068   template<class _Tp>                           \
01069     inline valarray<_Tp>&                       \
01070     valarray<_Tp>::operator _Op##=(const _Tp &__t)          \
01071     {                                   \
01072       _Array_augmented_##_Name(_Array<_Tp>(_M_data), _M_size, __t); \
01073       return *this;                         \
01074     }                                   \
01075                                     \
01076   template<class _Tp>                           \
01077     inline valarray<_Tp>&                       \
01078     valarray<_Tp>::operator _Op##=(const valarray<_Tp> &__v)        \
01079     {                                   \
01080       _GLIBCXX_DEBUG_ASSERT(_M_size == __v._M_size);                    \
01081       _Array_augmented_##_Name(_Array<_Tp>(_M_data), _M_size,       \
01082                    _Array<_Tp>(__v._M_data));       \
01083       return *this;                         \
01084     }
01085 
01086 _DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(+, __plus)
01087 _DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(-, __minus)
01088 _DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(*, __multiplies)
01089 _DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(/, __divides)
01090 _DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(%, __modulus)
01091 _DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(^, __bitwise_xor)
01092 _DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(&, __bitwise_and)
01093 _DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(|, __bitwise_or)
01094 _DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(<<, __shift_left)
01095 _DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(>>, __shift_right)
01096 
01097 #undef _DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT
01098 
01099 #define _DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(_Op, _Name)          \
01100   template<class _Tp> template<class _Dom>              \
01101     inline valarray<_Tp>&                       \
01102     valarray<_Tp>::operator _Op##=(const _Expr<_Dom, _Tp>& __e)     \
01103     {                                   \
01104       _Array_augmented_##_Name(_Array<_Tp>(_M_data), __e, _M_size); \
01105       return *this;                         \
01106     }
01107 
01108 _DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(+, __plus)
01109 _DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(-, __minus)
01110 _DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(*, __multiplies)
01111 _DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(/, __divides)
01112 _DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(%, __modulus)
01113 _DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(^, __bitwise_xor)
01114 _DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(&, __bitwise_and)
01115 _DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(|, __bitwise_or)
01116 _DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(<<, __shift_left)
01117 _DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(>>, __shift_right)
01118 
01119 #undef _DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT
01120     
01121 
01122 #define _DEFINE_BINARY_OPERATOR(_Op, _Name)             \
01123   template<typename _Tp>                        \
01124     inline _Expr<_BinClos<_Name, _ValArray, _ValArray, _Tp, _Tp>,       \
01125                  typename __fun<_Name, _Tp>::result_type>               \
01126     operator _Op(const valarray<_Tp>& __v, const valarray<_Tp>& __w)    \
01127     {                                   \
01128       _GLIBCXX_DEBUG_ASSERT(__v.size() == __w.size());                  \
01129       typedef _BinClos<_Name, _ValArray, _ValArray, _Tp, _Tp> _Closure; \
01130       typedef typename __fun<_Name, _Tp>::result_type _Rt;              \
01131       return _Expr<_Closure, _Rt>(_Closure(__v, __w));                  \
01132     }                                   \
01133                                     \
01134   template<typename _Tp>                        \
01135     inline _Expr<_BinClos<_Name, _ValArray,_Constant, _Tp, _Tp>,        \
01136                  typename __fun<_Name, _Tp>::result_type>               \
01137     operator _Op(const valarray<_Tp>& __v, const _Tp& __t)      \
01138     {                                   \
01139       typedef _BinClos<_Name, _ValArray, _Constant, _Tp, _Tp> _Closure; \
01140       typedef typename __fun<_Name, _Tp>::result_type _Rt;              \
01141       return _Expr<_Closure, _Rt>(_Closure(__v, __t));                  \
01142     }                                   \
01143                                     \
01144   template<typename _Tp>                        \
01145     inline _Expr<_BinClos<_Name, _Constant, _ValArray, _Tp, _Tp>,       \
01146                  typename __fun<_Name, _Tp>::result_type>               \
01147     operator _Op(const _Tp& __t, const valarray<_Tp>& __v)      \
01148     {                                   \
01149       typedef _BinClos<_Name, _Constant, _ValArray, _Tp, _Tp> _Closure; \
01150       typedef typename __fun<_Name, _Tp>::result_type _Rt;              \
01151       return _Expr<_Closure, _Rt>(_Closure(__t, __v));                  \
01152     }
01153 
01154 _DEFINE_BINARY_OPERATOR(+, __plus)
01155 _DEFINE_BINARY_OPERATOR(-, __minus)
01156 _DEFINE_BINARY_OPERATOR(*, __multiplies)
01157 _DEFINE_BINARY_OPERATOR(/, __divides)
01158 _DEFINE_BINARY_OPERATOR(%, __modulus)
01159 _DEFINE_BINARY_OPERATOR(^, __bitwise_xor)
01160 _DEFINE_BINARY_OPERATOR(&, __bitwise_and)
01161 _DEFINE_BINARY_OPERATOR(|, __bitwise_or)
01162 _DEFINE_BINARY_OPERATOR(<<, __shift_left)
01163 _DEFINE_BINARY_OPERATOR(>>, __shift_right)
01164 _DEFINE_BINARY_OPERATOR(&&, __logical_and)
01165 _DEFINE_BINARY_OPERATOR(||, __logical_or)
01166 _DEFINE_BINARY_OPERATOR(==, __equal_to)
01167 _DEFINE_BINARY_OPERATOR(!=, __not_equal_to)
01168 _DEFINE_BINARY_OPERATOR(<, __less)
01169 _DEFINE_BINARY_OPERATOR(>, __greater)
01170 _DEFINE_BINARY_OPERATOR(<=, __less_equal)
01171 _DEFINE_BINARY_OPERATOR(>=, __greater_equal)
01172 
01173 #undef _DEFINE_BINARY_OPERATOR
01174 
01175 #if __cplusplus >= 201103L
01176   /**
01177    *  @brief  Return an iterator pointing to the first element of
01178    *          the valarray.
01179    *  @param  __va  valarray.
01180    */
01181   template<class _Tp>
01182     inline _Tp*
01183     begin(valarray<_Tp>& __va)
01184     { return std::__addressof(__va[0]); }
01185 
01186   /**
01187    *  @brief  Return an iterator pointing to the first element of
01188    *          the const valarray.
01189    *  @param  __va  valarray.
01190    */
01191   template<class _Tp>
01192     inline const _Tp*
01193     begin(const valarray<_Tp>& __va)
01194     { return std::__addressof(__va[0]); }
01195 
01196   /**
01197    *  @brief  Return an iterator pointing to one past the last element of
01198    *          the valarray.
01199    *  @param  __va  valarray.
01200    */
01201   template<class _Tp>
01202     inline _Tp*
01203     end(valarray<_Tp>& __va)
01204     { return std::__addressof(__va[0]) + __va.size(); }
01205 
01206   /**
01207    *  @brief  Return an iterator pointing to one past the last element of
01208    *          the const valarray.
01209    *  @param  __va  valarray.
01210    */
01211   template<class _Tp>
01212     inline const _Tp*
01213     end(const valarray<_Tp>& __va)
01214     { return std::__addressof(__va[0]) + __va.size(); }
01215 #endif // C++11
01216 
01217   // @} group numeric_arrays
01218 
01219 _GLIBCXX_END_NAMESPACE_VERSION
01220 } // namespace
01221 
01222 #endif /* _GLIBCXX_VALARRAY */