Loading [MathJax]/extensions/TeX/AMSsymbols.js
Automatic Differentiation
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches
binary_log_loss.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_FUN_BINARY_LOG_LOSS_HPP
2#define STAN_MATH_PRIM_FUN_BINARY_LOG_LOSS_HPP
3
8#include <cmath>
9
10namespace stan {
11namespace math {
12
29template <typename T, require_arithmetic_t<T>* = nullptr>
30inline T binary_log_loss(int y, const T& y_hat) {
31 using std::log;
32 return y ? -log(y_hat) : -log1m(y_hat);
33}
34
45template <typename T1, typename T2, require_any_container_t<T1, T2>* = nullptr,
46 require_not_var_matrix_t<T2>* = nullptr>
47inline auto binary_log_loss(const T1& a, const T2& b) {
49 [](const auto& c, const auto& d) { return binary_log_loss(c, d); }, a, b);
50}
51
52} // namespace math
53} // namespace stan
54
55#endif
fvar< T > log(const fvar< T > &x)
Definition log.hpp:18
fvar< T > binary_log_loss(int y, const fvar< T > &y_hat)
fvar< T > log1m(const fvar< T > &x)
Definition log1m.hpp:12
auto apply_scalar_binary(const F &f, const T1 &x, const T2 &y)
Base template function for vectorization of binary scalar functions defined by applying a functor to ...
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...