Skip to contents

Element-wise psigamma function, like base::psigamma(): the deriv-th derivative of the digamma function, i.e. the (deriv + 1)-th derivative of the log-gamma function. For deriv = 0 this is the digamma function; for deriv = 1, trigamma() dispatches here.

Usage

nv_psigamma(x, deriv = 0L)

# S3 method for class 'AnvlArray'
trigamma(x)

Arguments

x, deriv

(arrayish)
The value to evaluate at and the order of the derivative. deriv typically holds non-negative whole numbers. Can be any numeric data type: the two are promoted to a common data type and that is then converted to the default float data type (see default_dtypes()) where it is not a float already, since a float is all prim_psigamma() takes. An R value assumes the other operand's data type within its data type category, and settles on the default float when neither has one. Scalars are broadcast to the shape of the other, so nv_psigamma(x, 1) works for any float x.

Value

(arrayish)
Has the inputs' broadcast shape, and their common data type – or the default float data type (see default_dtypes()) where that was an integer one.

The trigamma() generic

trigamma(x) is nv_psigamma(x, 1L).

See also

prim_psigamma() for the underlying primitive.

Examples

# the R `1` is built at `x`'s float data type and broadcast
x <- nv_array(c(0.5, 1, 2, 5))
nv_psigamma(x) # digamma
#> AnvlArray
#>  -1.9635
#>  -0.5772
#>   0.4228
#>   1.5061
#> [ CPUf32{4} ] 
nv_psigamma(x, 1) # trigamma
#> AnvlArray
#>  4.9348
#>  1.6449
#>  0.6449
#>  0.2213
#> [ CPUf32{4} ]