\hypertarget{dlgamma_8f90}{}\doxysection{utils/dlgamma.f90 File Reference}
\label{dlgamma_8f90}\index{utils/dlgamma.f90@{utils/dlgamma.f90}}
\doxysubsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
real(dp) function \mbox{\hyperlink{dlgamma_8f90_ad8f0f3e49d278dbb8965f01ac21958d7}{dlgamma}} (x)
\begin{DoxyCompactList}\small\item\em log Gamma function in double precision \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{dlgamma_8f90_ad8f0f3e49d278dbb8965f01ac21958d7}\label{dlgamma_8f90_ad8f0f3e49d278dbb8965f01ac21958d7}} 
\index{dlgamma.f90@{dlgamma.f90}!dlgamma@{dlgamma}}
\index{dlgamma@{dlgamma}!dlgamma.f90@{dlgamma.f90}}
\doxysubsubsection{\texorpdfstring{dlgamma()}{dlgamma()}}
{\footnotesize\ttfamily real(dp) function dlgamma (\begin{DoxyParamCaption}\item[{real(dp), intent(in)}]{x }\end{DoxyParamCaption})}



log Gamma function in double precision 


\begin{DoxyItemize}
\item upstream source url\+: \href{http://www.kurims.kyoto-u.ac.jp/~ooura/}{\texttt{ http\+://www.\+kurims.\+kyoto-\/u.\+ac.\+jp/$\sim$ooura/}}
\begin{DoxyItemize}
\item Rewrite for Fortran ($>$= 90) by Youhei S\+A\+S\+A\+KI
\end{DoxyItemize}
\end{DoxyItemize}


\begin{DoxyPre}
  Copyright(C) 1996 Takuya OOURA  ooura at mmm.t.u-\/tokyo.ac.jp
               2011 Youhei SASAKI \href{mailto:uwabami@gfd-dennou.org}{\texttt{ uwabami@gfd-\/dennou.org}}
>
  Redistribution and use in source and binary forms, with or without
  modification, are permitted provided that the following conditions
  are met:
  1. Redistributions of source code must retain the above copyright
     notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright
     notice, this list of conditions and the following disclaimer in the
     documentation and/or other materials provided with the distribution.
>
  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE HOLDERS OR
  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 \end{DoxyPre}
 

Definition at line 40 of file dlgamma.\+f90.


\begin{DoxyCode}{0}
\DoxyCodeLine{40   \textcolor{keywordtype}{use }dc\_types,   \textcolor{keywordtype}{only}: dp}
\DoxyCodeLine{41   \textcolor{keywordtype}{use }spml\_utils, \textcolor{keywordtype}{only}: pi}
\DoxyCodeLine{42   \textcolor{keywordtype}{implicit none}}
\DoxyCodeLine{43 \textcolor{keywordtype}{  real}(DP), \textcolor{keywordtype}{intent(in)}  :: x}
\DoxyCodeLine{44 \textcolor{keywordtype}{  real}(DP) :: y}
\DoxyCodeLine{45 \textcolor{keywordtype}{  real}(DP) :: a(0 : 21)}
\DoxyCodeLine{46 \textcolor{keywordtype}{  real}(DP) :: b(0 : 97)}
\DoxyCodeLine{47 \textcolor{keywordtype}{  real}(DP) :: c(0 : 64)}
\DoxyCodeLine{48 \textcolor{keywordtype}{  real}(DP) :: d(0 : 6)}
\DoxyCodeLine{49 \textcolor{keywordtype}{  real}(DP) :: t}
\DoxyCodeLine{50 \textcolor{keywordtype}{  real}(DP) :: v}
\DoxyCodeLine{51 \textcolor{keywordtype}{  real}(DP) :: w}
\DoxyCodeLine{52   \textcolor{keywordtype}{integer}  :: i}
\DoxyCodeLine{53   \textcolor{keywordtype}{integer}  :: k}
\DoxyCodeLine{54 }
\DoxyCodeLine{55   \textcolor{keyword}{data} (a(i), i = 0, 10)  / \&}
\DoxyCodeLine{56   \&     0.00009967270908702825d0, -\/0.00019831672170162227d0, \&}
\DoxyCodeLine{57   \&    -\/0.00117085315349625822d0,  0.00722012810948319552d0, \&}
\DoxyCodeLine{58   \&    -\/0.00962213009367802970d0, -\/0.04219772092994235254d0, \&}
\DoxyCodeLine{59   \&     0.16653861065243609743d0, -\/0.04200263501129018037d0, \&}
\DoxyCodeLine{60   \&    -\/0.65587807152061930091d0,  0.57721566490153514421d0, \&}
\DoxyCodeLine{61   \&     0.99999999999999999764d0 /}
\DoxyCodeLine{62   \textcolor{keyword}{data} (a(i), i = 11, 21)  / \&}
\DoxyCodeLine{63   \&     0.00004672097259011420d0, -\/0.00006812300803992063d0, \&}
\DoxyCodeLine{64   \&    -\/0.00132531159076610073d0,  0.00733521178107202770d0, \&}
\DoxyCodeLine{65   \&    -\/0.00968095666383935949d0, -\/0.04217642811873540280d0, \&}
\DoxyCodeLine{66   \&     0.16653313644244428256d0, -\/0.04200165481709274859d0, \&}
\DoxyCodeLine{67   \&    -\/0.65587818792782740945d0,  0.57721567315209190522d0, \&}
\DoxyCodeLine{68   \&     0.99999999973565236061d0 /}
\DoxyCodeLine{69   \textcolor{keyword}{data} (b(i), i = 0, 13)  / \&}
\DoxyCodeLine{70   \&    -\/0.00000000004587497028d0,  0.00000000019023633960d0, \&}
\DoxyCodeLine{71   \&     0.00000000086377323367d0,  0.00000001155136788610d0, \&}
\DoxyCodeLine{72   \&    -\/0.00000002556403058605d0, -\/0.00000015236723372486d0, \&}
\DoxyCodeLine{73   \&    -\/0.00000316805106385740d0,  0.00000122903704923381d0, \&}
\DoxyCodeLine{74   \&     0.00002334372474572637d0,  0.00111544038088797696d0, \&}
\DoxyCodeLine{75   \&     0.00344717051723468982d0,  0.03198287045148788384d0, \&}
\DoxyCodeLine{76   \&    -\/0.32705333652955399526d0,  0.40120442440953927615d0 /}
\DoxyCodeLine{77   \textcolor{keyword}{data} (b(i), i = 14, 27)  / \&}
\DoxyCodeLine{78   \&    -\/0.00000000005184290387d0, -\/0.00000000083355121068d0, \&}
\DoxyCodeLine{79   \&    -\/0.00000000256167239813d0,  0.00000001455875381397d0, \&}
\DoxyCodeLine{80   \&     0.00000013512178394703d0,  0.00000029898826810905d0, \&}
\DoxyCodeLine{81   \&    -\/0.00000358107254612779d0, -\/0.00002445260816156224d0, \&}
\DoxyCodeLine{82   \&    -\/0.00004417127762011821d0,  0.00112859455189416567d0, \&}
\DoxyCodeLine{83   \&     0.00804694454346728197d0,  0.04919775747126691372d0, \&}
\DoxyCodeLine{84   \&    -\/0.24818372840948854178d0,  0.11071780856646862561d0 /}
\DoxyCodeLine{85   \textcolor{keyword}{data} (b(i), i = 28, 41)  / \&}
\DoxyCodeLine{86   \&     0.00000000030279161576d0,  0.00000000160742167357d0, \&}
\DoxyCodeLine{87   \&    -\/0.00000000405596009522d0, -\/0.00000005089259920266d0, \&}
\DoxyCodeLine{88   \&    -\/0.00000002029496209743d0,  0.00000135130272477793d0, \&}
\DoxyCodeLine{89   \&     0.00000391430041115376d0, -\/0.00002871505678061895d0, \&}
\DoxyCodeLine{90   \&    -\/0.00023052137536922035d0,  0.00045534656385400747d0, \&}
\DoxyCodeLine{91   \&     0.01153444585593040046d0,  0.07924014651650476036d0, \&}
\DoxyCodeLine{92   \&    -\/0.12152192626936502982d0, -\/0.07916438300260539592d0 /}
\DoxyCodeLine{93   \textcolor{keyword}{data} (b(i), i = 42, 55)  / \&}
\DoxyCodeLine{94   \&    -\/0.00000000050919149580d0, -\/0.00000000115274986907d0, \&}
\DoxyCodeLine{95   \&     0.00000001237873512188d0,  0.00000002937383549209d0, \&}
\DoxyCodeLine{96   \&    -\/0.00000030621450667958d0, -\/0.00000077409414949954d0, \&}
\DoxyCodeLine{97   \&     0.00000816753874325579d0,  0.00002412433382517375d0, \&}
\DoxyCodeLine{98   \&    -\/0.00026061217606063700d0, -\/0.00091000087658659231d0, \&}
\DoxyCodeLine{99   \&     0.01068093850598380797d0,  0.11395654404408482305d0, \&}
\DoxyCodeLine{100   \&     0.07209569059984075595d0, -\/0.10971041451764266684d0 /}
\DoxyCodeLine{101   \textcolor{keyword}{data} (b(i), i = 56, 69)  / \&}
\DoxyCodeLine{102   \&     0.00000000040119897187d0, -\/0.00000000013224526679d0, \&}
\DoxyCodeLine{103   \&    -\/0.00000001002723190355d0,  0.00000002569249716518d0, \&}
\DoxyCodeLine{104   \&     0.00000020336011868466d0, -\/0.00000118097682726060d0, \&}
\DoxyCodeLine{105   \&    -\/0.00000300660303810663d0,  0.00004402212897757763d0, \&}
\DoxyCodeLine{106   \&    -\/0.00001462405876235375d0, -\/0.00164873795596001280d0, \&}
\DoxyCodeLine{107   \&     0.00513927520866443706d0,  0.13843580753590579416d0, \&}
\DoxyCodeLine{108   \&     0.32730190978254056722d0,  0.08588339725978624973d0 /}
\DoxyCodeLine{109   \textcolor{keyword}{data} (b(i), i = 70, 83)  / \&}
\DoxyCodeLine{110   \&    -\/0.00000000015413428348d0,  0.00000000064905779353d0, \&}
\DoxyCodeLine{111   \&     0.00000000160702811151d0, -\/0.00000002655645793815d0, \&}
\DoxyCodeLine{112   \&     0.00000007619544277956d0,  0.00000047604380765353d0, \&}
\DoxyCodeLine{113   \&    -\/0.00000490748870866195d0,  0.00000821513040821212d0, \&}
\DoxyCodeLine{114   \&     0.00014804944070262948d0, -\/0.00122152255762163238d0, \&}
\DoxyCodeLine{115   \&    -\/0.00087425289205498532d0,  0.14438703699657968310d0, \&}
\DoxyCodeLine{116   \&     0.61315889733595543766d0,  0.55513708159976477557d0 /}
\DoxyCodeLine{117   \textcolor{keyword}{data} (b(i), i = 84, 97)  / \&}
\DoxyCodeLine{118   \&     0.00000000001049740243d0, -\/0.00000000025832017855d0, \&}
\DoxyCodeLine{119   \&     0.00000000139591845075d0, -\/0.00000000021177278325d0, \&}
\DoxyCodeLine{120   \&    -\/0.00000005082950464905d0,  0.00000037801785193343d0, \&}
\DoxyCodeLine{121   \&    -\/0.00000073982266659145d0, -\/0.00001088918441519888d0, \&}
\DoxyCodeLine{122   \&     0.00012491810452478905d0, -\/0.00049171790705139895d0, \&}
\DoxyCodeLine{123   \&    -\/0.00425707089448266460d0,  0.13595080378472757216d0, \&}
\DoxyCodeLine{124   \&     0.89518356003149514744d0,  1.31073912535196238583d0 /}
\DoxyCodeLine{125   \textcolor{keyword}{data} (c(i), i = 0, 12)  / \&}
\DoxyCodeLine{126   \&     0.0000000116333640008d0,  -\/0.0000000833156123568d0,  \&}
\DoxyCodeLine{127   \&     0.0000003832869977018d0,  -\/0.0000015814047847688d0,  \&}
\DoxyCodeLine{128   \&     0.0000065010672324100d0,  -\/0.0000274514060128677d0,  \&}
\DoxyCodeLine{129   \&     0.0001209015360925566d0,  -\/0.0005666333178228163d0,  \&}
\DoxyCodeLine{130   \&     0.0029294103665559733d0,  -\/0.0180340086069185819d0,  \&}
\DoxyCodeLine{131   \&     0.1651788780501166204d0,   1.1031566406452431944d0,  \&}
\DoxyCodeLine{132   \&     1.2009736023470742248d0 /}
\DoxyCodeLine{133   \textcolor{keyword}{data} (c(i), i = 13, 25)  / \&}
\DoxyCodeLine{134   \&     0.0000000013842760642d0,  -\/0.0000000069417501176d0, \&}
\DoxyCodeLine{135   \&     0.0000000342976459827d0,  -\/0.0000001785317236779d0, \&}
\DoxyCodeLine{136   \&     0.0000009525947257118d0,  -\/0.0000052483007560905d0, \&}
\DoxyCodeLine{137   \&     0.0000302364659535708d0,  -\/0.0001858396115473822d0, \&}
\DoxyCodeLine{138   \&     0.0012634378559425382d0,  -\/0.0102594702201954322d0, \&}
\DoxyCodeLine{139   \&     0.1243625515195050218d0,   1.3888709263595291174d0, \&}
\DoxyCodeLine{140   \&     2.4537365708424422209d0 /}
\DoxyCodeLine{141    \textcolor{keyword}{data} (c(i), i = 26, 38)  / \&}
\DoxyCodeLine{142   \&     0.0000000001298977078d0,  -\/0.0000000008029574890d0, \&}
\DoxyCodeLine{143   \&     0.0000000049454846150d0,  -\/0.0000000317563534834d0, \&}
\DoxyCodeLine{144   \&     0.0000002092136698089d0,  -\/0.0000014252023958462d0, \&}
\DoxyCodeLine{145   \&     0.0000101652510114008d0,  -\/0.0000774550502862323d0, \&}
\DoxyCodeLine{146   \&     0.0006537746948291078d0,  -\/0.0066014912535521830d0, \&}
\DoxyCodeLine{147   \&     0.0996711934948138193d0,   1.6110931485817511402d0, \&}
\DoxyCodeLine{148   \&     3.9578139676187162939d0 /}
\DoxyCodeLine{149    \textcolor{keyword}{data} (c(i), i = 39, 51)  / \&}
\DoxyCodeLine{150   \&     0.0000000000183995642d0, -\/0.0000000001353537034d0,  \&}
\DoxyCodeLine{151   \&     0.0000000009984676809d0, -\/0.0000000076346363974d0,  \&}
\DoxyCodeLine{152   \&     0.0000000599311464148d0, -\/0.0000004868554120177d0,  \&}
\DoxyCodeLine{153   \&     0.0000041441957716669d0, -\/0.0000377160856623282d0,  \&}
\DoxyCodeLine{154   \&     0.0003805693126824884d0, -\/0.0045979851178130194d0,  \&}
\DoxyCodeLine{155   \&     0.0831422678749791178d0,  1.7929113303999329439d0,  \&}
\DoxyCodeLine{156   \&     5.6625620598571415285d0 /}
\DoxyCodeLine{157    \textcolor{keyword}{data} (c(i), i = 52, 64)  / \&}
\DoxyCodeLine{158   \&     0.0000000000034858778d0, -\/0.0000000000297587783d0,  \&}
\DoxyCodeLine{159   \&     0.0000000002557677575d0, -\/0.0000000022705728282d0,  \&}
\DoxyCodeLine{160   \&     0.0000000207024992450d0, -\/0.0000001954426390917d0,  \&}
\DoxyCodeLine{161   \&     0.0000019343161886722d0, -\/0.0000204790249102570d0,  \&}
\DoxyCodeLine{162   \&     0.0002405181940241215d0, -\/0.0033842087561074799d0,  \&}
\DoxyCodeLine{163   \&     0.0713079483483518997d0,  1.9467574842460867884d0,  \&}
\DoxyCodeLine{164   \&     7.5343642367587329552d0 /}
\DoxyCodeLine{165    \textcolor{keyword}{data} (d(i), i = 0, 6)  / \&}
\DoxyCodeLine{166   \&    -\/0.00163312359200500807d0, 0.00083644533703385956d0, \&}
\DoxyCodeLine{167   \&    -\/0.00059518947575728181d0, 0.00079365057505415415d0, \&}
\DoxyCodeLine{168   \&    -\/0.00277777777735463043d0, 0.08333333333333309869d0, \&}
\DoxyCodeLine{169   \&     0.91893853320467274178d0 /}
\DoxyCodeLine{170 }
\DoxyCodeLine{171 \textcolor{comment}{!! main loop}}
\DoxyCodeLine{172   w = x}
\DoxyCodeLine{173   \textcolor{keywordflow}{if} (x .lt. 0.0d0) w = 1.0d0 -\/ x}
\DoxyCodeLine{174   \textcolor{keywordflow}{if} (w .lt. 0.5d0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{175     k = 0}
\DoxyCodeLine{176     \textcolor{keywordflow}{if} (w .ge. 0.25d0) k = 11}
\DoxyCodeLine{177     y = ((((((((((a(k) * w + a(k + 1)) * w                    \&}
\DoxyCodeLine{178       \&      + a(k + 2)) * w + a(k + 3)) * w + a(k + 4)) * w  \&}
\DoxyCodeLine{179       \&      + a(k + 5)) * w + a(k + 6)) * w + a(k + 7)) * w  \&}
\DoxyCodeLine{180       \&      + a(k + 8)) * w + a(k + 9)) * w + a(k + 10)) * w}
\DoxyCodeLine{181     y = -\/dlog(y)}
\DoxyCodeLine{182   \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (w .lt. 3.5d0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{183     t = w -\/ 4.5d0 / (w + 0.5d0)}
\DoxyCodeLine{184     k = idint(t + 4)}
\DoxyCodeLine{185     t = t -\/ (k -\/ 3.5d0)}
\DoxyCodeLine{186     k = k * 14}
\DoxyCodeLine{187     y = ((((((((((((b(k) * t + b(k + 1)) * t                    \&}
\DoxyCodeLine{188       \&      + b(k + 2)) * t + b(k + 3)) * t + b(k + 4)) * t    \&}
\DoxyCodeLine{189       \&      + b(k + 5)) * t + b(k + 6)) * t + b(k + 7)) * t    \&}
\DoxyCodeLine{190       \&      + b(k + 8)) * t + b(k + 9)) * t + b(k + 10)) * t   \&}
\DoxyCodeLine{191       \&      + b(k + 11)) * t + b(k + 12)) * t + b(k + 13)}
\DoxyCodeLine{192   \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (w .lt. 8) \textcolor{keywordflow}{then}}
\DoxyCodeLine{193     k = (idint(w)) -\/ 3}
\DoxyCodeLine{194     t = w -\/ (k + 3.5d0)}
\DoxyCodeLine{195     k = k * 13}
\DoxyCodeLine{196     y = (((((((((((c(k) * t + c(k + 1)) * t                     \&}
\DoxyCodeLine{197       \&        + c(k + 2)) * t + c(k + 3)) * t + c(k + 4)) * t  \&}
\DoxyCodeLine{198       \&        + c(k + 5)) * t + c(k + 6)) * t + c(k + 7)) * t  \&}
\DoxyCodeLine{199       \&        + c(k + 8)) * t + c(k + 9)) * t + c(k + 10)) * t \&}
\DoxyCodeLine{200       \&        + c(k + 11)) * t + c(k + 12)}
\DoxyCodeLine{201   \textcolor{keywordflow}{else}}
\DoxyCodeLine{202     v = 1 / w}
\DoxyCodeLine{203     t = v * v}
\DoxyCodeLine{204     y = (((((d(0) * t + d(1)) * t + d(2)) * t           \&}
\DoxyCodeLine{205       \&      + d(3)) * t + d(4)) * t + d(5)) * v + d(6)}
\DoxyCodeLine{206     y = y + ( (w -\/ 0.5d0) * dlog(w) -\/ w )}
\DoxyCodeLine{207 \textcolor{keywordflow}{  end if}}
\DoxyCodeLine{208   \textcolor{keywordflow}{if} (x .lt. 0) y = log(pi / sin(pi * x)) -\/ y}

\end{DoxyCode}
