libstdc++
valarray_after.h
Go to the documentation of this file.
00001 // The template and inlines for the -*- C++ -*- internal _Meta class.
00002 
00003 // Copyright (C) 1997-2019 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 bits/valarray_after.h
00026  *  This is an internal header file, included by other library headers.
00027  *  Do not attempt to use it directly. @headername{valarray}
00028  */
00029 
00030 // Written by Gabriel Dos Reis <Gabriel.Dos-Reis@cmla.ens-cachan.fr>
00031 
00032 #ifndef _VALARRAY_AFTER_H
00033 #define _VALARRAY_AFTER_H 1
00034 
00035 #pragma GCC system_header
00036 
00037 namespace std _GLIBCXX_VISIBILITY(default)
00038 {
00039 _GLIBCXX_BEGIN_NAMESPACE_VERSION
00040 
00041 namespace __detail
00042 {
00043   //
00044   // gslice_array closure.
00045   //
00046   template<class _Dom>
00047     class _GBase
00048     {
00049     public:
00050       typedef typename _Dom::value_type value_type;
00051       
00052       _GBase (const _Dom& __e, const valarray<size_t>& __i)
00053       : _M_expr (__e), _M_index(__i) {}
00054       
00055       value_type
00056       operator[] (size_t __i) const
00057       { return _M_expr[_M_index[__i]]; }
00058       
00059       size_t
00060       size () const
00061       { return _M_index.size(); }
00062 
00063     private:
00064       typename _ValArrayRef<_Dom>::__type       _M_expr;
00065       const valarray<size_t>&                   _M_index;
00066     };
00067 
00068   template<typename _Tp>
00069     class _GBase<_Array<_Tp> >
00070     {
00071     public:
00072       typedef _Tp value_type;
00073       
00074       _GBase (_Array<_Tp> __a, const valarray<size_t>& __i)
00075       : _M_array (__a), _M_index(__i) {}
00076       
00077       value_type
00078       operator[] (size_t __i) const
00079       { return _M_array._M_data[_M_index[__i]]; }
00080       
00081       size_t
00082       size () const
00083       { return _M_index.size(); }
00084 
00085     private:
00086       const _Array<_Tp>       _M_array;
00087       const valarray<size_t>& _M_index;
00088     };
00089 
00090   template<class _Dom>
00091     struct _GClos<_Expr, _Dom>
00092     : _GBase<_Dom>
00093     {
00094       typedef _GBase<_Dom> _Base;
00095       typedef typename _Base::value_type value_type;
00096       
00097       _GClos (const _Dom& __e, const valarray<size_t>& __i)
00098       : _Base (__e, __i) {}
00099     };
00100 
00101   template<typename _Tp>
00102     struct _GClos<_ValArray, _Tp>
00103     : _GBase<_Array<_Tp> >
00104     {
00105       typedef _GBase<_Array<_Tp> > _Base;
00106       typedef typename _Base::value_type value_type;
00107       
00108       _GClos (_Array<_Tp> __a, const valarray<size_t>& __i)
00109       : _Base (__a, __i) {}
00110     };
00111 
00112   //
00113   // indirect_array closure
00114   //
00115   template<class _Dom>
00116     class _IBase
00117     {
00118     public:
00119       typedef typename _Dom::value_type value_type;
00120 
00121       _IBase (const _Dom& __e, const valarray<size_t>& __i)
00122       : _M_expr (__e), _M_index (__i) {}
00123       
00124       value_type
00125       operator[] (size_t __i) const
00126       { return _M_expr[_M_index[__i]]; }
00127       
00128       size_t
00129       size() const
00130       { return _M_index.size(); }
00131 
00132     private:
00133       typename _ValArrayRef<_Dom>::__type       _M_expr;
00134       const valarray<size_t>&                   _M_index;
00135     };
00136 
00137   template<class _Dom>
00138     struct _IClos<_Expr, _Dom>
00139     : _IBase<_Dom>
00140     {
00141       typedef _IBase<_Dom> _Base;
00142       typedef typename _Base::value_type value_type;
00143       
00144       _IClos (const _Dom& __e, const valarray<size_t>& __i)
00145       : _Base (__e, __i) {}
00146     };
00147 
00148   template<typename _Tp>
00149     struct _IClos<_ValArray, _Tp>
00150     : _IBase<valarray<_Tp> >
00151     {
00152       typedef _IBase<valarray<_Tp> > _Base;
00153       typedef _Tp value_type;
00154       
00155       _IClos (const valarray<_Tp>& __a, const valarray<size_t>& __i)
00156       : _Base (__a, __i) {}
00157     };
00158 } // namespace __detail
00159   
00160   //
00161   // class _Expr
00162   //
00163   template<class _Clos, typename _Tp>
00164     class _Expr
00165     {
00166     public:
00167       typedef _Tp value_type;
00168 
00169       _Expr(const _Clos&);
00170 
00171       const _Clos& operator()() const;
00172 
00173       value_type operator[](size_t) const;
00174       valarray<value_type> operator[](slice) const;
00175       valarray<value_type> operator[](const gslice&) const;
00176       valarray<value_type> operator[](const valarray<bool>&) const;
00177       valarray<value_type> operator[](const valarray<size_t>&) const;
00178 
00179       _Expr<_UnClos<__unary_plus, std::_Expr, _Clos>, value_type>
00180       operator+() const;
00181 
00182       _Expr<_UnClos<__negate, std::_Expr, _Clos>, value_type>
00183       operator-() const;
00184 
00185       _Expr<_UnClos<__bitwise_not, std::_Expr, _Clos>, value_type>
00186       operator~() const;
00187 
00188       _Expr<_UnClos<__logical_not, std::_Expr, _Clos>, bool>
00189       operator!() const;
00190 
00191       size_t size() const;
00192       value_type sum() const;
00193 
00194       valarray<value_type> shift(int) const;
00195       valarray<value_type> cshift(int) const;
00196 
00197       value_type min() const;
00198       value_type max() const;
00199 
00200       valarray<value_type> apply(value_type (*)(const value_type&)) const;
00201       valarray<value_type> apply(value_type (*)(value_type)) const;
00202 
00203     private:
00204       const _Clos _M_closure;
00205     };
00206 
00207   template<class _Clos, typename _Tp>
00208     inline
00209     _Expr<_Clos, _Tp>::_Expr(const _Clos& __c) : _M_closure(__c) {}
00210 
00211   template<class _Clos, typename _Tp>
00212     inline const _Clos&
00213     _Expr<_Clos, _Tp>::operator()() const
00214     { return _M_closure; }
00215 
00216   template<class _Clos, typename _Tp>
00217     inline _Tp
00218     _Expr<_Clos, _Tp>::operator[](size_t __i) const
00219     { return _M_closure[__i]; }
00220 
00221   template<class _Clos, typename _Tp>
00222     inline valarray<_Tp>
00223     _Expr<_Clos, _Tp>::operator[](slice __s) const
00224     {
00225       valarray<_Tp> __v = valarray<_Tp>(*this)[__s];
00226       return __v;
00227     }
00228 
00229   template<class _Clos, typename _Tp>
00230     inline valarray<_Tp>
00231     _Expr<_Clos, _Tp>::operator[](const gslice& __gs) const
00232     {
00233       valarray<_Tp> __v = valarray<_Tp>(*this)[__gs];
00234       return __v;
00235     }
00236 
00237   template<class _Clos, typename _Tp>
00238     inline valarray<_Tp>
00239     _Expr<_Clos, _Tp>::operator[](const valarray<bool>& __m) const
00240     {
00241       valarray<_Tp> __v = valarray<_Tp>(*this)[__m];
00242       return __v;
00243     }
00244 
00245   template<class _Clos, typename _Tp>
00246     inline valarray<_Tp>
00247     _Expr<_Clos, _Tp>::operator[](const valarray<size_t>& __i) const
00248     {
00249       valarray<_Tp> __v = valarray<_Tp>(*this)[__i];
00250       return __v;
00251     }
00252 
00253   template<class _Clos, typename _Tp>
00254     inline size_t
00255     _Expr<_Clos, _Tp>::size() const
00256     { return _M_closure.size(); }
00257 
00258   template<class _Clos, typename _Tp>
00259     inline valarray<_Tp>
00260     _Expr<_Clos, _Tp>::shift(int __n) const
00261     {
00262       valarray<_Tp> __v = valarray<_Tp>(*this).shift(__n);
00263       return __v;
00264     }
00265 
00266   template<class _Clos, typename _Tp>
00267     inline valarray<_Tp>
00268     _Expr<_Clos, _Tp>::cshift(int __n) const
00269     {
00270       valarray<_Tp> __v = valarray<_Tp>(*this).cshift(__n);
00271       return __v;
00272     }
00273 
00274   template<class _Clos, typename _Tp>
00275     inline valarray<_Tp>
00276     _Expr<_Clos, _Tp>::apply(_Tp __f(const _Tp&)) const
00277     {
00278       valarray<_Tp> __v = valarray<_Tp>(*this).apply(__f);
00279       return __v;
00280     }
00281 
00282   template<class _Clos, typename _Tp>
00283     inline valarray<_Tp>
00284     _Expr<_Clos, _Tp>::apply(_Tp __f(_Tp)) const
00285     {
00286       valarray<_Tp> __v = valarray<_Tp>(*this).apply(__f);
00287       return __v;
00288     }
00289 
00290   // XXX: replace this with a more robust summation algorithm.
00291   template<class _Clos, typename _Tp>
00292     inline _Tp
00293     _Expr<_Clos, _Tp>::sum() const
00294     {
00295       size_t __n = _M_closure.size();
00296       if (__n == 0)
00297         return _Tp();
00298       else
00299         {
00300           _Tp __s = _M_closure[--__n];
00301           while (__n != 0)
00302             __s += _M_closure[--__n];
00303           return __s;
00304         }
00305     }
00306 
00307   template<class _Clos, typename _Tp>
00308     inline _Tp
00309     _Expr<_Clos, _Tp>::min() const
00310     { return __valarray_min(_M_closure); }
00311 
00312   template<class _Clos, typename _Tp>
00313     inline _Tp
00314     _Expr<_Clos, _Tp>::max() const
00315     { return __valarray_max(_M_closure); }
00316 
00317   template<class _Dom, typename _Tp>
00318     inline _Expr<_UnClos<__logical_not, _Expr, _Dom>, bool>
00319     _Expr<_Dom, _Tp>::operator!() const
00320     {
00321       typedef _UnClos<__logical_not, std::_Expr, _Dom> _Closure;
00322       return _Expr<_Closure, bool>(_Closure(this->_M_closure));
00323     }
00324 
00325 #define _DEFINE_EXPR_UNARY_OPERATOR(_Op, _Name)                           \
00326   template<class _Dom, typename _Tp>                                      \
00327     inline _Expr<_UnClos<_Name, std::_Expr, _Dom>, _Tp>                   \
00328     _Expr<_Dom, _Tp>::operator _Op() const                                \
00329     {                                                                     \
00330       typedef _UnClos<_Name, std::_Expr, _Dom> _Closure;                  \
00331       return _Expr<_Closure, _Tp>(_Closure(this->_M_closure));            \
00332     }
00333 
00334     _DEFINE_EXPR_UNARY_OPERATOR(+, __unary_plus)
00335     _DEFINE_EXPR_UNARY_OPERATOR(-, __negate)
00336     _DEFINE_EXPR_UNARY_OPERATOR(~, __bitwise_not)
00337 
00338 #undef _DEFINE_EXPR_UNARY_OPERATOR
00339 
00340 #define _DEFINE_EXPR_BINARY_OPERATOR(_Op, _Name)                        \
00341   template<class _Dom1, class _Dom2>                                    \
00342     inline _Expr<_BinClos<_Name, _Expr, _Expr, _Dom1, _Dom2>,           \
00343            typename __fun<_Name, typename _Dom1::value_type>::result_type> \
00344     operator _Op(const _Expr<_Dom1, typename _Dom1::value_type>& __v,   \
00345                  const _Expr<_Dom2, typename _Dom2::value_type>& __w)   \
00346     {                                                                   \
00347       typedef typename _Dom1::value_type _Arg;                          \
00348       typedef typename __fun<_Name, _Arg>::result_type _Value;          \
00349       typedef _BinClos<_Name, _Expr, _Expr, _Dom1, _Dom2> _Closure;     \
00350       return _Expr<_Closure, _Value>(_Closure(__v(), __w()));           \
00351     }                                                                   \
00352                                                                         \
00353   template<class _Dom>                                                  \
00354     inline _Expr<_BinClos<_Name, _Expr, _Constant, _Dom,                \
00355                           typename _Dom::value_type>,                   \
00356              typename __fun<_Name, typename _Dom::value_type>::result_type> \
00357     operator _Op(const _Expr<_Dom, typename _Dom::value_type>& __v,     \
00358                  const typename _Dom::value_type& __t)                  \
00359     {                                                                   \
00360       typedef typename _Dom::value_type _Arg;                           \
00361       typedef typename __fun<_Name, _Arg>::result_type _Value;          \
00362       typedef _BinClos<_Name, _Expr, _Constant, _Dom, _Arg> _Closure;   \
00363       return _Expr<_Closure, _Value>(_Closure(__v(), __t));             \
00364     }                                                                   \
00365                                                                         \
00366   template<class _Dom>                                                  \
00367     inline _Expr<_BinClos<_Name, _Constant, _Expr,                      \
00368                           typename _Dom::value_type, _Dom>,             \
00369              typename __fun<_Name, typename _Dom::value_type>::result_type> \
00370     operator _Op(const typename _Dom::value_type& __t,                  \
00371                  const _Expr<_Dom, typename _Dom::value_type>& __v)     \
00372     {                                                                   \
00373       typedef typename _Dom::value_type _Arg;                           \
00374       typedef typename __fun<_Name, _Arg>::result_type _Value;          \
00375       typedef _BinClos<_Name, _Constant, _Expr, _Arg, _Dom> _Closure;   \
00376       return _Expr<_Closure, _Value>(_Closure(__t, __v()));             \
00377     }                                                                   \
00378                                                                         \
00379   template<class _Dom>                                                  \
00380     inline _Expr<_BinClos<_Name, _Expr, _ValArray,                      \
00381                           _Dom, typename _Dom::value_type>,             \
00382              typename __fun<_Name, typename _Dom::value_type>::result_type> \
00383     operator _Op(const _Expr<_Dom,typename _Dom::value_type>& __e,      \
00384                  const valarray<typename _Dom::value_type>& __v)        \
00385     {                                                                   \
00386       typedef typename _Dom::value_type _Arg;                           \
00387       typedef typename __fun<_Name, _Arg>::result_type _Value;          \
00388       typedef _BinClos<_Name, _Expr, _ValArray, _Dom, _Arg> _Closure;   \
00389       return _Expr<_Closure, _Value>(_Closure(__e(), __v));             \
00390     }                                                                   \
00391                                                                         \
00392   template<class _Dom>                                                  \
00393     inline _Expr<_BinClos<_Name, _ValArray, _Expr,                      \
00394                  typename _Dom::value_type, _Dom>,                      \
00395              typename __fun<_Name, typename _Dom::value_type>::result_type> \
00396     operator _Op(const valarray<typename _Dom::value_type>& __v,        \
00397                  const _Expr<_Dom, typename _Dom::value_type>& __e)     \
00398     {                                                                   \
00399       typedef typename _Dom::value_type _Tp;                            \
00400       typedef typename __fun<_Name, _Tp>::result_type _Value;           \
00401       typedef _BinClos<_Name, _ValArray, _Expr, _Tp, _Dom> _Closure;    \
00402       return _Expr<_Closure, _Value>(_Closure(__v, __e ()));            \
00403     }
00404 
00405     _DEFINE_EXPR_BINARY_OPERATOR(+, __plus)
00406     _DEFINE_EXPR_BINARY_OPERATOR(-, __minus)
00407     _DEFINE_EXPR_BINARY_OPERATOR(*, __multiplies)
00408     _DEFINE_EXPR_BINARY_OPERATOR(/, __divides)
00409     _DEFINE_EXPR_BINARY_OPERATOR(%, __modulus)
00410     _DEFINE_EXPR_BINARY_OPERATOR(^, __bitwise_xor)
00411     _DEFINE_EXPR_BINARY_OPERATOR(&, __bitwise_and)
00412     _DEFINE_EXPR_BINARY_OPERATOR(|, __bitwise_or)
00413     _DEFINE_EXPR_BINARY_OPERATOR(<<, __shift_left)
00414     _DEFINE_EXPR_BINARY_OPERATOR(>>, __shift_right)
00415     _DEFINE_EXPR_BINARY_OPERATOR(&&, __logical_and)
00416     _DEFINE_EXPR_BINARY_OPERATOR(||, __logical_or)
00417     _DEFINE_EXPR_BINARY_OPERATOR(==, __equal_to)
00418     _DEFINE_EXPR_BINARY_OPERATOR(!=, __not_equal_to)
00419     _DEFINE_EXPR_BINARY_OPERATOR(<, __less)
00420     _DEFINE_EXPR_BINARY_OPERATOR(>, __greater)
00421     _DEFINE_EXPR_BINARY_OPERATOR(<=, __less_equal)
00422     _DEFINE_EXPR_BINARY_OPERATOR(>=, __greater_equal)
00423 
00424 #undef _DEFINE_EXPR_BINARY_OPERATOR
00425 
00426 #define _DEFINE_EXPR_UNARY_FUNCTION(_Name, _UName)                       \
00427   template<class _Dom>                                                   \
00428     inline _Expr<_UnClos<_UName, _Expr, _Dom>,                           \
00429                  typename _Dom::value_type>                              \
00430     _Name(const _Expr<_Dom, typename _Dom::value_type>& __e)             \
00431     {                                                                    \
00432       typedef typename _Dom::value_type _Tp;                             \
00433       typedef _UnClos<_UName, _Expr, _Dom> _Closure;                     \
00434       return _Expr<_Closure, _Tp>(_Closure(__e()));                      \
00435     }                                                                    \
00436                                                                          \
00437   template<typename _Tp>                                                 \
00438     inline _Expr<_UnClos<_UName, _ValArray, _Tp>, _Tp>                   \
00439     _Name(const valarray<_Tp>& __v)                                      \
00440     {                                                                    \
00441       typedef _UnClos<_UName, _ValArray, _Tp> _Closure;                  \
00442       return _Expr<_Closure, _Tp>(_Closure(__v));                        \
00443     }
00444 
00445     _DEFINE_EXPR_UNARY_FUNCTION(abs, _Abs)
00446     _DEFINE_EXPR_UNARY_FUNCTION(cos, _Cos)
00447     _DEFINE_EXPR_UNARY_FUNCTION(acos, _Acos)
00448     _DEFINE_EXPR_UNARY_FUNCTION(cosh, _Cosh)
00449     _DEFINE_EXPR_UNARY_FUNCTION(sin, _Sin)
00450     _DEFINE_EXPR_UNARY_FUNCTION(asin, _Asin)
00451     _DEFINE_EXPR_UNARY_FUNCTION(sinh, _Sinh)
00452     _DEFINE_EXPR_UNARY_FUNCTION(tan, _Tan)
00453     _DEFINE_EXPR_UNARY_FUNCTION(tanh, _Tanh)
00454     _DEFINE_EXPR_UNARY_FUNCTION(atan, _Atan)
00455     _DEFINE_EXPR_UNARY_FUNCTION(exp, _Exp)
00456     _DEFINE_EXPR_UNARY_FUNCTION(log, _Log)
00457     _DEFINE_EXPR_UNARY_FUNCTION(log10, _Log10)
00458     _DEFINE_EXPR_UNARY_FUNCTION(sqrt, _Sqrt)
00459 
00460 #undef _DEFINE_EXPR_UNARY_FUNCTION
00461 
00462 #define _DEFINE_EXPR_BINARY_FUNCTION(_Fun, _UFun)                      \
00463   template<class _Dom1, class _Dom2>                                   \
00464     inline _Expr<_BinClos<_UFun, _Expr, _Expr, _Dom1, _Dom2>,          \
00465                  typename _Dom1::value_type>                           \
00466     _Fun(const _Expr<_Dom1, typename _Dom1::value_type>& __e1,         \
00467          const _Expr<_Dom2, typename _Dom2::value_type>& __e2)         \
00468     {                                                                  \
00469       typedef typename _Dom1::value_type _Tp;                          \
00470       typedef _BinClos<_UFun, _Expr, _Expr, _Dom1, _Dom2> _Closure;    \
00471       return _Expr<_Closure, _Tp>(_Closure(__e1(), __e2()));           \
00472     }                                                                  \
00473                                                                        \
00474   template<class _Dom>                                                 \
00475     inline _Expr<_BinClos<_UFun, _Expr, _ValArray, _Dom,               \
00476                           typename _Dom::value_type>,                  \
00477                  typename _Dom::value_type>                            \
00478     _Fun(const _Expr<_Dom, typename _Dom::value_type>& __e,            \
00479          const valarray<typename _Dom::value_type>& __v)               \
00480     {                                                                  \
00481       typedef typename _Dom::value_type _Tp;                           \
00482       typedef _BinClos<_UFun, _Expr, _ValArray, _Dom, _Tp> _Closure;   \
00483       return _Expr<_Closure, _Tp>(_Closure(__e(), __v));               \
00484     }                                                                  \
00485                                                                        \
00486   template<class _Dom>                                                 \
00487     inline _Expr<_BinClos<_UFun, _ValArray, _Expr,                     \
00488                           typename _Dom::value_type, _Dom>,            \
00489                  typename _Dom::value_type>                            \
00490     _Fun(const valarray<typename _Dom::valarray>& __v,                 \
00491          const _Expr<_Dom, typename _Dom::value_type>& __e)            \
00492     {                                                                  \
00493       typedef typename _Dom::value_type _Tp;                           \
00494       typedef _BinClos<_UFun, _ValArray, _Expr, _Tp, _Dom> _Closure;   \
00495       return _Expr<_Closure, _Tp>(_Closure(__v, __e()));               \
00496     }                                                                  \
00497                                                                        \
00498   template<class _Dom>                                                 \
00499     inline _Expr<_BinClos<_UFun, _Expr, _Constant, _Dom,               \
00500                           typename _Dom::value_type>,                  \
00501                  typename _Dom::value_type>                            \
00502     _Fun(const _Expr<_Dom, typename _Dom::value_type>& __e,            \
00503          const typename _Dom::value_type& __t)                         \
00504     {                                                                  \
00505       typedef typename _Dom::value_type _Tp;                           \
00506       typedef _BinClos<_UFun, _Expr, _Constant, _Dom, _Tp> _Closure;   \
00507       return _Expr<_Closure, _Tp>(_Closure(__e(), __t));               \
00508     }                                                                  \
00509                                                                        \
00510   template<class _Dom>                                                 \
00511     inline _Expr<_BinClos<_UFun, _Constant, _Expr,                     \
00512                           typename _Dom::value_type, _Dom>,            \
00513                  typename _Dom::value_type>                            \
00514     _Fun(const typename _Dom::value_type& __t,                         \
00515          const _Expr<_Dom, typename _Dom::value_type>& __e)            \
00516     {                                                                  \
00517       typedef typename _Dom::value_type _Tp;                           \
00518       typedef _BinClos<_UFun, _Constant, _Expr, _Tp, _Dom> _Closure;   \
00519       return _Expr<_Closure, _Tp>(_Closure(__t, __e()));               \
00520     }                                                                  \
00521                                                                        \
00522   template<typename _Tp>                                               \
00523     inline _Expr<_BinClos<_UFun, _ValArray, _ValArray, _Tp, _Tp>, _Tp> \
00524     _Fun(const valarray<_Tp>& __v, const valarray<_Tp>& __w)           \
00525     {                                                                  \
00526       typedef _BinClos<_UFun, _ValArray, _ValArray, _Tp, _Tp> _Closure;\
00527       return _Expr<_Closure, _Tp>(_Closure(__v, __w));                 \
00528     }                                                                  \
00529                                                                        \
00530   template<typename _Tp>                                               \
00531     inline _Expr<_BinClos<_UFun, _ValArray, _Constant, _Tp, _Tp>, _Tp> \
00532     _Fun(const valarray<_Tp>& __v,                                     \
00533          const typename valarray<_Tp>::value_type& __t)                \
00534     {                                                                  \
00535       typedef _BinClos<_UFun, _ValArray, _Constant, _Tp, _Tp> _Closure;\
00536       return _Expr<_Closure, _Tp>(_Closure(__v, __t));                 \
00537     }                                                                  \
00538                                                                        \
00539   template<typename _Tp>                                               \
00540     inline _Expr<_BinClos<_UFun, _Constant, _ValArray, _Tp, _Tp>, _Tp> \
00541     _Fun(const typename valarray<_Tp>::value_type& __t,                \
00542          const valarray<_Tp>& __v)                                     \
00543     {                                                                  \
00544       typedef _BinClos<_UFun, _Constant, _ValArray, _Tp, _Tp> _Closure;\
00545       return _Expr<_Closure, _Tp>(_Closure(__t, __v));                 \
00546     }
00547 
00548 _DEFINE_EXPR_BINARY_FUNCTION(atan2, _Atan2)
00549 _DEFINE_EXPR_BINARY_FUNCTION(pow, _Pow)
00550 
00551 #undef _DEFINE_EXPR_BINARY_FUNCTION
00552 
00553 _GLIBCXX_END_NAMESPACE_VERSION
00554 } // namespace
00555 
00556 #endif /* _CPP_VALARRAY_AFTER_H */