summaryrefslogtreecommitdiff
path: root/lib/math/test/sin-impl.myr
blob: 458f7ccba1031e02bb577fffafb758147b56820d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
use std
use math
use testr

const main = {
	math.fptrap(false)
	testr.run([
		[.name="sin-cos-01", .fn = sincos01], /* flt32 */
		[.name="sin-cos-02", .fn = sincos02], /* flt64 */
		[.name="sin-cos-03", .fn = sincos03], /* off-by-1-ulp quarantine */
		[.name="sin-cos-04", .fn = sincos04], /* exhaustively test C */
		[.name="sin-cos-05", .fn = sincos05], /* NaN handling */
	][:])
}

const same32 = {a, b
	if a == b
		-> true
	;;

	if std.isnan(std.flt32frombits(a)) && std.isnan(std.flt32frombits(b))
		-> true
	;;

	-> false
}

const same64 = {a, b
	if a == b
		-> true
	;;

	if std.isnan(std.flt64frombits(a)) && std.isnan(std.flt64frombits(b))
		-> true
	;;

	-> false
}

const sincos01 = {c
	var inputs : (uint32, uint32, uint32)[:] = [
		(0x00000000, 0x00000000, 0x3f800000),
		(0x3f000000, 0x3ef57744, 0x3f60a940),
		(0x6e000000, 0xbec002e4, 0xbf6d50ea),
		(0xeca5b501, 0x3f6e879c, 0x3eb9e60c),
		(0x67a9242b, 0xbf7fab81, 0xbd4fee38),
		(0xdf18b878, 0xbdad60f7, 0x3f7f14bb),
		(0x5f18b878, 0x3dad60f7, 0x3f7f14bb),
	][:]

	for (x, ys, yc) : inputs
		var xf : flt32 = std.flt32frombits(x)
		var rsf1, rcf1, rsf2, rcf2
		(rsf1, rcf1) = math.sincos(xf)
		rsf2 = math.sin(xf)
		rcf2 = math.cos(xf)

		var rsu1 = std.flt32bits(rsf1)
		var rcu1 = std.flt32bits(rcf1)
		var rsu2 = std.flt32bits(rsf2)
		var rcu2 = std.flt32bits(rcf2)

		testr.check(c, rsf1 == rsf2 && rcf1 == rcf2,
			"sincos(0x{b=16,w=8,p=0}) is (0x{b=16,w=8,p=0}, 0x{b=16,w=8,p=0}), individual results (0x{b=16,w=8,p=0}, 0x{b=16,w=8,p=0})",
			x, rsu1, rcu1, rsu2, rcu2)

		testr.check(c, same32(rsu1, ys) && same32(rcu1, yc),
			"sincos(0x{b=16,w=8,p=0}) should be (0x{b=16,w=8,p=0}, 0x{b=16,w=8,p=0}), was (0x{b=16,w=8,p=0}, 0x{b=16,w=8,p=0})",
			x, ys, yc, rsu1, rcu1)
	;;
}

const sincos02 = {c
	var inputs : (uint64, uint64, uint64)[:] = [
		(0x0000000000000000, 0x0000000000000000, 0x3ff0000000000000),
		(0x4100000000000000, 0xbfeff8bd7b10d6b0, 0x3fa58ced65ec8b50),
		(0x4b11000000000000, 0xbfef2cb48ed49aa6, 0x3fcce246843789ad),
		(0x020400000a0c0000, 0x020400000a0c0000, 0x3ff0000000000000),
		(0xbfeff57020000000, 0xbfeae79e2eb87020, 0x3fe1530a59ef0400),
		(0x44f5248560000000, 0xbfeff57010000001, 0xbfa9fdc6fcf27758),
		(0xc3e3170f00000000, 0xbfb5ac1ed995c7c4, 0x3fefe29770000000),
		(0x41bb951f1572eba5, 0xbc8f54f5227a4e84, 0x3ff0000000000000), /* [GB91]'s "Xhard" */
	][:]

	for (x, ys, yc) : inputs
		var xf : flt64 = std.flt64frombits(x)
		var rsf1, rcf1, rsf2, rcf2
		(rsf1, rcf1) = math.sincos(xf)
		rsf2 = math.sin(xf)
		rcf2 = math.cos(xf)

		var rsu1 = std.flt64bits(rsf1)
		var rcu1 = std.flt64bits(rcf1)
		var rsu2 = std.flt64bits(rsf2)
		var rcu2 = std.flt64bits(rcf2)

		testr.check(c, rsf1 == rsf2 && rcf1 == rcf2,
			"sincos(0x{b=16,w=16,p=0}) is (0x{b=16,w=16,p=0}, 0x{b=16,w=16,p=0}), individual results (0x{b=16,w=16,p=0}, 0x{b=16,w=16,p=0})",
			x, rsu1, rcu1, rsu2, rcu2)

		testr.check(c, same64(rsu1, ys) && same64(rcu1, yc),
			"sincos(0x{b=16,w=16,p=0}) should be (0x{b=16,w=16,p=0}, 0x{b=16,w=16,p=0}), was (0x{b=16,w=16,p=0}, 0x{b=16,w=16,p=0})",
			x, ys, yc, rsu1, rcu1)
	;;
}

const sincos03 = {c
	var inputs : (uint64, uint64, uint64, uint64, uint64)[:] = [
		(0x5101000000000000, 0x3fe9706123d509f1, 0xbfe369af9695aba1, 0x3fe9706123d509f0, 0xbfe369af9695aba0),
		(0xf83b13a6a142b6d5, 0xbf5a86f4edeb02f2, 0x3feffffd404efc20, 0xbf5a86f4edeb02f1, 0x3feffffd404efc20),
		(0x4b01000000000000, 0xbfe3e9527dc75f12, 0x3fe90cf80997c963, 0xbfe3e9527dc75f13, 0x3fe90cf80997c964),
	][:]

	for (x, ys_perfect, yc_perfect, ys_acceptable, yc_acceptable) : inputs
		var xf : flt64 = std.flt64frombits(x)
		var rsf1, rcf1, rsf2, rcf2
		(rsf1, rcf1) = math.sincos(xf)
		rsf2 = math.sin(xf)
		rcf2 = math.cos(xf)

		var rsu1 = std.flt64bits(rsf1)
		var rcu1 = std.flt64bits(rcf1)
		var rsu2 = std.flt64bits(rsf2)
		var rcu2 = std.flt64bits(rcf2)

		testr.check(c, rsf1 == rsf2 && rcf1 == rcf2,
			"sincos(0x{b=16,w=16,p=0}) is (0x{b=16,w=16,p=0}, 0x{b=16,w=16,p=0}), individual results (0x{b=16,w=16,p=0}, 0x{b=16,w=16,p=0})",
			x, rsu1, rcu1, rsu2, rcu2)

		testr.check(c, (same64(rsu1, ys_perfect) || same64(rsu1, ys_acceptable)) && \
			       (same64(rcu1, yc_perfect) || same64(rcu1, yc_acceptable)),
			"sincos(0x{b=16,w=16,p=0}) should be (0x{b=16,w=16,p=0}, 0x{b=16,w=16,p=0}), will also accept (0x{b=16,w=16,p=0}, 0x{b=16,w=16,p=0}), was (0x{b=16,w=16,p=0}, 0x{b=16,w=16,p=0})",
			x, ys_perfect, yc_perfect, ys_acceptable, yc_acceptable, rsu1, rcu1)
	;;
}

const sincos04 = {c
	/*
	   There should be one of these for each j, each corresponding
	   to the appropriate xi. This should ensure that, when
	   upgrading the C tables, things don't get too terribly
	   broken.
	 */
	var inputs : (uint64, uint64, uint64)[:] = [
		(0x00000000000000f6, 0x00000000000000f6, 0x3ff0000000000000),
		(0x512272897288fc3f, 0xbf74c1fa7a394e5a, 0xbfefffe511d2bf60),
		(0xbf7bf1bf57973983, 0xbf7bf1b122b6a164, 0x3fefffcf31e20334),
		(0x54b7c50a7a9883cb, 0xbfefff7870aeb34e, 0xbf874920cd9ace22),
		(0xdace0787a600a1ca, 0x3f8b9ca34b1db23a, 0xbfefff416335fa92),
		(0x72864769869c2318, 0x3feffeddc1ece35c, 0xbf910931b7190c35),
		(0xd91723aa83b79cb9, 0xbf942999d22d35b9, 0x3feffe696f1dc7b2),
		(0x475f423e817765ea, 0x3f96b423c56f5447, 0xbfeffdfc7adf3a9d),
		(0xe6ea21331235f850, 0xbf9c0c0fa6749f60, 0xbfeffced3639af5a),
		(0x6d2a3c2098179905, 0xbf9f11a72b55a41b, 0xbfeffc3a7f66553b),
		(0xf28fa3bd259e1376, 0xbfeffc23303dea74, 0xbf9f71111b7fd616),
		(0x7f26be7ff1138291, 0xbfa185023632479d, 0xbfeffb33e657eb59),
		(0x675c32e626080a1e, 0x3feff9b5b177af51, 0xbfa40f7a6e6b7994),
		(0x52924d2cbb5901d1, 0x3fa48c4b82d66c9b, 0x3feff9666f07db89),
		(0x417ec533964706ec, 0x3fa64f235d1be278, 0x3feff83843b411af),
		(0x52107ea0ff1110db, 0xbfeff6a3fc169867, 0x3fa877b2347f0a28),
		(0xd71b728c627f815d, 0x3faa8d784340586e, 0xbfeff4f9ef7c5107),
		(0xda739024569252ce, 0x3feff3eee1e5663a, 0x3fabc79919273897),
		(0xdb96494b55f3f081, 0xbfeff24bb7274d9e, 0x3fad9a5e1c7820a2),
		(0x739f3c2a746a1b50, 0xbfeff19570cd1d86, 0x3fae5c932d2f3605),
		(0x447aa716086a8c88, 0xbfb05ec5a49745a1, 0x3fefef3bdef16841),
		(0xf968280b3a414e54, 0xbfb12ed0ae4aeb09, 0xbfefed86a66a999f),
		(0xd02fb5bd9a62c870, 0x3fefebdb551c9f8e, 0x3fb1f1029914d91e),
		(0x60ffe411eafbc6da, 0x3fb245acb57399e6, 0x3fefeb1b39d132e8),
		(0x4f318e7d4aea96dc, 0xbfefe7f62e48f0eb, 0x3fb398e0aeb9c445),
		(0xc404978c116309d8, 0x3fb423d6b3b85040, 0x3fefe69c043f3e90),
		(0x43f2630170779582, 0x3fb5177a797d0e87, 0xbfefe4261d504451),
		(0x5fdbbf61f00b7f03, 0xbfefe38d527600ca, 0xbfb550ed5bee6d60),
		(0xc0197a1d458871ce, 0xbfb6018646c93b7b, 0x3fefe1ad70c7618a),
		(0xfec0c7c70c5fef38, 0xbfb72b204c19e155, 0xbfefde61e65655a4),
		(0x536118c6d0da429d, 0xbfb813122d1d4d33, 0x3fefdbb21abcadb1),
		(0x468bde452261d739, 0xbfefd95e3ccfcb94, 0x3fb8d51e4332cdff),
		(0x640531fd736dc271, 0xbfb9cb4924d9690e, 0xbfefd64f7c8c42d5),
		(0x45882463c54dff4d, 0x3fba4eb0d809a756, 0xbfefd4a15a83accd),
		(0xe47b0287f9f402c4, 0x3fbb4f875473f88e, 0xbfefd13fe58f7d94),
		(0x776a9cb59bc714b1, 0x3fefd05ef4cb673b, 0x3fbb90bc6355a021),
		(0x6e03d54eae350b2b, 0x3fbc40e4b1fc64b5, 0x3fefcdf4b6ba3d60),
		(0xd7e13510abfa4b8f, 0xbfbd8c17b8daf635, 0x3fefc9408a0ed455),
		(0xf5b0b388d525a652, 0x3fbe06c30febf5ed, 0xbfefc774aca78be1),
		(0xc872046ad7b74e5d, 0xbfefc4762a3df5f2, 0xbfbeceee72729a95),
		(0xe7de05b2f658e70f, 0xbfbf705c3c62b429, 0xbfefc1fd7092a24b),
		(0xcc324b95dbc8fd01, 0x3fc0705192fdc54c, 0xbfefbc2939080e96),
		(0xf721d915cf272a16, 0xbfefbb27b38fdf96, 0xbfc08f4641cf4d68),
		(0x727b9da90c1b363d, 0x3fefb822c42d1549, 0xbfc0ead5e194ff63),
		(0x76833092f555af28, 0xbfc16fc26448ec57, 0xbfefb3a2bb1657ce),
		(0x4aee1902b654832c, 0x3fefb04eed8111ec, 0x3fc1cf8146eca7eb),
		(0x4baf9ffda9dc11e3, 0x3fefac8684367fbe, 0xbfc239ecfe4bf73d),
		(0x5657a3059c18f2d9, 0xbfc297363782e038, 0xbfefa922de862569),
		(0x7bff45dd88b13800, 0xbfc2d478620b4e02, 0xbfefa6df905ff50e),
		(0x5dee435102358eaf, 0x3fefa1b101e4c684, 0xbfc35dd586187ce4),
		(0xde9d9f0cc9f77177, 0x3fc3defc1325ae88, 0x3fef9caef7a753cc),
		(0xfdda28f4488d7a83, 0xbfc415283aea05a2, 0x3fef9a8b282c574d),
		(0xf50af38a50f30e4c, 0xbfc4730a16260b3b, 0xbfef96c7b1abe323),
		(0xfb496fa21c023920, 0x3fc4cea2d28cfdfb, 0x3fef930a70b822c6),
		(0xe505ecdfee427dbd, 0x3fc554226a887900, 0x3fef8d78b9f34b72),
		(0xeb0d8c0df28dd71b, 0x3fc5b337c0fb9e5e, 0xbfef896b2289c5b2),
		(0x7509b2527112fd5b, 0xbfc630b105366287, 0x3fef83f5ac088905),
		(0xffd6c9165e18ac33, 0x3fef81c853e8136a, 0xbfc661f1ad0ce950),
		(0xe1c86c04b0706291, 0xbfef7d873a6519fe, 0x3fc6c0f2cce48329),
		(0x7f4ab100fd15ade5, 0x3fc7148e0c9e3182, 0x3fef79b97d3d745b),
		(0x4b1f0b0b22dfeef3, 0xbfc7c4eeb85ba3ff, 0x3fef718430c69651),
		(0xcb9bb37fc0f2a235, 0xbfc7d6435e271ea1, 0x3fef70b2445b8479),
		(0xd6e8414566d4c52e, 0xbfef6a8b61c9b366, 0x3fc856b04dcf03ea),
		(0xe79fb9553990f8be, 0xbfef64d85f36d000, 0xbfc8cb42fe24375f),
		(0x6dcb241574906b9f, 0x3fc9451b9809f028, 0x3fef5ec551a7ce80),
		(0xd35310f2b682fb52, 0x3fc976452c4ba67d, 0x3fef5c492d13c71d),
		(0x49b456519453bc2e, 0xbfef5770a5a4ac32, 0x3fc9d50bf14496e0),
		(0x59d7185ea4188d7a, 0x3fca6cd56e57cc8a, 0xbfef4f86fdc2aa14),
		(0xfddefd05372bf5b1, 0xbfca83aa03c4c548, 0x3fef4e52288add54),
		(0x7b7322413d2ae5f8, 0x3fef46fc203fc847, 0xbfcb0ccdf3f26a28),
		(0x6360cbf4cc0e423a, 0xbfcb8abc4d3fbf70, 0xbfef401cf3b2c8ad),
		(0xc2ef40aac8c0caff, 0xbfef3b40e2b1c574, 0x3fcbe2633bec6338),
		(0xc2ef40aac8c0caff, 0xbfef3b40e2b1c574, 0x3fcbe2633bec6338),
		(0x7517b932422321b3, 0xbfcc7c0a66359b8f, 0x3fef329516485b7e),
		(0x4d40e5da1750b47b, 0x3fccecafe584ca7a, 0x3fef2c1a191c72da),
		(0xd3eeab6f1ce0c65f, 0x3fef275dde80b9a5, 0xbfcd3ddea87ad082),
		(0x7332b1c80505c25d, 0x3fcdd243aeac42e6, 0xbfef1e91f34d9e70),
		(0xdd7f47ace75b1278, 0xbfef1ba6ee071cfd, 0x3fce02d275470464),
		(0xf6deca320321040f, 0x3fef1188ee0ff435, 0xbfcea8b76971a173),
		(0xde7018284f03e03f, 0x3fef0acf75273337, 0x3fcf14f3f457127c),
		(0x5a35f121d3d2a2e7, 0x3fcf3fb1a0b5d9eb, 0x3fef0820c67c621a),
		(0x5f8789fe1295b431, 0xbfcf801328302267, 0xbfef040f08a74b86),
		(0xeb60edaa99fb631b, 0xbfcff6c4e0ab7ecf, 0xbfeefc7723cce8e8),
		(0x740043f1ff2cdc39, 0x3feef58264f03ec2, 0xbfd030f4ca52cdfd),
		(0x755909d7a66ec123, 0x3fd05b0aacb3547b, 0xbfeeeffa179a7126),
		(0xce7378a1c330830a, 0xbfd092eb3679cee6, 0xbfeee889fe5671b2),
		(0x61229f2e883ad502, 0x3feee354dcbf5384, 0xbfd0b993622b89d8),
		(0xc308cff80474c43c, 0x3fd0f14e25183c0c, 0xbfeedbbc1b54a4a4),
		(0x5474ef4a0497c293, 0x3fd11f8458f1b696, 0xbfeed55af85d48b3),
		(0x64a85b58557d81d6, 0xbfd16ead3eb9741d, 0xbfeeca421433b493),
		(0xf77724543b8b3885, 0x3fd19ed46e8f52e9, 0x3feec36716fdec27),
		(0x464183db1f445d09, 0x3feec26f93025caa, 0xbfd1a593925c8dc8),
		(0x778eae02a44000a2, 0xbfeebb73eb5aed84, 0x3fd1d5fba8930f8f),
		(0x5cdc5f4b5e0d1940, 0xbfd224373cb42c70, 0x3feeafff121ff829),
		(0x525e3d38881ed63d, 0x3feea6cd7f0438c8, 0xbfd261f9b2e4fa14),
		(0x5a10e8f3294cb8da, 0xbfeea58f1791757a, 0x3fd26a434e6e77e4),
		(0x4fc23cca0a71ea3a, 0x3fee9b1b63dc509c, 0x3fd2af49e08c3126),
		(0xf60fe4b87e3c1da9, 0xbfd2d96cd21892d2, 0xbfee94a51d4d7187),
		(0xf57c4045e43ccaf9, 0xbfee8e15317f07be, 0x3fd303ce72c3ddcb),
		(0xfbba53b7ccff6358, 0xbfd337ace7d8abf2, 0x3fee85f74296d316),
		(0x7c92ab74e6d83f53, 0x3fee7e33cfcfc9c9, 0x3fd368bac190b88b),
		(0x6aa52ba172654ed1, 0x3fd3a3c7bd76153b, 0x3fee74be8564f496),
		(0x5c6e0f3ec20f8e7d, 0x3fee6c801bff99d9, 0x3fd3d6a1b9e825a9),
		(0x44438c0b81cf287e, 0xbfd3f7fb8049f941, 0xbfee670b3f6d116a),
		(0xe9eeb63337ece529, 0x3fd42bb1af27955a, 0x3fee5e814f8fa4ee),
		(0xd05cf079494581b4, 0xbfee58a3bd5aaaad, 0x3fd44ee2b0defb88),
		(0x685f1a87b750f254, 0xbfd4a144f9e741c4, 0xbfee4abc1dcdf720),
		(0x536b65af59fbc622, 0x3fee477e3635fcdf, 0x3fd4b4458e9e69ef),
		(0xdd2564daf3c4e467, 0x3fd4f0c8e7efe5da, 0xbfee3d15289f8043),
		(0x7fa52667c976d82e, 0xbfee3a08ee598072, 0xbfd5025b4e066b88),
		(0x72f883ad82e4a3ba, 0xbfee2fdf26ce794e, 0xbfd53c7e2146d269),
		(0xf6e835bc9adeaf59, 0xbfd57c6ac4883fb5, 0x3fee248e035dacb0),
		(0x42ea8e91bba3889d, 0x3fee202b02dd668d, 0xbfd594f8cca01aba),
		(0x58b1d3f25c054d48, 0x3fee179309c7e2fe, 0xbfd5c4b8add182bf),
		(0xe9e2cd65f67e2ee0, 0xbfee0dd7bea36726, 0x3fd5fa3dc3a4f8c7),
		(0x6b9ffac3db03a107, 0x3fd631fb285e219d, 0xbfee039865991e53),
		(0x6eb4d607fe115dcf, 0x3fedfa4b939ca0ac, 0x3fd66409024e6323),
		(0xf7917095f9a51925, 0xbfd69796d53fd17f, 0xbfedf09e862de5d1),
		(0x7118f8c15e2991c4, 0x3fedeb8848f6cf5b, 0xbfd6b27ba1696913),
		(0x79b55f3637cc4586, 0xbfd6f5638f450935, 0x3feddec291264c5d),
		(0x5fd1cfe5b08757a6, 0xbfd70ffb893ab566, 0x3fedd9a2fedb6c24),
		(0xc733503522b5f461, 0xbfd7554c3b69eebf, 0xbfedcc2869cbf541),
		(0x446d7c038f34a64a, 0x3fedc88bba34e66a, 0x3fd767b74c87b19e),
		(0xc3a23c3b9032b8f3, 0x3fd79831044581c9, 0xbfedbefa4c29de60),
		(0xc48d690c9e9f2305, 0xbfd7e8fd81ac1776, 0xbfedaed4c0b2b8f3),
		(0x6936ad82b0657c14, 0x3fd7f3be25e63b3f, 0xbfedaca9dc90a41b),
		(0x4d4c51754594c5a7, 0xbfed9c8f1505a0bd, 0xbfd842f47bbbff65),
		(0x53af975d069ceebf, 0x3fed98ae77ed0af4, 0xbfd855d9e1b87671),
		(0xbfd929812210b263, 0xbfd884d5b1521b6a, 0x3fed8efb1e579d8f),
		(0xf311b32b3a68939e, 0xbfed856f902db836, 0xbfd8b2aaa6160a9f),
		(0xc8bb45b934289a6f, 0xbfd8e9ef0de3dc36, 0xbfed79d12674cd54),
		(0xcf7f65187e57f8e0, 0x3fed6bc8263fc275, 0x3fd92bf37a97badc),
		(0xc8e046f199566a7b, 0x3fed61acdd8efca5, 0x3fd95aff9d017381),
		(0xe63586b4c42da14f, 0x3fd992a9570938bd, 0xbfed559aec9c0440),
		(0x7570d9f0f3faa4e7, 0x3fed51bace294110, 0xbfd9a46a32ec9b5d),
		(0xf6bb3c9916ba9b7b, 0x3fed454543bc2de4, 0x3fd9dd1b108a60cc),
		(0xd660ed6e55136cdf, 0x3fed37afb7050a25, 0x3fda1a4302c68bf6),
		(0x429a8fa0df460917, 0x3fed2f17f136daf1, 0xbfda409a52187af7),
		(0xebf471a9b1b6caa5, 0xbfda64f02f41d321, 0x3fed26e544de1649),
		(0xe65e21ead3c2ba60, 0xbfed22498d657c09, 0x3fda7942a404499c),
		(0x6ae3d5db498749f6, 0xbfed0e459db364cf, 0xbfdad0af537af3fc),
		(0x76bc0ffdf6576c1d, 0xbfdaf074aec69954, 0xbfed06ebcd22c8e7),
		(0x576061576fcdadfd, 0x3fecfe0996e5d249, 0x3fdb169da2f019c9),
		(0xe9922b0dd12503ba, 0x3fdb3e68e31cf5d6, 0x3fecf4b5b421be75),
		(0xf090512b08c64f2b, 0x3fece4479edc03c5, 0xbfdb83d63f9cb587),
		(0xc9064cce58144c06, 0x3fdbb290774db3ef, 0x3fecd91bf6c9a299),
		(0xd2c65def3f53a9b7, 0x3fdbd52702603513, 0x3fecd0c83afda1b0),
		(0xc366379b9a957cdb, 0x3fdc01b0c4b0e4d4, 0x3fecc5fc650dfa55),
		(0x739d5edf97b83065, 0xbfdc2b7a687242b7, 0x3fecbbc7dbedc827),
		(0xc40021d66b2f4d61, 0xbfdc4d9c4f8f51e7, 0xbfecb363f1bca281),
		(0xc76aa2fdbe146487, 0x3feca866fe836c4e, 0xbfdc7a02cee3d6de),
		(0x7738dad760be3d56, 0xbfec9933d62aa560, 0xbfdcb6e1350e6fb2),
		(0x666928445c6724e3, 0xbfec91c8c33109d5, 0x3fdcd45bdedee292),
		(0xc1a41b02da9ba0ea, 0x3fec863b137bd6e1, 0x3fdd01fa8ac7aa24),
		(0x7848fe3e78cb663c, 0xbfec79f540706d37, 0x3fdd320e30bad112),
		(0x5be9ac5535d046cc, 0xbfdd69dbc3730780, 0x3fec6b965f72d6d9),
		(0x7d00750f7493ec14, 0x3fec63edee9d4c7e, 0x3fdd8761eaf89474),
		(0x70b08a0803a2e4f7, 0x3fddab0ae8940bb3, 0x3fec5aa10a89a08b),
		(0x55fbd54cc4be5f3c, 0x3fdddcb4a70293c4, 0x3fec4d956bba1326),
		(0xf3554e8402f6265a, 0x3fde1f406db596ad, 0xbfec3beecfce2cf7),
		(0xd1c4f6c0576b4ceb, 0x3fde321eb7b4e647, 0x3fec36e47718b312),
		(0x7d59507f71b8f889, 0xbfec27de7468cb95, 0x3fde6a02a16464fe),
		(0xdc7e5afce57e9cd7, 0x3fdea90fe172c6c6, 0xbfec16c09e490bad),
		(0xeb073e7d1af5222d, 0xbfdec9544c37d497, 0xbfec0dec6f134e6c),
		(0xc60882772b865dc5, 0x3fec07c509e4da5b, 0x3fdedfb80fb87768),
		(0x75dc9fbbd1640b6a, 0xbfebf854a6961d91, 0xbfdf1787a24fb4b4),
		(0x633901c12d4cb6e1, 0x3fdf4c84cada936a, 0x3febe98a62583ac2),
		(0x7f04dacd2c2ca8ce, 0xbfebe3a53f98fb9a, 0xbfdf6182e7252bac),
		(0x4332ecebbe152c9a, 0xbfebd268556dddea, 0xbfdf9e7c5618737b),
		(0x5ac66c5d9fa15663, 0x3fdfc21149cd81f9, 0x3febc844c23cdafa),
		(0xc404cdd7bc992e30, 0x3febb629d34f27fa, 0xbfe0008c6d07e1bd),
		(0xc53d64204fdf1db3, 0xbfebafa459158ca0, 0x3fe00bd23ae3931f),
		(0xf9d4afa07a8a6ce7, 0xbfeba1a3c12f4839, 0x3fe023e2f03b637d),
		(0x637f1d1420fea3f8, 0xbfe0448291240078, 0x3feb8e7b76ad81a3),
		(0x72eae57421307d45, 0xbfeb849a47abb68b, 0x3fe05533525f37a3),
		(0xc2e6fa2f34fd750b, 0x3feb7482e375b78d, 0xbfe070318df28781),
		(0x6d7ed298ca67fbc5, 0x3feb65bbbbb39c6c, 0x3fe088c7245680ca),
		(0x4d744a5ecf95fd93, 0xbfe08d4873b04602, 0xbfeb630334f1eee3),
		(0xd0b010cb5af6b5b1, 0xbfe0a62065b173bc, 0x3feb53effed8251e),
		(0xfa89d1a75f768cd0, 0x3feb42d7b90ec7ad, 0x3fe0c20f7c61cec5),
		(0x6ce2de1511d237eb, 0x3fe0ce8b7293b359, 0xbfeb3b2725681250),
		(0x56a33b90bd51784c, 0x3fe0e8cc84a7b798, 0x3feb2ae16eac76c8),
		(0xd998ed50ac13add1, 0x3feb20901b10690f, 0x3fe0f954fc1fd74a),
		(0xd2573e1a86722c43, 0xbfeb0fa0f7a8064b, 0xbfe114476b668554),
		(0x498c3881301c9450, 0xbfeafe2803de2552, 0xbfe12fd761d178a8),
		(0x676028d2e9aa9de4, 0x3feaf378b320bee9, 0xbfe14093da4a17db),
		(0x4e22da5810e48e2c, 0xbfeae18365d0ce13, 0xbfe15c81b1c187a4),
		(0xfc2b1173d2f9d7c5, 0x3fe16349ac5ca8bf, 0x3feadd20fb79cee5),
		(0x7473a4f18d083564, 0xbfe1853ad10a9564, 0x3feac70a53c134e8),
		(0xfb85676d181e0881, 0xbfe19133a8342b55, 0xbfeabf312f9ba36c),
		(0x6269a55fd3dcfce2, 0x3fe19f8d1330bb0a, 0xbfeab5befc7864f0),
		(0x4598ddfdd67bf239, 0x3fea9eb39a3896ce, 0x3fe1c248efe0508e),
		(0xd95338bde4d930aa, 0xbfe1d9d6772be796, 0x3fea8eee09962254),
		(0x611503484c027608, 0x3fea8b32e1adee9a, 0xbfe1df6247815710),
		(0x5c2ee2e8eb412270, 0xbfe1f6da5410afd9, 0x3fea7b56645112df),
		(0xcb58f3d014fca0aa, 0xbfea66537cfebec2, 0x3fe215acd67cbd00),
		(0x43c6b36129529847, 0xbfea610121a2376e, 0xbfe21d6f232602fd),
		(0xfa1614294a9f72c8, 0x3fea49e8d6077dc7, 0x3fe23ee2fa2c432c),
		(0x473b0851ec7a71fc, 0xbfea3ae9bc9717ab, 0xbfe2546b8f878bb2),
		(0xf6d74bab0f0688d3, 0x3fe26ad4d6d860df, 0x3fea2b3235d28e02),
		(0xe9bee3b9d2c67c03, 0xbfe26e2812e3c037, 0x3fea28dacda84df7),
		(0xcc92e4c94a84e291, 0x3fe285c9915a00bf, 0xbfea1824b911e6c7),
		(0xf8aab297bc40c6d3, 0xbfe2a8efe687cdd7, 0x3fe9ff0dac00a59e),
		(0x6bfb68a736eeb1b6, 0x3fe2b1176d2ab489, 0x3fe9f931533ac9e4),
		(0xcf94cd7e76b5d43b, 0x3fe9eefebc7842b3, 0x3fe2bf3ae0fb4f01),
		(0x58e19d8279e73d8c, 0x3fe2e269a7c9fff8, 0x3fe9d56b655c37fc),
		(0x4c2f18aaaae1a9a5, 0x3fe9c6856bb54b0c, 0x3fe2f6ba53166329),
		(0x4473bbb450eb9885, 0xbfe9bd919cb7c452, 0xbfe302df564ec155),
		(0x5352f27ad3264f74, 0xbfe3105c54f5cb4c, 0xbfe9b395db2fe1b5),
		(0xd70c16903457ac91, 0xbfe32d9f9dbb21f9, 0xbfe99dc756e89b3d),
		(0xcac2e8c8c586b2d1, 0xbfe345aa02d0e659, 0xbfe98bb610c6fd7a),
		(0x72d7978807cae706, 0xbfe35d2b78fbd0b9, 0x3fe979e9612ca3a5),
		(0xe6c2f09d247a94a9, 0xbfe36b250c0e3485, 0x3fe96f44150abf2c),
		(0xfa6723c5149699bc, 0xbfe95f43f91aa66f, 0xbfe380085ac23ee0),
		(0xff8223b58fd12c2f, 0x3fe94bba9f307406, 0xbfe39959860b58ec),
		(0x75296e4dd81e95f4, 0x3fe3a3e75e16aa44, 0x3fe94389b95f2efa),
		(0x7e5b65a329da9204, 0x3fe3c1f15c9eb331, 0xbfe92c12b84a4ade),
		(0xee3f0726908f6f7e, 0xbfe91cc6ea4e16dc, 0x3fe3d55ed2290c82),
		(0x7af275b9d87202c4, 0x3fe3d7db0cdad96d, 0x3fe91ad03ab42e84),
		(0x58404c6817fb0387, 0xbfe3ecf399bb98a3, 0x3fe90a151c0f3a99),
		(0x4e24e759fc383d3b, 0x3fe8f9c1d2e98eb7, 0xbfe401664bfe107a),
		(0x6e6e238154fe510b, 0xbfe8dc876efe2cea, 0xbfe425ad5d3088a4),
		(0x51115721fcb875a5, 0x3fe8ce38b96c431d, 0xbfe4374857dced36),
		(0xcd0f08fce53215fe, 0x3fe44b7fa906b663, 0x3fe8bdb137695bac),
		(0xc793de849b92e545, 0x3fe8ae29fd1807b2, 0xbfe45e5f09a79710),
		(0xf14f3d838006f1f3, 0x3fe8a0e6c0cb53d4, 0xbfe46e665c9bfa98),
		(0x485b3050ec24e894, 0xbfe89ac1501c4664, 0x3fe475ccc67a5a6f),
		(0x53cdd772c04825b7, 0xbfe499d932904180, 0xbfe87c9a6ee0e5f4),
		(0xf3830e1d9fcb8a63, 0x3fe49ee7f784dc34, 0xbfe878583c6d1b17),
		(0x4fd516dfb479c284, 0xbfe4b8fa646a8702, 0x3fe86247ec1b5405),
		(0x401c9636ba305733, 0x3fe852f4e454503a, 0x3fe4caf517981ddf),
		(0x74e6629d161dcdf0, 0x3fe84b4f58913c4f, 0x3fe4d3e3c394b4c3),
		(0xc831ccafeb5988ca, 0xbfe4e9f00dc7029d, 0x3fe8385704515fc8),
		(0xea8b6c2e5b7438e9, 0xbfe821d634afb0ed, 0x3fe503e361ffde43),
		(0x50ddbc2d3d77331b, 0xbfe51e8f21a24dd4, 0xbfe80a82564c99e1),
		(0xd31f8e19edda2f9a, 0x3fe802894421cfd0, 0x3fe5279f1e05c5c6),
		(0xfbb16b339d0a17fe, 0xbfe542cec6203a63, 0xbfe7ea79c4f28160),
		(0xfe93c58449c8fd51, 0x3fe7e653ec9effe6, 0xbfe547784cf0eeb5),
		(0xe125d9535e1d7d96, 0x3fe56a646c9bc577, 0xbfe7c70e160b76ba),
		(0xe9492784719b40f6, 0xbfe7bd8d74e13697, 0x3fe574eca79f247d),
		(0x76693dbf45a5c11c, 0x3fe7a6aca203b146, 0x3fe58e21d55361dd),
		(0xca01a90ba147a7a8, 0x3fe7a0e9b1cc2382, 0x3fe594727d17c430),
		(0xeba7b196f2ce8a86, 0x3fe792dcb3fd68a0, 0x3fe5a3caee7bef45),
		(0x65cec0767168cebc, 0xbfe781dbdad094ee, 0xbfe5b64237c79451),
		(0xe46e9ddaa8d41951, 0xbfe76df89a6184ca, 0x3fe5cbb6beaf19d3),
		(0xc394901bb60cd165, 0x3fe5e7e07a75103e, 0xbfe753a5e9dd67ee),
		(0xefe39e4669e6b8e3, 0xbfe5ee1e7c908e91, 0xbfe74dc7ad48a603),
		(0x6606d5cab1344ed4, 0xbfe60bbb919e2739, 0x3fe731c5d36a20ec),
		(0xe151f4cddef4501f, 0xbfe7201c54d669d7, 0xbfe61e41c6dae1e5),
		(0xd9381aa73bb196ba, 0xbfe719018e9ef492, 0xbfe625acfdb6514e),
		(0x4de08bca51af503b, 0xbfe7060f07286185, 0xbfe6395ed52b7540),
		(0x43ba67829cbf5ddd, 0xbfe64d04587eee54, 0xbfe6f307ef31a64f),
		(0x51c3d8b11e8e3186, 0x3fe664fbc2d6363c, 0x3fe6dba5765c9f8b),
		(0x762158955b8d3e1f, 0x3fe67b88d77e47ab, 0xbfe6c577911c77f9),
		(0x7e1f8126bc820e3d, 0x3fe685a6ed43a0f0, 0x3fe6bb75e2686a13),
		(0x77c0705a72b5023d, 0x3fe69d4e28e80836, 0x3fe6a3ee27f25da6),
	][:]

	for (x, ys, yc) : inputs
		var xf : flt64 = std.flt64frombits(x)
		var rsf1, rcf1, rsf2, rcf2
		(rsf1, rcf1) = math.sincos(xf)
		rsf2 = math.sin(xf)
		rcf2 = math.cos(xf)

		var rsu1 = std.flt64bits(rsf1)
		var rcu1 = std.flt64bits(rcf1)
		var rsu2 = std.flt64bits(rsf2)
		var rcu2 = std.flt64bits(rcf2)

		testr.check(c, rsf1 == rsf2 && rcf1 == rcf2,
			"sincos(0x{b=16,w=16,p=0}) is (0x{b=16,w=16,p=0}, 0x{b=16,w=16,p=0}), individual results (0x{b=16,w=16,p=0}, 0x{b=16,w=16,p=0})",
			x, rsu1, rcu1, rsu2, rcu2)

		testr.check(c, same64(rsu1, ys) && same64(rcu1, yc),
			"sincos(0x{b=16,w=16,p=0}) should be (0x{b=16,w=16,p=0}, 0x{b=16,w=16,p=0}), was (0x{b=16,w=16,p=0}, 0x{b=16,w=16,p=0})",
			x, ys, yc, rsu1, rcu1)
	;;
}

const sincos05 = {c
	testr.check(c, std.isnan(math.cos(std.flt64nan())), "cos(NaN64) should be NaN")
	testr.check(c, std.isnan(math.sin(std.flt64nan())), "sin(NaN64) should be NaN")
	testr.check(c, std.isnan(math.cos(std.flt32nan())), "cos(NaN32) should be NaN")
	testr.check(c, std.isnan(math.sin(std.flt32nan())), "sin(NaN32) should be NaN")

	var s1, c1, s2, c2
	(s1, c1) = math.sincos(std.flt64nan())
	testr.check(c, std.isnan(s1), "sincos(NaN64) should be (NaN, NaN)")
	testr.check(c, std.isnan(c1), "sincos(NaN64) should be (NaN, NaN)")
	(s2, c2) = math.sincos(std.flt32nan())
	testr.check(c, std.isnan(s2), "sincos(NaN32) should be (NaN, NaN)")
	testr.check(c, std.isnan(c2), "sincos(NaN32) should be (NaN, NaN)")
}