1
/* Copyright (C) 2004 Garrett A. Kajmowicz
3
This file is part of the uClibc++ Library.
5
This library is free software; you can redistribute it and/or
6
modify it under the terms of the GNU Lesser General Public
7
License as published by the Free Software Foundation; either
8
version 2.1 of the License, or (at your option) any later version.
10
This library is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
Lesser General Public License for more details.
15
You should have received a copy of the GNU Lesser General Public
16
License along with this library; if not, write to the Free Software
17
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
#include <basic_definitions>
22
#ifndef __HEADER_STD_VALARRAY
23
#define __HEADER_STD_VALARRAY 1
28
#pragma GCC visibility push(default)
32
template<class T> class valarray;
34
template<class T> class slice_array;
36
template<class T> class gslice_array;
37
template<class T> class mask_array;
38
template<class T> class indirect_array;
40
//Actual class definitions
43
class _UCXXEXPORT slice {
50
slice() : sta(0), siz(0), str(0){ }
51
slice(size_t a, size_t b, size_t c) : sta(a), siz(b), str(c) { }
52
slice(const slice& s) : sta(s.sta), siz(s.siz), str(s.str) { }
60
size_t stride() const{
67
template<class T> class _UCXXEXPORT valarray {
68
friend class slice_array<T>;
76
valarray() : data(0), length(0) { }
78
explicit valarray(size_t t) : data(0), length(t){
82
valarray(const T& v, size_t t) : data(0), length(t){
84
for(size_t i = 0; i < length; ++i){
88
valarray(const T* p, size_t t) : data(0), length(t) {
90
for(size_t i = 0; i < length; ++i){
94
valarray(const valarray& v) : data(0), length(v.length){
96
for(size_t i = 0; i < length; ++i){
100
valarray(const slice_array<T> & sa) : data(0), length(sa.s.size()){
101
data = new T[length];
102
for(unsigned int i = 0; i < length; ++i){
103
data[i] = sa.array->data[sa.s.start() + i * sa.s.stride()];
106
valarray(const gslice_array<T>&);
107
valarray(const mask_array<T>&);
108
valarray(const indirect_array<T>&);
115
valarray<T>& operator=(const valarray<T>& v){
116
for(size_t i =0; i< length; ++i){
121
valarray<T>& operator=(const T& t){
122
for(size_t i = 0; i < length; ++i){
127
valarray<T>& operator=(const slice_array<T>& sa){
128
for(size_t i =0; i < length; ++i){
129
data[i] = sa.data[sa.s.start() + i * sa.s.stride()];
133
valarray<T>& operator=(const gslice_array<T>&);
134
valarray<T>& operator=(const mask_array<T>&);
135
valarray<T>& operator=(const indirect_array<T>&);
137
T operator[](size_t t) const{
140
T& operator[](size_t t){
144
valarray<T> operator[](slice s) const{
145
valarray<T> retval(s.size());
146
for(unsigned int i = 0; i< s.size(); ++i){
147
retval.data[i] = data[s.start() + i * s.stride()];
152
slice_array<T> operator[](slice sl){
153
slice_array<T> retval;
159
valarray<T> operator[](const gslice&) const;
160
gslice_array<T> operator[](const gslice&);
161
valarray<T> operator[](const valarray<bool>&) const;
162
mask_array<T> operator[](const valarray<bool>&);
163
valarray<T> operator[](const valarray<size_t>&) const;
164
indirect_array<T> operator[](const valarray<size_t>&);
166
valarray<T> operator+() const{
167
valarray<T> retval(length);
168
for(size_t i = 0; i< length ; ++i){
169
retval.data[i] = +data[i];
173
valarray<T> operator-() const{
174
valarray<T> retval(length);
175
for(size_t i = 0; i< length; ++i){
176
retval.data[i] = -data[i];
180
valarray<T> operator~() const{
181
valarray<T> retval(length);
182
for(size_t i = 0; i< length ; ++i){
183
retval.data[i] = ~data[i];
187
valarray<T> operator!() const{
188
valarray<T> retval(length);
189
for(size_t i = 0; i< length ; ++i){
190
retval.data[i] = !data[i];
194
valarray<T>& operator*= (const T& t){
195
for(size_t i=0;i<length;++i){
200
valarray<T>& operator/= (const T& t){
201
for(size_t i=0;i<length;++i){
206
valarray<T>& operator%= (const T& t){
207
for(size_t i=0;i<length;++i){
212
valarray<T>& operator+= (const T& t){
213
for(size_t i=0;i<length;++i){
218
valarray<T>& operator-= (const T& t){
219
for(size_t i=0;i<length;++i){
224
valarray<T>& operator^= (const T& t){
225
for(size_t i=0;i<length;++i){
230
valarray<T>& operator&= (const T& t){
231
for(size_t i=0;i<length;++i){
236
valarray<T>& operator|= (const T& t){
237
for(size_t i=0;i<length; ++i){
242
valarray<T>& operator<<=(const T& t){
243
for(size_t i=0;i<length;++i){
248
valarray<T>& operator>>=(const T& t){
249
for(size_t i=0;i<length;++i){
254
valarray<T>& operator*= (const valarray<T>& a){
255
for(size_t i=0;i<length;++i){
256
data[i] *= a.data[i];
260
valarray<T>& operator/= (const valarray<T>& a){
261
for(size_t i=0;i<length;++i){
262
data[i] /= a.data[i];
266
valarray<T>& operator%= (const valarray<T>& a){
267
for(size_t i=0;i<length;++i){
268
data[i] %= a.data[i];
272
valarray<T>& operator+= (const valarray<T>& a){
273
for(size_t i=0;i<length;++i){
274
data[i] += a.data[i];
278
valarray<T>& operator-= (const valarray<T>& a){
279
for(size_t i=0;i<length ;++i){
280
data[i] -= a.data[i];
284
valarray<T>& operator^= (const valarray<T>& a){
285
for(size_t i=0;i<length;++i){
286
data[i] ^= a.data[i];
290
valarray<T>& operator|= (const valarray<T>& a){
291
for(size_t i=0;i<length ;++i){
292
data[i] |= a.data[i];
296
valarray<T>& operator&= (const valarray<T>& a){
297
for(size_t i=0;i<length;++i){
298
data[i] &= a.data[i];
302
valarray<T>& operator<<=(const valarray<T>& a){
303
for(size_t i=0;i<length;++i){
304
data[i] <<= a.data[i];
308
valarray<T>& operator>>=(const valarray<T>& a){
309
for(size_t i=0;i<length;++i){
310
data[i] >>= a.data[i];
321
for(size_t i = 1; i< length; ++i){
329
for(size_t i = 1; i< length; ++i){
330
if(data[i] < retval){
339
for(size_t i = 1; i< length; ++i){
340
if(retval < data[i]){
347
valarray<T> shift (int n) const{
348
valarray<T> retval(length);
349
for(size_t i = 0; i < length ; ++i){
350
if(i + n > 0 && i + n < length){
351
retval.data[i] = data[i + n];
356
valarray<T> cshift(int n) const{
357
valarray<T> retval(length);
358
for(size_t i = 0; i < length ; ++i){
359
retval.data[i] = data[ (i + n) % length ];
363
valarray<T> apply(T func(T) ) const{
364
valarray<T> retval(length);
365
for(size_t i = 0; i< length; ++i){
366
retval.data[i] = func(data[i]);
370
valarray<T> apply(T func(const T&)) const{
371
valarray<T> retval(length);
372
for(size_t i = 0; i< length; ++i){
373
retval.data[i] = func(data[i]);
377
void resize(size_t sz, T c = T()){
382
for(size_t i = 0; i < sz; ++i){
392
template <class T> class _UCXXEXPORT slice_array {
393
friend class valarray<T>;
395
typedef T value_type;
397
void operator= (const valarray<T>& v) const{
398
for(unsigned int i = 0; i < s.size(); ++i){
399
array->data[s.start() + i * s.stride()] = v[i];
402
void operator= (const T & v){
403
for(unsigned int i = 0; i < s.size(); ++i){
404
array->data[s.start() + i * s.stride()] = v;
407
void fill(const T & v){
408
for(unsigned int i = 0; i < s.size(); ++i){
409
array->data[s.start() + i * s.stride()] = v;
412
void operator*= (const valarray<T>& v) const{
413
for(unsigned int i = 0; i < s.size(); ++i){
414
array->data[s.start() + i * s.stride()] *= v[i];
417
void operator/= (const valarray<T>& v) const{
418
for(unsigned int i = 0; i < s.size(); ++i){
419
array->data[s.start() + i * s.stride()] /= v[i];
422
void operator%= (const valarray<T>& v) const{
423
for(unsigned int i = 0; i < s.size(); ++i){
424
array->data[s.start() + i * s.stride()] %= v[i];
427
void operator+= (const valarray<T>& v) const{
428
for(unsigned int i = 0; i < s.size(); ++i){
429
array->data[s.start() + i * s.stride()] += v[i];
432
void operator-= (const valarray<T>& v) const{
433
for(unsigned int i = 0; i < s.size(); ++i){
434
array->data[s.start() + i * s.stride()] -= v[i];
437
void operator^= (const valarray<T>& v) const{
438
for(unsigned int i = 0; i < s.size(); ++i){
439
array->data[s.start() + i * s.stride()] ^= v[i];
442
void operator&= (const valarray<T>& v) const{
443
for(unsigned int i = 0; i < s.size(); ++i){
444
array->data[s.start() + i * s.stride()] &= v[i];
447
void operator|= (const valarray<T>& v) const{
448
for(unsigned int i = 0; i < s.size(); ++i){
449
array->data[s.start() + i * s.stride()] |= v[i];
452
void operator<<=(const valarray<T>& v) const{
453
for(unsigned int i = 0; i < s.size(); ++i){
454
array->data[s.start() + i * s.stride()] <<= v[i];
457
void operator>>=(const valarray<T>& v) const{
458
for(unsigned int i = 0; i < s.size(); ++i){
459
array->data[s.start() + i * s.stride()] >>= v[i];
467
slice_array() : array(0){ }
470
slice_array(const slice_array& sa) : array(sa.array), s(sa.s){ }
471
slice_array& operator=(const slice_array& sa){
482
class _UCXXEXPORT gslice {
485
valarray<size_t> siz;
486
valarray<size_t> str;
489
gslice() : sta(0) { }
490
gslice(size_t s, const valarray<size_t>& l, const valarray<size_t>& d)
491
: sta(s), siz(l), str(d) { }
493
size_t start() const{
496
valarray<size_t> size() const{
499
valarray<size_t> stride() const{
504
template <class T> class gslice_array {
506
friend class valarray<T>;
511
void operator=(const valarray<T>& array) const;
512
void operator*=(const valarray<T>& array) const;
513
void operator/=(const valarray<T>& array) const;
514
void operator%=(const valarray<T>& array) const;
515
void operator+=(const valarray<T>& array) const;
516
void operator-=(const valarray<T>& array) const;
517
void operator^=(const valarray<T>& array) const;
518
void operator&=(const valarray<T>& array) const;
519
void operator|=(const valarray<T>& array) const;
520
void operator<<=(const valarray<T>& array) const;
521
void operator>>=(const valarray<T>& array) const;
523
void operator=(const T&);
527
gslice_array(const gslice_array<T>&);
528
gslice_array<T>& operator= (const gslice_array<T>& array);
533
template<class T> valarray<T> operator* (const valarray<T>& lhs, const valarray<T>& rhs){
534
valarray<T> retval(lhs);
539
template<class T> valarray<T> operator* (const valarray<T>& lhs, const T& rhs){
540
valarray<T> retval(lhs);
544
template<class T> valarray<T> operator* (const T& lhs, const valarray<T>& rhs){
545
valarray<T> retval(rhs);
549
template<class T> valarray<T> operator/ (const valarray<T>& lhs, const valarray<T>& rhs){
550
valarray<T> retval(lhs);
554
template<class T> valarray<T> operator/ (const valarray<T>& lhs, const T& rhs){
555
valarray<T> retval(lhs);
559
template<class T> valarray<T> operator/ (const T& lhs, const valarray<T>& rhs){
560
valarray<T> retval(lhs, rhs.size());
564
template<class T> valarray<T> operator% (const valarray<T>& lhs, const valarray<T>& rhs){
565
valarray<T> retval(lhs);
569
template<class T> valarray<T> operator% (const valarray<T>& lhs, const T& rhs){
570
valarray<T> retval(lhs);
574
template<class T> valarray<T> operator% (const T& lhs, const valarray<T>& rhs){
575
valarray<T> retval(lhs, rhs.size());
579
template<class T> valarray<T> operator+ (const valarray<T>& lhs, const valarray<T>& rhs){
580
valarray<T> retval(lhs);
584
template<class T> valarray<T> operator+ (const valarray<T>& lhs, const T& rhs){
585
valarray<T> retval(lhs);
589
template<class T> valarray<T> operator+ (const T& lhs, const valarray<T>& rhs){
590
valarray<T> retval(lhs, rhs.size());
594
template<class T> valarray<T> operator- (const valarray<T>& lhs, const valarray<T>& rhs){
595
valarray<T> retval(lhs);
599
template<class T> valarray<T> operator- (const valarray<T>& lhs, const T& rhs){
600
valarray<T> retval(lhs);
604
template<class T> valarray<T> operator- (const T& lhs, const valarray<T>& rhs){
605
valarray<T> retval(lhs, rhs.size());
609
template<class T> valarray<T> operator^ (const valarray<T>& lhs, const valarray<T>& rhs){
610
valarray<T> retval(lhs);
614
template<class T> valarray<T> operator^ (const valarray<T>& lhs, const T& rhs){
615
valarray<T> retval(lhs);
619
template<class T> valarray<T> operator^ (const T& lhs, const valarray<T>& rhs){
620
valarray<T> retval(lhs, rhs.size());
624
template<class T> valarray<T> operator& (const valarray<T>& lhs, const valarray<T>& rhs){
625
valarray<T> retval(lhs);
629
template<class T> valarray<T> operator& (const valarray<T>& lhs, const T& rhs){
630
valarray<T> retval(lhs);
634
template<class T> valarray<T> operator& (const T& lhs, const valarray<T>& rhs){
635
valarray<T> retval(lhs, rhs.size());
639
template<class T> valarray<T> operator| (const valarray<T>& lhs, const valarray<T>& rhs){
640
valarray<T> retval(lhs);
644
template<class T> valarray<T> operator| (const valarray<T>& lhs, const T& rhs){
645
valarray<T> retval(lhs);
649
template<class T> valarray<T> operator| (const T& lhs, const valarray<T>& rhs){
650
valarray<T> retval(lhs, rhs.size());
654
template<class T> valarray<T> operator<<(const valarray<T>& lhs, const valarray<T>& rhs){
655
valarray<T> retval(lhs);
659
template<class T> valarray<T> operator<<(const valarray<T>& lhs, const T& rhs){
660
valarray<T> retval(lhs);
664
template<class T> valarray<T> operator<<(const T& lhs, const valarray<T>& rhs){
665
valarray<T> retval(lhs, rhs.size());
669
template<class T> valarray<T> operator>>(const valarray<T>& lhs, const valarray<T>& rhs){
670
valarray<T> retval(lhs);
674
template<class T> valarray<T> operator>>(const valarray<T>& lhs, const T& rhs){
675
valarray<T> retval(lhs);
679
template<class T> valarray<T> operator>>(const T& lhs, const valarray<T>& rhs){
680
valarray<T> retval(lhs, rhs.size());
685
template<class T> valarray<bool> operator&&(const valarray<T>& lhs, const valarray<T>& rhs){
686
valarray<bool> retval(lhs.size());
687
for(size_t i = 0; i < retval.size(); ++i){
688
retval[i] = lhs[i] && rhs[i];
692
template<class T> valarray<bool> operator&&(const valarray<T>& lhs, const T& rhs){
693
valarray<bool> retval(lhs.size());
694
for(size_t i = 0; i <retval.size(); ++i){
695
retval[i] = lhs[i] && rhs;
699
template<class T> valarray<bool> operator&&(const T& lhs, const valarray<T>& rhs){
700
valarray<bool> retval(rhs.size());
701
for(size_t i = 0; i <retval.size(); ++i){
702
retval[i] = lhs && rhs[i];
706
template<class T> valarray<bool> operator||(const valarray<T>&lhs, const valarray<T>& rhs){
707
valarray<bool> retval(lhs.size());
708
for(size_t i = 0; i <retval.size(); ++i){
709
retval[i] = lhs[i] || rhs[i];
713
template<class T> valarray<bool> operator||(const valarray<T>& lhs, const T& rhs){
714
valarray<bool> retval(lhs.size());
715
for(size_t i = 0; i <retval.size(); ++i){
716
retval[i] = lhs[i] || rhs;
720
template<class T> valarray<bool> operator||(const T& lhs, const valarray<T>& rhs){
721
valarray<bool> retval(rhs.size());
722
for(size_t i = 0; i < retval.size(); ++i){
723
retval[i] = lhs || rhs[i];
728
template<class T> valarray<bool> operator==(const valarray<T>& lhs, const valarray<T>& rhs){
729
valarray<bool> retval(lhs.size());
730
for(size_t i = 0; i <retval.size(); ++i){
731
retval[i] = lhs[i] == rhs[i];
735
template<class T> valarray<bool> operator==(const valarray<T>& lhs, const T& rhs){
736
valarray<bool> retval(lhs.size());
737
for(size_t i = 0; i < retval.size(); ++i){
738
retval[i] = lhs[i] == rhs;
742
template<class T> valarray<bool> operator==(const T& lhs, const valarray<T>& rhs){
743
valarray<bool> retval(rhs.size());
744
for(size_t i = 0; i < retval.size(); ++i){
745
retval[i] = lhs == rhs[i];
749
template<class T> valarray<bool> operator!=(const valarray<T>& lhs, const valarray<T>& rhs){
750
valarray<bool> retval(lhs.size());
751
for(size_t i = 0; i <retval.size(); ++i){
752
retval[i] = lhs[i] != rhs[i];
756
template<class T> valarray<bool> operator!=(const valarray<T>& lhs, const T& rhs){
757
valarray<bool> retval(lhs.size());
758
for(size_t i = 0; i <retval.size(); ++i){
759
retval[i] = lhs[i] != rhs;
763
template<class T> valarray<bool> operator!=(const T& lhs, const valarray<T>& rhs){
764
valarray<bool> retval(rhs.size());
765
for(size_t i = 0; i <retval.size(); ++i){
766
retval[i] = lhs != rhs[i];
770
template<class T> valarray<bool> operator< (const valarray<T>& lhs, const valarray<T>& rhs){
771
valarray<bool> retval(lhs.size());
772
for(size_t i = 0; i <retval.size(); ++i){
773
retval[i] = lhs[i] < rhs[i];
777
template<class T> valarray<bool> operator< (const valarray<T>& lhs, const T& rhs){
778
valarray<bool> retval(lhs.size());
779
for(size_t i = 0; i <retval.size(); ++i){
780
retval[i] = lhs[i] < rhs;
784
template<class T> valarray<bool> operator< (const T& lhs, const valarray<T>& rhs){
785
valarray<bool> retval(rhs.size());
786
for(size_t i = 0; i <retval.size(); ++i){
787
retval[i] = lhs < rhs[i];
791
template<class T> valarray<bool> operator> (const valarray<T>& lhs, const valarray<T>& rhs){
792
valarray<bool> retval(lhs.size());
793
for(size_t i = 0; i <retval.size(); ++i){
794
retval[i] = lhs[i] > rhs[i];
798
template<class T> valarray<bool> operator> (const valarray<T>& lhs, const T& rhs){
799
valarray<bool> retval(lhs.size());
800
for(size_t i = 0; i <retval.size(); ++i){
801
retval[i] = lhs[i] > rhs;
805
template<class T> valarray<bool> operator> (const T& rhs, const valarray<T>& lhs){
806
valarray<bool> retval(rhs.size());
807
for(size_t i = 0; i <retval.size(); ++i){
808
retval[i] = lhs > rhs[i];
812
template<class T> valarray<bool> operator<=(const valarray<T>& lhs, const valarray<T>& rhs){
813
valarray<bool> retval(lhs.size());
814
for(size_t i = 0; i <retval.size(); ++i){
815
retval[i] = lhs[i] <= rhs[i];
819
template<class T> valarray<bool> operator<=(const valarray<T>& lhs, const T& rhs){
820
valarray<bool> retval(lhs.size());
821
for(size_t i = 0; i <retval.size(); ++i){
822
retval[i] = lhs[i] <= rhs;
826
template<class T> valarray<bool> operator<=(const T& lhs, const valarray<T>& rhs){
827
valarray<bool> retval(rhs.size());
828
for(size_t i = 0; i <retval.size(); ++i){
829
retval[i] = lhs <= rhs[i];
833
template<class T> valarray<bool> operator>=(const valarray<T>& lhs, const valarray<T>& rhs){
834
valarray<bool> retval(lhs.size());
835
for(size_t i = 0; i <retval.size(); ++i){
836
retval[i] = lhs[i] >= rhs[i];
840
template<class T> valarray<bool> operator>=(const valarray<T>& lhs, const T& rhs){
841
valarray<bool> retval(lhs.size());
842
for(size_t i = 0; i <retval.size(); ++i){
843
retval[i] = lhs[i] >= rhs;
847
template<class T> valarray<bool> operator>=(const T& lhs, const valarray<T>& rhs){
848
valarray<bool> retval(rhs.size());
849
for(size_t i = 0; i <retval.size(); ++i){
850
retval[i] = lhs >= rhs[i];
854
template<class T> T min(const valarray<T>& x){
856
for(size_t i = 1; i < x.size(); ++i){
862
template<class T> T max(const valarray<T>& x){
864
for(size_t i = 1; i < x.size(); ++i){
871
template<class T> valarray<T> abs (const valarray<T>& x){
872
valarray<T> retval(x.size());
873
for(size_t i = 0; i < retval.size(); ++i){
874
retval[i] = abs(x[i]);
877
template<class T> valarray<T> acos (const valarray<T>& x){
878
valarray<T> retval(x.size());
879
for(size_t i = 0; i < retval.size(); ++i){
880
retval[i] = acos(x[i]);
883
template<class T> valarray<T> asin (const valarray<T>& x){
884
valarray<T> retval(x.size());
885
for(size_t i = 0; i < retval.size(); ++i){
886
retval[i] = asin(x[i]);
889
template<class T> valarray<T> atan (const valarray<T>& x){
890
valarray<T> retval(x.size());
891
for(size_t i = 0; i < retval.size(); ++i){
892
retval[i] = atan(x[i]);
895
template<class T> valarray<T> atan2(const valarray<T>& y, const valarray<T>& x){
896
valarray<T> retval(y.size());
897
for(size_t i = 0; i < retval.size(); ++i){
898
retval[i] = atan2(y[i], x[i]);
901
template<class T> valarray<T> atan2(const valarray<T>& y, const T& x){
902
valarray<T> retval(y.size());
903
for(size_t i = 0; i < retval.size(); ++i){
904
retval[i] = atan2(y[i], x);
907
template<class T> valarray<T> atan2(const T& y, const valarray<T>& x){
908
valarray<T> retval(x.size());
909
for(size_t i = 0; i < retval.size(); ++i){
910
retval[i] = abs(y, x[i]);
913
template<class T> valarray<T> cos (const valarray<T>& x){
914
valarray<T> retval(x.size());
915
for(size_t i = 0; i < retval.size(); ++i){
916
retval[i] = cos(x[i]);
919
template<class T> valarray<T> cosh (const valarray<T>& x){
920
valarray<T> retval(x.size());
921
for(size_t i = 0; i < retval.size(); ++i){
922
retval[i] = cosh(x[i]);
925
template<class T> valarray<T> exp (const valarray<T>& x){
926
valarray<T> retval(x.size());
927
for(size_t i = 0; i < retval.size(); ++i){
928
retval[i] = exp(x[i]);
931
template<class T> valarray<T> log (const valarray<T>& x){
932
valarray<T> retval(x.size());
933
for(size_t i = 0; i < retval.size(); ++i){
934
retval[i] = log(x[i]);
937
template<class T> valarray<T> log10(const valarray<T>& x){
938
valarray<T> retval(x.size());
939
for(size_t i = 0; i < retval.size(); ++i){
940
retval[i] = log10(x[i]);
943
template<class T> valarray<T> pow (const valarray<T>& x, const valarray<T>& y){
944
valarray<T> retval(x.size());
945
for(size_t i = 0; i < retval.size(); ++i){
946
retval[i] = pow(x[i], y[i]);
949
template<class T> valarray<T> pow (const valarray<T>& x, const T& y){
950
valarray<T> retval(x.size());
951
for(size_t i = 0; i < retval.size(); ++i){
952
retval[i] = pow(x[i], y);
955
template<class T> valarray<T> pow (const T& x, const valarray<T>& y){
956
valarray<T> retval(x.size());
957
for(size_t i = 0; i < retval.size(); ++i){
958
retval[i] = pow(x, y[i]);
961
template<class T> valarray<T> sin (const valarray<T>& x){
962
valarray<T> retval(x.size());
963
for(size_t i = 0; i < retval.size(); ++i){
964
retval[i] = sin(x[i]);
967
template<class T> valarray<T> sinh (const valarray<T>& x){
968
valarray<T> retval(x.size());
969
for(size_t i = 0; i < retval.size(); ++i){
970
retval[i] = sinh(x[i]);
973
template<class T> valarray<T> sqrt (const valarray<T>& x){
974
valarray<T> retval(x.size());
975
for(size_t i = 0; i < retval.size(); ++i){
976
retval[i] = sqrt(x[i]);
979
template<class T> valarray<T> tan (const valarray<T>& x){
980
valarray<T> retval(x.size());
981
for(size_t i = 0; i < retval.size(); ++i){
982
retval[i] = tan(x[i]);
985
template<class T> valarray<T> tanh (const valarray<T>& x){
986
valarray<T> retval(x.size());
987
for(size_t i = 0; i < retval.size(); ++i){
988
retval[i] = tanh(x[i]);
994
#pragma GCC visibility pop