Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:57:09

0001 // This file is part of Eigen, a lightweight C++ template library
0002 // for linear algebra.
0003 //
0004 // Copyright (C) 2016 Gael Guennebaud <gael.guennebaud@inria.fr>
0005 //
0006 // This Source Code Form is subject to the terms of the Mozilla
0007 // Public License v. 2.0. If a copy of the MPL was not distributed
0008 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
0009 
0010 
0011 #ifndef EIGEN_SPECIALFUNCTIONS_ARRAYAPI_H
0012 #define EIGEN_SPECIALFUNCTIONS_ARRAYAPI_H
0013 
0014 namespace Eigen {
0015 
0016 /** \cpp11 \returns an expression of the coefficient-wise igamma(\a a, \a x) to the given arrays.
0017   *
0018   * This function computes the coefficient-wise incomplete gamma function.
0019   *
0020   * \note This function supports only float and double scalar types in c++11 mode. To support other scalar types,
0021   * or float/double in non c++11 mode, the user has to provide implementations of igammac(T,T) for any scalar
0022   * type T to be supported.
0023   *
0024   * \sa Eigen::igammac(), Eigen::lgamma()
0025   */
0026 template<typename Derived,typename ExponentDerived>
0027 EIGEN_STRONG_INLINE const Eigen::CwiseBinaryOp<Eigen::internal::scalar_igamma_op<typename Derived::Scalar>, const Derived, const ExponentDerived>
0028 igamma(const Eigen::ArrayBase<Derived>& a, const Eigen::ArrayBase<ExponentDerived>& x)
0029 {
0030   return Eigen::CwiseBinaryOp<Eigen::internal::scalar_igamma_op<typename Derived::Scalar>, const Derived, const ExponentDerived>(
0031     a.derived(),
0032     x.derived()
0033   );
0034 }
0035 
0036 /** \cpp11 \returns an expression of the coefficient-wise igamma_der_a(\a a, \a x) to the given arrays.
0037   *
0038   * This function computes the coefficient-wise derivative of the incomplete
0039   * gamma function with respect to the parameter a.
0040   *
0041   * \note This function supports only float and double scalar types in c++11
0042   * mode. To support other scalar types,
0043   * or float/double in non c++11 mode, the user has to provide implementations
0044   * of igamma_der_a(T,T) for any scalar
0045   * type T to be supported.
0046   *
0047   * \sa Eigen::igamma(), Eigen::lgamma()
0048   */
0049 template <typename Derived, typename ExponentDerived>
0050 EIGEN_STRONG_INLINE const Eigen::CwiseBinaryOp<Eigen::internal::scalar_igamma_der_a_op<typename Derived::Scalar>, const Derived, const ExponentDerived>
0051 igamma_der_a(const Eigen::ArrayBase<Derived>& a, const Eigen::ArrayBase<ExponentDerived>& x) {
0052   return Eigen::CwiseBinaryOp<Eigen::internal::scalar_igamma_der_a_op<typename Derived::Scalar>, const Derived, const ExponentDerived>(
0053     a.derived(),
0054     x.derived());
0055 }
0056 
0057 /** \cpp11 \returns an expression of the coefficient-wise gamma_sample_der_alpha(\a alpha, \a sample) to the given arrays.
0058   *
0059   * This function computes the coefficient-wise derivative of the sample
0060   * of a Gamma(alpha, 1) random variable with respect to the parameter alpha.
0061   *
0062   * \note This function supports only float and double scalar types in c++11
0063   * mode. To support other scalar types,
0064   * or float/double in non c++11 mode, the user has to provide implementations
0065   * of gamma_sample_der_alpha(T,T) for any scalar
0066   * type T to be supported.
0067   *
0068   * \sa Eigen::igamma(), Eigen::lgamma()
0069   */
0070 template <typename AlphaDerived, typename SampleDerived>
0071 EIGEN_STRONG_INLINE const Eigen::CwiseBinaryOp<Eigen::internal::scalar_gamma_sample_der_alpha_op<typename AlphaDerived::Scalar>, const AlphaDerived, const SampleDerived>
0072 gamma_sample_der_alpha(const Eigen::ArrayBase<AlphaDerived>& alpha, const Eigen::ArrayBase<SampleDerived>& sample) {
0073   return Eigen::CwiseBinaryOp<Eigen::internal::scalar_gamma_sample_der_alpha_op<typename AlphaDerived::Scalar>, const AlphaDerived, const SampleDerived>(
0074       alpha.derived(),
0075       sample.derived());
0076 }
0077 
0078 /** \cpp11 \returns an expression of the coefficient-wise igammac(\a a, \a x) to the given arrays.
0079   *
0080   * This function computes the coefficient-wise complementary incomplete gamma function.
0081   *
0082   * \note This function supports only float and double scalar types in c++11 mode. To support other scalar types,
0083   * or float/double in non c++11 mode, the user has to provide implementations of igammac(T,T) for any scalar
0084   * type T to be supported.
0085   *
0086   * \sa Eigen::igamma(), Eigen::lgamma()
0087   */
0088 template<typename Derived,typename ExponentDerived>
0089 EIGEN_STRONG_INLINE const Eigen::CwiseBinaryOp<Eigen::internal::scalar_igammac_op<typename Derived::Scalar>, const Derived, const ExponentDerived>
0090 igammac(const Eigen::ArrayBase<Derived>& a, const Eigen::ArrayBase<ExponentDerived>& x)
0091 {
0092   return Eigen::CwiseBinaryOp<Eigen::internal::scalar_igammac_op<typename Derived::Scalar>, const Derived, const ExponentDerived>(
0093     a.derived(),
0094     x.derived()
0095   );
0096 }
0097 
0098 /** \cpp11 \returns an expression of the coefficient-wise polygamma(\a n, \a x) to the given arrays.
0099   *
0100   * It returns the \a n -th derivative of the digamma(psi) evaluated at \c x.
0101   *
0102   * \note This function supports only float and double scalar types in c++11 mode. To support other scalar types,
0103   * or float/double in non c++11 mode, the user has to provide implementations of polygamma(T,T) for any scalar
0104   * type T to be supported.
0105   *
0106   * \sa Eigen::digamma()
0107   */
0108 // * \warning Be careful with the order of the parameters: x.polygamma(n) is equivalent to polygamma(n,x)
0109 // * \sa ArrayBase::polygamma()
0110 template<typename DerivedN,typename DerivedX>
0111 EIGEN_STRONG_INLINE const Eigen::CwiseBinaryOp<Eigen::internal::scalar_polygamma_op<typename DerivedX::Scalar>, const DerivedN, const DerivedX>
0112 polygamma(const Eigen::ArrayBase<DerivedN>& n, const Eigen::ArrayBase<DerivedX>& x)
0113 {
0114   return Eigen::CwiseBinaryOp<Eigen::internal::scalar_polygamma_op<typename DerivedX::Scalar>, const DerivedN, const DerivedX>(
0115     n.derived(),
0116     x.derived()
0117   );
0118 }
0119 
0120 /** \cpp11 \returns an expression of the coefficient-wise betainc(\a x, \a a, \a b) to the given arrays.
0121   *
0122   * This function computes the regularized incomplete beta function (integral).
0123   *
0124   * \note This function supports only float and double scalar types in c++11 mode. To support other scalar types,
0125   * or float/double in non c++11 mode, the user has to provide implementations of betainc(T,T,T) for any scalar
0126   * type T to be supported.
0127   *
0128   * \sa Eigen::betainc(), Eigen::lgamma()
0129   */
0130 template<typename ArgADerived, typename ArgBDerived, typename ArgXDerived>
0131 EIGEN_STRONG_INLINE const Eigen::CwiseTernaryOp<Eigen::internal::scalar_betainc_op<typename ArgXDerived::Scalar>, const ArgADerived, const ArgBDerived, const ArgXDerived>
0132 betainc(const Eigen::ArrayBase<ArgADerived>& a, const Eigen::ArrayBase<ArgBDerived>& b, const Eigen::ArrayBase<ArgXDerived>& x)
0133 {
0134   return Eigen::CwiseTernaryOp<Eigen::internal::scalar_betainc_op<typename ArgXDerived::Scalar>, const ArgADerived, const ArgBDerived, const ArgXDerived>(
0135     a.derived(),
0136     b.derived(),
0137     x.derived()
0138   );
0139 }
0140 
0141 
0142 /** \returns an expression of the coefficient-wise zeta(\a x, \a q) to the given arrays.
0143   *
0144   * It returns the Riemann zeta function of two arguments \a x and \a q:
0145   *
0146   * \param x is the exponent, it must be > 1
0147   * \param q is the shift, it must be > 0
0148   *
0149   * \note This function supports only float and double scalar types. To support other scalar types, the user has
0150   * to provide implementations of zeta(T,T) for any scalar type T to be supported.
0151   *
0152   * \sa ArrayBase::zeta()
0153   */
0154 template<typename DerivedX,typename DerivedQ>
0155 EIGEN_STRONG_INLINE const Eigen::CwiseBinaryOp<Eigen::internal::scalar_zeta_op<typename DerivedX::Scalar>, const DerivedX, const DerivedQ>
0156 zeta(const Eigen::ArrayBase<DerivedX>& x, const Eigen::ArrayBase<DerivedQ>& q)
0157 {
0158   return Eigen::CwiseBinaryOp<Eigen::internal::scalar_zeta_op<typename DerivedX::Scalar>, const DerivedX, const DerivedQ>(
0159     x.derived(),
0160     q.derived()
0161   );
0162 }
0163 
0164 
0165 } // end namespace Eigen
0166 
0167 #endif // EIGEN_SPECIALFUNCTIONS_ARRAYAPI_H