1 #ifndef STAN_MATH_PRIM_FUN_LOGICAL_AND_HPP
2 #define STAN_MATH_PRIM_FUN_LOGICAL_AND_HPP
3 
4 #include <stan/math/prim/meta.hpp>
5 namespace stan {
6 namespace math {
7 
8 /**
9  * The logical and function which returns 1 if both arguments
10  * are unequal to zero and 0 otherwise.
11  * Equivalent
12  * to <code>x1 != 0 && x2 != 0</code>.
13  *
14    \f[
15    \mbox{operator\&\&}(x, y) =
16    \begin{cases}
17      0 & \mbox{if } x = 0 \textrm{ or } y=0 \\
18      1 & \mbox{if } x, y \neq 0 \\[6pt]
19      1 & \mbox{if } x = \textrm{NaN or } y = \textrm{NaN}
20    \end{cases}
21    \f]
22  *
23  * @tparam T1 type of first argument
24  * @tparam T2 type of second argument
25  * @param x1 first argument
26  * @param x2 second argument
27  * @return <code>true</code> if both x1 and x2 are not equal to 0.
28  */
29 template <typename T1, typename T2>
logical_and(const T1 x1,const T2 x2)30 inline int logical_and(const T1 x1, const T2 x2) {
31   return (x1 != 0) && (x2 != 0);
32 }
33 
34 }  // namespace math
35 }  // namespace stan
36 
37 #endif
38