racket/collects/plot/tests/extreme-bounds-tests.rkt
Neil Toronto 75f76986c3 Plots with intervals too small or too large for flonums (2D and 3D)
Bounds fixpoint computation now uses only exact rationals
Speed improvements (3d-plot-area% now uses flonums internally as much as possible)
2011-11-14 22:01:07 -08:00

57 lines
1.8 KiB
Racket
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#lang racket
(require plot plot/utils)
(plot-x-label #f)
(plot-y-label #f)
(define stops (list (* 2 (inexact->exact -max.0))
(inexact->exact -max.0)
(inexact->exact -min.0)
0
(inexact->exact +min.0)
(inexact->exact +max.0)
(* 2 (inexact->exact +max.0))))
(define (extreme-real->string x)
(real->plot-label x (digits-for-range 0 (abs x))))
(define num-2d 0)
(time
(for ([x-min (in-list stops)]
[x-max (in-list (rest stops))]
#:when #t
[y-min (in-list stops)]
[y-max (in-list (rest stops))])
(displayln
(list (format "[~a,~a] × [~a,~a]"
(extreme-real->string x-min) (extreme-real->string x-max)
(extreme-real->string y-min) (extreme-real->string y-max))
(time (plot (lines (list (vector x-min y-min) (vector x-max y-max)))))))
(set! num-2d (+ 1 num-2d))))
(printf "Total 2D plots: ~a~n" num-2d)
(printf "-----------------------------------------~n")
(define num-3d 0)
(time
(for ([x-min (in-list stops)]
[x-max (in-list (rest stops))]
#:when #t
[y-min (in-list stops)]
[y-max (in-list (rest stops))]
#:when #t
[z-min (in-list stops)]
[z-max (in-list (rest stops))])
(displayln
(list (format "[~a,~a] × [~a,~a] × [~a,~a]"
(extreme-real->string x-min) (extreme-real->string x-max)
(extreme-real->string y-min) (extreme-real->string y-max)
(extreme-real->string z-min) (extreme-real->string z-max))
(time (plot3d (lines3d (list (vector x-min y-min z-min) (vector x-max y-max z-max)))))))
(set! num-3d (+ 1 num-3d))))
(printf "Total plots: ~a~n" num-3d)
(printf "-----------------------------------------~n")