]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/26_numerics/valarray/30416.cc
1 // 2007-01-11 Paolo Carlini <pcarlini@suse.de>
3 // Copyright (C) 2007 Free Software Foundation, Inc.
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)
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.
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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
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.
31 #include <testsuite_hooks.h>
34 comp_vala(const std::valarray
<int>& v1
, const std::valarray
<int>& v2
)
36 if (v1
.size() == v2
.size())
38 for (size_t i
= 0; i
< v1
.size(); ++i
)
47 init_vala(std::valarray
<int>& v
, size_t first
, size_t last
, int val
)
49 for (size_t i
= first
; i
<= last
; ++i
)
56 bool test
__attribute__((unused
)) = true;
61 valarray
<int> v1_ris(v1
.shift(0));
62 VERIFY( comp_vala(v1
, v1_ris
) );
65 valarray
<int> v2_ris(v2
.shift(10));
66 VERIFY( comp_vala(v2
, v2_ris
) );
69 valarray
<int> v3_ris(v3
.shift(-10));
70 VERIFY( comp_vala(v3
, v3_ris
) );
73 valarray
<int> v4_ris(v4
.shift(0));
74 VERIFY( comp_vala(v4
, v4_ris
) );
77 init_vala(v5
, 0, 9, 1);
78 valarray
<int> v5_ref(10);
80 valarray
<int> v5_ris(v5
.shift(16));
81 VERIFY( comp_vala(v5_ris
, v5_ref
) );
84 init_vala(v6
, 0, 9, 1);
85 valarray
<int> v6_ref(10);
87 valarray
<int> v6_ris(v6
.shift(-16));
88 VERIFY( comp_vala(v6_ris
, v6_ref
) );
91 init_vala(v7
, 0, 9, 1);
92 valarray
<int> v7_ref(10);
94 valarray
<int> v7_ris(v7
.shift(10));
95 VERIFY( comp_vala(v7_ris
, v7_ref
) );
98 init_vala(v8
, 0, 9, 1);
99 valarray
<int> v8_ref(10);
101 valarray
<int> v8_ris(v8
.shift(-10));
102 VERIFY( comp_vala(v8_ris
, v8_ref
) );
104 valarray
<int> v9(10);
105 init_vala(v9
, 0, 9, 1);
106 valarray
<int> v9_ref(10);
107 init_vala(v9_ref
, 0, 3, 7);
109 valarray
<int> v9_ris(v9
.shift(6));
110 VERIFY( comp_vala(v9_ris
, v9_ref
) );
112 valarray
<int> v10(10);
113 init_vala(v10
, 0, 9, 1);
114 valarray
<int> v10_ref(10);
115 init_vala(v10_ref
, 6, 9, 1);
117 valarray
<int> v10_ris(v10
.shift(-6));
118 VERIFY( comp_vala(v10_ris
, v10_ref
) );
122 valarray
<int> v11_ris(v11
.cshift(0));
123 VERIFY( comp_vala(v11
, v11_ris
) );
126 valarray
<int> v12_ris(v12
.cshift(10));
127 VERIFY( comp_vala(v12
, v12_ris
) );
130 valarray
<int> v13_ris(v13
.cshift(-10));
131 VERIFY( comp_vala(v13
, v13_ris
) );
133 valarray
<int> v14(10);
134 valarray
<int> v14_ris(v14
.cshift(0));
135 VERIFY( comp_vala(v14
, v14_ris
) );
137 valarray
<int> v15(10);
138 init_vala(v15
, 0, 9, 1);
139 valarray
<int> v15_ref(10);
140 init_vala(v15_ref
, 0, 3, 7);
141 init_vala(v15_ref
, 4, 9, 1);
143 valarray
<int> v15_ris(v15
.cshift(16));
144 VERIFY( comp_vala(v15_ris
, v15_ref
) );
146 valarray
<int> v16(10);
147 init_vala(v16
, 0, 9, 1);
148 valarray
<int> v16_ref(10);
149 init_vala(v16_ref
, 0, 5, 5);
150 init_vala(v16_ref
, 6, 9, 1);
152 valarray
<int> v16_ris(v16
.cshift(-16));
153 VERIFY( comp_vala(v16_ris
, v16_ref
) );
155 valarray
<int> v17(10);
156 init_vala(v17
, 0, 9, 1);
158 valarray
<int> v17_ris(v15
.cshift(10));
159 VERIFY( comp_vala(v17
, v17_ris
) );
161 valarray
<int> v18(10);
162 init_vala(v18
, 0, 9, 1);
164 valarray
<int> v18_ris(v18
.cshift(-10));
165 VERIFY( comp_vala(v18
, v18_ris
) );
167 valarray
<int> v19(10);
168 init_vala(v19
, 0, 9, 1);
169 valarray
<int> v19_ref(10);
170 init_vala(v19_ref
, 0, 3, 7);
171 init_vala(v19_ref
, 4, 9, 1);
173 valarray
<int> v19_ris(v15
.cshift(6));
174 VERIFY( comp_vala(v19_ris
, v19_ref
) );
176 valarray
<int> v20(10);
177 init_vala(v20
, 0, 9, 1);
178 valarray
<int> v20_ref(10);
179 init_vala(v20_ref
, 0, 5, 5);
180 init_vala(v20_ref
, 6, 9, 1);
182 valarray
<int> v20_ris(v20
.cshift(-6));
183 VERIFY( comp_vala(v20_ris
, v20_ref
) );