1 #include <stan/math/prim.hpp>
2 #include <gtest/gtest.h>
3 #include <cmath>
4 #include <limits>
5 #include <stdexcept>
6 
TEST(MathFunctions,lambert_w)7 TEST(MathFunctions, lambert_w) {
8   using stan::math::exp;
9   using stan::math::lambert_w0;
10   using stan::math::lambert_wm1;
11 
12   EXPECT_FLOAT_EQ(-1.0, lambert_w0(-1 / exp(1)));
13   EXPECT_FLOAT_EQ(1.7455280027406994, lambert_w0(10.));
14   EXPECT_FLOAT_EQ(1.7455280027406994, lambert_w0(10));
15   EXPECT_FLOAT_EQ(-1.0, lambert_wm1(-1 / exp(1)));
16   EXPECT_FLOAT_EQ(lambert_wm1(-std::numeric_limits<double>::min()),
17                   -714.96865723796634);
18 }
19 
TEST(MathFunctions,lambert_wn1_at_0)20 TEST(MathFunctions, lambert_wn1_at_0) {
21   EXPECT_TRUE(std::isinf(stan::math::lambert_wm1(0)));
22 }
23