Changeset 25802 in project
- Timestamp:
- 01/10/12 22:12:53 (9 years ago)
- Location:
- release/4/numbers/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
release/4/numbers/trunk/numbers.scm
r25798 r25802 1360 1360 1361 1361 (define (%log x) 1362 (cond 1363 ((%> x 0.0 'log) ; avoid calling inexact->exact on X here (to avoid overflow?) 1364 (##core#inline_allocate ("C_a_i_log" 4) (%exact->inexact x))) 1365 ((%= x 0.0) 1366 (if (%exact? x) 1367 (log0 'log x) 1368 (##core#inline_allocate ("C_a_i_log" 4) (%exact->inexact x)))) 1369 (else ; negative 1370 (%+ (%log (%magnitude x)) (* (make-complex 0 1) (%angle x)))))) 1362 (let ((type (%check-number x))) 1363 (cond 1364 ;; avoid calling inexact->exact on X here (to avoid overflow?) 1365 ((or (eq? type COMP) (%< x 0.0 'log)) ; General case 1366 (%+ (%log (%magnitude x)) (* (make-complex 0 1) (%angle x)))) 1367 ((eq? x 0) ; Exact zero? That's undefined 1368 (log0 'log x)) 1369 ((eq? type NONE) 1370 (bad-number 'exp x)) 1371 (else ; Simple real number case 1372 (##core#inline_allocate ("C_a_i_log" 4) (%exact->inexact x)))))) 1371 1373 1372 1374 (define log %log) -
release/4/numbers/trunk/tests/numbers-test.scm
r25798 r25802 419 419 (test "log of -1" (string->number "0.0+3.141592653589793i") (log -1)) 420 420 421 (test "log with complex number" 422 (string->number "0.0+1.5707963267948966i") 423 (log (string->number "+i"))) 424 425 (test "exp(log(x)) = x" 426 (string->number "2.0-3.0i") (exp (log (string->number "2.0-3.0i")))) 427 421 428 (letrec ((fac (lambda (n) 422 429 (if (zero? n)
Note: See TracChangeset
for help on using the changeset viewer.