2019-08-01 00:29:32 +00:00
|
|
|
#include <Functions/FunctionMathUnary.h>
|
2018-12-03 03:17:06 +00:00
|
|
|
#include <Functions/FunctionFactory.h>
|
|
|
|
|
2020-08-20 09:27:29 +00:00
|
|
|
#if defined(OS_DARWIN)
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
/// Is defined in libglibc-compatibility.a
|
|
|
|
double lgamma_r(double x, int * signgamp);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-12-03 03:17:06 +00:00
|
|
|
namespace DB
|
|
|
|
{
|
2020-09-07 18:00:37 +00:00
|
|
|
namespace
|
|
|
|
{
|
2018-12-03 03:17:06 +00:00
|
|
|
|
2020-08-20 09:27:29 +00:00
|
|
|
/// Use wrapper and use lgamma_r version because std::lgamma is not threadsafe.
|
|
|
|
static Float64 lgamma_wrapper(Float64 arg)
|
|
|
|
{
|
|
|
|
int signp;
|
|
|
|
return lgamma_r(arg, &signp);
|
|
|
|
}
|
|
|
|
|
2018-12-03 03:17:06 +00:00
|
|
|
struct LGammaName { static constexpr auto name = "lgamma"; };
|
2020-08-20 09:27:29 +00:00
|
|
|
using FunctionLGamma = FunctionMathUnary<UnaryFunctionPlain<LGammaName, lgamma_wrapper>>;
|
2018-12-03 03:17:06 +00:00
|
|
|
|
2020-09-07 18:00:37 +00:00
|
|
|
}
|
|
|
|
|
2018-12-03 03:17:06 +00:00
|
|
|
void registerFunctionLGamma(FunctionFactory & factory)
|
|
|
|
{
|
|
|
|
factory.registerFunction<FunctionLGamma>();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|