mirror of https://github.com/prometheus/prometheus
Add inverse hyperbolic functions
Signed-off-by: Levi Harrison <git@leviharrison.dev>pull/9239/head
parent
74faea64dd
commit
6faca22eec
|
@ -440,8 +440,11 @@ aggregation even if the values are not equally spaced throughout the interval.
|
||||||
The trigonometric functions work in radians:
|
The trigonometric functions work in radians:
|
||||||
|
|
||||||
- `acos(v instant-vector)`: calculates the arccosine of all elements in `v` ([special cases](https://pkg.go.dev/math#Acos)).
|
- `acos(v instant-vector)`: calculates the arccosine of all elements in `v` ([special cases](https://pkg.go.dev/math#Acos)).
|
||||||
|
- `acosh(v instant-vector)`: calculates the inverse hyperbolic cosine of all elements in `v` ([special cases](https://pkg.go.dev/math#Acosh)).
|
||||||
- `asin(v instant-vector)`: calculates the arcsine of all elements in `v` ([special cases](https://pkg.go.dev/math#Asin)).
|
- `asin(v instant-vector)`: calculates the arcsine of all elements in `v` ([special cases](https://pkg.go.dev/math#Asin)).
|
||||||
|
- `asinh(v instant-vector)`: calculates the inverse hyperbolic sine of all elements in `v` ([special cases](https://pkg.go.dev/math#Asinh)).
|
||||||
- `atan(v instant-vector)`: calculates the arctangent of all elements in `v` ([special cases](https://pkg.go.dev/math#Atan)).
|
- `atan(v instant-vector)`: calculates the arctangent of all elements in `v` ([special cases](https://pkg.go.dev/math#Atan)).
|
||||||
|
- `atanh(v instant-vector)`: calculates the inverse hyperbolic tangent of all elements in `v` ([special cases](https://pkg.go.dev/math#Atanh)).
|
||||||
- `cos(v instant-vector)`: calculates the cosine of all elements in `v` ([special cases](https://pkg.go.dev/math#Cos)).
|
- `cos(v instant-vector)`: calculates the cosine of all elements in `v` ([special cases](https://pkg.go.dev/math#Cos)).
|
||||||
- `cosh(v instant-vector)`: calculates the hyperbolic cosine of all elements in `v` ([special cases](https://pkg.go.dev/math#Cosh)).
|
- `cosh(v instant-vector)`: calculates the hyperbolic cosine of all elements in `v` ([special cases](https://pkg.go.dev/math#Cosh)).
|
||||||
- `sin(v instant-vector)`: calculates the sine of all elements in `v` ([special cases](https://pkg.go.dev/math#Sin)).
|
- `sin(v instant-vector)`: calculates the sine of all elements in `v` ([special cases](https://pkg.go.dev/math#Sin)).
|
||||||
|
|
|
@ -615,6 +615,21 @@ func funcTanh(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper)
|
||||||
return simpleFunc(vals, enh, math.Tanh)
|
return simpleFunc(vals, enh, math.Tanh)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// == asinh(Vector parser.ValueTypeVector) Vector ===
|
||||||
|
func funcAsinh(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper) Vector {
|
||||||
|
return simpleFunc(vals, enh, math.Asinh)
|
||||||
|
}
|
||||||
|
|
||||||
|
// == acosh(Vector parser.ValueTypeVector) Vector ===
|
||||||
|
func funcAcosh(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper) Vector {
|
||||||
|
return simpleFunc(vals, enh, math.Acosh)
|
||||||
|
}
|
||||||
|
|
||||||
|
// == atanh(Vector parser.ValueTypeVector) Vector ===
|
||||||
|
func funcAtanh(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper) Vector {
|
||||||
|
return simpleFunc(vals, enh, math.Atanh)
|
||||||
|
}
|
||||||
|
|
||||||
// === rad(Vector parser.ValueTypeVector) Vector ===
|
// === rad(Vector parser.ValueTypeVector) Vector ===
|
||||||
func funcRad(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper) Vector {
|
func funcRad(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper) Vector {
|
||||||
return simpleFunc(vals, enh, func(v float64) float64 {
|
return simpleFunc(vals, enh, func(v float64) float64 {
|
||||||
|
@ -1002,8 +1017,11 @@ var FunctionCalls = map[string]FunctionCall{
|
||||||
"absent": funcAbsent,
|
"absent": funcAbsent,
|
||||||
"absent_over_time": funcAbsentOverTime,
|
"absent_over_time": funcAbsentOverTime,
|
||||||
"acos": funcAcos,
|
"acos": funcAcos,
|
||||||
|
"acosh": funcAcosh,
|
||||||
"asin": funcAsin,
|
"asin": funcAsin,
|
||||||
|
"asinh": funcAsinh,
|
||||||
"atan": funcAtan,
|
"atan": funcAtan,
|
||||||
|
"atanh": funcAtanh,
|
||||||
"avg_over_time": funcAvgOverTime,
|
"avg_over_time": funcAvgOverTime,
|
||||||
"ceil": funcCeil,
|
"ceil": funcCeil,
|
||||||
"changes": funcChanges,
|
"changes": funcChanges,
|
||||||
|
|
|
@ -44,16 +44,31 @@ var Functions = map[string]*Function{
|
||||||
ArgTypes: []ValueType{ValueTypeVector},
|
ArgTypes: []ValueType{ValueTypeVector},
|
||||||
ReturnType: ValueTypeVector,
|
ReturnType: ValueTypeVector,
|
||||||
},
|
},
|
||||||
|
"acosh": {
|
||||||
|
Name: "acosh",
|
||||||
|
ArgTypes: []ValueType{ValueTypeVector},
|
||||||
|
ReturnType: ValueTypeVector,
|
||||||
|
},
|
||||||
"asin": {
|
"asin": {
|
||||||
Name: "asin",
|
Name: "asin",
|
||||||
ArgTypes: []ValueType{ValueTypeVector},
|
ArgTypes: []ValueType{ValueTypeVector},
|
||||||
ReturnType: ValueTypeVector,
|
ReturnType: ValueTypeVector,
|
||||||
},
|
},
|
||||||
|
"asinh": {
|
||||||
|
Name: "asinh",
|
||||||
|
ArgTypes: []ValueType{ValueTypeVector},
|
||||||
|
ReturnType: ValueTypeVector,
|
||||||
|
},
|
||||||
"atan": {
|
"atan": {
|
||||||
Name: "atan",
|
Name: "atan",
|
||||||
ArgTypes: []ValueType{ValueTypeVector},
|
ArgTypes: []ValueType{ValueTypeVector},
|
||||||
ReturnType: ValueTypeVector,
|
ReturnType: ValueTypeVector,
|
||||||
},
|
},
|
||||||
|
"atanh": {
|
||||||
|
Name: "atanh",
|
||||||
|
ArgTypes: []ValueType{ValueTypeVector},
|
||||||
|
ReturnType: ValueTypeVector,
|
||||||
|
},
|
||||||
"avg_over_time": {
|
"avg_over_time": {
|
||||||
Name: "avg_over_time",
|
Name: "avg_over_time",
|
||||||
ArgTypes: []ValueType{ValueTypeMatrix},
|
ArgTypes: []ValueType{ValueTypeMatrix},
|
||||||
|
|
|
@ -50,6 +50,21 @@ eval instant at 5m tanh(trig)
|
||||||
{l="y"} 1
|
{l="y"} 1
|
||||||
{l="NaN"} NaN
|
{l="NaN"} NaN
|
||||||
|
|
||||||
|
eval instant at 5m asinh(trig)
|
||||||
|
{l="x"} 2.99822295029797
|
||||||
|
{l="y"} 3.6895038689889055
|
||||||
|
{l="NaN"} NaN
|
||||||
|
|
||||||
|
eval instant at 5m acosh(trig)
|
||||||
|
{l="x"} 2.993222846126381
|
||||||
|
{l="y"} 3.6882538673612966
|
||||||
|
{l="NaN"} NaN
|
||||||
|
|
||||||
|
eval instant at 5m atanh(trig - 10.1)
|
||||||
|
{l="x"} -0.10033534773107522
|
||||||
|
{l="y"} NaN
|
||||||
|
{l="NaN"} NaN
|
||||||
|
|
||||||
eval instant at 5m rad(trig)
|
eval instant at 5m rad(trig)
|
||||||
{l="x"} 0.17453292519943295
|
{l="x"} 0.17453292519943295
|
||||||
{l="y"} 0.3490658503988659
|
{l="y"} 0.3490658503988659
|
||||||
|
|
Loading…
Reference in New Issue