/pkgs/math-pkgs/math-lib/math/private/utils/flonum-tests.rkt
Unknown | 535 lines | 473 code | 62 blank | 0 comment | 0 complexity | edc6f1386ecfd50f7405a6a33d359bb2 MD5 | raw file
1#lang typed/racket/base 2 3(require racket/math 4 racket/list 5 "../base/base-random.rkt" 6 "../flonum/expansion/expansion-base.rkt" 7 "../flonum/expansion/expansion-exp.rkt" 8 "../flonum/expansion/expansion-log.rkt" 9 "../flonum/flonum-functions.rkt" 10 "../flonum/flonum-constants.rkt" 11 "../flonum/flonum-bits.rkt" 12 "../flonum/flonum-error.rkt" 13 "../flonum/flonum-log.rkt" 14 "../bigfloat/bigfloat-log-arithmetic.rkt" 15 "../distributions/dist-struct.rkt" 16 "../distributions/geometric-dist.rkt" 17 "../../bigfloat.rkt") 18 19(provide 20 print-fp-test-progress? 21 ;; Unary flonum tests 22 test-flabs 23 test-flsqrt 24 test-fllog 25 test-flexp 26 test-flsin 27 test-flcos 28 test-fltan 29 test-flasin 30 test-flacos 31 test-flatan 32 test-fllog2 33 ;; Binary flonum tests 34 test-fl+ 35 test-fl* 36 test-fl- 37 test-fl/ 38 test-flexpt 39 test-fllogb 40 ;; Unary flop/error tests 41 test-flsqr/error 42 test-flsqrt/error 43 test-flexp/error 44 ;; Binary flop/error tests 45 test-fl+/error 46 test-fl-/error 47 test-fl*/error 48 test-fl//error 49 ;; fl2 conversion test 50 test-fl2 51 ;; Unary fl2 tests 52 test-fl2abs 53 test-fl2sqr 54 test-fl2sqrt 55 test-fl2exp 56 test-fl2expm1 57 test-fl2log 58 test-fl2log1p 59 ;; Binary fl2 tests 60 test-fl2+ 61 test-fl2- 62 test-fl2* 63 test-fl2/ 64 ;; Comprehensive test 65 test-floating-point) 66 67;; Allowable error for different kinds of functions, in ulps 68(define flonum-fun-ulps 0.5) 69(define fllog2-ulps 1.0) 70(define fllogb-ulps 2.5) 71(define flonum/error-fun-ulps 0.5) 72(define flexp/error-fun-ulps 3.0) 73(define fl2-conversion-ulps 0.5) 74(define unary-fl2-fun-ulps 1.0) 75(define binary-fl2-fun-ulps 8.0) 76(define fl2exp-fun-ulps 3.0) 77(define fl2log-fun-ulps 2.0) 78 79(: current-max-ulp-error (Parameterof Nonnegative-Flonum)) 80(define current-max-ulp-error (make-parameter 0.0)) 81 82;; =================================================================================================== 83;; Helpers 84 85(: different-zero? (Real Real -> Boolean)) 86(define (different-zero? x y) 87 (or (and (eqv? x -0.0) (eqv? y 0.0)) 88 (and (eqv? x 0.0) (eqv? y -0.0)))) 89 90(: fl2->real* (Flonum Flonum -> Real)) 91;; Like `fl2->real', but returns signed flonum zeros 92(define (fl2->real* x2 x1) 93 (define x.0 (fl+ x2 x1)) 94 (cond [(zero? x.0) x2] 95 [else (fl2->real x2 x1)])) 96 97(: bigfloat->real* (Bigfloat -> Real)) 98;; Like `bigfloat->real*', but returns a signed infinity or a signed flonum zero if conversion would 99;; overflow or underflow a flonum 100(define (bigfloat->real* x) 101 (define x.0 (bigfloat->flonum x)) 102 (cond [(fl= x.0 0.0) x.0] 103 [(flrational? x.0) (bigfloat->real x)] 104 [else x.0])) 105 106(: filter/ulp-error (All (A B) ((Listof (List A (U B Flonum))) 107 Flonum -> (Listof (List A (U B Flonum)))))) 108(define (filter/ulp-error xes ulps) 109 (filter (?: ([xe : (List A (U B Flonum))]) 110 (define e (second xe)) 111 (or (not (flonum? e)) (e . fl> . ulps))) 112 xes)) 113 114(: print-fp-test-progress? (Parameterof Boolean)) 115(define print-fp-test-progress? (make-parameter #t)) 116 117(define progress-chunk-size 200) 118(define progress-superchunk-chunks 5) 119 120(: maybe-print-progress (Symbol Integer Natural -> Void)) 121(define (maybe-print-progress name i m) 122 (when (and (print-fp-test-progress?) (i . > . 0) (i . <= . m)) 123 (let* ([flush? (cond [(= i 1) (printf "~a: " name)] 124 [else #f])] 125 [flush? (cond [(= 0 (modulo i progress-chunk-size)) 126 (cond [(= 0 (modulo i (* progress-superchunk-chunks 127 progress-chunk-size))) 128 (printf "* ~a " i)] 129 [else (printf "*")])] 130 [else flush?])] 131 [flush? (cond [(= i m) (printf "* ~a~n" m)] 132 [else flush?])]) 133 (when flush? (flush-output))))) 134 135;; =================================================================================================== 136;; Test case generation 137 138;; Deteriministic test cases 139 140(define standard-xs 141 (list 142 ;; Test the sign of the return value of `flexpt' 143 -1001.0 -10.0 -0.1 +0.1 +10.0 +1001.0 144 ;; Test squaring 145 (- (flsqrt +min.0)) (flsqrt +min.0) 146 (- (flsqrt +max-subnormal.0)) (flsqrt +max-subnormal.0) 147 (- (flsqrt +max-subnormal.hi)) (flsqrt +max-subnormal.hi) 148 (- (flsqrt +max.0)) (flsqrt +max.0) 149 ;; Test exp limits 150 (fllog +min.0) (fllog +max-subnormal.0) (fllog +max-subnormal.hi) (fllog +max.0) 151 ;; Standard special values 152 -inf.0 -max.0 -1.0 -max-subnormal.hi -max-subnormal.0 -min.0 -0.0 153 +inf.0 +max.0 +1.0 +max-subnormal.hi +max-subnormal.0 +min.0 +0.0 154 +nan.0)) 155 156(define standard-rs 157 (append standard-xs 158 (list +10 +1 +1/7 +1/10 +1/13 159 -10 -1 -1/7 -1/10 -1/13 160 0))) 161 162(: product (All (A B) ((Listof A) (Listof B) -> (Values (Listof A) (Listof B))))) 163(define (product as bs) 164 (define abs 165 (append* 166 (for/list: : (Listof (Listof (Pair A B))) ([a (in-list as)]) 167 (for/list: : (Listof (Pair A B)) ([b (in-list bs)]) 168 (cons a b))))) 169 (values (map (inst car A B) abs) (map (inst cdr A B) abs))) 170 171;; Random test cases 172 173(define min-subnormal-ord (flonum->ordinal -max-subnormal.0)) 174(define max-subnormal-ord (+ 1 (flonum->ordinal +max-subnormal.0))) 175 176(define min-fl2-subnormal-ord (flonum->ordinal -max-subnormal.hi)) 177(define max-fl2-subnormal-ord (+ 1 (flonum->ordinal +max-subnormal.hi))) 178 179(: sample-flonum (case-> (Integer -> (Listof Flonum)) 180 (Integer Flonum Flonum -> (Listof Flonum)))) 181(define (sample-flonum n [mn -inf.0] [mx +inf.0]) 182 (define min-ord (flonum->ordinal mn)) 183 (define max-ord (+ 1 (flonum->ordinal mx))) 184 (let ([min-subnormal-ord (max min-ord min-subnormal-ord)] 185 [max-subnormal-ord (min max-ord max-subnormal-ord)] 186 [min-fl2-subnormal-ord (max min-ord min-fl2-subnormal-ord)] 187 [max-fl2-subnormal-ord (min max-ord max-fl2-subnormal-ord)]) 188 (build-list 189 n (? (_) 190 (define r (random)) 191 (ordinal->flonum 192 (cond [(and (min-subnormal-ord . < . max-subnormal-ord) (r . < . 0.1)) 193 (random-integer min-subnormal-ord max-subnormal-ord)] 194 [(and (min-fl2-subnormal-ord . < . max-fl2-subnormal-ord) (r . < . 0.2)) 195 (random-integer min-subnormal-ord max-subnormal-ord)] 196 [else 197 (random-integer min-ord max-ord)])))))) 198 199(define denom-dist (geometric-dist 1e-32)) 200 201(: sample-rational (Integer -> (Listof Exact-Rational))) 202(define (sample-rational n) 203 (map (?: ([f1 : Flonum] [d : Integer]) 204 (+ (inexact->exact f1) 205 (* (if ((random) . > . 0.5) -1 1) 206 (/ (random-natural (+ 1 d)) d) 207 (expt 2 (- (exact-round (/ (fllog (flabs f1)) (fllog 2.0))) 52))))) 208 (sample-flonum n) 209 (map (?: ([x : Flonum]) (+ 1 (exact-floor x))) (sample denom-dist n)))) 210 211;; =================================================================================================== 212;; Flonum functions 213 214(define-type Flonum-Error (U Flonum (List Symbol Flonum Real))) 215(define-type Unary-Flonum-Failure (List (List Symbol Flonum) Flonum-Error)) 216(define-type Binary-Flonum-Failure (List (List Symbol Flonum Flonum) Flonum-Error)) 217 218(: flonum-error (Flonum Bigfloat -> Flonum-Error)) 219(define (flonum-error z z0.bf) 220 (define z0 (bigfloat->real* z0.bf)) 221 (cond [(different-zero? z z0) (list 'different-zero? z z0)] 222 [else (flulp-error z z0)])) 223 224(: unary-flonum-fun-error ((Flonum -> Flonum) (Bigfloat -> Bigfloat) Flonum -> Flonum-Error)) 225(define (unary-flonum-fun-error f g x) 226 (flonum-error (f x) (parameterize ([bf-precision 53]) 227 (g (bf x))))) 228 229(: test-unary-flonum-fun 230 (Symbol (Flonum -> Flonum) (Bigfloat -> Bigfloat) Integer Flonum Flonum 231 -> (Listof Unary-Flonum-Failure))) 232(define (test-unary-flonum-fun name f g n mn mx) 233 (define xs (append standard-xs (sample-flonum n mn mx))) 234 (define m (length xs)) 235 (filter/ulp-error 236 (for/list: : (Listof Unary-Flonum-Failure) ([x (in-list xs)] 237 [i (in-naturals 1)]) 238 (maybe-print-progress name i m) 239 (list (list name x) (unary-flonum-fun-error f g x))) 240 (current-max-ulp-error))) 241 242(: binary-flonum-fun-error 243 ((Flonum Flonum -> Flonum) (Bigfloat Bigfloat -> Bigfloat) Flonum Flonum -> Flonum-Error)) 244(define (binary-flonum-fun-error f g x y) 245 (flonum-error (f x y) (parameterize ([bf-precision 53]) 246 (g (bf x) (bf y))))) 247 248(: test-binary-flonum-fun 249 (Symbol (Flonum Flonum -> Flonum) (Bigfloat Bigfloat -> Bigfloat) Integer 250 -> (Listof Binary-Flonum-Failure))) 251(define (test-binary-flonum-fun name f g n) 252 (define-values (pre-xs pre-ys) (product standard-xs standard-xs)) 253 (define xs (append pre-xs (sample-flonum n))) 254 (define ys (append pre-ys (sample-flonum n))) 255 (define m (length xs)) 256 (filter/ulp-error 257 (for/list: : (Listof Binary-Flonum-Failure) ([x (in-list xs)] 258 [y (in-list ys)] 259 [i (in-naturals 1)]) 260 (maybe-print-progress name i m) 261 (list (list name x y) (binary-flonum-fun-error f g x y))) 262 (current-max-ulp-error))) 263 264;; =================================================================================================== 265;; fl2 conversion 266 267(define-type Fl2-Error (U Flonum (List Symbol Flonum Real))) 268(define-type Fl2-Failure (List (List 'fl2 Real) Fl2-Error)) 269 270(: fl2-error (Flonum Flonum Real -> Fl2-Error)) 271(define (fl2-error x2 x1 x) 272 (cond [(not (fl2? x2 x1)) (list 'not-fl2? x2 x1)] 273 [(different-zero? x2 x) (list 'different-zero? x2 x)] 274 [else (fl2ulp-error x2 x1 x)])) 275 276(: fl2-conversion-error (Real -> Fl2-Error)) 277(define (fl2-conversion-error x) 278 (define-values (x2 x1) (fl2 x)) 279 (fl2-error x2 x1 x)) 280 281(: test-fl2-conversion (Integer -> (Listof Fl2-Failure))) 282(define (test-fl2-conversion n) 283 (define xs (append standard-rs (sample-rational n))) 284 (define m (length xs)) 285 (filter/ulp-error 286 (for/list: : (Listof Fl2-Failure) ([x (in-list xs)] 287 [i (in-naturals 1)]) 288 (maybe-print-progress 'fl2 i m) 289 (list (list 'fl2 x) (fl2-conversion-error x))) 290 (current-max-ulp-error))) 291 292;; =================================================================================================== 293;; Flonum arithmetic with error 294 295(define-type Unary-Fl/Error-Failure (List (List Symbol Flonum) Fl2-Error)) 296(define-type Binary-Fl/Error-Failure (List (List Symbol Flonum Flonum) Fl2-Error)) 297 298(: unary-flonum/error-fun-error ((Flonum -> (Values Flonum Flonum)) (Bigfloat -> Bigfloat) Flonum 299 -> Fl2-Error)) 300(define (unary-flonum/error-fun-error f g x) 301 (define-values (z2 z1) (f x)) 302 (fl2-error z2 z1 (parameterize ([bf-precision 256]) 303 (bigfloat->real* (g (bf x)))))) 304 305(: binary-flonum/error-fun-error ((Flonum Flonum -> (Values Flonum Flonum)) 306 (Bigfloat Bigfloat -> Bigfloat) 307 Flonum Flonum 308 -> Fl2-Error)) 309(define (binary-flonum/error-fun-error f g x y) 310 (define-values (z2 z1) (f x y)) 311 (fl2-error z2 z1 (parameterize ([bf-precision 256]) 312 (bigfloat->real* (g (bf x) (bf y)))))) 313 314(: test-unary-flonum/error-fun 315 (Symbol (Flonum -> (Values Flonum Flonum)) (Bigfloat -> Bigfloat) Integer 316 -> (Listof Unary-Fl/Error-Failure))) 317(define (test-unary-flonum/error-fun name f g n) 318 (define xs (append standard-xs (sample-flonum n))) 319 (define m (length xs)) 320 (filter/ulp-error 321 (for/list: : (Listof Unary-Fl/Error-Failure) ([x (in-list xs)] 322 [i (in-naturals 1)]) 323 (maybe-print-progress name i m) 324 (list (list name x) (unary-flonum/error-fun-error f g x))) 325 (current-max-ulp-error))) 326 327(: test-binary-flonum/error-fun 328 (Symbol (Flonum Flonum -> (Values Flonum Flonum)) (Bigfloat Bigfloat -> Bigfloat) Integer 329 -> (Listof Binary-Fl/Error-Failure))) 330(define (test-binary-flonum/error-fun name f g n) 331 (define-values (pre-xs pre-ys) (product standard-xs standard-xs)) 332 (define xs (append pre-xs (sample-flonum n))) 333 (define ys (append pre-ys (sample-flonum n))) 334 (define m (length xs)) 335 (filter/ulp-error 336 (for/list: : (Listof Binary-Fl/Error-Failure) ([x (in-list xs)] 337 [y (in-list ys)] 338 [i (in-naturals 1)]) 339 (maybe-print-progress name i m) 340 (list (list name x y) (binary-flonum/error-fun-error f g x y))) 341 (current-max-ulp-error))) 342 343;; =================================================================================================== 344;; Flonum expansions 345 346(define-type Unary-Fl2-Failure (List (List Symbol Flonum Flonum) Fl2-Error)) 347(define-type Binary-Fl2-Failure (List (List Symbol Flonum Flonum Flonum Flonum) Fl2-Error)) 348 349(: unary-fl2-fun-error ((Flonum Flonum -> (Values Flonum Flonum)) (Bigfloat -> Bigfloat) 350 Flonum Flonum -> Fl2-Error)) 351(define (unary-fl2-fun-error f g x2 x1) 352 (define-values (z2 z1) (f x2 x1)) 353 (fl2-error z2 z1 (parameterize ([bf-precision 256]) 354 (bigfloat->real* (g (bf (fl2->real* x2 x1))))))) 355 356(: test-unary-fl2-fun 357 (Symbol (Flonum Flonum -> (Values Flonum Flonum)) (Bigfloat -> Bigfloat) Integer 358 -> (Listof Unary-Fl2-Failure))) 359(define (test-unary-fl2-fun name f g n) 360 (define xs (append standard-rs (sample-rational n))) 361 (define m (length xs)) 362 (filter/ulp-error 363 (for/list: : (Listof Unary-Fl2-Failure) ([x (in-list xs)] 364 [i (in-naturals 1)]) 365 (maybe-print-progress name i m) 366 (define-values (x2 x1) (fl2 x)) 367 (list (list name x2 x1) (unary-fl2-fun-error f g x2 x1))) 368 (current-max-ulp-error))) 369 370(: binary-fl2-fun-error ((Flonum Flonum Flonum Flonum -> (Values Flonum Flonum)) 371 (Bigfloat Bigfloat -> Bigfloat) 372 Flonum Flonum Flonum Flonum 373 -> Fl2-Error)) 374(define (binary-fl2-fun-error f g x2 x1 y2 y1) 375 (define-values (z2 z1) (f x2 x1 y2 y1)) 376 (fl2-error z2 z1 (parameterize ([bf-precision 256]) 377 (bigfloat->real* (g (bf (fl2->real* x2 x1)) (bf (fl2->real* y2 y1))))))) 378 379(: test-binary-fl2-fun 380 (Symbol (Flonum Flonum Flonum Flonum -> (Values Flonum Flonum)) (Bigfloat Bigfloat -> Bigfloat) 381 Integer -> (Listof Binary-Fl2-Failure))) 382(define (test-binary-fl2-fun name f g n) 383 (define-values (pre-xs pre-ys) (product standard-rs standard-rs)) 384 (define xs (append pre-xs (sample-rational n))) 385 (define ys (append pre-ys (sample-rational n))) 386 (define m (length xs)) 387 (filter/ulp-error 388 (for/list: : (Listof Binary-Fl2-Failure) ([x (in-list xs)] 389 [y (in-list ys)] 390 [i (in-naturals 1)]) 391 (maybe-print-progress name i m) 392 (define-values (x2 x1) (fl2 x)) 393 (define-values (y2 y1) (fl2 y)) 394 (list (list name x2 x1 y2 y1) (binary-fl2-fun-error f g x2 x1 y2 y1))) 395 (current-max-ulp-error))) 396 397;; =================================================================================================== 398;; Flonum tests 399 400(define-syntax-rule (define-unary-flonum-test test-name flop bfop mn mx ulps) 401 (begin (: test-name (Natural -> (Listof Unary-Flonum-Failure))) 402 (define (test-name n) 403 (parameterize ([current-max-ulp-error ulps]) 404 (test-unary-flonum-fun 'flop flop bfop n mn mx))))) 405 406(define-syntax-rule (define-binary-flonum-test test-name flop bfop ulps) 407 (begin (: test-name (Natural -> (Listof Binary-Flonum-Failure))) 408 (define (test-name n) 409 (parameterize ([current-max-ulp-error ulps]) 410 (test-binary-flonum-fun 'flop flop bfop n))))) 411 412(define-unary-flonum-test test-flabs flabs bfabs -inf.0 +inf.0 flonum-fun-ulps) 413(define-unary-flonum-test test-flsqrt flsqrt bfsqrt 0.0 +inf.0 flonum-fun-ulps) 414(define-unary-flonum-test test-fllog fllog bflog 0.0 +inf.0 flonum-fun-ulps) 415(define-unary-flonum-test test-flexp flexp bfexp -746.0 710.0 flonum-fun-ulps) 416(define-unary-flonum-test test-flsin flsin bfsin -inf.0 +inf.0 flonum-fun-ulps) 417(define-unary-flonum-test test-flcos flcos bfcos -inf.0 +inf.0 flonum-fun-ulps) 418(define-unary-flonum-test test-fltan fltan bftan -inf.0 +inf.0 flonum-fun-ulps) 419(define-unary-flonum-test test-flasin flasin bfasin -1.0 1.0 flonum-fun-ulps) 420(define-unary-flonum-test test-flacos flacos bfacos -1.0 1.0 flonum-fun-ulps) 421(define-unary-flonum-test test-flatan flatan bfatan -inf.0 +inf.0 flonum-fun-ulps) 422(define-unary-flonum-test test-fllog2 fllog2 bflog2 0.0 +inf.0 fllog2-ulps) 423(define-binary-flonum-test test-fl+ fl+ bf+ flonum-fun-ulps) 424(define-binary-flonum-test test-fl- fl- bf- flonum-fun-ulps) 425(define-binary-flonum-test test-fl* fl* bf* flonum-fun-ulps) 426(define-binary-flonum-test test-fl/ fl/ bf/ flonum-fun-ulps) 427(define-binary-flonum-test test-flexpt flexpt bfexpt flonum-fun-ulps) 428(define-binary-flonum-test test-fllogb fllogb bflogb fllogb-ulps) 429 430;; =================================================================================================== 431;; Flonum/error tests 432 433(define-syntax-rule (define-unary-flop/error-test test-name flop bfop ulps) 434 (begin (: test-name (Natural -> (Listof Unary-Fl/Error-Failure))) 435 (define (test-name n) 436 (parameterize ([current-max-ulp-error ulps]) 437 (test-unary-flonum/error-fun 'flop flop bfop n))))) 438 439(define-syntax-rule (define-binary-flop/error-test test-name flop bfop ulps) 440 (begin (: test-name (Natural -> (Listof Binary-Fl/Error-Failure))) 441 (define (test-name n) 442 (parameterize ([current-max-ulp-error ulps]) 443 (test-binary-flonum/error-fun 'flop flop bfop n))))) 444 445(define-unary-flop/error-test test-flsqr/error flsqr/error bfsqr flonum/error-fun-ulps) 446(define-unary-flop/error-test test-flsqrt/error flsqrt/error bfsqrt flonum/error-fun-ulps) 447(define-unary-flop/error-test test-flexp/error flexp/error bfexp flexp/error-fun-ulps) 448(define-binary-flop/error-test test-fl+/error fl+/error bf+ flonum/error-fun-ulps) 449(define-binary-flop/error-test test-fl-/error fl-/error bf- flonum/error-fun-ulps) 450(define-binary-flop/error-test test-fl*/error fl*/error bf* flonum/error-fun-ulps) 451(define-binary-flop/error-test test-fl//error fl//error bf/ flonum/error-fun-ulps) 452 453;; =================================================================================================== 454;; fl2 tests 455 456(: test-fl2 (Natural -> (Listof Fl2-Failure))) 457(define (test-fl2 n) 458 (parameterize ([current-max-ulp-error fl2-conversion-ulps]) 459 (test-fl2-conversion n))) 460 461(define-syntax-rule (define-unary-fl2-test test-name fl2op bfop ulps) 462 (begin (: test-name (Natural -> (Listof Unary-Fl2-Failure))) 463 (define (test-name n) 464 (parameterize ([current-max-ulp-error ulps]) 465 (test-unary-fl2-fun 'fl2op fl2op bfop n))))) 466 467(define-syntax-rule (define-binary-fl2-test test-name fl2op bfop ulps) 468 (begin (: test-name (Natural -> (Listof Binary-Fl2-Failure))) 469 (define (test-name n) 470 (parameterize ([current-max-ulp-error ulps]) 471 (test-binary-fl2-fun 'fl2op fl2op bfop n))))) 472 473(define-unary-fl2-test test-fl2abs fl2abs bfabs unary-fl2-fun-ulps) 474(define-unary-fl2-test test-fl2sqr fl2sqr bfsqr unary-fl2-fun-ulps) 475(define-unary-fl2-test test-fl2sqrt fl2sqrt bfsqrt unary-fl2-fun-ulps) 476(define-unary-fl2-test test-fl2exp fl2exp bfexp fl2exp-fun-ulps) 477(define-unary-fl2-test test-fl2expm1 fl2expm1 bfexpm1 fl2exp-fun-ulps) 478(define-unary-fl2-test test-fl2log fl2log bflog fl2log-fun-ulps) 479(define-unary-fl2-test test-fl2log1p fl2log1p bflog1p fl2log-fun-ulps) 480(define-binary-fl2-test test-fl2+ fl2+ bf+ binary-fl2-fun-ulps) 481(define-binary-fl2-test test-fl2- fl2- bf- binary-fl2-fun-ulps) 482(define-binary-fl2-test test-fl2* fl2* bf* binary-fl2-fun-ulps) 483(define-binary-fl2-test test-fl2/ fl2/ bf/ binary-fl2-fun-ulps) 484 485;; =================================================================================================== 486;; Comprehensive test 487 488(: test-floating-point (Natural -> (Listof (U Unary-Flonum-Failure 489 Binary-Flonum-Failure 490 Unary-Fl/Error-Failure 491 Binary-Fl/Error-Failure 492 Fl2-Failure 493 Unary-Fl2-Failure 494 Binary-Fl2-Failure)))) 495(define (test-floating-point n) 496 (append 497 ;; Hardware implementation tests 498 (test-flabs n) 499 (test-fl+ n) 500 (test-fl* n) 501 (test-fl- n) 502 (test-fl/ n) 503 (test-flsqrt n) 504 (test-fllog n) 505 (test-flexp n) 506 (test-flexpt n) 507 (test-flsin n) 508 (test-flcos n) 509 (test-fltan n) 510 (test-flasin n) 511 (test-flacos n) 512 (test-flatan n) 513 (test-fllog2 n) 514 (test-fllogb n) 515 ;; Derived tests 516 (test-fl+/error n) 517 (test-fl-/error n) 518 (test-fl*/error n) 519 (test-flsqr/error n) 520 (test-fl//error n) 521 (test-fl2 n) 522 (test-fl2abs n) 523 (test-fl2+ n) 524 (test-fl2- n) 525 (test-fl2* n) 526 (test-fl2sqr n) 527 (test-fl2/ n) 528 (test-flsqrt/error n) 529 (test-fl2sqrt n) 530 (test-flexp/error n) 531 (test-fl2exp n) 532 (test-fl2expm1 n) 533 (test-fl2log n) 534 (test-fl2log1p n) 535 ))