Skip to content

Commit 2302838

Browse files
committed
updated tests and docs and changed deg2rad impl
1 parent 4dee5d5 commit 2302838

File tree

4 files changed

+21
-27
lines changed

4 files changed

+21
-27
lines changed

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

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,21 @@ limitations under the License.
2727
## Usage
2828

2929
```javascript
30-
var sin = require( '@stdlib/math/base/special/sin' );
30+
var sind = require( '@stdlib/math/base/special/sind' );
3131
```
3232

33-
#### sin( x )
33+
#### sind( x )
3434

35-
Computes the [sine][sine] of a `number` (in radians).
35+
Computes the [sine][sine] of a `number` (in degress).
3636

3737
```javascript
38-
var v = sin( 0.0 );
38+
var v = sind( 0.0 );
3939
// returns ~0.0
4040

41-
v = sin( 3.141592653589793/2.0 );
41+
v = sind( 90 );
4242
// returns ~1.0
4343

44-
v = sin( -3.141592653589793/6.0 );
44+
v = sind( -30 );
4545
// returns ~-0.5
4646
```
4747

@@ -57,14 +57,13 @@ v = sin( -3.141592653589793/6.0 );
5757

5858
```javascript
5959
var linspace = require( '@stdlib/array/base/linspace' );
60-
var TWO_PI = require( '@stdlib/constants/float64/two-pi' );
61-
var sin = require( '@stdlib/math/base/special/sin' );
60+
var sind = require( '@stdlib/math/base/special/sind' );
6261

63-
var x = linspace( 0.0, TWO_PI, 100 );
62+
var x = linspace( 0.0, 360, 555 );
6463

6564
var i;
6665
for ( i = 0; i < x.length; i++ ) {
67-
console.log( sin( x[ i ] ) );
66+
console.log( sind( x[ i ] ) );
6867
}
6968
```
7069

@@ -81,7 +80,7 @@ for ( i = 0; i < x.length; i++ ) {
8180
## See Also
8281

8382
- <span class="package-name">[`@stdlib/math/base/special/cos`][@stdlib/math/base/special/cos]</span><span class="delimiter">: </span><span class="description">compute the cosine of a number.</span>
84-
- <span class="package-name">[`@stdlib/math/base/special/sinpi`][@stdlib/math/base/special/sinpi]</span><span class="delimiter">: </span><span class="description">compute sin(πx).</span>
83+
- <span class="package-name">[`@stdlib/math/base/special/sin`][@stdlib/math/base/special/sin]</span><span class="delimiter">: </span><span class="description">compute the sine of a number.</span>
8584
- <span class="package-name">[`@stdlib/math/base/special/tan`][@stdlib/math/base/special/tan]</span><span class="delimiter">: </span><span class="description">evaluate the tangent of a number.</span>
8685

8786
</section>
@@ -98,7 +97,7 @@ for ( i = 0; i < x.length; i++ ) {
9897

9998
[@stdlib/math/base/special/cos]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/cos
10099

101-
[@stdlib/math/base/special/sinpi]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/sinpi
100+
[@stdlib/math/base/special/sin]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/sin
102101

103102
[@stdlib/math/base/special/tan]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/tan
104103

lib/node_modules/@stdlib/math/base/special/sind/lib/sind.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@
2222

2323
var isnan = require('@stdlib/math/base/assert/is-nan');
2424
var isinfinite = require('@stdlib/math/base/assert/is-infinite');
25-
var abs = require('@stdlib/math/base/special/abs');
2625
var kernelSin = require('@stdlib/math/base/special/kernel-sin');
2726
var kernelCos = require('@stdlib/math/base/special/kernel-cos');
28-
var PI = require('@stdlib/constants/float64/pi');
27+
var deg2rad = require('@stdlib/math/base/special/deg2rad')
2928

3029
/**
3130
* Compute the sine of a number.
@@ -48,10 +47,6 @@ var PI = require('@stdlib/constants/float64/pi');
4847
* // returns NaN
4948
*/
5049

51-
function deg2rad(x) {
52-
return (x * PI) / 180;
53-
}
54-
5550
function sind(x) {
5651
if (isinfinite(x)) {
5752
return NaN;

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"name": "@stdlib/math/base/special/sin",
2+
"name": "@stdlib/math/base/special/sind",
33
"version": "0.0.0",
4-
"description": "Compute the sine of a number.",
4+
"description": "Compute the sine of a number (in degrees).",
55
"license": "Apache-2.0",
66
"author": {
77
"name": "The Stdlib Authors",
@@ -15,7 +15,6 @@
1515
],
1616
"main": "./lib",
1717
"directories": {
18-
"benchmark": "./benchmark",
1918
"doc": "./docs",
2019
"example": "./examples",
2120
"lib": "./lib",
@@ -55,6 +54,7 @@
5554
"math",
5655
"math.sin",
5756
"sin",
57+
"sind",
5858
"sine",
5959
"trig",
6060
"trigonometry",

lib/node_modules/@stdlib/math/base/special/sind/test/test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ tape( 'the function computes the sine (medium negative values)', function test(
6464
t.equal( y, expected[ i ], 'x: '+x[i]+'. Expected: '+expected[i] );
6565
} else {
6666
delta = abs( y - expected[ i ] );
67-
tol = EPS * abs( expected[ i ] );
67+
tol = 3.0 * EPS * abs( expected[ i ] );
6868
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' );
6969
}
7070
}
@@ -88,7 +88,7 @@ tape( 'the function computes the sine (medium positive values)', function test(
8888
t.equal( y, expected[ i ], 'x: '+x[i]+'. Expected: '+expected[i] );
8989
} else {
9090
delta = abs( y - expected[ i ] );
91-
tol = EPS * abs( expected[ i ] );
91+
tol = 3.0 * EPS * abs( expected[ i ] );
9292
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' );
9393
}
9494
}
@@ -112,7 +112,7 @@ tape( 'the function computes the sine (large negative values)', function test( t
112112
t.equal( y, expected[ i ], 'x: '+x[i]+'. Expected: '+expected[i] );
113113
} else {
114114
delta = abs( y - expected[ i ] );
115-
tol = EPS * abs( expected[ i ] );
115+
tol = 3.0 * EPS * abs( expected[ i ] );
116116
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' );
117117
}
118118
}
@@ -136,7 +136,7 @@ tape( 'the function computes the sine (large positive values)', function test( t
136136
t.equal( y, expected[ i ], 'x: '+x[i]+'. Expected: '+expected[i] );
137137
} else {
138138
delta = abs( y - expected[ i ] );
139-
tol = EPS * abs( expected[ i ] );
139+
tol = 3.0 * EPS * abs( expected[ i ] );
140140
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' );
141141
}
142142
}
@@ -160,7 +160,7 @@ tape( 'the function computes the sine (huge negative values)', function test( t
160160
t.equal( y, expected[ i ], 'x: '+x[i]+'. Expected: '+expected[i] );
161161
} else {
162162
delta = abs( y - expected[ i ] );
163-
tol = EPS * abs( expected[ i ] );
163+
tol = 3.0 * EPS * abs( expected[ i ] );
164164
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' );
165165
}
166166
}
@@ -184,7 +184,7 @@ tape( 'the function computes the sine (huge positive values)', function test( t
184184
t.equal( y, expected[ i ], 'x: '+x[i]+'. Expected: '+expected[i] );
185185
} else {
186186
delta = abs( y - expected[ i ] );
187-
tol = EPS * abs( expected[ i ] );
187+
tol = 3.0 * EPS * abs( expected[ i ] );
188188
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' );
189189
}
190190
}

0 commit comments

Comments
 (0)