Automatic Differentiation
 
Loading...
Searching...
No Matches
log2.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_FUN_LOG2_HPP
2#define STAN_MATH_PRIM_FUN_LOG2_HPP
3
7#include <cmath>
8
9namespace stan {
10namespace math {
11
17inline constexpr double log2() { return LOG_TWO; }
18
19template <typename T, require_arithmetic_t<T>* = nullptr>
20inline auto log2(T&& x) {
21 return std::log2(x);
22}
23
27struct log2_fun {
35 template <typename T>
36 static inline auto fun(T&& x) {
37 return log2(std::forward<T>(x));
38 }
39};
40
51template <typename T, require_not_var_matrix_t<T>* = nullptr,
52 require_not_nonscalar_prim_or_rev_kernel_expression_t<T>* = nullptr,
53 require_container_t<T>* = nullptr>
54inline auto log2(T&& x) {
55 return apply_scalar_unary<log2_fun, T>::apply(std::forward<T>(x));
56}
57
58} // namespace math
59} // namespace stan
60
61#endif
constexpr double log2()
Return natural logarithm of two.
Definition log2.hpp:17
static constexpr double LOG_TWO
The natural logarithm of 2, .
Definition constants.hpp:80
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
Base template class for vectorization of unary scalar functions defined by a template class F to a sc...
static auto fun(T &&x)
Return the base two logarithm of the specified argument.
Definition log2.hpp:36
Structure to wrap log2() so it can be vectorized.
Definition log2.hpp:27