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"
|
|
|
|
{
|
|
|
|
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.
|
2020-09-08 09:16:50 +00:00
|
|
|
Float64 lgamma_wrapper(Float64 arg)
|
2020-08-20 09:27:29 +00:00
|
|
|
{
|
|
|
|
int signp;
|
|
|
|
return lgamma_r(arg, &signp);
|
|
|
|
}
|
|
|
|
|
2018-12-03 03:17:06 +00:00
|
|
|
struct LGammaName { static constexpr auto name = "lgamma"; };
|
2022-01-22 18:44:36 +00:00
|
|
|
using FunctionLGamma = FunctionMathUnary<UnaryFunctionVectorized<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>();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|