1#ifndef STAN_MATH_REV_FUN_SQRT_HPP
2#define STAN_MATH_REV_FUN_SQRT_HPP
47 if (vi.val() != 0.0) {
48 a.adj() += vi.adj() / (2.0 * vi.val());
60template <
typename T, require_var_matrix_t<T>* =
nullptr>
61inline auto sqrt(
const T& a) {
63 a.val().array().sqrt().matrix(), [a](
auto& vi)
mutable {
65 += (vi.val_op().array() == 0.0)
66 .select(0.0, vi.adj().array() / (2.0 * vi.val_op().array()));
76inline std::complex<var>
sqrt(
const std::complex<var>& z) {
77 return internal::complex_sqrt(z);
var_value< plain_type_t< T > > make_callback_var(T &&value, F &&functor)
Creates a new var initialized with a callback_vari with a given value and reverse-pass callback funct...
fvar< T > sqrt(const fvar< T > &x)
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...