Loading...
Searching...
No Matches
SymEngine::PolyGamma Class Reference
+ Inheritance diagram for SymEngine::PolyGamma:
+ Collaboration diagram for SymEngine::PolyGamma:

Public Member Functions

virtual void accept (Visitor &v) const
 
virtual void accept (EvalRealDoubleVisitorFinal &v) const
 
 PolyGamma (const RCP< const Basic > &n, const RCP< const Basic > &x)
 PolyGamma Constructor. More...
 
bool is_canonical (const RCP< const Basic > &n, const RCP< const Basic > &x)
 
RCP< const Basicrewrite_as_zeta () const
 
virtual RCP< const Basiccreate (const RCP< const Basic > &a, const RCP< const Basic > &b) const
 
virtual RCP< const Basiccreate (const RCP< const Basic > &a, const RCP< const Basic > &b) const=0
 
RCP< const Basiccreate (const vec_basic &b) const
 
- Public Member Functions inherited from SymEngine::TwoArgBasic< BaseClass >
 TwoArgBasic (const RCP< const Basic > &a, const RCP< const Basic > &b)
 b in TwoArgBasic(a, b) More...
 
hash_t __hash__ () const
 
RCP< const Basicget_arg1 () const
 
RCP< const Basicget_arg2 () const
 
virtual vec_basic get_args () const
 
virtual RCP< const Basiccreate (const RCP< const Basic > &a, const RCP< const Basic > &b) const =0
 Method to construct classes with canonicalization. More...
 
RCP< const Basiccreate (const vec_basic &b) const
 
virtual bool __eq__ (const Basic &o) const
 
virtual int compare (const Basic &o) const
 Structural equality comparator. More...
 

Static Public Attributes

static const TypeID type_code_id = SYMENGINE_POLYGAMMA
 

Detailed Description

Definition at line 1204 of file functions.h.

Constructor & Destructor Documentation

◆ PolyGamma()

SymEngine::PolyGamma::PolyGamma ( const RCP< const Basic > &  n,
const RCP< const Basic > &  x 
)
inline

PolyGamma Constructor.

Definition at line 1220 of file functions.h.

1221 : TwoArgFunction(n, x)
1222 {
1223 SYMENGINE_ASSIGN_TYPEID()
1224 SYMENGINE_ASSERT(is_canonical(n, x))
1225 }

Member Function Documentation

◆ create() [1/3]

RCP< const Basic > SymEngine::PolyGamma::create ( const RCP< const Basic > &  a,
const RCP< const Basic > &  b 
) const
virtual
Returns
canonicalized PolyGamma

Implements SymEngine::TwoArgBasic< BaseClass >.

Definition at line 3391 of file functions.cpp.

3393{
3394 return polygamma(a, b);
3395}
RCP< const Basic > polygamma(const RCP< const Basic > &n_, const RCP< const Basic > &x_)
Canonicalize PolyGamma.
Definition: functions.cpp:3397

◆ create() [2/3]

virtual RCP< const Basic > SymEngine::TwoArgBasic< BaseClass >::create ( const RCP< const Basic > &  a,
const RCP< const Basic > &  b 
) const
virtual

The polygamma function

It is a meromorphic function on \mathbb{C} and defined as the (n+1)-th derivative of the logarithm of the gamma function:

.. math:: \psi^{(n)} (z) := \frac{\mathrm{d}^{n+1}}{\mathrm{d} z^{n+1}} \log\Gamma(z).

Implements SymEngine::TwoArgBasic< BaseClass >.

◆ create() [3/3]

RCP< const Basic > SymEngine::TwoArgBasic< BaseClass >::create ( const vec_basic b) const
inline

The polygamma function

It is a meromorphic function on \mathbb{C} and defined as the (n+1)-th derivative of the logarithm of the gamma function:

.. math:: \psi^{(n)} (z) := \frac{\mathrm{d}^{n+1}}{\mathrm{d} z^{n+1}} \log\Gamma(z).

Definition at line 108 of file functions.h.

109 {
110 SYMENGINE_ASSERT(b.size() == 2);
111 return create(b[0], b[1]);
112 }
virtual RCP< const Basic > create(const RCP< const Basic > &a, const RCP< const Basic > &b) const
Definition: functions.cpp:3391

◆ is_canonical()

bool SymEngine::PolyGamma::is_canonical ( const RCP< const Basic > &  n,
const RCP< const Basic > &  x 
)

Definition at line 3354 of file functions.cpp.

3356{
3357 if (is_a_Number(*x) and not(down_cast<const Number &>(*x)).is_positive()) {
3358 return false;
3359 }
3360 if (eq(*n, *zero)) {
3361 if (eq(*x, *one)) {
3362 return false;
3363 }
3364 if (is_a<Rational>(*x)) {
3365 auto x_ = rcp_static_cast<const Rational>(x);
3366 auto den = get_den(x_->as_rational_class());
3367 if (den == 2 or den == 3 or den == 4) {
3368 return false;
3369 }
3370 }
3371 }
3372 return true;
3373}
bool is_a_Number(const Basic &b)
Definition: number.h:130
bool eq(const Basic &a, const Basic &b)
Checks equality for a and b
Definition: basic-inl.h:21

◆ rewrite_as_zeta()

RCP< const Basic > SymEngine::PolyGamma::rewrite_as_zeta ( ) const

Definition at line 3375 of file functions.cpp.

3376{
3377 if (not is_a<Integer>(*get_arg1())) {
3378 return rcp_from_this();
3379 }
3380 RCP<const Integer> n = rcp_static_cast<const Integer>(get_arg1());
3381 if (not(n->is_positive())) {
3382 return rcp_from_this();
3383 }
3384 if ((n->as_int() & 1) == 0) {
3385 return neg(mul(factorial(n->as_int()), zeta(add(n, one), get_arg2())));
3386 } else {
3387 return mul(factorial(n->as_int()), zeta(add(n, one), get_arg2()));
3388 }
3389}
RCP< const Basic > get_arg2() const
Definition: functions.h:96
RCP< const Basic > get_arg1() const
Definition: functions.h:91
RCP< const Basic > zeta(const RCP< const Basic > &s, const RCP< const Basic > &a)
Create a new Zeta instance:
Definition: functions.cpp:2800
RCP< const Basic > mul(const RCP< const Basic > &a, const RCP< const Basic > &b)
Multiplication.
Definition: mul.cpp:352
RCP< const Integer > factorial(unsigned long n)
Factorial.
Definition: ntheory.cpp:153
RCP< const Basic > add(const RCP< const Basic > &a, const RCP< const Basic > &b)
Adds two objects (safely).
Definition: add.cpp:425
RCP< const Basic > neg(const RCP< const Basic > &a)
Negation.
Definition: mul.cpp:443

Field Documentation

◆ type_code_id

const TypeID SymEngine::PolyGamma::type_code_id = SYMENGINE_POLYGAMMA
static

Type_code_id shared by all instances

Definition at line 1218 of file functions.h.


The documentation for this class was generated from the following files: