ClickHouse/src/Functions/asin.cpp

48 lines
1.4 KiB
C++
Raw Normal View History

2019-08-01 00:29:32 +00:00
#include <Functions/FunctionMathUnary.h>
#include <Functions/FunctionFactory.h>
2019-12-29 01:13:17 +00:00
namespace DB
{
2020-09-07 18:00:37 +00:00
namespace
{
struct AsinName { static constexpr auto name = "asin"; };
2019-08-01 00:29:32 +00:00
using FunctionAsin = FunctionMathUnary<UnaryFunctionVectorized<AsinName, asin>>;
2020-09-07 18:00:37 +00:00
}
REGISTER_FUNCTION(Asin)
{
factory.registerFunction<FunctionAsin>(FunctionDocumentation
2022-08-27 20:06:03 +00:00
{
.description=R"(
2022-08-27 20:06:03 +00:00
Calculates the arcsine of the argument.
Takes arbitrary numeric type, which includes floating point and integer numbers, as well as big integers and decimals and returns Float64.
For arguments in range [-1, 1] it returns the value in range of [-pi() / 2, pi() / 2].
It represents an inverse function to function 'sin' on this range:
[example:inverse]
It always returns Float64, even if the argument has Float32 type:
[example:float32]
For arguments outside of this range, it returns nan:
[example:nan]
Every self-respectful data scientist knows how to apply arcsine to improve ads click-through rate with ClickHouse.
For more details, see [https://en.wikipedia.org/wiki/Inverse_trigonometric_functions].
)",
.examples{
{"inverse", "SELECT asin(1.0) = pi() / 2, sin(asin(1)), asin(sin(1))", ""},
{"float32", "SELECT toTypeName(asin(1.0::Float32))", ""},
{"nan", "SELECT asin(1.1), asin(-2), asin(inf), asin(nan)", ""}},
.categories{"Mathematical", "Trigonometric"}
2022-08-27 20:06:03 +00:00
},
FunctionFactory::CaseInsensitive);
}
}