# Path: autograd/extend.py

# 
# Path: autograd/numpy/numpy_vjps.py
# def unbroadcast_f(target, f):
#     target_meta = anp.metadata(target)
#     return lambda g: unbroadcast(f(g), target_meta)
# 
# Path: autograd/scipy/special.py
# def make_gammainc_vjp_arg1(sign):
#     def gammainc_vjp_arg1(ans, a, x):
# def make_grad_logsumexp(ans, x, axis=None, b=1.0, keepdims=False):
#     def vjp(g):
# def fwd_grad_logsumexp(g, ans, x, axis=None, b=1.0, keepdims=False):


import autograd.numpy as np
import scipy.stats
from autograd.extend import primitive, defvjp
from autograd.numpy.numpy_vjps import unbroadcast_f
from autograd.scipy.special import gamma, psi
from __future__ import absolute_import


cdf = primitive(scipy.stats.gamma.cdf)
logpdf = primitive(scipy.stats.gamma.logpdf)
pdf = primitive(scipy.stats.gamma.pdf)

def grad_gamma_logpdf_arg0(x, a):
    return (a - x - 1) / x

def grad_gamma_logpdf_arg1(x, a):

# Path: autograd/extend.py

# 
# Path: autograd/numpy/numpy_vjps.py
# def unbroadcast_f(target, f):
#     target_meta = anp.metadata(target)
#     return lambda g: unbroadcast(f(g), target_meta)
# 
# Path: autograd/scipy/special.py
# def make_gammainc_vjp_arg1(sign):
#     def gammainc_vjp_arg1(ans, a, x):
# def make_grad_logsumexp(ans, x, axis=None, b=1.0, keepdims=False):
#     def vjp(g):
# def fwd_grad_logsumexp(g, ans, x, axis=None, b=1.0, keepdims=False):


# Path: autograd/scipy/stats/gamma.py
import autograd.numpy as np
import scipy.stats
from autograd.extend import primitive, defvjp
from autograd.numpy.numpy_vjps import unbroadcast_f
from autograd.scipy.special import gamma, psi

from __future__ import absolute_import


cdf = primitive(scipy.stats.gamma.cdf)
logpdf = primitive(scipy.stats.gamma.logpdf)
pdf = primitive(scipy.stats.gamma.pdf)

def grad_gamma_logpdf_arg0(x, a):
    return (a - x - 1) / x

def grad_gamma_logpdf_arg1(x, a):

    return np.log(x) - psi(a)