|
Revision 26, 0.7 kB
(checked in by lhealy, 9 months ago)
|
|
Subversion version stamp.
|
-
Property svn:keywords set to
Id
|
| Line | |
|---|
| 1 | ;; Integer powers |
|---|
| 2 | ;; Liam Healy, Sun Apr 30 2006 - 22:46 |
|---|
| 3 | ;; Time-stamp: <2008-02-16 22:39:17EST power.lisp> |
|---|
| 4 | ;; $Id$ |
|---|
| 5 | |
|---|
| 6 | (in-package :gsl) |
|---|
| 7 | |
|---|
| 8 | (defmfun pow (x n) |
|---|
| 9 | "gsl_sf_pow_int_e" ((x :double) (n :int) (ret sf-result)) |
|---|
| 10 | :documentation ; FDL |
|---|
| 11 | "The power x^n for integer n. The |
|---|
| 12 | power is computed using the minimum number of multiplications. For |
|---|
| 13 | example, x^8 is computed as ((x^2)^2)^2, requiring only 3 |
|---|
| 14 | multiplications. For reasons of efficiency, these functions do not |
|---|
| 15 | check for overflow or underflow conditions.") |
|---|
| 16 | |
|---|
| 17 | #| |
|---|
| 18 | (make-tests power |
|---|
| 19 | (pow 3.5d0 5)) |
|---|
| 20 | |# |
|---|
| 21 | |
|---|
| 22 | (LISP-UNIT:DEFINE-TEST POWER |
|---|
| 23 | (LISP-UNIT::ASSERT-NUMERICAL-EQUAL |
|---|
| 24 | (LIST 525.21875d0 9.329759187437503d-13) |
|---|
| 25 | (MULTIPLE-VALUE-LIST (POW 3.5d0 5)))) |
|---|