Automatic Differentiation
 
Loading...
Searching...
No Matches
norm1.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_FWD_FUN_NORM1_HPP
2#define STAN_MATH_FWD_FUN_NORM1_HPP
3
12
13namespace stan {
14namespace math {
15
23template <typename Container, require_eigen_vt<is_fvar, Container>* = nullptr>
24inline auto norm1(const Container& x) {
26 to_ref(x), [&](const auto& v) {
27 using T_fvar_inner = typename value_type_t<decltype(v)>::Scalar;
28 return fvar<T_fvar_inner>(norm1(v.val()),
29 v.d().cwiseProduct(sign(v.val())).sum());
30 });
31}
32
33} // namespace math
34} // namespace stan
35#endif
typename value_type< T >::type value_type_t
Helper function for accessing underlying type.
auto sign(const T &x)
Returns signs of the arguments.
Definition sign.hpp:18
ref_type_t< T && > to_ref(T &&a)
This evaluates expensive Eigen expressions.
Definition to_ref.hpp:17
auto norm1(const Container &x)
Compute the L1 norm of the specified vector of values.
Definition norm1.hpp:24
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,...
Definition fvar.hpp:40