From 7fc645507925be0054765d1db3f3381eb489d1fc Mon Sep 17 00:00:00 2001 From: liam <liam@a3d8a0fb-c1db-0310-ace7-a616afeb9e30> Date: Sat, 22 Apr 2006 21:47:04 +0000 Subject: [PATCH] New directory init for all initialization and interface definitions. Added unit (regression) test from http://www.cs.northwestern.edu/academics/courses/325/readings/lisp-unit.html and defined my own floating-point comparison using 12 digits of the printed representation. Uncommented #'polynomial-solve-ws as it should compile correctly even though it's not terribly useful as-is. git-svn-id: svn+ssh://pop/opt/space/mathematics/gsl/trunk@3044 a3d8a0fb-c1db-0310-ace7-a616afeb9e30 --- gsll.asd | 20 +++-- init.lisp => init/init.lisp | 0 interface.lisp => init/interface.lisp | 0 polynomial.lisp | 3 +- special-functions/fermi-dirac.lisp | 106 ++++++++++++++++++++++++++ 5 files changed, 120 insertions(+), 9 deletions(-) rename init.lisp => init/init.lisp (100%) rename interface.lisp => init/interface.lisp (100%) create mode 100644 special-functions/fermi-dirac.lisp diff --git a/gsll.asd b/gsll.asd index 34c7902f..87cf313a 100644 --- a/gsll.asd +++ b/gsll.asd @@ -3,7 +3,7 @@ ; description: Definition of GSLL system ; date: ; author: Liam Healy -; modified: Thu Apr 6 2006 - 18:22 +; modified: Sat Apr 22 2006 - 17:32 ;******************************************************** ;;; $Id: $ @@ -13,20 +13,25 @@ :version "0" :author "Liam M. Healy" :licence "GPL" - :depends-on (cffi cffi-unix) ; http://www.cliki.net/cffi-unix + :depends-on (cffi cffi-unix) ; http://www.cliki.net/cffi-unix :components - ((:file "init") - (:file "interface" :depends-on (init)) - (:module general + ((:module init :depends-on (init interface) :components + ((:file "init") + (:file "interface" :depends-on (init)) + (:file "lisp-unit") + (:file "tests"))) + (:module general + :depends-on (init) + :components ((:file "conditions") (:file "mathematical"))) ;; complex numbers not necessary? Just make a struct. (:file "cffi-array") (:file "polynomial" :depends-on (init interface cffi-array)) ; see file (:module data - :depends-on (init interface) + :depends-on (init) :components ((:file "data") (:file "block" :depends-on (data)) @@ -35,7 +40,7 @@ (:file "permutation" :depends-on (data)) (:file "combination" :depends-on (data)))) (:module special-functions - :depends-on (init interface) + :depends-on (init) :components ((:file "airy") (:file "bessel") ; one left @@ -51,4 +56,5 @@ (:file "error-functions") (:file "exponential-functions") (:file "exponential-integrals") + (:file "fermi-dirac") )))) diff --git a/init.lisp b/init/init.lisp similarity index 100% rename from init.lisp rename to init/init.lisp diff --git a/interface.lisp b/init/interface.lisp similarity index 100% rename from interface.lisp rename to init/interface.lisp diff --git a/polynomial.lisp b/polynomial.lisp index 986b4786..effd66bb 100644 --- a/polynomial.lisp +++ b/polynomial.lisp @@ -3,7 +3,7 @@ ; description: Polynomials ; date: Tue Mar 21 2006 - 18:33 ; author: Liam M. Healy -; modified: Fri Apr 21 2006 - 09:20 +; modified: Sat Apr 22 2006 - 15:29 ;******************************************************** ;;; $Id: $ @@ -210,7 +210,6 @@ :c-return-value :void) ,workspace)))) -#+future (defun-gsl polynomial-solve-ws ((coefficients (:double n)) (workspace poly-complex-workspace)) "gsl_poly_complex_solve" diff --git a/special-functions/fermi-dirac.lisp b/special-functions/fermi-dirac.lisp new file mode 100644 index 00000000..34db2c34 --- /dev/null +++ b/special-functions/fermi-dirac.lisp @@ -0,0 +1,106 @@ +;******************************************************** +; file: fermi-dirac.lisp +; description: Fermi-Dirac function. +; date: Sat Apr 22 2006 - 16:12 +; author: Liam M. Healy +; modified: Sat Apr 22 2006 - 17:41 +;******************************************************** +;;; $Id: $ + +(in-package :gsl) + +;;;;**************************************************************************** +;;;; Complete Fermi-Dirac Integrals +;;;;**************************************************************************** + +(defun-gsl fermi-dirac-m1 ((x :double)) + "gsl_sf_fermi_dirac_m1_e" + :documentation + "The complete Fermi-Dirac integral with an index of @math{-1}. + This integral is given by @c{$F_{-1}(x) = e^x / (1 + e^x)$} + @math{F_@{-1@}(x) = e^x / (1 + e^x)}." + :return (sf-result)) + +(defun-gsl fermi-dirac-0 ((x :double)) + "gsl_sf_fermi_dirac_0_e" + :documentation + "The complete Fermi-Dirac integral with an index of @math{0}. + This integral is given by @math{F_0(x) = \ln(1 + e^x)}." + :return (sf-result)) + +(defun-gsl fermi-dirac-1 ((x :double)) + "gsl_sf_fermi_dirac_1_e" + :documentation + "The complete Fermi-Dirac integral with an index of @math{1}, + @math{F_1(x) = \int_0^\infty dt (t /(\exp(t-x)+1))}." + :return (sf-result)) + +(defun-gsl fermi-dirac-2 ((x :double)) + "gsl_sf_fermi_dirac_2_e" + :documentation + "The complete Fermi-Dirac integral with an index of @math{2}, + @math{F_2(x) = (1/2) \int_0^\infty dt (t^2 /(\exp(t-x)+1))}." + :return (sf-result)) + +(defun-gsl fermi-dirac-integral ((j :int) (x :double)) + "gsl_sf_fermi_dirac_int_e" + :documentation + "The complete Fermi-Dirac integral with an integer index of @math{j}, + @math{F_j(x) = (1/\Gamma(j+1)) \int_0^\infty dt (t^j /(\exp(t-x)+1))}." + :return (sf-result)) + +(defun-gsl fermi-dirac-m1/2 ((x :double)) + "gsl_sf_fermi_dirac_mhalf_e" + :documentation + "The complete Fermi-Dirac integral @c{$F_{-1/2}(x)$}" + :return (sf-result)) + +(defun-gsl fermi-dirac-1/2 ((x :double)) + "gsl_sf_fermi_dirac_half_e" + :documentation + "The complete Fermi-Dirac integral @c{$F_{1/2}(x)$}." + :return (sf-result)) + +(defun-gsl fermi-dirac-3/2 ((x :double)) + "gsl_sf_fermi_dirac_3half_e" + :documentation + "The complete Fermi-Dirac integral @c{$F_{3/2}(x)$}." + :return (sf-result)) + +;;;;**************************************************************************** +;;;; Incomplete Fermi-Dirac Integrals +;;;;**************************************************************************** + +(defun-gsl fermi-dirac-inc-0 ((x :double) (b :double)) + "gsl_sf_fermi_dirac_inc_0_e" + :documentation + "The incomplete Fermi-Dirac integral with an index + of zero, @c{$F_0(x,b) = \ln(1 + e^{b-x}) - (b-x)$}." + :return (sf-result)) + +;;;;**************************************************************************** +;;;; Examples and unit test +;;;;**************************************************************************** + +(lisp-unit:define-test fermi-dirac + (lisp-unit:assert-first-fp-equal + "0.622459331202d+00" + (fermi-dirac-m1 0.5d0)) + (lisp-unit:assert-first-fp-equal + "0.113687100611d+01" + (fermi-dirac-0 0.75d0)) + (lisp-unit:assert-first-fp-equal + "0.425894306124d+00" + (fermi-dirac-1 -0.75d0)) + (lisp-unit:assert-first-fp-equal + "0.113016301626d+01" + (fermi-dirac-2 0.25d0)) + (lisp-unit:assert-first-fp-equal + "0.666882708765d+04" + (fermi-dirac-integral 5 12.35d0)) + (lisp-unit:assert-first-fp-equal + "0.282372127740d+01" + (fermi-dirac-1/2 2.0d0)) + (lisp-unit:assert-first-fp-equal + "0.170141327798d+01" + (fp-string (fermi-dirac-inc-0 2.0d0 0.5d0)))) -- GitLab