Use flsqrt.
Eliminate pointless micro-optimizations. svn: r17330
This commit is contained in:
parent
45e84ca087
commit
9e6e9696af
|
@ -28,16 +28,12 @@ Correct output N = 1000 is
|
|||
;; ------------------------------
|
||||
;; define planetary masses, initial positions & velocity
|
||||
|
||||
(define-syntax-rule (defconst id n)
|
||||
(define-syntax (id stx) (quote-syntax n)))
|
||||
(define +pi+ 3.141592653589793) ;; define locally to enable inlining
|
||||
(define +days-per-year+ 365.24)
|
||||
|
||||
(defconst +pi+ 3.141592653589793)
|
||||
(defconst +days-per-year+ 365.24)
|
||||
(define +solar-mass+ (* 4 +pi+ +pi+))
|
||||
|
||||
;; +solar-mass+ = (* 4 +pi+ +pi+)
|
||||
(defconst +solar-mass+ 39.47841760435743)
|
||||
|
||||
(defconst +dt+ 0.01)
|
||||
(define +dt+ 0.01)
|
||||
|
||||
(define make-body flvector)
|
||||
(define-syntax-rule (deffield n getter setter)
|
||||
|
@ -91,7 +87,7 @@ Correct output N = 1000 is
|
|||
(fl* 5.15138902046611451e-05 +solar-mass+)))
|
||||
|
||||
(define *system* (vector *sun* *jupiter* *saturn* *uranus* *neptune*))
|
||||
(defconst *system-size* 5)
|
||||
(define *system-size* 5)
|
||||
;; -------------------------------
|
||||
(define (offset-momentum)
|
||||
(let loop-i ([i 0] [px 0.0] [py 0.0] [pz 0.0])
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
;; v.Bv /(v.v) eigenvalue of v
|
||||
(let loop ([i 0][vBv 0.0][vv 0.0])
|
||||
(if (= i n)
|
||||
(sqrt (unsafe-fl/ vBv vv))
|
||||
(unsafe-flsqrt (unsafe-fl/ vBv vv))
|
||||
(let ([vi (unsafe-flvector-ref v i)])
|
||||
(loop (unsafe-fx+ 1 i)
|
||||
(unsafe-fl+ vBv (unsafe-fl* (unsafe-flvector-ref u i) vi))
|
||||
|
|
Loading…
Reference in New Issue
Block a user