Skip to content

Commit 4cb9cc3

Browse files
committed
Update descriptions and examples and clean-up
1 parent 8f0dd4c commit 4cb9cc3

File tree

11 files changed

+74
-42
lines changed

11 files changed

+74
-42
lines changed

lib/node_modules/@stdlib/math/base/special/sinh/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ limitations under the License.
2020

2121
# sinh
2222

23-
> Compute the [hyperbolic sine][hyperbolic-sine] of a number.
23+
> Compute the [hyperbolic sine][hyperbolic-sine] of a double-precision floating-point number.
2424
2525
<section class="usage">
2626

@@ -32,7 +32,7 @@ var sinh = require( '@stdlib/math/base/special/sinh' );
3232

3333
#### sinh( x )
3434

35-
Computes the [hyperbolic sine][hyperbolic-sine] of `x`.
35+
Computes the [hyperbolic sine][hyperbolic-sine] of double-precision floating-point number `x`.
3636

3737
```javascript
3838
var v = sinh( 0.0 );
@@ -105,7 +105,7 @@ for ( i = 0; i < x.length; i++ ) {
105105

106106
#### stdlib_base_sinh( x )
107107

108-
Computes the [hyperbolic sine][hyperbolic-sine] of `x`.
108+
Computes the [hyperbolic sine][hyperbolic-sine] of double-precision floating-point number `x`.
109109

110110
```c
111111
double out = stdlib_base_sinh( 2.0 );
@@ -146,7 +146,7 @@ double stdlib_base_sinh( const double x );
146146
#include <stdio.h>
147147
148148
int main() {
149-
double x[] = { -5.0, -3.89, -2.78, -1.67, -0.56, 0.56, 1.67, 2.78, 3.89, 5.0 };
149+
const double x[] = { -5.0, -3.89, -2.78, -1.67, -0.56, 0.56, 1.67, 2.78, 3.89, 5.0 };
150150
double v;
151151
int i;
152152

lib/node_modules/@stdlib/math/base/special/sinh/docs/repl.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
{{alias}}( x )
3-
Computes the hyperbolic sine of a number.
3+
Computes the hyperbolic sine of a double-precision floating-point number.
44

55
Parameters
66
----------

lib/node_modules/@stdlib/math/base/special/sinh/docs/types/index.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
// TypeScript Version: 2.0
2020

2121
/**
22-
* Computes the hyperbolic sine of a number.
22+
* Computes the hyperbolic sine of a double-precision floating-point number.
2323
*
2424
* @param x - input value
2525
* @returns hyperbolic sine

lib/node_modules/@stdlib/math/base/special/sinh/examples/c/example.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include <stdio.h>
2121

2222
int main() {
23-
double x[] = { -5.0, -3.89, -2.78, -1.67, -0.56, 0.56, 1.67, 2.78, 3.89, 5.0 };
23+
const double x[] = { -5.0, -3.89, -2.78, -1.67, -0.56, 0.56, 1.67, 2.78, 3.89, 5.0 };
2424
double v;
2525
int i;
2626

lib/node_modules/@stdlib/math/base/special/sinh/include/stdlib/math/base/special/sinh.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ extern "C" {
2727
#endif
2828

2929
/**
30-
* Computes the hyperbolic sine of a number.
30+
* Computes the hyperbolic sine of a double-precision floating-point number.
3131
*/
3232
double stdlib_base_sinh( const double x );
3333

lib/node_modules/@stdlib/math/base/special/sinh/lib/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
'use strict';
2020

2121
/**
22-
* Compute the hyperbolic sine of a number.
22+
* Compute the hyperbolic sine of a double-precision floating-point number.
2323
*
2424
* @module @stdlib/math/base/special/sinh
2525
*

lib/node_modules/@stdlib/math/base/special/sinh/lib/main.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ var LARGE = MAXLOG - LN2;
5959
// MAIN //
6060

6161
/**
62-
* Computes the hyperbolic sine of a number.
62+
* Computes the hyperbolic sine of a double-precision floating-point number.
6363
*
6464
* ## Method
6565
*
@@ -109,10 +109,10 @@ function sinh( x ) {
109109
if ( x === 0.0 ) {
110110
return x; // handles `+-0`
111111
}
112-
a = abs( x );
113112
if ( x > POS_OVERFLOW || x < NEG_OVERFLOW ) {
114113
return ( x > 0.0 ) ? PINF : NINF;
115114
}
115+
a = abs( x );
116116
if ( a > 1.0 ) {
117117
if ( a >= LARGE ) {
118118
a = exp( 0.5*a );

lib/node_modules/@stdlib/math/base/special/sinh/lib/native.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ var addon = require( './../src/addon.node' );
2626
// MAIN //
2727

2828
/**
29-
* Computes the hyperbolic sine of a number.
29+
* Computes the hyperbolic sine of a double-precision floating-point number.
3030
*
3131
* @private
3232
* @param {number} x - input value

lib/node_modules/@stdlib/math/base/special/sinh/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@stdlib/math/base/special/sinh",
33
"version": "0.0.0",
4-
"description": "Compute the hyperbolic sine of a number.",
4+
"description": "Compute the hyperbolic sine of a double-precision floating-point number.",
55
"license": "Apache-2.0",
66
"author": {
77
"name": "The Stdlib Authors",

lib/node_modules/@stdlib/math/base/special/sinh/src/main.c

+60-28
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*
1919
* ## Notice
2020
*
21-
* The original C code, long comment, copyright, license, and constants are from [Cephes]{@link http://www.netlib.org/cephes}. The implementation follows the original, but has been modified for JavaScript.
21+
* The original C code, long comment, copyright, license, and constants are from [Cephes]{@link http://www.netlib.org/cephes}. The implementation follows the original, but has been modified according to project conventions.
2222
*
2323
* ```text
2424
* Copyright 1984, 1995, 2000 by Stephen L. Moshier
@@ -38,8 +38,13 @@
3838
#include "stdlib/constants/float64/ln_two.h"
3939
#include <stdint.h>
4040

41+
// MAXLOG + LN2 = ln(2^1024) + LN2
4142
static const double POS_OVERFLOW = 7.09782712893383996843e2 + STDLIB_CONSTANT_FLOAT64_LN2;
43+
44+
// MINLOG - LN2 = ln(2^-1022) - LN2
4245
static const double NEG_OVERFLOW = -7.08396418532264106224e2 - STDLIB_CONSTANT_FLOAT64_LN2;
46+
47+
// MAXLOG - LN2 = ln(2^1024) - LN2
4348
static const double LARGE = 7.09782712893383996843e2 - STDLIB_CONSTANT_FLOAT64_LN2;
4449

4550
/* Begin auto-generated functions. The following functions are auto-generated. Do not edit directly. */
@@ -88,40 +93,67 @@ static double rational_pq( const double x ) {
8893
/* End auto-generated functions. */
8994

9095
/**
91-
* Computes the hyperbolic sine of a number.
96+
* Computes the hyperbolic sine of a double-precision floating-point number.
97+
*
98+
* ## Method
99+
*
100+
* The range is partitioned into two segments. If \\( |x| \le 1 \\), we use a rational function of the form
101+
*
102+
* ```tex
103+
* x + x^3 \frac{\mathrm{P}(x)}{\mathrm{Q}(x)}
104+
* ```
105+
*
106+
* Otherwise, the calculation is
107+
*
108+
* ```tex
109+
* \operatorname{sinh}(x) = \frac{ e^x - e^{-x} }{2}.
110+
* ```
111+
*
112+
* ## Notes
113+
*
114+
* - Relative error:
115+
*
116+
* | arithmetic | domain | # trials | peak | rms |
117+
* |:----------:|:--------:|:--------:|:-------:|:-------:|
118+
* | DEC | +- 88 | 50000 | 4.0e-17 | 7.7e-18 |
119+
* | IEEE | +-MAXLOG | 30000 | 2.6e-16 | 5.7e-17 |
92120
*
93121
* @param x input value
94122
* @return output value
95123
*
96124
* @example
97125
* double out = stdlib_base_sinh( 0.0 );
98126
* // returns 0.0
127+
*
128+
* @example
129+
* double out = stdlib_base_sinh( 2.0 );
130+
* // returns ~3.627
99131
*/
100132
double stdlib_base_sinh( const double x ) {
101-
double a;
102-
if ( x == 0.0 ) {
103-
return x; // handles `+-0`
104-
}
105-
a = stdlib_base_abs( x );
106-
if ( x > POS_OVERFLOW || x < NEG_OVERFLOW ) {
107-
return ( x > 0.0 ) ? STDLIB_CONSTANT_FLOAT64_PINF : STDLIB_CONSTANT_FLOAT64_NINF;
108-
}
109-
if ( a > 1.0 ) {
110-
if ( a >= LARGE ) {
111-
a = stdlib_base_exp( 0.5 * a );
112-
a *= 0.5 * a;
113-
if ( x < 0.0 ) {
114-
a = -a;
115-
}
116-
return a;
117-
}
118-
a = stdlib_base_exp( a );
119-
a = ( 0.5 * a ) - ( 0.5 / a );
120-
if ( x < 0.0 ) {
121-
a = -a;
122-
}
123-
return a;
124-
}
125-
a *= a;
126-
return x + ( x * a * rational_pq( a ) );
133+
double a;
134+
if ( x == 0.0 ) {
135+
return x; // handles `+-0`
136+
}
137+
if ( x > POS_OVERFLOW || x < NEG_OVERFLOW ) {
138+
return ( x > 0.0 ) ? STDLIB_CONSTANT_FLOAT64_PINF : STDLIB_CONSTANT_FLOAT64_NINF;
139+
}
140+
a = stdlib_base_abs( x );
141+
if ( a > 1.0 ) {
142+
if ( a >= LARGE ) {
143+
a = stdlib_base_exp( 0.5*a );
144+
a *= 0.5 * a;
145+
if ( x < 0.0 ) {
146+
a = -a;
147+
}
148+
return a;
149+
}
150+
a = stdlib_base_exp( a );
151+
a = ( 0.5*a ) - ( 0.5/a );
152+
if ( x < 0.0 ) {
153+
a = -a;
154+
}
155+
return a;
156+
}
157+
a *= a;
158+
return x + ( x * a * rational_pq( a ) );
127159
}

lib/node_modules/@stdlib/math/base/special/sinh/test/test.native.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ var isNegativeZero = require( '@stdlib/math/base/assert/is-negative-zero' );
2828
var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' );
2929
var PINF = require( '@stdlib/constants/float64/pinf' );
3030
var NINF = require( '@stdlib/constants/float64/ninf' );
31-
var tryRequire = require( '@stdlib/utils/try-require' );
3231
var EPS = require( '@stdlib/constants/float64/eps' );
3332
var abs = require( '@stdlib/math/base/special/abs' );
33+
var tryRequire = require( '@stdlib/utils/try-require' );
3434

3535

3636
// FIXTURES //

0 commit comments

Comments
 (0)