source: tests/mathX.cfa @ d84f2ae

Last change on this file since d84f2ae was 10b5970, checked in by Michael Brooks <mlbrooks@…>, 2 weeks ago

Fix many test-suite- and libcfa-caused unused variable warnings.

In scope are easy fixes among tests whose sole warnings were unused variable. Reduces the wflags lax list by 40%.

  • Property mode set to 100644
File size: 11.7 KB
Line 
1//
2// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
3//
4// The contents of this file are covered under the licence agreement in the
5// file "LICENCE" distributed with Cforall.
6//
7// mathX.cfa --
8//
9// Author           : Peter A. Buhr
10// Created On       : Thu May 24 20:56:54 2018
11// Last Modified By : Peter A. Buhr
12// Last Modified On : Sun Aug  8 22:33:46 2021
13// Update Count     : 31
14//
15
16#include <fstream.hfa>
17#include <math.hfa>
18
19int main( void ) {
20        signed char sc, scr1, scr2, scr3;
21        unsigned char uc, ucr1, ucr2, ucr3;
22        short int si, sir1, sir2, sir3;
23        unsigned short int usi, usir1, usir2, usir3;
24        int i, ir1, ir2, ir3;
25        unsigned int ui, uir1, uir2, uir3;
26        long int li, lir1, lir2, lir3;
27        unsigned long int uli, ulir1, ulir2, ulir3;
28        long long int lli, llir1, llir2, llir3;
29        unsigned long long int ulli, ullir1, ullir2, ullir3;
30
31        //---------------------- Nearest Integer ----------------------
32
33        //============================================================
34#if 1
35        sout | nl | "floor" | nl | nl;
36
37        sout | "signed char";
38        for ( sc = 1; sc != 0; sc <<= 1 ) {
39                scr1 = floor( sc, sc ); scr2 = floor( sc + 2hh, sc ); scr3 = floor( -sc - 2hh, sc );
40                sout | "floor(" | sc | ", " | sc | ") = " | scr1 | ", floor(" | sc + 2hh | ", " | sc | ") = " | scr2 | ", floor(" | -sc - 2hh | ", " | sc | ") = " | scr3;
41        } // for
42        sout | nl;
43
44        sout | "unsigned char";
45        for ( uc = 1; uc != 0; uc <<= 1 ) {
46                ucr1 = floor( uc, uc ); ucr2 = floor( uc + 2uhh, uc ); ucr3 = floor( -uc - 2uhh, uc );
47                sout | "floor(" | uc | ", " | uc | ") = " | ucr1 | ", floor(" | uc + 2uhh | ", " | uc | ") = " | ucr2 | ", floor(" | -uc - 2uhh | ", " | uc | ") = " | ucr3;
48        } // for
49        sout | nl;
50
51        sout | "short int";
52        for ( si = 1; si != 0; si <<= 1 ) {
53                sir1 = floor( si, si ); sir2 = floor( si + 2h, si ); sir3 = floor( -si - 2h, si );
54                sout | "floor(" | si | ", " | si | ") = " | sir1 | ", floor(" | si + 2h | ", " | si | ") = " | sir2 | ", floor(" | -si - 2h | ", " | si | ") = " | sir3;
55        } // for
56        sout | nl;
57
58        sout | "unsigned short int";
59        for ( usi = 1; usi != 0; usi <<= 1 ) {
60                usir1 = floor( usi, usi ); usir2 = floor( usi + 2uh, usi ); usir3 = floor( -usi - 2uh, usi );
61                sout | "floor(" | usi | ", " | usi | ") = " | usir1 | ", floor(" | usi + 2uh | ", " | usi | ") = " | usir2 | ", floor(" | -usi - 2uh | ", " | usi | ") = " | usir3;
62        } // for
63        sout | nl;
64
65        sout | "int";
66        for ( i = 1; i != 0; i <<= 1 ) {
67                ir1 = floor( i, i ); ir2 = floor( i + 2n, i ); ir3 = floor( -i - 2n, i );
68                sout | "floor(" | i | ", " | i | ") = " | ir1 | ", floor(" | i + 2n | ", " | i | ") = " | ir2 | ", floor(" | -i - 2n | ", " | i | ") = " | ir3;
69        } // for
70        sout | nl;
71
72        sout | "unsigned int";
73        for ( ui = 1; ui != 0; ui <<= 1 ) {
74                uir1 = floor( ui, ui ); uir2 = floor( ui + 2un, ui ); uir3 = floor( -ui - 2un, ui );
75                sout | "floor(" | ui | ", " | ui | ") = " | uir1 | ", floor(" | ui + 2un | ", " | ui | ") = " | uir2 | ", floor(" | -ui - 2un | ", " | ui | ") = " | uir3;
76        } // for
77        sout | nl;
78
79        sout | "long int";
80        for ( li = 1; li != 0; li <<= 1 ) {
81                lir1 = floor( li, li ); lir2 = floor( li + 2l, li ); lir3 = floor( -li - 2l, li );
82                sout | "floor(" | li | ", " | li | ") = " | lir1 | ", floor(" | li + 2l | ", " | li | ") = " | lir2 | ", floor(" | -li - 2l | ", " | li | ") = " | lir3;
83        } // for
84        sout | nl;
85
86        sout | "unsigned long int";
87        for ( uli = 1; uli != 0; uli <<= 1 ) {
88                ulir1 = floor( uli, uli ); ulir2 = floor( uli + 2ul, uli ); ulir3 = floor( -uli - 2ul, uli );
89                sout | "floor(" | uli | ", " | uli | ") = " | ulir1 | ", floor(" | uli + 2ul | ", " | uli | ") = " | ulir2 | ", floor(" | -uli - 2ul | ", " | uli | ") = " | ulir3;
90        } // for
91        sout | nl;
92
93        sout | "long long int";
94        for ( lli = 1; lli != 0; lli <<= 1 ) {
95                llir1 = floor( lli, lli ); llir2 = floor( lli + 2ll, lli ); llir3 = floor( -lli - 2ll, lli );
96                sout | "floor(" | lli | ", " | lli | ") = " | llir1 | ", floor(" | lli + 2ll | ", " | lli | ") = " | llir2 | ", floor(" | -lli - 2ll | ", " | lli | ") = " | llir3;
97        } // for
98        sout | nl;
99
100        sout | "unsigned long long int";
101        for ( ulli = 1; ulli != 0; ulli <<= 1 ) {
102                ullir1 = floor( ulli, ulli ); ullir2 = floor( ulli + 2ull, ulli ); ullir3 = floor( -ulli - 2ull, ulli );
103                sout | "floor(" | ulli | ", " | ulli | ") = " | ullir1 | ", floor(" | ulli + 2ull | ", " | ulli | ") = " | ullir2 | ", floor(" | -ulli - 2ull | ", " | ulli | ") = " | ullir3;
104        } // for
105        sout | nl;
106#endif // 0
107        //============================================================
108#if 1
109        sout | nl | "ceiling_div" | nl | nl;
110
111        sout | "signed char";
112        for ( sc = 1; sc != 0; sc <<= 1 ) {
113                scr1 = ceiling_div( sc, sc ); scr2 = ceiling_div( sc + 2hh, sc ); scr3 = ceiling_div( -sc - 2hh, sc );
114                sout | "ceiling_div(" | sc | ", " | sc | ") = " | scr1 | ", ceiling_div(" | sc + 2hh | ", " | sc | ") = " | scr2 | ", ceiling_div(" | -sc - 2hh | ", " | sc | ") = " | scr3;
115        } // for
116        sout | nl;
117
118        sout | "unsigned char";
119        for ( uc = 1; uc != 0; uc <<= 1 ) {
120                ucr1 = ceiling_div( uc, uc ); ucr2 = ceiling_div( uc + 2uhh, uc ); ucr3 = ceiling_div( -uc - 2uhh, uc );
121                sout | "ceiling_div(" | uc | ", " | uc | ") = " | ucr1 | ", ceiling_div(" | uc + 2uhh | ", " | uc | ") = " | ucr2 | ", ceiling_div(" | -uc - 2uhh | ", " | uc | ") = " | ucr3;
122        } // for
123        sout | nl;
124
125        sout | "short int";
126        for ( si = 1; si != 0; si <<= 1 ) {
127                sir1 = ceiling_div( si, si ); sir2 = ceiling_div( si + 2h, si ); sir3 = ceiling_div( -si - 2h, si );
128                sout | "ceiling_div(" | si | ", " | si | ") = " | sir1 | ", ceiling_div(" | si + 2h | ", " | si | ") = " | sir2 | ", ceiling_div(" | -si - 2h | ", " | si | ") = " | sir3;
129        } // for
130        sout | nl;
131
132        sout | "unsigned short int";
133        for ( usi = 1; usi != 0; usi <<= 1 ) {
134                usir1 = ceiling_div( usi, usi ); usir2 = ceiling_div( usi + 2h, usi ); usir3 = ceiling_div( -usi - 2h, usi );
135                sout | "ceiling_div(" | usi | ", " | usi | ") = " | usir1 | ", ceiling_div(" | usi + 2uh | ", " | usi | ") = " | usir2 | ", ceiling_div(" | -usi - 2uh | ", " | usi | ") = " | usir3;
136        } // for
137        sout | nl;
138
139        sout | "int";
140        for ( i = 1; i != 0; i <<= 1 ) {
141                ir1 = ceiling_div( i, i ); ir2 = ceiling_div( i + 2n, i ); ir3 = ceiling_div( -i - 2n, i );
142                sout | "ceiling_div(" | i | ", " | i | ") = " | ir1 | ", ceiling_div(" | i + 2n | ", " | i | ") = " | ir2 | ", ceiling_div(" | -i - 2n | ", " | i | ") = " | ir3;
143        } // for
144        sout | nl;
145
146        sout | "unsigned int";
147        for ( ui = 1; ui != 0; ui <<= 1 ) {
148                uir1 = ceiling_div( ui, ui ); uir2 = ceiling_div( ui + 2un, ui ); uir3 = ceiling_div( -ui - 2un, ui );
149                sout | "ceiling_div(" | ui | ", " | ui | ") = " | uir1 | ", ceiling_div(" | ui + 2un | ", " | ui | ") = " | uir2 | ", ceiling_div(" | -ui - 2un | ", " | ui | ") = " | uir3;
150        } // for
151        sout | nl;
152
153        sout | "long int";
154        for ( li = 1; li != 0; li <<= 1 ) {
155                lir1 = ceiling_div( li, li ); lir2 = ceiling_div( li + 2l, li ); lir3 = ceiling_div( -li - 2l, li );
156                sout | "ceiling_div(" | li | ", " | li | ") = " | lir1 | ", ceiling_div(" | li + 2l | ", " | li | ") = " | lir2 | ", ceiling_div(" | -li - 2l | ", " | li | ") = " | lir3;
157        } // for
158        sout | nl;
159
160        sout | "unsigned long int";
161        for ( uli = 1; uli != 0; uli <<= 1 ) {
162                ulir1 = ceiling_div( uli, uli ); ulir2 = ceiling_div( uli + 2ul, uli ); ulir3 = ceiling_div( -uli - 2ul, uli );
163                sout | "ceiling_div(" | uli | ", " | uli | ") = " | ulir1 | ", ceiling_div(" | uli + 2ul | ", " | uli | ") = " | ulir2 | ", ceiling_div(" | -uli - 2ul | ", " | uli | ") = " | ulir3;
164        } // for
165        sout | nl;
166
167        sout | "long long int";
168        for ( lli = 1; lli != 0; lli <<= 1 ) {
169                llir1 = ceiling_div( lli, lli ); llir2 = ceiling_div( lli + 2ll, lli ); llir3 = ceiling_div( -lli - 2ll, lli );
170                sout | "ceiling_div(" | lli | ", " | lli | ") = " | llir1 | ", ceiling_div(" | lli + 2ll | ", " | lli | ") = " | llir2 | ", ceiling_div(" | -lli - 2ll | ", " | lli | ") = " | llir3;
171        } // for
172        sout | nl;
173
174        sout | "unsigned long long int";
175        for ( ulli = 1; ulli != 0; ulli <<= 1 ) {
176                ullir1 = ceiling_div( ulli, ulli ); ullir2 = ceiling_div( ulli + 2ull, ulli ); ullir3 = ceiling_div( -ulli - 2ull, ulli );
177                sout | "ceiling_div(" | ulli | ", " | ulli | ") = " | ullir1 | ", ceiling_div(" | ulli + 2ull | ", " | ulli | ") = " | ullir2 | ", ceiling_div(" | -ulli - 2ull | ", " | ulli | ") = " | ullir3;
178        } // for
179        sout | nl;
180#endif // 0
181        //============================================================
182#if 1
183        sout | nl | "ceiling" | nl | nl;
184
185        sout | "signed char";
186        for ( sc = 1; sc != 0; sc <<= 1 ) {
187                scr1 = ceiling( sc, sc ); scr2 = ceiling( sc + 2hh, sc ); scr3 = ceiling( -sc - 2hh, sc );
188                sout | "ceiling(" | sc | ", " | sc | ") = " | scr1 | ", ceiling(" | sc + 2hh | ", " | sc | ") = " | scr2 | ", ceiling(" | -sc - 2hh | ", " | sc | ") = " | scr3;
189        } // for
190        sout | nl;
191
192        sout | "unsigned char";
193        for ( uc = 1; uc != 0; uc <<= 1 ) {
194                ucr1 = ceiling( uc, uc ); ucr2 = ceiling( uc + 2uhh, uc ); ucr3 = ceiling( -uc - 2uhh, uc );
195                sout | "ceiling(" | uc | ", " | uc | ") = " | ucr1 | ", ceiling(" | uc + 2uhh | ", " | uc | ") = " | ucr2 | ", ceiling(" | -uc - 2uhh | ", " | uc | ") = " | ucr3;
196        } // for
197        sout | nl;
198
199        sout | "short int";
200        for ( si = 1; si != 0; si <<= 1 ) {
201                sir1 = ceiling( si, si ); sir2 = ceiling( si + 2h, si ); sir3 = ceiling( -si - 2h, si );
202                sout | "ceiling(" | si | ", " | si | ") = " | sir1 | ", ceiling(" | si + 2h | ", " | si | ") = " | sir2 | ", ceiling(" | -si - 2h | ", " | si | ") = " | sir3;
203        } // for
204        sout | nl;
205
206        sout | "unsigned short int";
207        for ( usi = 1; usi != 0; usi <<= 1 ) {
208                usir1 = ceiling( usi, usi ); usir2 = ceiling( usi + 2uh, usi ); usir3 = ceiling( -usi - 2uh, usi );
209                sout | "ceiling(" | usi | ", " | usi | ") = " | usir1 | ", ceiling(" | usi + 2uh | ", " | usi | ") = " | usir2 | ", ceiling(" | -usi - 2uh | ", " | usi | ") = " | usir3;
210        } // for
211        sout | nl;
212
213        sout | "int";
214        for ( i = 1; i != 0; i <<= 1 ) {
215                ir1 = ceiling( i, i ); ir2 = ceiling( i + 2n, i ); ir3 = ceiling( -i - 2n, i );
216                sout | "ceiling(" | i | ", " | i | ") = " | ir1 | ", ceiling(" | i + 2n | ", " | i | ") = " | ir2 | ", ceiling(" | -i - 2n | ", " | i | ") = " | ir3;
217        } // for
218        sout | nl;
219
220        sout | "unsigned int";
221        for ( ui = 1; ui != 0; ui <<= 1 ) {
222                uir1 = ceiling( ui, ui ); uir2 = ceiling( ui + 2un, ui ); uir3 = ceiling( -ui - 2un, ui );
223                sout | "ceiling(" | ui | ", " | ui | ") = " | uir1 | ", ceiling(" | ui + 2un | ", " | ui | ") = " | uir2 | ", ceiling(" | -ui - 2un | ", " | ui | ") = " | uir3;
224        } // for
225        sout | nl;
226
227        sout | "long int";
228        for ( li = 1; li != 0; li <<= 1 ) {
229                lir1 = ceiling( li, li ); lir2 = ceiling( li + 2l, li ); lir3 = ceiling( -li - 2l, li );
230                sout | "ceiling(" | li | ", " | li | ") = " | lir1 | ", ceiling(" | li + 2l | ", " | li | ") = " | lir2 | ", ceiling(" | -li - 2l | ", " | li | ") = " | lir3;
231        } // for
232        sout | nl;
233
234        sout | "unsigned long int";
235        for ( uli = 1; uli != 0; uli <<= 1 ) {
236                ulir1 = ceiling( uli, uli ); ulir2 = ceiling( uli + 2ul, uli ); ulir3 = ceiling( -uli - 2ul, uli );
237                sout | "ceiling(" | uli | ", " | uli | ") = " | ulir1 | ", ceiling(" | uli + 2ul | ", " | uli | ") = " | ulir2 | ", ceiling(" | -uli - 2ul | ", " | uli | ") = " | ulir3;
238        } // for
239        sout | nl;
240
241        sout | "long long int";
242        for ( lli = 1; lli != 0; lli <<= 1 ) {
243                llir1 = ceiling( lli, lli ); llir2 = ceiling( lli + 2ll, lli ); llir3 = ceiling( -lli - 2ll, lli );
244                sout | "ceiling(" | lli | ", " | lli | ") = " | llir1 | ", ceiling(" | lli + 2ll | ", " | lli | ") = " | llir2 | ", ceiling(" | -lli - 2ll | ", " | lli | ") = " | llir3;
245        } // for
246        sout | nl;
247
248        sout | "unsigned long long int";
249        for ( ulli = 1; ulli != 0; ulli <<= 1 ) {
250                ullir1 = ceiling( ulli, ulli ); ullir2 = ceiling( ulli + 2ull, ulli ); ullir3 = ceiling( -ulli - 2ull, ulli );
251                sout | "ceiling(" | ulli | ", " | ulli | ") = " | ullir1 | ", ceiling(" | ulli + 2ull | ", " | ulli | ") = " | ullir2 | ", ceiling(" | -ulli - 2ull | ", " | ulli | ") = " | ullir3;
252        } // for
253        sout | nl;
254#endif // 0
255} // main
256
257// Local Variables: //
258// tab-width: 4 //
259// compile-command: "cfa mathX.cfa" //
260// End: //
Note: See TracBrowser for help on using the repository browser.