OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc3/] [libstdc++-v3/] [testsuite/] [26_numerics/] [valarray/] [30416.cc] - Blame information for rev 516

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 424 jeremybenn
// 2007-01-11  Paolo Carlini  <pcarlini@suse.de>
2
 
3
// Copyright (C) 2007, 2009 Free Software Foundation, Inc.
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 3, 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 COPYING3.  If not see
18
// <http://www.gnu.org/licenses/>.
19
 
20
 
21
#include <valarray>
22
#include <testsuite_hooks.h>
23
 
24
bool
25
comp_vala(const std::valarray<int>& v1, const std::valarray<int>& v2)
26
{
27
  if (v1.size() == v2.size())
28
    {
29
      for (size_t i = 0; i < v1.size(); ++i)
30
        if (v1[i] != v2[i])
31
          return false;
32
      return true;
33
    }
34
  return false;
35
}
36
 
37
void
38
init_vala(std::valarray<int>& v, size_t first, size_t last, int val)
39
{
40
  for (size_t i = first; i <= last; ++i)
41
    v[i] = val++;
42
}
43
 
44
// libstdc++/30416
45
void test01()
46
{
47
  bool test __attribute__((unused)) = true;
48
  using namespace std;
49
 
50
  // shift
51
  valarray<int> v1;
52
  valarray<int> v1_ris(v1.shift(0));
53
  VERIFY( comp_vala(v1, v1_ris) );
54
 
55
  valarray<int> v2;
56
  valarray<int> v2_ris(v2.shift(10));
57
  VERIFY( comp_vala(v2, v2_ris) );
58
 
59
  valarray<int> v3;
60
  valarray<int> v3_ris(v3.shift(-10));
61
  VERIFY( comp_vala(v3, v3_ris) );
62
 
63
  valarray<int> v4(10);
64
  valarray<int> v4_ris(v4.shift(0));
65
  VERIFY( comp_vala(v4, v4_ris) );
66
 
67
  valarray<int> v5(10);
68
  init_vala(v5, 0, 9, 1);
69
  valarray<int> v5_ref(10);
70
 
71
  valarray<int> v5_ris(v5.shift(16));
72
  VERIFY( comp_vala(v5_ris, v5_ref) );
73
 
74
  valarray<int> v6(10);
75
  init_vala(v6, 0, 9, 1);
76
  valarray<int> v6_ref(10);
77
 
78
  valarray<int> v6_ris(v6.shift(-16));
79
  VERIFY( comp_vala(v6_ris, v6_ref) );
80
 
81
  valarray<int> v7(10);
82
  init_vala(v7, 0, 9, 1);
83
  valarray<int> v7_ref(10);
84
 
85
  valarray<int> v7_ris(v7.shift(10));
86
  VERIFY( comp_vala(v7_ris, v7_ref) );
87
 
88
  valarray<int> v8(10);
89
  init_vala(v8, 0, 9, 1);
90
  valarray<int> v8_ref(10);
91
 
92
  valarray<int> v8_ris(v8.shift(-10));
93
  VERIFY( comp_vala(v8_ris, v8_ref) );
94
 
95
  valarray<int> v9(10);
96
  init_vala(v9, 0, 9, 1);
97
  valarray<int> v9_ref(10);
98
  init_vala(v9_ref, 0, 3, 7);
99
 
100
  valarray<int> v9_ris(v9.shift(6));
101
  VERIFY( comp_vala(v9_ris, v9_ref) );
102
 
103
  valarray<int> v10(10);
104
  init_vala(v10, 0, 9, 1);
105
  valarray<int> v10_ref(10);
106
  init_vala(v10_ref, 6, 9, 1);
107
 
108
  valarray<int> v10_ris(v10.shift(-6));
109
  VERIFY( comp_vala(v10_ris, v10_ref) );
110
 
111
  // cshift
112
  valarray<int> v11;
113
  valarray<int> v11_ris(v11.cshift(0));
114
  VERIFY( comp_vala(v11, v11_ris) );
115
 
116
  valarray<int> v12;
117
  valarray<int> v12_ris(v12.cshift(10));
118
  VERIFY( comp_vala(v12, v12_ris) );
119
 
120
  valarray<int> v13;
121
  valarray<int> v13_ris(v13.cshift(-10));
122
  VERIFY( comp_vala(v13, v13_ris) );
123
 
124
  valarray<int> v14(10);
125
  valarray<int> v14_ris(v14.cshift(0));
126
  VERIFY( comp_vala(v14, v14_ris) );
127
 
128
  valarray<int> v15(10);
129
  init_vala(v15, 0, 9, 1);
130
  valarray<int> v15_ref(10);
131
  init_vala(v15_ref, 0, 3, 7);
132
  init_vala(v15_ref, 4, 9, 1);
133
 
134
  valarray<int> v15_ris(v15.cshift(16));
135
  VERIFY( comp_vala(v15_ris, v15_ref) );
136
 
137
  valarray<int> v16(10);
138
  init_vala(v16, 0, 9, 1);
139
  valarray<int> v16_ref(10);
140
  init_vala(v16_ref, 0, 5, 5);
141
  init_vala(v16_ref, 6, 9, 1);
142
 
143
  valarray<int> v16_ris(v16.cshift(-16));
144
  VERIFY( comp_vala(v16_ris, v16_ref) );
145
 
146
  valarray<int> v17(10);
147
  init_vala(v17, 0, 9, 1);
148
 
149
  valarray<int> v17_ris(v15.cshift(10));
150
  VERIFY( comp_vala(v17, v17_ris) );
151
 
152
  valarray<int> v18(10);
153
  init_vala(v18, 0, 9, 1);
154
 
155
  valarray<int> v18_ris(v18.cshift(-10));
156
  VERIFY( comp_vala(v18, v18_ris) );
157
 
158
  valarray<int> v19(10);
159
  init_vala(v19, 0, 9, 1);
160
  valarray<int> v19_ref(10);
161
  init_vala(v19_ref, 0, 3, 7);
162
  init_vala(v19_ref, 4, 9, 1);
163
 
164
  valarray<int> v19_ris(v15.cshift(6));
165
  VERIFY( comp_vala(v19_ris, v19_ref) );
166
 
167
  valarray<int> v20(10);
168
  init_vala(v20, 0, 9, 1);
169
  valarray<int> v20_ref(10);
170
  init_vala(v20_ref, 0, 5, 5);
171
  init_vala(v20_ref, 6, 9, 1);
172
 
173
  valarray<int> v20_ris(v20.cshift(-6));
174
  VERIFY( comp_vala(v20_ris, v20_ref) );
175
}
176
 
177
int main()
178
{
179
  test01();
180
  return 0;
181
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.