Skip to content

Commit

Permalink
Add sinh function to return hyperbolic sine
Browse files Browse the repository at this point in the history
  • Loading branch information
ebyhr committed Mar 14, 2023
1 parent 887ec7d commit f965df6
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1155,6 +1155,14 @@ public static double sin(@SqlType(StandardTypes.DOUBLE) double num)
return Math.sin(num);
}

@Description("Hyperbolic sine")
@ScalarFunction
@SqlType(StandardTypes.DOUBLE)
public static double sinh(@SqlType(StandardTypes.DOUBLE) double num)
{
return Math.sinh(num);
}

@Description("Square root")
@ScalarFunction
@SqlType(StandardTypes.DOUBLE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2500,6 +2500,21 @@ public void testSin()
.isNull(DOUBLE);
}

@Test
public void testSinh()
{
for (double doubleValue : DOUBLE_VALUES) {
assertThat(assertions.function("sinh", Double.toString(doubleValue)))
.isEqualTo(Math.sinh(doubleValue));

assertThat(assertions.function("sinh", "REAL '%s'".formatted((float) doubleValue)))
.isEqualTo(Math.sinh((float) doubleValue));
}

assertThat(assertions.function("sinh", "NULL"))
.isNull(DOUBLE);
}

@Test
public void testSqrt()
{
Expand Down
1 change: 1 addition & 0 deletions docs/src/main/sphinx/functions/list-by-topic.rst
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ For more details, see :doc:`math`
* :func:`round`
* :func:`sign`
* :func:`sin`
* :func:`sinh`
* :func:`sqrt`
* :func:`tan`
* :func:`tanh`
Expand Down
1 change: 1 addition & 0 deletions docs/src/main/sphinx/functions/list.rst
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ S
- :func:`sign`
- :func:`simplify_geometry`
- :func:`sin`
- :func:`sinh`
- :func:`skewness`
- :func:`slice`
- :ref:`SOME <quantified_comparison_predicates>`
Expand Down
4 changes: 4 additions & 0 deletions docs/src/main/sphinx/functions/math.rst
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ See unit conversion functions :func:`degrees` and :func:`radians`.

Returns the sine of ``x``.

.. function:: sinh(x) -> double

Returns the hyperbolic sine of ``x``.

.. function:: tan(x) -> double

Returns the tangent of ``x``.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
round | double | double, integer | scalar | true | Round to given number of decimal places |
row_number | bigint | | window | true | |
sin | double | double | scalar | true | Sine |
sinh | double | double | scalar | true | Hyperbolic sine |
sqrt | double | double | scalar | true | Square root |
stddev | double | bigint | aggregate | true | Returns the sample standard deviation of the argument |
stddev | double | double | aggregate | true | Returns the sample standard deviation of the argument |
Expand Down

0 comments on commit f965df6

Please sign in to comment.