Automatic Differentiation
 
Loading...
Searching...
No Matches
norm1.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_FUN_NORM1_HPP
2#define STAN_MATH_PRIM_FUN_NORM1_HPP
3
7
8namespace stan {
9namespace math {
10
19template <typename T, require_eigen_vt<std::is_arithmetic, T>* = nullptr>
20inline double norm1(const T& v) {
21 ref_type_t<T> v_ref = v;
22 return v_ref.template lpNorm<1>();
23}
24
33template <typename Container, require_std_vector_t<Container>* = nullptr>
34inline auto norm1(const Container& x) {
35 return apply_vector_unary<Container>::reduce(
36 x, [](const auto& v) { return norm1(v); });
37}
38
39} // namespace math
40} // namespace stan
41
42#endif
auto norm1(const Container &x)
Compute the L1 norm of the specified vector of values.
Definition norm1.hpp:24
typename ref_type_if< true, T >::type ref_type_t
Definition ref_type.hpp:55
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...