gccxml_gem 0.9-x86-darwin-9
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +75 -0
- data/bin/gccxml +0 -0
- data/bin/gccxml_cc1plus +0 -0
- data/gccxml.rb +44 -0
- data/share/doc/gccxml-0.9/Copyright.txt +55 -0
- data/share/doc/gccxml-0.9/gccxml.html +168 -0
- data/share/doc/gccxml-0.9/gccxml.txt +293 -0
- data/share/gccxml-0.9/GCC/2.95/algorithm +76 -0
- data/share/gccxml-0.9/GCC/2.95/bitset +17 -0
- data/share/gccxml-0.9/GCC/2.95/cctype +24 -0
- data/share/gccxml-0.9/GCC/2.95/clocale +14 -0
- data/share/gccxml-0.9/GCC/2.95/cmath +33 -0
- data/share/gccxml-0.9/GCC/2.95/complex +38 -0
- data/share/gccxml-0.9/GCC/2.95/csetjmp +13 -0
- data/share/gccxml-0.9/GCC/2.95/csignal +14 -0
- data/share/gccxml-0.9/GCC/2.95/cstdarg +12 -0
- data/share/gccxml-0.9/GCC/2.95/cstddef +13 -0
- data/share/gccxml-0.9/GCC/2.95/cstdio +55 -0
- data/share/gccxml-0.9/GCC/2.95/cstdlib +66 -0
- data/share/gccxml-0.9/GCC/2.95/cstring +34 -0
- data/share/gccxml-0.9/GCC/2.95/ctime +24 -0
- data/share/gccxml-0.9/GCC/2.95/cwchar +65 -0
- data/share/gccxml-0.9/GCC/2.95/cwctype +31 -0
- data/share/gccxml-0.9/GCC/2.95/deque +19 -0
- data/share/gccxml-0.9/GCC/2.95/exception +20 -0
- data/share/gccxml-0.9/GCC/2.95/fstream +23 -0
- data/share/gccxml-0.9/GCC/2.95/functional +64 -0
- data/share/gccxml-0.9/GCC/2.95/gccxml_bitset +1066 -0
- data/share/gccxml-0.9/GCC/2.95/iomanip +20 -0
- data/share/gccxml-0.9/GCC/2.95/iosfwd +20 -0
- data/share/gccxml-0.9/GCC/2.95/iostream +27 -0
- data/share/gccxml-0.9/GCC/2.95/iterator +39 -0
- data/share/gccxml-0.9/GCC/2.95/list +19 -0
- data/share/gccxml-0.9/GCC/2.95/map +20 -0
- data/share/gccxml-0.9/GCC/2.95/memory +21 -0
- data/share/gccxml-0.9/GCC/2.95/new +13 -0
- data/share/gccxml-0.9/GCC/2.95/numeric +15 -0
- data/share/gccxml-0.9/GCC/2.95/pthread.h +16 -0
- data/share/gccxml-0.9/GCC/2.95/queue +20 -0
- data/share/gccxml-0.9/GCC/2.95/set +20 -0
- data/share/gccxml-0.9/GCC/2.95/sstream +24 -0
- data/share/gccxml-0.9/GCC/2.95/stack +19 -0
- data/share/gccxml-0.9/GCC/2.95/std/bastring.cc +524 -0
- data/share/gccxml-0.9/GCC/2.95/std/complext.h +397 -0
- data/share/gccxml-0.9/GCC/2.95/std/dcomplex.h +92 -0
- data/share/gccxml-0.9/GCC/2.95/std/fcomplex.h +88 -0
- data/share/gccxml-0.9/GCC/2.95/std/gslice_array.h +170 -0
- data/share/gccxml-0.9/GCC/2.95/std/indirect_array.h +157 -0
- data/share/gccxml-0.9/GCC/2.95/std/ldcomplex.h +96 -0
- data/share/gccxml-0.9/GCC/2.95/std/mask_array.h +154 -0
- data/share/gccxml-0.9/GCC/2.95/std/slice_array.h +156 -0
- data/share/gccxml-0.9/GCC/2.95/std/std_valarray.h +728 -0
- data/share/gccxml-0.9/GCC/2.95/std/straits.h +162 -0
- data/share/gccxml-0.9/GCC/2.95/std/valarray_meta.h +1035 -0
- data/share/gccxml-0.9/GCC/2.95/stdexcept +17 -0
- data/share/gccxml-0.9/GCC/2.95/stl_alloc.h +1057 -0
- data/share/gccxml-0.9/GCC/2.95/stl_bvector.h +836 -0
- data/share/gccxml-0.9/GCC/2.95/stl_deque.h +1699 -0
- data/share/gccxml-0.9/GCC/2.95/stl_list.h +843 -0
- data/share/gccxml-0.9/GCC/2.95/stl_tree.h +1331 -0
- data/share/gccxml-0.9/GCC/2.95/stl_vector.h +828 -0
- data/share/gccxml-0.9/GCC/2.95/string +26 -0
- data/share/gccxml-0.9/GCC/2.95/strstream +23 -0
- data/share/gccxml-0.9/GCC/2.95/typeinfo +11 -0
- data/share/gccxml-0.9/GCC/2.95/utility +25 -0
- data/share/gccxml-0.9/GCC/2.95/valarray +52 -0
- data/share/gccxml-0.9/GCC/2.95/vector +19 -0
- data/share/gccxml-0.9/GCC/2.96/sstream +305 -0
- data/share/gccxml-0.9/GCC/3.0/pthread.h +16 -0
- data/share/gccxml-0.9/GCC/3.1/pthread.h +16 -0
- data/share/gccxml-0.9/GCC/3.2/bits/fstream.tcc +500 -0
- data/share/gccxml-0.9/GCC/3.2/bits/istream.tcc +1207 -0
- data/share/gccxml-0.9/GCC/3.2/bits/locale_facets.h +1810 -0
- data/share/gccxml-0.9/GCC/3.2/bits/locale_facets.tcc +2397 -0
- data/share/gccxml-0.9/GCC/3.2/bits/messages_members.h +108 -0
- data/share/gccxml-0.9/GCC/3.2/bits/ostream.tcc +713 -0
- data/share/gccxml-0.9/GCC/3.2/bits/sstream.tcc +241 -0
- data/share/gccxml-0.9/GCC/3.2/bits/stl_deque.h +1682 -0
- data/share/gccxml-0.9/GCC/3.2/bits/stl_list.h +989 -0
- data/share/gccxml-0.9/GCC/3.2/bits/stl_tree.h +1462 -0
- data/share/gccxml-0.9/GCC/3.2/bits/stl_vector.h +1085 -0
- data/share/gccxml-0.9/GCC/3.2/bits/valarray_meta.h +1063 -0
- data/share/gccxml-0.9/GCC/3.2/fstream +579 -0
- data/share/gccxml-0.9/GCC/3.2/pthread.h +16 -0
- data/share/gccxml-0.9/GCC/3.2/sstream +384 -0
- data/share/gccxml-0.9/GCC/3.3/bits/fstream.tcc +530 -0
- data/share/gccxml-0.9/GCC/3.3/bits/list.tcc +378 -0
- data/share/gccxml-0.9/GCC/3.3/bits/locale_facets.h +2050 -0
- data/share/gccxml-0.9/GCC/3.3/bits/messages_members.h +108 -0
- data/share/gccxml-0.9/GCC/3.3/bits/sstream.tcc +243 -0
- data/share/gccxml-0.9/GCC/3.3/bits/stl_deque.h +1603 -0
- data/share/gccxml-0.9/GCC/3.3/bits/stl_list.h +1167 -0
- data/share/gccxml-0.9/GCC/3.3/bits/stl_tree.h +1462 -0
- data/share/gccxml-0.9/GCC/3.3/bits/stl_vector.h +992 -0
- data/share/gccxml-0.9/GCC/3.3/bits/valarray_meta.h +1135 -0
- data/share/gccxml-0.9/GCC/3.3/fstream +842 -0
- data/share/gccxml-0.9/GCC/3.3/gccxml_builtins.h +22 -0
- data/share/gccxml-0.9/GCC/3.3/sstream +638 -0
- data/share/gccxml-0.9/GCC/3.4/gccxml_builtins.h +91 -0
- data/share/gccxml-0.9/GCC/4.0/gccxml_builtins.h +128 -0
- data/share/gccxml-0.9/GCC/4.1/bits/gthr-default.h +618 -0
- data/share/gccxml-0.9/GCC/4.1/gccxml_builtins.h +131 -0
- data/share/gccxml-0.9/GCC/4.2/gccxml_builtins.h +131 -0
- data/share/gccxml-0.9/GCC/find_flags +105 -0
- data/share/gccxml-0.9/Intel/find_flags +56 -0
- data/share/gccxml-0.9/Intel/pthread.h +16 -0
- data/share/gccxml-0.9/MIPSpro/7.3/exception +9 -0
- data/share/gccxml-0.9/MIPSpro/7.3/gccxml_mpro_internals.h +21 -0
- data/share/gccxml-0.9/MIPSpro/7.3/iomanip +161 -0
- data/share/gccxml-0.9/MIPSpro/7.3/ostream +9 -0
- data/share/gccxml-0.9/MIPSpro/7.3/stddef.h +9 -0
- data/share/gccxml-0.9/MIPSpro/7.3/stl_config.h +9 -0
- data/share/gccxml-0.9/MIPSpro/7.3/stl_locale.h +17 -0
- data/share/gccxml-0.9/MIPSpro/7.3/stl_monetary.h +14 -0
- data/share/gccxml-0.9/MIPSpro/7.3/stl_numeric_facets.h +13 -0
- data/share/gccxml-0.9/MIPSpro/7.3/stl_threads.h +11 -0
- data/share/gccxml-0.9/MIPSpro/7.3/string +18 -0
- data/share/gccxml-0.9/MIPSpro/find_flags +137 -0
- data/share/gccxml-0.9/Sun/5.8/adaptation.patch +168 -0
- data/share/gccxml-0.9/Sun/README +8 -0
- data/share/gccxml-0.9/Sun/adapt_headers.sh +24 -0
- data/share/gccxml-0.9/Sun/find_flags +69 -0
- data/share/gccxml-0.9/gccxml_config +2 -0
- data/share/gccxml-0.9/gccxml_find_flags +93 -0
- data/share/man/man1/gccxml.1 +246 -0
- metadata +204 -0
@@ -0,0 +1,154 @@
|
|
1
|
+
// The template and inlines for the -*- C++ -*- mask_array class.
|
2
|
+
|
3
|
+
// Copyright (C) 1997-1999 Cygnus Solutions
|
4
|
+
//
|
5
|
+
// This file is part of the GNU ISO C++ Library. This library is free
|
6
|
+
// software; you can redistribute it and/or modify it under the
|
7
|
+
// terms of the GNU General Public License as published by the
|
8
|
+
// Free Software Foundation; either version 2, or (at your option)
|
9
|
+
// any later version.
|
10
|
+
|
11
|
+
// This library is distributed in the hope that it will be useful,
|
12
|
+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
// GNU General Public License for more details.
|
15
|
+
|
16
|
+
// You should have received a copy of the GNU General Public License along
|
17
|
+
// with this library; see the file COPYING. If not, write to the Free
|
18
|
+
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
19
|
+
// USA.
|
20
|
+
|
21
|
+
// As a special exception, you may use this file as part of a free software
|
22
|
+
// library without restriction. Specifically, if other files instantiate
|
23
|
+
// templates or use macros or inline functions from this file, or you compile
|
24
|
+
// this file and link it with other files to produce an executable, this
|
25
|
+
// file does not by itself cause the resulting executable to be covered by
|
26
|
+
// the GNU General Public License. This exception does not however
|
27
|
+
// invalidate any other reasons why the executable file might be covered by
|
28
|
+
// the GNU General Public License.
|
29
|
+
|
30
|
+
// Written by Gabriel Dos Reis <Gabriel.Dos-Reis@DPTMaths.ENS-Cachan.Fr>
|
31
|
+
|
32
|
+
#ifndef __MASK_ARRAY__
|
33
|
+
#define __MASK_ARRAY__
|
34
|
+
|
35
|
+
extern "C++" {
|
36
|
+
|
37
|
+
template <class _T> class mask_array
|
38
|
+
{
|
39
|
+
public:
|
40
|
+
typedef _T value_type;
|
41
|
+
|
42
|
+
void operator= (const valarray<_T>&) const;
|
43
|
+
void operator*= (const valarray<_T>&) const;
|
44
|
+
void operator/= (const valarray<_T>&) const;
|
45
|
+
void operator%= (const valarray<_T>&) const;
|
46
|
+
void operator+= (const valarray<_T>&) const;
|
47
|
+
void operator-= (const valarray<_T>&) const;
|
48
|
+
void operator^= (const valarray<_T>&) const;
|
49
|
+
void operator&= (const valarray<_T>&) const;
|
50
|
+
void operator|= (const valarray<_T>&) const;
|
51
|
+
void operator<<=(const valarray<_T>&) const;
|
52
|
+
void operator>>=(const valarray<_T>&) const;
|
53
|
+
void operator= (const _T&);
|
54
|
+
|
55
|
+
template<class _Dom>
|
56
|
+
void operator= (const _Expr<_Dom,_T>&) const;
|
57
|
+
template<class _Dom>
|
58
|
+
void operator*= (const _Expr<_Dom,_T>&) const;
|
59
|
+
template<class _Dom>
|
60
|
+
void operator/= (const _Expr<_Dom,_T>&) const;
|
61
|
+
template<class _Dom>
|
62
|
+
void operator%= (const _Expr<_Dom,_T>&) const;
|
63
|
+
template<class _Dom>
|
64
|
+
void operator+= (const _Expr<_Dom,_T>&) const;
|
65
|
+
template<class _Dom>
|
66
|
+
void operator-= (const _Expr<_Dom,_T>&) const;
|
67
|
+
template<class _Dom>
|
68
|
+
void operator^= (const _Expr<_Dom,_T>&) const;
|
69
|
+
template<class _Dom>
|
70
|
+
void operator&= (const _Expr<_Dom,_T>&) const;
|
71
|
+
template<class _Dom>
|
72
|
+
void operator|= (const _Expr<_Dom,_T>&) const;
|
73
|
+
template<class _Dom>
|
74
|
+
void operator<<=(const _Expr<_Dom,_T>&) const;
|
75
|
+
template<class _Dom>
|
76
|
+
void operator>>=(const _Expr<_Dom,_T>&) const;
|
77
|
+
|
78
|
+
private:
|
79
|
+
mask_array (_Array<_T>, size_t, _Array<bool>);
|
80
|
+
friend class valarray<_T>;
|
81
|
+
|
82
|
+
const size_t _M_sz;
|
83
|
+
const _Array<bool> _M_mask;
|
84
|
+
const _Array<_T> _M_array;
|
85
|
+
|
86
|
+
mask_array (const mask_array&);
|
87
|
+
|
88
|
+
// not implemented
|
89
|
+
mask_array ();
|
90
|
+
mask_array& operator= (const mask_array&);
|
91
|
+
};
|
92
|
+
|
93
|
+
template<typename _Tp>
|
94
|
+
inline mask_array<_Tp>::mask_array (const mask_array<_Tp>& a)
|
95
|
+
: _M_sz (a._M_sz), _M_mask (a._M_mask), _M_array (a._M_array) {}
|
96
|
+
|
97
|
+
template<typename _T>
|
98
|
+
inline
|
99
|
+
mask_array<_T>::mask_array (_Array<_T> __a, size_t __s, _Array<bool> __m)
|
100
|
+
: _M_sz (__s), _M_mask (__m), _M_array (__a) {}
|
101
|
+
|
102
|
+
template<typename _T>
|
103
|
+
inline void
|
104
|
+
mask_array<_T>::operator= (const _T& __t)
|
105
|
+
{ __valarray_fill (_M_array, _M_sz, _M_mask, __t); }
|
106
|
+
|
107
|
+
template<typename _T>
|
108
|
+
inline void
|
109
|
+
mask_array<_T>::operator= (const valarray<_T>& __v) const
|
110
|
+
{ __valarray_copy (_Array<_T> (__v), __v.size (), _M_array, _M_mask); }
|
111
|
+
|
112
|
+
template<typename _T>
|
113
|
+
template<class E>
|
114
|
+
inline void
|
115
|
+
mask_array<_T>::operator= (const _Expr<E, _T>& __e) const
|
116
|
+
{ __valarray_copy (__e, __e.size (), _M_array, _M_mask); }
|
117
|
+
|
118
|
+
#undef _DEFINE_VALARRAY_OPERATOR
|
119
|
+
#define _DEFINE_VALARRAY_OPERATOR(op, name) \
|
120
|
+
template<typename _T> \
|
121
|
+
inline void \
|
122
|
+
mask_array<_T>::operator op##= (const valarray<_T>& __v) const \
|
123
|
+
{ \
|
124
|
+
_Array_augmented_##name (_M_array, _M_mask, \
|
125
|
+
_Array<_T> (__v), __v.size ()); \
|
126
|
+
} \
|
127
|
+
\
|
128
|
+
template<typename _T> template<class E> \
|
129
|
+
inline void \
|
130
|
+
mask_array<_T>::operator op##= (const _Expr<E, _T>& __e) const \
|
131
|
+
{ \
|
132
|
+
_Array_augmented_##name (_M_array, _M_mask, __e, __e.size ()); \
|
133
|
+
}
|
134
|
+
|
135
|
+
_DEFINE_VALARRAY_OPERATOR(*, multiplies)
|
136
|
+
_DEFINE_VALARRAY_OPERATOR(/, divides)
|
137
|
+
_DEFINE_VALARRAY_OPERATOR(%, modulus)
|
138
|
+
_DEFINE_VALARRAY_OPERATOR(+, plus)
|
139
|
+
_DEFINE_VALARRAY_OPERATOR(-, minus)
|
140
|
+
_DEFINE_VALARRAY_OPERATOR(^, xor)
|
141
|
+
_DEFINE_VALARRAY_OPERATOR(&, and)
|
142
|
+
_DEFINE_VALARRAY_OPERATOR(|, or)
|
143
|
+
_DEFINE_VALARRAY_OPERATOR(<<, shift_left)
|
144
|
+
_DEFINE_VALARRAY_OPERATOR(>>, shift_right)
|
145
|
+
|
146
|
+
#undef _DEFINE_VALARRAY_OPERATOR
|
147
|
+
|
148
|
+
} // extern "C++"
|
149
|
+
|
150
|
+
#endif // __MASK_ARRAY__
|
151
|
+
|
152
|
+
// Local Variables:
|
153
|
+
// mode:c++
|
154
|
+
// End:
|
@@ -0,0 +1,156 @@
|
|
1
|
+
// The template and inlines for the -*- C++ -*- slice_array class.
|
2
|
+
|
3
|
+
// Copyright (C) 1997-1999 Cygnus Solutions
|
4
|
+
//
|
5
|
+
// This file is part of the GNU ISO C++ Library. This library is free
|
6
|
+
// software; you can redistribute it and/or modify it under the
|
7
|
+
// terms of the GNU General Public License as published by the
|
8
|
+
// Free Software Foundation; either version 2, or (at your option)
|
9
|
+
// any later version.
|
10
|
+
|
11
|
+
// This library is distributed in the hope that it will be useful,
|
12
|
+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
// GNU General Public License for more details.
|
15
|
+
|
16
|
+
// You should have received a copy of the GNU General Public License along
|
17
|
+
// with this library; see the file COPYING. If not, write to the Free
|
18
|
+
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
19
|
+
// USA.
|
20
|
+
|
21
|
+
// As a special exception, you may use this file as part of a free software
|
22
|
+
// library without restriction. Specifically, if other files instantiate
|
23
|
+
// templates or use macros or inline functions from this file, or you compile
|
24
|
+
// this file and link it with other files to produce an executable, this
|
25
|
+
// file does not by itself cause the resulting executable to be covered by
|
26
|
+
// the GNU General Public License. This exception does not however
|
27
|
+
// invalidate any other reasons why the executable file might be covered by
|
28
|
+
// the GNU General Public License.
|
29
|
+
|
30
|
+
// Written by Gabriel Dos Reis <Gabriel.Dos-Reis@DPTMaths.ENS-Cachan.Fr>
|
31
|
+
|
32
|
+
#ifndef __SLICE_ARRAY__
|
33
|
+
#define __SLICE_ARRAY__
|
34
|
+
|
35
|
+
extern "C++" {
|
36
|
+
|
37
|
+
template<typename _T>
|
38
|
+
class slice_array
|
39
|
+
{
|
40
|
+
public:
|
41
|
+
typedef _T value_type;
|
42
|
+
|
43
|
+
void operator= (const valarray<_T>&) const;
|
44
|
+
void operator*= (const valarray<_T>&) const;
|
45
|
+
void operator/= (const valarray<_T>&) const;
|
46
|
+
void operator%= (const valarray<_T>&) const;
|
47
|
+
void operator+= (const valarray<_T>&) const;
|
48
|
+
void operator-= (const valarray<_T>&) const;
|
49
|
+
void operator^= (const valarray<_T>&) const;
|
50
|
+
void operator&= (const valarray<_T>&) const;
|
51
|
+
void operator|= (const valarray<_T>&) const;
|
52
|
+
void operator<<= (const valarray<_T>&) const;
|
53
|
+
void operator>>= (const valarray<_T>&) const;
|
54
|
+
void operator= (const _T &);
|
55
|
+
|
56
|
+
template<class _Dom>
|
57
|
+
void operator= (const _Expr<_Dom,_T>&) const;
|
58
|
+
template<class _Dom>
|
59
|
+
void operator*= (const _Expr<_Dom,_T>&) const;
|
60
|
+
template<class _Dom>
|
61
|
+
void operator/= (const _Expr<_Dom,_T>&) const;
|
62
|
+
template<class _Dom>
|
63
|
+
void operator%= (const _Expr<_Dom,_T>&) const;
|
64
|
+
template<class _Dom>
|
65
|
+
void operator+= (const _Expr<_Dom,_T>&) const;
|
66
|
+
template<class _Dom>
|
67
|
+
void operator-= (const _Expr<_Dom,_T>&) const;
|
68
|
+
template<class _Dom>
|
69
|
+
void operator^= (const _Expr<_Dom,_T>&) const;
|
70
|
+
template<class _Dom>
|
71
|
+
void operator&= (const _Expr<_Dom,_T>&) const;
|
72
|
+
template<class _Dom>
|
73
|
+
void operator|= (const _Expr<_Dom,_T>&) const;
|
74
|
+
template<class _Dom>
|
75
|
+
void operator<<= (const _Expr<_Dom,_T>&) const;
|
76
|
+
template<class _Dom>
|
77
|
+
void operator>>= (const _Expr<_Dom,_T>&) const;
|
78
|
+
|
79
|
+
private:
|
80
|
+
friend class valarray<_T>;
|
81
|
+
slice_array(_Array<_T>, const slice&);
|
82
|
+
|
83
|
+
const size_t _M_sz;
|
84
|
+
const size_t _M_stride;
|
85
|
+
const _Array<_T> _M_array;
|
86
|
+
|
87
|
+
// this constructor is implemented since we need to return a value.
|
88
|
+
slice_array (const slice_array&);
|
89
|
+
|
90
|
+
// not implemented
|
91
|
+
slice_array ();
|
92
|
+
slice_array& operator= (const slice_array&);
|
93
|
+
};
|
94
|
+
|
95
|
+
template<typename _T>
|
96
|
+
inline slice_array<_T>::slice_array (_Array<_T> __a, const slice& __s)
|
97
|
+
: _M_sz (__s.size ()), _M_stride (__s.stride ()),
|
98
|
+
_M_array (__a.begin () + __s.start ()) {}
|
99
|
+
|
100
|
+
template<typename _Tp>
|
101
|
+
inline slice_array<_Tp>::slice_array(const slice_array<_Tp>& a)
|
102
|
+
: _M_sz(a._M_sz), _M_stride(a._M_stride), _M_array(a._M_array) {}
|
103
|
+
|
104
|
+
template<typename _T>
|
105
|
+
inline void
|
106
|
+
slice_array<_T>::operator= (const _T& __t)
|
107
|
+
{ __valarray_fill (_M_array, _M_sz, _M_stride, __t); }
|
108
|
+
|
109
|
+
template<typename _T>
|
110
|
+
inline void
|
111
|
+
slice_array<_T>::operator= (const valarray<_T>& __v) const
|
112
|
+
{ __valarray_copy (_Array<_T> (__v), _M_array, _M_sz, _M_stride); }
|
113
|
+
|
114
|
+
template<typename _T>
|
115
|
+
template<class _Dom>
|
116
|
+
inline void
|
117
|
+
slice_array<_T>::operator= (const _Expr<_Dom,_T>& __e) const
|
118
|
+
{ __valarray_copy (__e, _M_sz, _M_array, _M_stride); }
|
119
|
+
|
120
|
+
#undef _DEFINE_VALARRAY_OPERATOR
|
121
|
+
#define _DEFINE_VALARRAY_OPERATOR(op, name) \
|
122
|
+
template<typename _T> \
|
123
|
+
inline void \
|
124
|
+
slice_array<_T>::operator op##= (const valarray<_T>& __v) const \
|
125
|
+
{ \
|
126
|
+
_Array_augmented_##name (_M_array, _M_sz, _M_stride, _Array<_T> (__v));\
|
127
|
+
} \
|
128
|
+
\
|
129
|
+
template<typename _T> template<class _Dom> \
|
130
|
+
inline void \
|
131
|
+
slice_array<_T>::operator op##= (const _Expr<_Dom,_T>& __e) const \
|
132
|
+
{ \
|
133
|
+
_Array_augmented_##name (_M_array, _M_stride, __e, _M_sz); \
|
134
|
+
}
|
135
|
+
|
136
|
+
|
137
|
+
_DEFINE_VALARRAY_OPERATOR(*, multiplies)
|
138
|
+
_DEFINE_VALARRAY_OPERATOR(/, divides)
|
139
|
+
_DEFINE_VALARRAY_OPERATOR(%, modulus)
|
140
|
+
_DEFINE_VALARRAY_OPERATOR(+, plus)
|
141
|
+
_DEFINE_VALARRAY_OPERATOR(-, minus)
|
142
|
+
_DEFINE_VALARRAY_OPERATOR(^, xor)
|
143
|
+
_DEFINE_VALARRAY_OPERATOR(&, and)
|
144
|
+
_DEFINE_VALARRAY_OPERATOR(|, or)
|
145
|
+
_DEFINE_VALARRAY_OPERATOR(<<, shift_left)
|
146
|
+
_DEFINE_VALARRAY_OPERATOR(>>, shift_right)
|
147
|
+
|
148
|
+
#undef _DEFINE_VALARRAY_OPERATOR
|
149
|
+
|
150
|
+
} // extern "C++"
|
151
|
+
|
152
|
+
#endif // __SLICE_ARRAY__
|
153
|
+
|
154
|
+
// Local Variables:
|
155
|
+
// mode:c++
|
156
|
+
// End:
|
@@ -0,0 +1,728 @@
|
|
1
|
+
// The template and inlines for the -*- C++ -*- valarray class.
|
2
|
+
|
3
|
+
// Copyright (C) 1997-1999 Cygnus Solutions
|
4
|
+
//
|
5
|
+
// This file is part of the GNU ISO C++ Library. This library is free
|
6
|
+
// software; you can redistribute it and/or modify it under the
|
7
|
+
// terms of the GNU General Public License as published by the
|
8
|
+
// Free Software Foundation; either version 2, or (at your option)
|
9
|
+
// any later version.
|
10
|
+
|
11
|
+
// This library is distributed in the hope that it will be useful,
|
12
|
+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
// GNU General Public License for more details.
|
15
|
+
|
16
|
+
// You should have received a copy of the GNU General Public License along
|
17
|
+
// with this library; see the file COPYING. If not, write to the Free
|
18
|
+
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
19
|
+
// USA.
|
20
|
+
|
21
|
+
// As a special exception, you may use this file as part of a free software
|
22
|
+
// library without restriction. Specifically, if other files instantiate
|
23
|
+
// templates or use macros or inline functions from this file, or you compile
|
24
|
+
// this file and link it with other files to produce an executable, this
|
25
|
+
// file does not by itself cause the resulting executable to be covered by
|
26
|
+
// the GNU General Public License. This exception does not however
|
27
|
+
// invalidate any other reasons why the executable file might be covered by
|
28
|
+
// the GNU General Public License.
|
29
|
+
|
30
|
+
// Written by Gabriel Dos Reis <Gabriel.Dos-Reis@DPTMaths.ENS-Cachan.Fr>
|
31
|
+
|
32
|
+
#ifndef __STD_VALARRAY__
|
33
|
+
#define __STD_VALARRAY__
|
34
|
+
#define _G_NO_VALARRAY_TEMPLATE_EXPORT 1
|
35
|
+
|
36
|
+
#include <cstddef>
|
37
|
+
#include <cmath>
|
38
|
+
#include <cstdlib>
|
39
|
+
#include <numeric>
|
40
|
+
#include <functional>
|
41
|
+
#include <algorithm>
|
42
|
+
|
43
|
+
#ifndef alloca
|
44
|
+
#ifdef __GNUC__
|
45
|
+
#define alloca __builtin_alloca
|
46
|
+
#else /* not GNU C. */
|
47
|
+
#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
|
48
|
+
#include <alloca.h>
|
49
|
+
#else /* not sparc */
|
50
|
+
#if defined (MSDOS) && !defined (__TURBOC__)
|
51
|
+
#include <malloc.h>
|
52
|
+
#else /* not MSDOS, or __TURBOC__ */
|
53
|
+
#if defined(_AIX)
|
54
|
+
#include <malloc.h>
|
55
|
+
#pragma alloca
|
56
|
+
#else /* not MSDOS, __TURBOC__, or _AIX */
|
57
|
+
#ifdef __hpux
|
58
|
+
#endif /* __hpux */
|
59
|
+
#endif /* not _AIX */
|
60
|
+
#endif /* not MSDOS, or __TURBOC__ */
|
61
|
+
#endif /* not sparc. */
|
62
|
+
#endif /* not GNU C. */
|
63
|
+
#endif /* alloca not defined. */
|
64
|
+
|
65
|
+
extern "C" {
|
66
|
+
void* alloca(size_t);
|
67
|
+
}
|
68
|
+
|
69
|
+
|
70
|
+
extern "C++" {
|
71
|
+
|
72
|
+
template<class _Clos, typename _Tp> class _Expr;
|
73
|
+
|
74
|
+
template<typename _Tp1, typename _Tp2> class _ValArray;
|
75
|
+
|
76
|
+
template<template<class> class _Oper,
|
77
|
+
template<class, class> class _Meta, class _Dom> struct _UnClos;
|
78
|
+
|
79
|
+
template<template<class> class _Oper,
|
80
|
+
template<class, class> class _Meta1,
|
81
|
+
template<class, class> class _Meta2,
|
82
|
+
class _Dom1, class _Dom2> class _BinClos;
|
83
|
+
|
84
|
+
template<template<class, class> class _Meta, class _Dom> class _SClos;
|
85
|
+
|
86
|
+
template<template<class, class> class _Meta, class _Dom> class _GClos;
|
87
|
+
|
88
|
+
template<template<class, class> class _Meta, class _Dom> class _IClos;
|
89
|
+
|
90
|
+
template<template<class, class> class _Meta, class _Dom> class _ValFunClos;
|
91
|
+
|
92
|
+
template<template<class, class> class _Meta, class _Dom> class _RefFunClos;
|
93
|
+
|
94
|
+
template<class _Tp> struct _Unary_plus;
|
95
|
+
template<class _Tp> struct _Bitwise_and;
|
96
|
+
template<class _Tp> struct _Bitwise_or;
|
97
|
+
template<class _Tp> struct _Bitwise_xor;
|
98
|
+
template<class _Tp> struct _Bitwise_not;
|
99
|
+
template<class _Tp> struct _Shift_left;
|
100
|
+
template<class _Tp> struct _Shift_right;
|
101
|
+
|
102
|
+
template<class _Tp> class valarray; // An array of type _Tp
|
103
|
+
class slice; // BLAS-like slice out of an array
|
104
|
+
template<class _Tp> class slice_array;
|
105
|
+
class gslice; // generalized slice out of an array
|
106
|
+
template<class _Tp> class gslice_array;
|
107
|
+
template<class _Tp> class mask_array; // masked array
|
108
|
+
template<class _Tp> class indirect_array; // indirected array
|
109
|
+
|
110
|
+
} // extern "C++"
|
111
|
+
|
112
|
+
#include <std/valarray_array.h>
|
113
|
+
#include <std/valarray_meta.h>
|
114
|
+
|
115
|
+
extern "C++" {
|
116
|
+
|
117
|
+
template<class _Tp> class valarray
|
118
|
+
{
|
119
|
+
public:
|
120
|
+
typedef _Tp value_type;
|
121
|
+
|
122
|
+
// _lib.valarray.cons_ construct/destroy:
|
123
|
+
valarray();
|
124
|
+
explicit valarray(size_t);
|
125
|
+
valarray(const _Tp&, size_t);
|
126
|
+
valarray(const _Tp* __restrict__, size_t);
|
127
|
+
valarray(const valarray&);
|
128
|
+
valarray(const slice_array<_Tp>&);
|
129
|
+
valarray(const gslice_array<_Tp>&);
|
130
|
+
valarray(const mask_array<_Tp>&);
|
131
|
+
valarray(const indirect_array<_Tp>&);
|
132
|
+
template<class _Dom>
|
133
|
+
valarray(const _Expr<_Dom,_Tp>& __e);
|
134
|
+
~valarray();
|
135
|
+
|
136
|
+
// _lib.valarray.assign_ assignment:
|
137
|
+
valarray<_Tp>& operator=(const valarray<_Tp>&);
|
138
|
+
valarray<_Tp>& operator=(const _Tp&);
|
139
|
+
valarray<_Tp>& operator=(const slice_array<_Tp>&);
|
140
|
+
valarray<_Tp>& operator=(const gslice_array<_Tp>&);
|
141
|
+
valarray<_Tp>& operator=(const mask_array<_Tp>&);
|
142
|
+
valarray<_Tp>& operator=(const indirect_array<_Tp>&);
|
143
|
+
|
144
|
+
template<class _Dom> valarray<_Tp>&
|
145
|
+
operator= (const _Expr<_Dom,_Tp>&);
|
146
|
+
|
147
|
+
// _lib.valarray.access_ element access:
|
148
|
+
_Tp operator[](size_t) const;
|
149
|
+
_Tp& operator[](size_t);
|
150
|
+
// _lib.valarray.sub_ subset operations:
|
151
|
+
_Expr<_SClos<_ValArray,_Tp>, _Tp> operator[](slice) const;
|
152
|
+
slice_array<_Tp> operator[](slice);
|
153
|
+
_Expr<_GClos<_ValArray,_Tp>, _Tp> operator[](const gslice&) const;
|
154
|
+
gslice_array<_Tp> operator[](const gslice&);
|
155
|
+
valarray<_Tp> operator[](const valarray<bool>&) const;
|
156
|
+
mask_array<_Tp> operator[](const valarray<bool>&);
|
157
|
+
_Expr<_IClos<_ValArray, _Tp>, _Tp>
|
158
|
+
operator[](const valarray<size_t>&) const;
|
159
|
+
indirect_array<_Tp> operator[](const valarray<size_t>&);
|
160
|
+
|
161
|
+
// _lib.valarray.unary_ unary operators:
|
162
|
+
_Expr<_UnClos<_Unary_plus,_ValArray,_Tp>,_Tp> operator+ () const;
|
163
|
+
_Expr<_UnClos<negate,_ValArray,_Tp>,_Tp> operator- () const;
|
164
|
+
_Expr<_UnClos<_Bitwise_not,_ValArray,_Tp>,_Tp> operator~ () const;
|
165
|
+
_Expr<_UnClos<logical_not,_ValArray,_Tp>,bool> operator! () const;
|
166
|
+
|
167
|
+
// _lib.valarray.cassign_ computed assignment:
|
168
|
+
valarray<_Tp>& operator*= (const _Tp&);
|
169
|
+
valarray<_Tp>& operator/= (const _Tp&);
|
170
|
+
valarray<_Tp>& operator%= (const _Tp&);
|
171
|
+
valarray<_Tp>& operator+= (const _Tp&);
|
172
|
+
valarray<_Tp>& operator-= (const _Tp&);
|
173
|
+
valarray<_Tp>& operator^= (const _Tp&);
|
174
|
+
valarray<_Tp>& operator&= (const _Tp&);
|
175
|
+
valarray<_Tp>& operator|= (const _Tp&);
|
176
|
+
valarray<_Tp>& operator<<=(const _Tp&);
|
177
|
+
valarray<_Tp>& operator>>=(const _Tp&);
|
178
|
+
valarray<_Tp>& operator*= (const valarray<_Tp>&);
|
179
|
+
valarray<_Tp>& operator/= (const valarray<_Tp>&);
|
180
|
+
valarray<_Tp>& operator%= (const valarray<_Tp>&);
|
181
|
+
valarray<_Tp>& operator+= (const valarray<_Tp>&);
|
182
|
+
valarray<_Tp>& operator-= (const valarray<_Tp>&);
|
183
|
+
valarray<_Tp>& operator^= (const valarray<_Tp>&);
|
184
|
+
valarray<_Tp>& operator|= (const valarray<_Tp>&);
|
185
|
+
valarray<_Tp>& operator&= (const valarray<_Tp>&);
|
186
|
+
valarray<_Tp>& operator<<=(const valarray<_Tp>&);
|
187
|
+
valarray<_Tp>& operator>>=(const valarray<_Tp>&);
|
188
|
+
|
189
|
+
template<class _Dom>
|
190
|
+
valarray<_Tp>& operator*= (const _Expr<_Dom,_Tp>&);
|
191
|
+
template<class _Dom>
|
192
|
+
valarray<_Tp>& operator/= (const _Expr<_Dom,_Tp>&);
|
193
|
+
template<class _Dom>
|
194
|
+
valarray<_Tp>& operator%= (const _Expr<_Dom,_Tp>&);
|
195
|
+
template<class _Dom>
|
196
|
+
valarray<_Tp>& operator+= (const _Expr<_Dom,_Tp>&);
|
197
|
+
template<class _Dom>
|
198
|
+
valarray<_Tp>& operator-= (const _Expr<_Dom,_Tp>&);
|
199
|
+
template<class _Dom>
|
200
|
+
valarray<_Tp>& operator^= (const _Expr<_Dom,_Tp>&);
|
201
|
+
template<class _Dom>
|
202
|
+
valarray<_Tp>& operator|= (const _Expr<_Dom,_Tp>&);
|
203
|
+
template<class _Dom>
|
204
|
+
valarray<_Tp>& operator&= (const _Expr<_Dom,_Tp>&);
|
205
|
+
template<class _Dom>
|
206
|
+
valarray<_Tp>& operator<<=(const _Expr<_Dom,_Tp>&);
|
207
|
+
template<class _Dom>
|
208
|
+
valarray<_Tp>& operator>>=(const _Expr<_Dom,_Tp>&);
|
209
|
+
|
210
|
+
|
211
|
+
// _lib.valarray.members_ member functions:
|
212
|
+
size_t size() const;
|
213
|
+
_Tp sum() const;
|
214
|
+
_Tp min() const;
|
215
|
+
_Tp max() const;
|
216
|
+
|
217
|
+
// FIXME: Extension
|
218
|
+
_Tp product () const;
|
219
|
+
|
220
|
+
valarray<_Tp> shift (int) const;
|
221
|
+
valarray<_Tp> cshift(int) const;
|
222
|
+
_Expr<_ValFunClos<_ValArray,_Tp>,_Tp> apply(_Tp func(_Tp)) const;
|
223
|
+
_Expr<_RefFunClos<_ValArray,_Tp>,_Tp> apply(_Tp func(const _Tp&)) const;
|
224
|
+
void resize(size_t __size, _Tp __c = _Tp());
|
225
|
+
|
226
|
+
private:
|
227
|
+
size_t _M_size;
|
228
|
+
_Tp* __restrict__ _M_data;
|
229
|
+
|
230
|
+
friend class _Array<_Tp>;
|
231
|
+
};
|
232
|
+
|
233
|
+
|
234
|
+
template<typename _Tp> struct _Unary_plus : unary_function<_Tp,_Tp> {
|
235
|
+
_Tp operator() (const _Tp& __t) const { return __t; }
|
236
|
+
};
|
237
|
+
|
238
|
+
template<typename _Tp> struct _Bitwise_and : binary_function<_Tp,_Tp,_Tp> {
|
239
|
+
_Tp operator() (_Tp __x, _Tp __y) const { return __x & __y; }
|
240
|
+
};
|
241
|
+
|
242
|
+
template<typename _Tp> struct _Bitwise_or : binary_function<_Tp,_Tp,_Tp> {
|
243
|
+
_Tp operator() (_Tp __x, _Tp __y) const { return __x | __y; }
|
244
|
+
};
|
245
|
+
|
246
|
+
template<typename _Tp> struct _Bitwise_xor : binary_function<_Tp,_Tp,_Tp> {
|
247
|
+
_Tp operator() (_Tp __x, _Tp __y) const { return __x ^ __y; }
|
248
|
+
};
|
249
|
+
|
250
|
+
template<typename _Tp> struct _Bitwise_not : unary_function<_Tp,_Tp> {
|
251
|
+
_Tp operator() (_Tp __t) const { return ~__t; }
|
252
|
+
};
|
253
|
+
|
254
|
+
template<typename _Tp> struct _Shift_left : unary_function<_Tp,_Tp> {
|
255
|
+
_Tp operator() (_Tp __x, _Tp __y) const { return __x << __y; }
|
256
|
+
};
|
257
|
+
|
258
|
+
template<typename _Tp> struct _Shift_right : unary_function<_Tp,_Tp> {
|
259
|
+
_Tp operator() (_Tp __x, _Tp __y) const { return __x >> __y; }
|
260
|
+
};
|
261
|
+
|
262
|
+
|
263
|
+
template<typename _Tp>
|
264
|
+
inline _Tp
|
265
|
+
valarray<_Tp>::operator[] (size_t __i) const
|
266
|
+
{ return _M_data[__i]; }
|
267
|
+
|
268
|
+
template<typename _Tp>
|
269
|
+
inline _Tp&
|
270
|
+
valarray<_Tp>::operator[] (size_t __i)
|
271
|
+
{ return _M_data[__i]; }
|
272
|
+
|
273
|
+
} // extern "C++"
|
274
|
+
|
275
|
+
#include <std/slice.h>
|
276
|
+
#include <std/slice_array.h>
|
277
|
+
#include <std/gslice.h>
|
278
|
+
#include <std/gslice_array.h>
|
279
|
+
#include <std/mask_array.h>
|
280
|
+
#include <std/indirect_array.h>
|
281
|
+
|
282
|
+
extern "C++" {
|
283
|
+
|
284
|
+
template<typename _Tp>
|
285
|
+
inline valarray<_Tp>::valarray () : _M_size (0), _M_data (0) {}
|
286
|
+
|
287
|
+
template<typename _Tp>
|
288
|
+
inline valarray<_Tp>::valarray (size_t __n)
|
289
|
+
: _M_size (__n), _M_data (new _Tp[__n]) {}
|
290
|
+
|
291
|
+
template<typename _Tp>
|
292
|
+
inline valarray<_Tp>::valarray (const _Tp& __t, size_t __n)
|
293
|
+
: _M_size (__n), _M_data (new _Tp[__n])
|
294
|
+
{ __valarray_fill (_M_data, _M_size, __t); }
|
295
|
+
|
296
|
+
template<typename _Tp>
|
297
|
+
inline valarray<_Tp>::valarray (const _Tp* __restrict__ __pT, size_t __n)
|
298
|
+
: _M_size (__n), _M_data (new _Tp[__n])
|
299
|
+
{ __valarray_copy (__pT, __n, _M_data); }
|
300
|
+
|
301
|
+
template<typename _Tp>
|
302
|
+
inline valarray<_Tp>::valarray (const valarray<_Tp>& __v)
|
303
|
+
: _M_size (__v._M_size), _M_data (new _Tp[__v._M_size])
|
304
|
+
{ __valarray_copy (__v._M_data, _M_size, _M_data); }
|
305
|
+
|
306
|
+
template<typename _Tp>
|
307
|
+
inline valarray<_Tp>::valarray (const slice_array<_Tp>& __sa)
|
308
|
+
: _M_size (__sa._M_sz), _M_data (new _Tp[__sa._M_sz])
|
309
|
+
{ __valarray_copy (__sa._M_array, __sa._M_sz, __sa._M_stride,
|
310
|
+
_Array<_Tp>(_M_data)); }
|
311
|
+
|
312
|
+
template<typename _Tp>
|
313
|
+
inline valarray<_Tp>::valarray (const gslice_array<_Tp>& __ga)
|
314
|
+
: _M_size (__ga._M_index.size()), _M_data (new _Tp[_M_size])
|
315
|
+
{ __valarray_copy (__ga._M_array, _Array<size_t>(__ga._M_index),
|
316
|
+
_Array<_Tp>(_M_data), _M_size); }
|
317
|
+
|
318
|
+
template<typename _Tp>
|
319
|
+
inline valarray<_Tp>::valarray (const mask_array<_Tp>& __ma)
|
320
|
+
: _M_size (__ma._M_sz), _M_data (new _Tp[__ma._M_sz])
|
321
|
+
{ __valarray_copy (__ma._M_array, __ma._M_mask,
|
322
|
+
_Array<_Tp>(_M_data), _M_size); }
|
323
|
+
|
324
|
+
template<typename _Tp>
|
325
|
+
inline valarray<_Tp>::valarray (const indirect_array<_Tp>& __ia)
|
326
|
+
: _M_size (__ia._M_sz), _M_data (new _Tp[__ia._M_sz])
|
327
|
+
{ __valarray_copy (__ia._M_array, __ia._M_index,
|
328
|
+
_Array<_Tp>(_M_data), _M_size); }
|
329
|
+
|
330
|
+
template<typename _Tp> template<class _Dom>
|
331
|
+
inline valarray<_Tp>::valarray (const _Expr<_Dom, _Tp>& __e)
|
332
|
+
: _M_size (__e.size ()), _M_data (new _Tp[_M_size])
|
333
|
+
{ __valarray_copy (__e, _M_size, _Array<_Tp>(_M_data)); }
|
334
|
+
|
335
|
+
template<typename _Tp>
|
336
|
+
inline valarray<_Tp>::~valarray () { delete[] _M_data; }
|
337
|
+
|
338
|
+
template<typename _Tp>
|
339
|
+
inline valarray<_Tp>&
|
340
|
+
valarray<_Tp>::operator= (const valarray<_Tp>& __v)
|
341
|
+
{
|
342
|
+
__valarray_copy(__v._M_data, _M_size, _M_data);
|
343
|
+
return *this;
|
344
|
+
}
|
345
|
+
|
346
|
+
template<typename _Tp>
|
347
|
+
inline valarray<_Tp>&
|
348
|
+
valarray<_Tp>::operator= (const _Tp& __t)
|
349
|
+
{
|
350
|
+
__valarray_fill (_M_data, _M_size, __t);
|
351
|
+
return *this;
|
352
|
+
}
|
353
|
+
|
354
|
+
template<typename _Tp>
|
355
|
+
inline valarray<_Tp>&
|
356
|
+
valarray<_Tp>::operator= (const slice_array<_Tp>& __sa)
|
357
|
+
{
|
358
|
+
__valarray_copy (__sa._M_array, __sa._M_sz,
|
359
|
+
__sa._M_stride, _Array<_Tp>(_M_data));
|
360
|
+
return *this;
|
361
|
+
}
|
362
|
+
|
363
|
+
template<typename _Tp>
|
364
|
+
inline valarray<_Tp>&
|
365
|
+
valarray<_Tp>::operator= (const gslice_array<_Tp>& __ga)
|
366
|
+
{
|
367
|
+
__valarray_copy (__ga._M_array, _Array<size_t>(__ga._M_index),
|
368
|
+
_Array<_Tp>(_M_data), _M_size);
|
369
|
+
return *this;
|
370
|
+
}
|
371
|
+
|
372
|
+
template<typename _Tp>
|
373
|
+
inline valarray<_Tp>&
|
374
|
+
valarray<_Tp>::operator= (const mask_array<_Tp>& __ma)
|
375
|
+
{
|
376
|
+
__valarray_copy (__ma._M_array, __ma._M_mask,
|
377
|
+
_Array<_Tp>(_M_data), _M_size);
|
378
|
+
return *this;
|
379
|
+
}
|
380
|
+
|
381
|
+
template<typename _Tp>
|
382
|
+
inline valarray<_Tp>&
|
383
|
+
valarray<_Tp>::operator= (const indirect_array<_Tp>& __ia)
|
384
|
+
{
|
385
|
+
__valarray_copy (__ia._M_array, __ia._M_index,
|
386
|
+
_Array<_Tp>(_M_data), _M_size);
|
387
|
+
return *this;
|
388
|
+
}
|
389
|
+
|
390
|
+
template<typename _Tp> template<class _Dom>
|
391
|
+
inline valarray<_Tp>&
|
392
|
+
valarray<_Tp>::operator= (const _Expr<_Dom, _Tp>& __e)
|
393
|
+
{
|
394
|
+
__valarray_copy (__e, _M_size, _Array<_Tp>(_M_data));
|
395
|
+
return *this;
|
396
|
+
}
|
397
|
+
|
398
|
+
template<typename _Tp>
|
399
|
+
inline _Expr<_SClos<_ValArray,_Tp>, _Tp>
|
400
|
+
valarray<_Tp>::operator[] (slice __s) const
|
401
|
+
{
|
402
|
+
typedef _SClos<_ValArray,_Tp> _Closure;
|
403
|
+
return _Expr<_Closure, _Tp> (_Closure (_Array<_Tp>(_M_data), __s));
|
404
|
+
}
|
405
|
+
|
406
|
+
template<typename _Tp>
|
407
|
+
inline slice_array<_Tp>
|
408
|
+
valarray<_Tp>::operator[] (slice __s)
|
409
|
+
{
|
410
|
+
return slice_array<_Tp> (_Array<_Tp>(_M_data), __s);
|
411
|
+
}
|
412
|
+
|
413
|
+
template<typename _Tp>
|
414
|
+
inline _Expr<_GClos<_ValArray,_Tp>, _Tp>
|
415
|
+
valarray<_Tp>::operator[] (const gslice& __gs) const
|
416
|
+
{
|
417
|
+
typedef _GClos<_ValArray,_Tp> _Closure;
|
418
|
+
return _Expr<_Closure, _Tp>
|
419
|
+
(_Closure (_Array<_Tp>(_M_data), __gs._M_index->_M_index));
|
420
|
+
}
|
421
|
+
|
422
|
+
template<typename _Tp>
|
423
|
+
inline gslice_array<_Tp>
|
424
|
+
valarray<_Tp>::operator[] (const gslice& __gs)
|
425
|
+
{
|
426
|
+
return gslice_array<_Tp>
|
427
|
+
(_Array<_Tp>(_M_data), __gs._M_index->_M_index);
|
428
|
+
}
|
429
|
+
|
430
|
+
template<typename _Tp>
|
431
|
+
inline valarray<_Tp>
|
432
|
+
valarray<_Tp>::operator[] (const valarray<bool>& __m) const
|
433
|
+
{
|
434
|
+
size_t __s (0);
|
435
|
+
size_t __e (__m.size ());
|
436
|
+
for (size_t __i=0; __i<__e; ++__i)
|
437
|
+
if (__m[__i]) ++__s;
|
438
|
+
return valarray<_Tp> (mask_array<_Tp> (_Array<_Tp>(_M_data), __s,
|
439
|
+
_Array<bool> (__m)));
|
440
|
+
}
|
441
|
+
|
442
|
+
template<typename _Tp>
|
443
|
+
inline mask_array<_Tp>
|
444
|
+
valarray<_Tp>::operator[] (const valarray<bool>& __m)
|
445
|
+
{
|
446
|
+
size_t __s (0);
|
447
|
+
size_t __e (__m.size ());
|
448
|
+
for (size_t __i=0; __i<__e; ++__i)
|
449
|
+
if (__m[__i]) ++__s;
|
450
|
+
return mask_array<_Tp> (_Array<_Tp>(_M_data), __s, _Array<bool> (__m));
|
451
|
+
}
|
452
|
+
|
453
|
+
template<typename _Tp>
|
454
|
+
inline _Expr<_IClos<_ValArray,_Tp>, _Tp>
|
455
|
+
valarray<_Tp>::operator[] (const valarray<size_t>& __i) const
|
456
|
+
{
|
457
|
+
typedef _IClos<_ValArray,_Tp> _Closure;
|
458
|
+
return _Expr<_Closure, _Tp> (_Closure (*this, __i));
|
459
|
+
}
|
460
|
+
|
461
|
+
template<typename _Tp>
|
462
|
+
inline indirect_array<_Tp>
|
463
|
+
valarray<_Tp>::operator[] (const valarray<size_t>& __i)
|
464
|
+
{
|
465
|
+
return indirect_array<_Tp> (_Array<_Tp>(_M_data), __i.size(),
|
466
|
+
_Array<size_t> (__i));
|
467
|
+
}
|
468
|
+
|
469
|
+
template<class _Tp>
|
470
|
+
inline size_t valarray<_Tp>::size () const { return _M_size; }
|
471
|
+
|
472
|
+
template<class _Tp>
|
473
|
+
inline _Tp
|
474
|
+
valarray<_Tp>::sum () const
|
475
|
+
{
|
476
|
+
return accumulate (_M_data, _M_data + _M_size, _Tp ());
|
477
|
+
}
|
478
|
+
|
479
|
+
template<typename _Tp>
|
480
|
+
inline _Tp
|
481
|
+
valarray<_Tp>::product () const
|
482
|
+
{
|
483
|
+
return accumulate (_M_data, _M_data+_M_size, _Tp(1), multiplies<_Tp> ());
|
484
|
+
}
|
485
|
+
|
486
|
+
template <class _Tp>
|
487
|
+
inline valarray<_Tp>
|
488
|
+
valarray<_Tp>::shift (int __n) const
|
489
|
+
{
|
490
|
+
_Tp* const __a = static_cast<_Tp*> (alloca (sizeof(_Tp) * _M_size));
|
491
|
+
if (! __n) // __n == 0: no shift
|
492
|
+
__valarray_copy (_M_data, _M_size, __a);
|
493
|
+
else if (__n > 0) { // __n > 0: shift left
|
494
|
+
if (__n > _M_size)
|
495
|
+
__valarray_fill(__a, __n, _Tp());
|
496
|
+
else {
|
497
|
+
__valarray_copy (_M_data+__n, _M_size-__n, __a);
|
498
|
+
__valarray_fill (__a+_M_size-__n, __n, _Tp());
|
499
|
+
}
|
500
|
+
}
|
501
|
+
else { // __n < 0: shift right
|
502
|
+
__valarray_copy (_M_data, _M_size+__n, __a-__n);
|
503
|
+
__valarray_fill(__a, -__n, _Tp());
|
504
|
+
}
|
505
|
+
return valarray<_Tp> (__a, _M_size);
|
506
|
+
}
|
507
|
+
|
508
|
+
template <class _Tp>
|
509
|
+
inline valarray<_Tp>
|
510
|
+
valarray<_Tp>::cshift (int __n) const
|
511
|
+
{
|
512
|
+
_Tp* const __a = static_cast<_Tp*> (alloca (sizeof(_Tp) * _M_size));
|
513
|
+
if (! __n) // __n == 0: no cshift
|
514
|
+
__valarray_copy(_M_data, _M_size, __a);
|
515
|
+
else if (__n > 0) { // __n > 0: cshift left
|
516
|
+
__valarray_copy (_M_data, __n, __a + _M_size-__n);
|
517
|
+
__valarray_copy (_M_data + __n, _M_size-__n, __a);
|
518
|
+
}
|
519
|
+
else { // __n < 0: cshift right
|
520
|
+
__valarray_copy (_M_data + _M_size + __n, -__n, __a);
|
521
|
+
__valarray_copy (_M_data, _M_size + __n, __a - __n);
|
522
|
+
}
|
523
|
+
return valarray<_Tp> (__a, _M_size);
|
524
|
+
}
|
525
|
+
|
526
|
+
template <class _Tp>
|
527
|
+
inline void
|
528
|
+
valarray<_Tp>::resize (size_t __n, _Tp __c)
|
529
|
+
{
|
530
|
+
if (_M_size != __n) {
|
531
|
+
delete[] _M_data;
|
532
|
+
_M_size = __n;
|
533
|
+
_M_data = new _Tp[_M_size];
|
534
|
+
}
|
535
|
+
__valarray_fill (_M_data, _M_size, __c);
|
536
|
+
}
|
537
|
+
|
538
|
+
template<typename _Tp>
|
539
|
+
inline _Tp
|
540
|
+
valarray<_Tp>::min() const
|
541
|
+
{
|
542
|
+
return *min_element (_M_data, _M_data+_M_size);
|
543
|
+
}
|
544
|
+
|
545
|
+
template<typename _Tp>
|
546
|
+
inline _Tp
|
547
|
+
valarray<_Tp>::max() const
|
548
|
+
{
|
549
|
+
return *max_element (_M_data, _M_data+_M_size);
|
550
|
+
}
|
551
|
+
|
552
|
+
template<class _Tp>
|
553
|
+
inline _Expr<_ValFunClos<_ValArray,_Tp>,_Tp>
|
554
|
+
valarray<_Tp>::apply (_Tp func (_Tp)) const
|
555
|
+
{
|
556
|
+
typedef _ValFunClos<_ValArray,_Tp> _Closure;
|
557
|
+
return _Expr<_Closure,_Tp> (_Closure (*this, func));
|
558
|
+
}
|
559
|
+
|
560
|
+
template<class _Tp>
|
561
|
+
inline _Expr<_RefFunClos<_ValArray,_Tp>,_Tp>
|
562
|
+
valarray<_Tp>::apply (_Tp func (const _Tp &)) const
|
563
|
+
{
|
564
|
+
typedef _RefFunClos<_ValArray,_Tp> _Closure;
|
565
|
+
return _Expr<_Closure,_Tp> (_Closure (*this, func));
|
566
|
+
}
|
567
|
+
|
568
|
+
#define _DEFINE_VALARRAY_UNARY_OPERATOR(_Op, _Name) \
|
569
|
+
template<typename _Tp> \
|
570
|
+
inline _Expr<_UnClos<_Name,_ValArray,_Tp>, _Tp> \
|
571
|
+
valarray<_Tp>::operator _Op() const \
|
572
|
+
{ \
|
573
|
+
typedef _UnClos<_Name,_ValArray,_Tp> _Closure; \
|
574
|
+
return _Expr<_Closure, _Tp> (_Closure (*this)); \
|
575
|
+
}
|
576
|
+
|
577
|
+
_DEFINE_VALARRAY_UNARY_OPERATOR(+, _Unary_plus)
|
578
|
+
_DEFINE_VALARRAY_UNARY_OPERATOR(-, negate)
|
579
|
+
_DEFINE_VALARRAY_UNARY_OPERATOR(~, _Bitwise_not)
|
580
|
+
|
581
|
+
#undef _DEFINE_VALARRAY_UNARY_OPERATOR
|
582
|
+
|
583
|
+
template<typename _Tp>
|
584
|
+
inline _Expr<_UnClos<logical_not,_ValArray,_Tp>, bool>
|
585
|
+
valarray<_Tp>::operator!() const
|
586
|
+
{
|
587
|
+
typedef _UnClos<logical_not,_ValArray,_Tp> _Closure;
|
588
|
+
return _Expr<_Closure, bool> (_Closure (*this));
|
589
|
+
}
|
590
|
+
|
591
|
+
#define _DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(_Op, _Name) \
|
592
|
+
template<class _Tp> \
|
593
|
+
inline valarray<_Tp> & \
|
594
|
+
valarray<_Tp>::operator _Op##= (const _Tp &__t) \
|
595
|
+
{ \
|
596
|
+
_Array_augmented_##_Name (_Array<_Tp>(_M_data), _M_size, __t); \
|
597
|
+
return *this; \
|
598
|
+
} \
|
599
|
+
\
|
600
|
+
template<class _Tp> \
|
601
|
+
inline valarray<_Tp> & \
|
602
|
+
valarray<_Tp>::operator _Op##= (const valarray<_Tp> &__v) \
|
603
|
+
{ \
|
604
|
+
_Array_augmented_##_Name (_Array<_Tp>(_M_data), _M_size, \
|
605
|
+
_Array<_Tp>(__v._M_data)); \
|
606
|
+
return *this; \
|
607
|
+
}
|
608
|
+
|
609
|
+
_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(+, plus)
|
610
|
+
_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(-, minus)
|
611
|
+
_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(*, multiplies)
|
612
|
+
_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(/, divides)
|
613
|
+
_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(%, modulus)
|
614
|
+
_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(^, xor)
|
615
|
+
_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(&, and)
|
616
|
+
_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(|, or)
|
617
|
+
_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(<<, shift_left)
|
618
|
+
_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(>>, shift_right)
|
619
|
+
|
620
|
+
#undef _DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT
|
621
|
+
|
622
|
+
|
623
|
+
#define _DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(_Op, _Name) \
|
624
|
+
template<class _Tp> template<class _Dom> \
|
625
|
+
inline valarray<_Tp> & \
|
626
|
+
valarray<_Tp>::operator _Op##= (const _Expr<_Dom,_Tp> &__e) \
|
627
|
+
{ \
|
628
|
+
_Array_augmented_##_Name (_Array<_Tp>(_M_data), __e, _M_size); \
|
629
|
+
return *this; \
|
630
|
+
}
|
631
|
+
|
632
|
+
_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(+, plus)
|
633
|
+
_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(-, minus)
|
634
|
+
_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(*, multiplies)
|
635
|
+
_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(/, divides)
|
636
|
+
_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(%, modulus)
|
637
|
+
_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(^, xor)
|
638
|
+
_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(&, and)
|
639
|
+
_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(|, or)
|
640
|
+
_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(<<, shift_left)
|
641
|
+
_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(>>, shift_right)
|
642
|
+
|
643
|
+
#undef _DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT
|
644
|
+
|
645
|
+
|
646
|
+
#define _DEFINE_BINARY_OPERATOR(_Op, _Name) \
|
647
|
+
template<typename _Tp> \
|
648
|
+
inline _Expr<_BinClos<_Name,_ValArray,_ValArray,_Tp,_Tp>, _Tp> \
|
649
|
+
operator _Op (const valarray<_Tp> &__v, const valarray<_Tp> &__w) \
|
650
|
+
{ \
|
651
|
+
typedef _BinClos<_Name,_ValArray,_ValArray,_Tp,_Tp> _Closure; \
|
652
|
+
return _Expr<_Closure, _Tp> (_Closure (__v, __w)); \
|
653
|
+
} \
|
654
|
+
\
|
655
|
+
template<typename _Tp> \
|
656
|
+
inline _Expr<_BinClos<_Name,_ValArray,_Constant,_Tp,_Tp>,_Tp> \
|
657
|
+
operator _Op (const valarray<_Tp> &__v, const _Tp &__t) \
|
658
|
+
{ \
|
659
|
+
typedef _BinClos<_Name,_ValArray,_Constant,_Tp,_Tp> _Closure; \
|
660
|
+
return _Expr<_Closure, _Tp> (_Closure (__v, __t)); \
|
661
|
+
} \
|
662
|
+
\
|
663
|
+
template<typename _Tp> \
|
664
|
+
inline _Expr<_BinClos<_Name,_Constant,_ValArray,_Tp,_Tp>,_Tp> \
|
665
|
+
operator _Op (const _Tp &__t, const valarray<_Tp> &__v) \
|
666
|
+
{ \
|
667
|
+
typedef _BinClos<_Name,_Constant,_ValArray,_Tp,_Tp> _Closure; \
|
668
|
+
return _Expr<_Closure, _Tp> (_Closure (__t, __v)); \
|
669
|
+
}
|
670
|
+
|
671
|
+
_DEFINE_BINARY_OPERATOR(+, plus)
|
672
|
+
_DEFINE_BINARY_OPERATOR(-, minus)
|
673
|
+
_DEFINE_BINARY_OPERATOR(*, multiplies)
|
674
|
+
_DEFINE_BINARY_OPERATOR(/, divides)
|
675
|
+
_DEFINE_BINARY_OPERATOR(%, modulus)
|
676
|
+
_DEFINE_BINARY_OPERATOR(^, _Bitwise_xor)
|
677
|
+
_DEFINE_BINARY_OPERATOR(&, _Bitwise_and)
|
678
|
+
_DEFINE_BINARY_OPERATOR(|, _Bitwise_or)
|
679
|
+
_DEFINE_BINARY_OPERATOR(<<, _Shift_left)
|
680
|
+
_DEFINE_BINARY_OPERATOR(>>, _Shift_right)
|
681
|
+
|
682
|
+
#undef _DEFINE_BINARY_OPERATOR
|
683
|
+
|
684
|
+
#define _DEFINE_LOGICAL_OPERATOR(_Op, _Name) \
|
685
|
+
template<typename _Tp> \
|
686
|
+
inline _Expr<_BinClos<_Name,_ValArray,_ValArray,_Tp,_Tp>,bool> \
|
687
|
+
operator _Op (const valarray<_Tp> &__v, const valarray<_Tp> &__w) \
|
688
|
+
{ \
|
689
|
+
typedef _BinClos<_Name,_ValArray,_ValArray,_Tp,_Tp> _Closure; \
|
690
|
+
return _Expr<_Closure, bool> (_Closure (__v, __w)); \
|
691
|
+
} \
|
692
|
+
\
|
693
|
+
template<class _Tp> \
|
694
|
+
inline _Expr<_BinClos<_Name,_ValArray,_Constant,_Tp,_Tp>,bool> \
|
695
|
+
operator _Op (const valarray<_Tp> &__v, const _Tp &__t) \
|
696
|
+
{ \
|
697
|
+
typedef _BinClos<_Name,_ValArray,_Constant,_Tp,_Tp> _Closure; \
|
698
|
+
return _Expr<_Closure, bool> (_Closure (__v, __t)); \
|
699
|
+
} \
|
700
|
+
\
|
701
|
+
template<class _Tp> \
|
702
|
+
inline _Expr<_BinClos<_Name,_Constant,_ValArray,_Tp,_Tp>,bool> \
|
703
|
+
operator _Op (const _Tp &__t, const valarray<_Tp> &__v) \
|
704
|
+
{ \
|
705
|
+
typedef _BinClos<_Name,_Constant,_ValArray,_Tp,_Tp> _Closure; \
|
706
|
+
return _Expr<_Closure, bool> (_Closure (__t, __v)); \
|
707
|
+
}
|
708
|
+
|
709
|
+
_DEFINE_LOGICAL_OPERATOR(&&, logical_and)
|
710
|
+
_DEFINE_LOGICAL_OPERATOR(||, logical_or)
|
711
|
+
_DEFINE_LOGICAL_OPERATOR(==, equal_to)
|
712
|
+
_DEFINE_LOGICAL_OPERATOR(!=, not_equal_to)
|
713
|
+
_DEFINE_LOGICAL_OPERATOR(<, less)
|
714
|
+
_DEFINE_LOGICAL_OPERATOR(>, greater)
|
715
|
+
_DEFINE_LOGICAL_OPERATOR(<=, less_equal)
|
716
|
+
_DEFINE_LOGICAL_OPERATOR(>=, greater_equal)
|
717
|
+
|
718
|
+
#undef _DEFINE_VALARRAY_OPERATOR
|
719
|
+
|
720
|
+
#undef _G_NO_VALARRAY_TEMPLATE_EXPORT
|
721
|
+
|
722
|
+
} // extern "C++"
|
723
|
+
|
724
|
+
#endif // __STD_VALARRAY__
|
725
|
+
|
726
|
+
// Local Variables:
|
727
|
+
// mode:c++
|
728
|
+
// End:
|