1#ifndef STAN_MATH_REV_FUN_SQRT_HPP
2#define STAN_MATH_REV_FUN_SQRT_HPP
46 if (vi.val() != 0.0) {
47 a.adj() += vi.adj() / (2.0 * vi.val());
59template <
typename T, require_var_matrix_t<T>* =
nullptr>
60inline auto sqrt(
const T& a) {
62 a.val().array().sqrt().matrix(), [a](
auto& vi)
mutable {
64 += (vi.val_op().array() == 0.0)
65 .select(0.0, vi.adj().array() / (2.0 * vi.val_op().array()));
75inline std::complex<var>
sqrt(
const std::complex<var>& z) {
76 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 ...