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(Container&& x) {
24 to_ref(std::forward<Container>(x)), [](
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.
auto norm2(Container &&x)
Compute the L2 norm of the specified vector of values.
ref_type_t< T && > to_ref(T &&a)
This evaluates expensive Eigen expressions.
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,...