Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
;********************************************************
; file: psi.lisp
; description: Psi (digamma) functions
; date: Mon May 1 2006 - 22:11
; author: Liam M. Healy
; modified: Mon May 1 2006 - 22:25
;********************************************************
;;; $Id: $
(in-package :gsl)
;;;;****************************************************************************
;;;; Digamma Function
;;;;****************************************************************************
(defgeneric psi (x)
(:documentation "The psi, or digamma, function."))
(defun-gsl psi ((n :int))
"gsl_sf_psi_int_e"
:method ((n fixnum))
:documentation "Domain: n integer, n > 0."
:return (sf-result))
(defun-gsl psi ((x :double))
"gsl_sf_psi_e"
:method ((x double-float))
:documentation "Domain: x /= 0.0, -1.0, -2.0, ..."
:return (sf-result))
(defun-gsl psi-1piy ((x :double))
"gsl_sf_psi_1piy_e"
:documentation "The real part of the digamma function
on the line @math{1+i y}, @math{\Re[\psi(1 + i y)]}."
:return (sf-result))
;;;;****************************************************************************
;;;; Trigamma Function
;;;;****************************************************************************
(defgeneric psi-1 (x)
(:documentation "The Trigamma function."))
(defun-gsl psi-1 ((n :int))
"gsl_sf_psi_1_int_e"
:method ((n fixnum))
:documentation "Domain: n integer, n > 0."
:return (sf-result))
(defun-gsl psi-1 ((x :double))
"gsl_sf_psi_1_e"
:method ((x double-float))
:documentation "Domain: x /= 0.0, -1.0, -2.0, ..."
:return (sf-result))
;;;;****************************************************************************
;;;; Polygamma
;;;;****************************************************************************
(defun-gsl psi-n ((m :int) (x :double))
"gsl_sf_psi_n_e"
:documentation "The polygamma function @math{\psi^@{(m)@}(x)} for
@math{m >= 0}, @math{x > 0}."
:return (sf-result))
;;;;****************************************************************************
;;;; Examples and unit test
;;;;****************************************************************************
(lisp-unit:define-test psi
(LISP-UNIT:ASSERT-FIRST-FP-EQUAL "0.125611766843d+01" (PSI 4))
(LISP-UNIT:ASSERT-FIRST-FP-EQUAL "0.125611766843d+01" (PSI 4.0d0))
(LISP-UNIT:ASSERT-FIRST-FP-EQUAL "0.283822955737d+00" (PSI-1 4))
(LISP-UNIT:ASSERT-FIRST-FP-EQUAL "0.283822955737d+00" (PSI-1 4.0d0))
(LISP-UNIT:ASSERT-FIRST-FP-EQUAL "-0.800397322451d-01" (PSI-N 2 4.0d0)))