1#ifndef STAN_MATH_FWD_FUN_NORM2_HPP
2#define STAN_MATH_FWD_FUN_NORM2_HPP
21template <
typename Container, require_eigen_vt<is_fvar, Container>* =
nullptr>
22inline auto norm2(
const Container& x) {
24 to_ref(x), [&](
const auto& v) {
25 using T_fvar_inner =
typename value_type_t<
decltype(v)>::Scalar;
26 T_fvar_inner res =
norm2(v.val());
28 v.d().cwiseProduct((v.val() / res)).sum());
typename value_type< T >::type value_type_t
Helper function for accessing underlying type.
ref_type_t< T && > to_ref(T &&a)
This evaluates expensive Eigen expressions.
auto norm2(const Container &x)
Compute the L2 norm of the specified vector of values.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
This template class represents scalars used in forward-mode automatic differentiation,...