]> www.ginac.de Git - ginac.git/blobdiff - ginac/inifcns_gamma.cpp
documentation update
[ginac.git] / ginac / inifcns_gamma.cpp
index e6ba5b1155f569e60073d8c50550f01c5e186fa0..c4f4f1a9aec248c2b1c1aaba4549925188e829de 100644 (file)
@@ -4,7 +4,7 @@
  *  some related stuff. */
 
 /*
- *  GiNaC Copyright (C) 1999-2000 Johannes Gutenberg University Mainz, Germany
+ *  GiNaC Copyright (C) 1999-2001 Johannes Gutenberg University Mainz, Germany
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -25,7 +25,6 @@
 #include <stdexcept>
 
 #include "inifcns.h"
-#include "ex.h"
 #include "constant.h"
 #include "pseries.h"
 #include "numeric.h"
@@ -34,9 +33,7 @@
 #include "symbol.h"
 #include "utils.h"
 
-#ifndef NO_NAMESPACE_GINAC
 namespace GiNaC {
-#endif // ndef NO_NAMESPACE_GINAC
 
 //////////
 // Logarithm of Gamma function
@@ -64,7 +61,7 @@ static ex lgamma_eval(const ex & x)
                if (x.info(info_flags::integer)) {
                        // lgamma(n) -> log((n-1)!) for postitive n
                        if (x.info(info_flags::posint))
-                               return log(factorial(x.exadd(_ex_1())));
+                               return log(factorial(x + _ex_1()));
                        else
                                throw (pole_error("lgamma_eval(): logarithmic pole",0));
                }
@@ -85,9 +82,9 @@ static ex lgamma_deriv(const ex & x, unsigned deriv_param)
 
 
 static ex lgamma_series(const ex & arg,
-                                               const relational & rel,
-                                               int order,
-                                               unsigned options)
+                        const relational & rel,
+                        int order,
+                        unsigned options)
 {
        // method:
        // Taylor series where there is no pole falls back to psi function
@@ -105,15 +102,15 @@ static ex lgamma_series(const ex & arg,
        ex recur;
        for (numeric p; p<=m; ++p)
                recur += log(arg+p);
-       cout << recur << endl;
        return (lgamma(arg+m+_ex1())-recur).series(rel, order, options);
 }
 
 
 REGISTER_FUNCTION(lgamma, eval_func(lgamma_eval).
-                                                 evalf_func(lgamma_evalf).
-                                                 derivative_func(lgamma_deriv).
-                                                 series_func(lgamma_series));
+                          evalf_func(lgamma_evalf).
+                          derivative_func(lgamma_deriv).
+                          series_func(lgamma_series).
+                          latex_name("\\log \\Gamma"));
 
 
 //////////
@@ -182,9 +179,9 @@ static ex tgamma_deriv(const ex & x, unsigned deriv_param)
 
 
 static ex tgamma_series(const ex & arg,
-                                               const relational & rel,
-                                               int order,
-                                               unsigned options)
+                        const relational & rel,
+                        int order,
+                        unsigned options)
 {
        // method:
        // Taylor series where there is no pole falls back to psi function
@@ -207,9 +204,10 @@ static ex tgamma_series(const ex & arg,
 
 
 REGISTER_FUNCTION(tgamma, eval_func(tgamma_eval).
-                                                 evalf_func(tgamma_evalf).
-                                                 derivative_func(tgamma_deriv).
-                                                 series_func(tgamma_series));
+                          evalf_func(tgamma_evalf).
+                          derivative_func(tgamma_deriv).
+                          series_func(tgamma_series).
+                          latex_name("\\Gamma"));
 
 
 //////////
@@ -280,10 +278,10 @@ static ex beta_deriv(const ex & x, const ex & y, unsigned deriv_param)
 
 
 static ex beta_series(const ex & arg1,
-                                         const ex & arg2,
-                                         const relational & rel,
-                                         int order,
-                                         unsigned options)
+                      const ex & arg2,
+                      const relational & rel,
+                      int order,
+                      unsigned options)
 {
        // method:
        // Taylor series where there is no pole of one of the tgamma functions
@@ -295,7 +293,7 @@ static ex beta_series(const ex & arg1,
        const symbol *s = static_cast<symbol *>(rel.lhs().bp);
        ex arg1_ser, arg2_ser, arg1arg2_ser;
        if ((!arg1_pt.info(info_flags::integer) || arg1_pt.info(info_flags::positive)) &&
-               (!arg2_pt.info(info_flags::integer) || arg2_pt.info(info_flags::positive)))
+           (!arg2_pt.info(info_flags::integer) || arg2_pt.info(info_flags::positive)))
                throw do_taylor();  // caught by function::series()
        // trap the case where arg1 is on a pole:
        if (arg1.info(info_flags::integer) && !arg1.info(info_flags::positive))
@@ -318,9 +316,10 @@ static ex beta_series(const ex & arg1,
 
 
 REGISTER_FUNCTION(beta, eval_func(beta_eval).
-                                               evalf_func(beta_evalf).
-                                               derivative_func(beta_deriv).
-                                               series_func(beta_series));
+                        evalf_func(beta_evalf).
+                        derivative_func(beta_deriv).
+                        series_func(beta_series).
+                        latex_name("\\mbox{B}"));
 
 
 //////////
@@ -390,9 +389,9 @@ static ex psi1_deriv(const ex & x, unsigned deriv_param)
 }
 
 static ex psi1_series(const ex & arg,
-                                         const relational & rel,
-                                         int order,
-                                         unsigned options)
+                      const relational & rel,
+                      int order,
+                      unsigned options)
 {
        // method:
        // Taylor series where there is no pole falls back to polygamma function
@@ -415,11 +414,11 @@ static ex psi1_series(const ex & arg,
 
 const unsigned function_index_psi1 =
        function::register_new(function_options("psi").
-                                                  eval_func(psi1_eval).
-                                                  evalf_func(psi1_evalf).
-                          derivative_func(psi1_deriv).
-                          series_func(psi1_series).
-                          overloaded(2));
+                              eval_func(psi1_eval).
+                              evalf_func(psi1_evalf).
+                              derivative_func(psi1_deriv).
+                              series_func(psi1_series).
+                              overloaded(2));
 
 //////////
 // Psi-functions (aka polygamma-functions)  psi(0,x)==psi(x)
@@ -513,10 +512,10 @@ static ex psi2_deriv(const ex & n, const ex & x, unsigned deriv_param)
 }
 
 static ex psi2_series(const ex & n,
-                                         const ex & arg,
-                                         const relational & rel,
-                                         int order,
-                                         unsigned options)
+                      const ex & arg,
+                      const relational & rel,
+                      int order,
+                      unsigned options)
 {
        // method:
        // Taylor series where there is no pole falls back to polygamma function
@@ -541,13 +540,12 @@ static ex psi2_series(const ex & n,
 
 const unsigned function_index_psi2 =
        function::register_new(function_options("psi").
-                                                  eval_func(psi2_eval).
-                                                  evalf_func(psi2_evalf).
-                          derivative_func(psi2_deriv).
-                          series_func(psi2_series).
-                          overloaded(2));
+                              eval_func(psi2_eval).
+                              evalf_func(psi2_evalf).
+                              derivative_func(psi2_deriv).
+                              series_func(psi2_series).
+                           latex_name("\\psi").
+                              overloaded(2));
 
 
-#ifndef NO_NAMESPACE_GINAC
 } // namespace GiNaC
-#endif // ndef NO_NAMESPACE_GINAC