source: tests/mathX.cfa @ d0e80f61

ADTarm-ehast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since d0e80f61 was 6cb7a92, checked in by Peter A. Buhr <pabuhr@…>, 4 years ago

formatting, rename match2 to mathX (extra)

  • 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 : Sat Feb 20 18:26:38 2021
13// Update Count     : 30
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        float f;
32        double d;
33        long double l;
34
35        //---------------------- Nearest Integer ----------------------
36
37        //============================================================
38#if 1
39        sout | nl | "floor" | nl | nl;
40
41        sout | "signed char";
42        for ( sc = 1; sc != 0; sc <<= 1 ) {
43                scr1 = floor( sc, sc ); scr2 = floor( sc + 2hh, sc ); scr3 = floor( -sc - 2hh, sc );
44                sout | "floor(" | sc | ", " | sc | ") = " | scr1 | ", floor(" | sc + 2hh | ", " | sc | ") = " | scr2 | ", floor(" | -sc - 2hh | ", " | sc | ") = " | scr3;
45        } // for
46        sout | nl;
47
48        sout | "unsigned char";
49        for ( uc = 1; uc != 0; uc <<= 1 ) {
50                ucr1 = floor( uc, uc ); ucr2 = floor( uc + 2uhh, uc ); ucr3 = floor( -uc - 2uhh, uc );
51                sout | "floor(" | uc | ", " | uc | ") = " | ucr1 | ", floor(" | uc + 2uhh | ", " | uc | ") = " | ucr2 | ", floor(" | -uc - 2uhh | ", " | uc | ") = " | ucr3;
52        } // for
53        sout | nl;
54
55        sout | "short int";
56        for ( si = 1; si != 0; si <<= 1 ) {
57                sir1 = floor( si, si ); sir2 = floor( si + 2h, si ); sir3 = floor( -si - 2h, si );
58                sout | "floor(" | si | ", " | si | ") = " | sir1 | ", floor(" | si + 2h | ", " | si | ") = " | sir2 | ", floor(" | -si - 2h | ", " | si | ") = " | sir3;
59        } // for
60        sout | nl;
61
62        sout | "unsigned short int";
63        for ( usi = 1; usi != 0; usi <<= 1 ) {
64                usir1 = floor( usi, usi ); usir2 = floor( usi + 2uh, usi ); usir3 = floor( -usi - 2uh, usi );
65                sout | "floor(" | usi | ", " | usi | ") = " | usir1 | ", floor(" | usi + 2uh | ", " | usi | ") = " | usir2 | ", floor(" | -usi - 2uh | ", " | usi | ") = " | usir3;
66        } // for
67        sout | nl;
68
69        sout | "int";
70        for ( i = 1; i != 0; i <<= 1 ) {
71                ir1 = floor( i, i ); ir2 = floor( i + 2n, i ); ir3 = floor( -i - 2n, i );
72                sout | "floor(" | i | ", " | i | ") = " | ir1 | ", floor(" | i + 2n | ", " | i | ") = " | ir2 | ", floor(" | -i - 2n | ", " | i | ") = " | ir3;
73        } // for
74        sout | nl;
75
76        sout | "unsigned int";
77        for ( ui = 1; ui != 0; ui <<= 1 ) {
78                uir1 = floor( ui, ui ); uir2 = floor( ui + 2un, ui ); uir3 = floor( -ui - 2un, ui );
79                sout | "floor(" | ui | ", " | ui | ") = " | uir1 | ", floor(" | ui + 2un | ", " | ui | ") = " | uir2 | ", floor(" | -ui - 2un | ", " | ui | ") = " | uir3;
80        } // for
81        sout | nl;
82
83        sout | "long int";
84        for ( li = 1; li != 0; li <<= 1 ) {
85                lir1 = floor( li, li ); lir2 = floor( li + 2l, li ); lir3 = floor( -li - 2l, li );
86                sout | "floor(" | li | ", " | li | ") = " | lir1 | ", floor(" | li + 2l | ", " | li | ") = " | lir2 | ", floor(" | -li - 2l | ", " | li | ") = " | lir3;
87        } // for
88        sout | nl;
89
90        sout | "unsigned long int";
91        for ( uli = 1; uli != 0; uli <<= 1 ) {
92                ulir1 = floor( uli, uli ); ulir2 = floor( uli + 2ul, uli ); ulir3 = floor( -uli - 2ul, uli );
93                sout | "floor(" | uli | ", " | uli | ") = " | ulir1 | ", floor(" | uli + 2ul | ", " | uli | ") = " | ulir2 | ", floor(" | -uli - 2ul | ", " | uli | ") = " | ulir3;
94        } // for
95        sout | nl;
96
97        sout | "long long int";
98        for ( lli = 1; lli != 0; lli <<= 1 ) {
99                llir1 = floor( lli, lli ); llir2 = floor( lli + 2ll, lli ); llir3 = floor( -lli - 2ll, lli );
100                sout | "floor(" | lli | ", " | lli | ") = " | llir1 | ", floor(" | lli + 2ll | ", " | lli | ") = " | llir2 | ", floor(" | -lli - 2ll | ", " | lli | ") = " | llir3;
101        } // for
102        sout | nl;
103
104        sout | "unsigned long long int";
105        for ( ulli = 1; ulli != 0; ulli <<= 1 ) {
106                ullir1 = floor( ulli, ulli ); ullir2 = floor( ulli + 2ull, ulli ); ullir3 = floor( -ulli - 2ull, ulli );
107                sout | "floor(" | ulli | ", " | ulli | ") = " | ullir1 | ", floor(" | ulli + 2ull | ", " | ulli | ") = " | ullir2 | ", floor(" | -ulli - 2ull | ", " | ulli | ") = " | ullir3;
108        } // for
109        sout | nl;
110#endif // 0
111        //============================================================
112#if 1
113        sout | nl | "ceiling_div" | nl | nl;
114
115        sout | "signed char";
116        for ( sc = 1; sc != 0; sc <<= 1 ) {
117                scr1 = ceiling_div( sc, sc ); scr2 = ceiling_div( sc + 2hh, sc ); scr3 = ceiling_div( -sc - 2hh, sc );
118                sout | "ceiling_div(" | sc | ", " | sc | ") = " | scr1 | ", ceiling_div(" | sc + 2hh | ", " | sc | ") = " | scr2 | ", ceiling_div(" | -sc - 2hh | ", " | sc | ") = " | scr3;
119        } // for
120        sout | nl;
121
122        sout | "unsigned char";
123        for ( uc = 1; uc != 0; uc <<= 1 ) {
124                ucr1 = ceiling_div( uc, uc ); ucr2 = ceiling_div( uc + 2uhh, uc ); ucr3 = ceiling_div( -uc - 2uhh, uc );
125                sout | "ceiling_div(" | uc | ", " | uc | ") = " | ucr1 | ", ceiling_div(" | uc + 2uhh | ", " | uc | ") = " | ucr2 | ", ceiling_div(" | -uc - 2uhh | ", " | uc | ") = " | ucr3;
126        } // for
127        sout | nl;
128
129        sout | "short int";
130        for ( si = 1; si != 0; si <<= 1 ) {
131                sir1 = ceiling_div( si, si ); sir2 = ceiling_div( si + 2h, si ); sir3 = ceiling_div( -si - 2h, si );
132                sout | "ceiling_div(" | si | ", " | si | ") = " | sir1 | ", ceiling_div(" | si + 2h | ", " | si | ") = " | sir2 | ", ceiling_div(" | -si - 2h | ", " | si | ") = " | sir3;
133        } // for
134        sout | nl;
135
136        sout | "unsigned short int";
137        for ( usi = 1; usi != 0; usi <<= 1 ) {
138                usir1 = ceiling_div( usi, usi ); usir2 = ceiling_div( usi + 2h, usi ); usir3 = ceiling_div( -usi - 2h, usi );
139                sout | "ceiling_div(" | usi | ", " | usi | ") = " | usir1 | ", ceiling_div(" | usi + 2uh | ", " | usi | ") = " | usir2 | ", ceiling_div(" | -usi - 2uh | ", " | usi | ") = " | usir3;
140        } // for
141        sout | nl;
142
143        sout | "int";
144        for ( i = 1; i != 0; i <<= 1 ) {
145                ir1 = ceiling_div( i, i ); ir2 = ceiling_div( i + 2n, i ); ir3 = ceiling_div( -i - 2n, i );
146                sout | "ceiling_div(" | i | ", " | i | ") = " | ir1 | ", ceiling_div(" | i + 2n | ", " | i | ") = " | ir2 | ", ceiling_div(" | -i - 2n | ", " | i | ") = " | ir3;
147        } // for
148        sout | nl;
149
150        sout | "unsigned int";
151        for ( ui = 1; ui != 0; ui <<= 1 ) {
152                uir1 = ceiling_div( ui, ui ); uir2 = ceiling_div( ui + 2un, ui ); uir3 = ceiling_div( -ui - 2un, ui );
153                sout | "ceiling_div(" | ui | ", " | ui | ") = " | uir1 | ", ceiling_div(" | ui + 2un | ", " | ui | ") = " | uir2 | ", ceiling_div(" | -ui - 2un | ", " | ui | ") = " | uir3;
154        } // for
155        sout | nl;
156
157        sout | "long int";
158        for ( li = 1; li != 0; li <<= 1 ) {
159                lir1 = ceiling_div( li, li ); lir2 = ceiling_div( li + 2l, li ); lir3 = ceiling_div( -li - 2l, li );
160                sout | "ceiling_div(" | li | ", " | li | ") = " | lir1 | ", ceiling_div(" | li + 2l | ", " | li | ") = " | lir2 | ", ceiling_div(" | -li - 2l | ", " | li | ") = " | lir3;
161        } // for
162        sout | nl;
163
164        sout | "unsigned long int";
165        for ( uli = 1; uli != 0; uli <<= 1 ) {
166                ulir1 = ceiling_div( uli, uli ); ulir2 = ceiling_div( uli + 2ul, uli ); ulir3 = ceiling_div( -uli - 2ul, uli );
167                sout | "ceiling_div(" | uli | ", " | uli | ") = " | ulir1 | ", ceiling_div(" | uli + 2ul | ", " | uli | ") = " | ulir2 | ", ceiling_div(" | -uli - 2ul | ", " | uli | ") = " | ulir3;
168        } // for
169        sout | nl;
170
171        sout | "long long int";
172        for ( lli = 1; lli != 0; lli <<= 1 ) {
173                llir1 = ceiling_div( lli, lli ); llir2 = ceiling_div( lli + 2ll, lli ); llir3 = ceiling_div( -lli - 2ll, lli );
174                sout | "ceiling_div(" | lli | ", " | lli | ") = " | llir1 | ", ceiling_div(" | lli + 2ll | ", " | lli | ") = " | llir2 | ", ceiling_div(" | -lli - 2ll | ", " | lli | ") = " | llir3;
175        } // for
176        sout | nl;
177
178        sout | "unsigned long long int";
179        for ( ulli = 1; ulli != 0; ulli <<= 1 ) {
180                ullir1 = ceiling_div( ulli, ulli ); ullir2 = ceiling_div( ulli + 2ull, ulli ); ullir3 = ceiling_div( -ulli - 2ull, ulli );
181                sout | "ceiling_div(" | ulli | ", " | ulli | ") = " | ullir1 | ", ceiling_div(" | ulli + 2ull | ", " | ulli | ") = " | ullir2 | ", ceiling_div(" | -ulli - 2ull | ", " | ulli | ") = " | ullir3;
182        } // for
183        sout | nl;
184#endif // 0
185        //============================================================
186#if 1
187        sout | nl | "ceiling" | nl | nl;
188
189        sout | "signed char";
190        for ( sc = 1; sc != 0; sc <<= 1 ) {
191                scr1 = ceiling( sc, sc ); scr2 = ceiling( sc + 2hh, sc ); scr3 = ceiling( -sc - 2hh, sc );
192                sout | "ceiling(" | sc | ", " | sc | ") = " | scr1 | ", ceiling(" | sc + 2hh | ", " | sc | ") = " | scr2 | ", ceiling(" | -sc - 2hh | ", " | sc | ") = " | scr3;
193        } // for
194        sout | nl;
195
196        sout | "unsigned char";
197        for ( uc = 1; uc != 0; uc <<= 1 ) {
198                ucr1 = ceiling( uc, uc ); ucr2 = ceiling( uc + 2uhh, uc ); ucr3 = ceiling( -uc - 2uhh, uc );
199                sout | "ceiling(" | uc | ", " | uc | ") = " | ucr1 | ", ceiling(" | uc + 2uhh | ", " | uc | ") = " | ucr2 | ", ceiling(" | -uc - 2uhh | ", " | uc | ") = " | ucr3;
200        } // for
201        sout | nl;
202
203        sout | "short int";
204        for ( si = 1; si != 0; si <<= 1 ) {
205                sir1 = ceiling( si, si ); sir2 = ceiling( si + 2h, si ); sir3 = ceiling( -si - 2h, si );
206                sout | "ceiling(" | si | ", " | si | ") = " | sir1 | ", ceiling(" | si + 2h | ", " | si | ") = " | sir2 | ", ceiling(" | -si - 2h | ", " | si | ") = " | sir3;
207        } // for
208        sout | nl;
209
210        sout | "unsigned short int";
211        for ( usi = 1; usi != 0; usi <<= 1 ) {
212                usir1 = ceiling( usi, usi ); usir2 = ceiling( usi + 2uh, usi ); usir3 = ceiling( -usi - 2uh, usi );
213                sout | "ceiling(" | usi | ", " | usi | ") = " | usir1 | ", ceiling(" | usi + 2uh | ", " | usi | ") = " | usir2 | ", ceiling(" | -usi - 2uh | ", " | usi | ") = " | usir3;
214        } // for
215        sout | nl;
216
217        sout | "int";
218        for ( i = 1; i != 0; i <<= 1 ) {
219                ir1 = ceiling( i, i ); ir2 = ceiling( i + 2n, i ); ir3 = ceiling( -i - 2n, i );
220                sout | "ceiling(" | i | ", " | i | ") = " | ir1 | ", ceiling(" | i + 2n | ", " | i | ") = " | ir2 | ", ceiling(" | -i - 2n | ", " | i | ") = " | ir3;
221        } // for
222        sout | nl;
223
224        sout | "unsigned int";
225        for ( ui = 1; ui != 0; ui <<= 1 ) {
226                uir1 = ceiling( ui, ui ); uir2 = ceiling( ui + 2un, ui ); uir3 = ceiling( -ui - 2un, ui );
227                sout | "ceiling(" | ui | ", " | ui | ") = " | uir1 | ", ceiling(" | ui + 2un | ", " | ui | ") = " | uir2 | ", ceiling(" | -ui - 2un | ", " | ui | ") = " | uir3;
228        } // for
229        sout | nl;
230
231        sout | "long int";
232        for ( li = 1; li != 0; li <<= 1 ) {
233                lir1 = ceiling( li, li ); lir2 = ceiling( li + 2l, li ); lir3 = ceiling( -li - 2l, li );
234                sout | "ceiling(" | li | ", " | li | ") = " | lir1 | ", ceiling(" | li + 2l | ", " | li | ") = " | lir2 | ", ceiling(" | -li - 2l | ", " | li | ") = " | lir3;
235        } // for
236        sout | nl;
237
238        sout | "unsigned long int";
239        for ( uli = 1; uli != 0; uli <<= 1 ) {
240                ulir1 = ceiling( uli, uli ); ulir2 = ceiling( uli + 2ul, uli ); ulir3 = ceiling( -uli - 2ul, uli );
241                sout | "ceiling(" | uli | ", " | uli | ") = " | ulir1 | ", ceiling(" | uli + 2ul | ", " | uli | ") = " | ulir2 | ", ceiling(" | -uli - 2ul | ", " | uli | ") = " | ulir3;
242        } // for
243        sout | nl;
244
245        sout | "long long int";
246        for ( lli = 1; lli != 0; lli <<= 1 ) {
247                llir1 = ceiling( lli, lli ); llir2 = ceiling( lli + 2ll, lli ); llir3 = ceiling( -lli - 2ll, lli );
248                sout | "ceiling(" | lli | ", " | lli | ") = " | llir1 | ", ceiling(" | lli + 2ll | ", " | lli | ") = " | llir2 | ", ceiling(" | -lli - 2ll | ", " | lli | ") = " | llir3;
249        } // for
250        sout | nl;
251
252        sout | "unsigned long long int";
253        for ( ulli = 1; ulli != 0; ulli <<= 1 ) {
254                ullir1 = ceiling( ulli, ulli ); ullir2 = ceiling( ulli + 2ull, ulli ); ullir3 = ceiling( -ulli - 2ull, ulli );
255                sout | "ceiling(" | ulli | ", " | ulli | ") = " | ullir1 | ", ceiling(" | ulli + 2ull | ", " | ulli | ") = " | ullir2 | ", ceiling(" | -ulli - 2ull | ", " | ulli | ") = " | ullir3;
256        } // for
257        printf( "\n" );
258#endif // 0
259} // main
260
261// Local Variables: //
262// tab-width: 4 //
263// compile-command: "cfa mathX.cfa" //
264// End: //
Note: See TracBrowser for help on using the repository browser.