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
11
12namespace stan {
13namespace math {
14
22template <typename Container, require_eigen_vt<is_fvar, Container>* = nullptr>
23inline auto norm1(const Container& x) {
25 to_ref(x), [&](const auto& v) {
26 using T_fvar_inner = typename value_type_t<decltype(v)>::Scalar;
27 return fvar<T_fvar_inner>(norm1(v.val()),
28 v.d().cwiseProduct(sign(v.val())).sum());
29 });
30}
31
32} // namespace math
33} // namespace stan
34#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:23
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