ClickHouse/src/Functions/lgamma.cpp

34 lines
643 B
C++
Raw Normal View History

2019-08-01 00:29:32 +00:00
#include <Functions/FunctionMathUnary.h>
#include <Functions/FunctionFactory.h>
#if defined(OS_DARWIN)
extern "C"
{
double lgamma_r(double x, int * signgamp);
}
#endif
namespace DB
{
2020-09-07 18:00:37 +00:00
namespace
{
/// 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)
{
int signp;
return lgamma_r(arg, &signp);
}
struct LGammaName { static constexpr auto name = "lgamma"; };
2022-01-22 18:44:36 +00:00
using FunctionLGamma = FunctionMathUnary<UnaryFunctionVectorized<LGammaName, lgamma_wrapper>>;
2020-09-07 18:00:37 +00:00
}
void registerFunctionLGamma(FunctionFactory & factory)
{
factory.registerFunction<FunctionLGamma>();
}
}