Skip to content

Commit 5312594

Browse files
committed
fix: update the function according to reference implementation
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: passed - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 484aa75 commit 5312594

File tree

5 files changed

+22
-59
lines changed

5 files changed

+22
-59
lines changed

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

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,8 @@
2020

2121
// MODULES //
2222

23-
var tan = require( '@stdlib/math/base/special/tan' );
24-
var isInteger = require( '@stdlib/math/base/assert/is-integer' );
25-
var deg2rad = require( '@stdlib/math/base/special/deg2rad' );
26-
var isInfinite = require( '@stdlib/assert/is-infinite' );
23+
var sind = require( '@stdlib/math/base/special/sind' );
24+
var cosd = require( '@stdlib/math/base/special/cosd' );
2725

2826

2927
// MAIN //
@@ -51,23 +49,7 @@ var isInfinite = require( '@stdlib/assert/is-infinite' );
5149
* // returns NaN
5250
*/
5351
function tand( x ) {
54-
var xRad;
55-
56-
if ( isInfinite( x ) ) {
57-
return NaN;
58-
}
59-
60-
if ( isInteger( ( ( x / 90.0 ) - 1.0 ) / 2.0 ) ) {
61-
return Infinity;
62-
}
63-
64-
if ( isInteger( ( x / 90.0 ) / 2.0 ) ) {
65-
return 0.0;
66-
}
67-
68-
xRad = deg2rad( x );
69-
70-
return tan( xRad );
52+
return sind( x ) / cosd( x );
7153
}
7254

7355

lib/node_modules/@stdlib/math/base/special/tand/manifest.json

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,8 @@
3737
"libpath": [],
3838
"dependencies": [
3939
"@stdlib/math/base/napi/unary",
40-
"@stdlib/math/base/special/deg2rad",
41-
"@stdlib/math/base/special/tan",
42-
"@stdlib/math/base/assert/is-integer",
43-
"@stdlib/math/base/assert/is-infinite"
40+
"@stdlib/math/base/special/sind",
41+
"@stdlib/math/base/special/cosd"
4442
]
4543
},
4644
{
@@ -54,10 +52,8 @@
5452
"libraries": [],
5553
"libpath": [],
5654
"dependencies": [
57-
"@stdlib/math/base/special/deg2rad",
58-
"@stdlib/math/base/special/tan",
59-
"@stdlib/math/base/assert/is-integer",
60-
"@stdlib/math/base/assert/is-infinite"
55+
"@stdlib/math/base/special/sind",
56+
"@stdlib/math/base/special/cosd"
6157
]
6258
},
6359
{
@@ -71,10 +67,8 @@
7167
"libraries": [],
7268
"libpath": [],
7369
"dependencies": [
74-
"@stdlib/math/base/special/deg2rad",
75-
"@stdlib/math/base/special/tan",
76-
"@stdlib/math/base/assert/is-integer",
77-
"@stdlib/math/base/assert/is-infinite"
70+
"@stdlib/math/base/special/sind",
71+
"@stdlib/math/base/special/cosd"
7872
]
7973
}
8074
]

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

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,8 @@
1717
*/
1818

1919
#include "stdlib/math/base/special/tand.h"
20-
#include "stdlib/math/base/special/tan.h"
21-
#include "stdlib/math/base/special/deg2rad.h"
22-
#include "stdlib/math/base/assert/is_integer.h"
23-
#include "stdlib/math/base/assert/is_infinite.h"
20+
#include "stdlib/math/base/special/sind.h"
21+
#include "stdlib/math/base/special/cosd.h"
2422

2523
/**
2624
* Computes the tangent of an angle measured in degrees.
@@ -33,16 +31,5 @@
3331
* // returns 0.0
3432
*/
3533
double stdlib_base_tand( const double x ) {
36-
double xRad;
37-
if ( stdlib_base_is_infinite( x ) ) {
38-
return 0.0 / 0.0; // NaN
39-
}
40-
if ( stdlib_base_is_integer( ( ( x / 90.0 ) - 1.0 ) / 2.0 ) ) {
41-
return x / 0.0; // Infinity
42-
}
43-
if ( stdlib_base_is_integer( ( x / 90.0 ) / 2.0 ) ) {
44-
return 0.0;
45-
}
46-
xRad = stdlib_base_deg2rad( x );
47-
return stdlib_base_tan( xRad );
34+
return stdlib_base_sind( x ) / stdlib_base_cosd( x );
4835
}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ tape( 'the function computes the tangent of an angle measured in degrees (negati
6060
t.equal( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i] );
6161
} else {
6262
delta = abs( y - expected[i] );
63-
tol = 1.4 * EPS * abs( expected[i] );
63+
tol = 2.0 * EPS * abs( expected[i] );
6464
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' );
6565
}
6666
}
@@ -84,7 +84,7 @@ tape( 'the function computes the tangent of an angle measured in degrees (positi
8484
t.equal( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i] );
8585
} else {
8686
delta = abs( y - expected[i] );
87-
tol = 1.4 * EPS * abs( expected[i] );
87+
tol = 2.0 * EPS * abs( expected[i] );
8888
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' );
8989
}
9090
}
@@ -97,13 +97,13 @@ tape( 'if provided a `NaN`, the function returns `NaN`', function test( t ) {
9797
t.end();
9898
});
9999

100-
tape( 'if provided `+infinity`, the function returns `NaN`', function test( t ) {
100+
tape( 'if provided `+Infinity`, the function returns `NaN`', function test( t ) {
101101
var v = tand( PINF );
102102
t.equal( isnan( v ), true, 'returns expected value' );
103103
t.end();
104104
});
105105

106-
tape( 'if provided `-infinity`, the function returns `NaN`', function test( t ) {
106+
tape( 'if provided `-Infinity`, the function returns `NaN`', function test( t ) {
107107
var v = tand( NINF );
108108
t.equal( isnan( v ), true, 'returns expected value' );
109109
t.end();
@@ -115,7 +115,7 @@ tape( 'if provided `90.0`, the function returns `Infinity`', function test( t )
115115
t.end();
116116
});
117117

118-
tape( 'if provided `180.0`, the function returns `Infinity`', function test( t ) {
118+
tape( 'if provided `180.0`, the function returns `0`', function test( t ) {
119119
var v = tand( 180.0 );
120120
t.equal( v, 0.0, 'returns expected value' );
121121
t.end();

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ tape( 'the function computes the tangent of an angle measured in degrees (negati
6969
t.equal( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i] );
7070
} else {
7171
delta = abs( y - expected[i] );
72-
tol = 1.4 * EPS * abs( expected[i] );
72+
tol = 1.8 * EPS * abs( expected[i] );
7373
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' );
7474
}
7575
}
@@ -93,7 +93,7 @@ tape( 'the function computes the tangent of an angle measured in degrees (positi
9393
t.equal( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i] );
9494
} else {
9595
delta = abs( y - expected[i] );
96-
tol = 1.4 * EPS * abs( expected[i] );
96+
tol = 1.8 * EPS * abs( expected[i] );
9797
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' );
9898
}
9999
}
@@ -106,13 +106,13 @@ tape( 'if provided a `NaN`, the function returns `NaN`', opts, function test( t
106106
t.end();
107107
});
108108

109-
tape( 'if provided `+infinity`, the function returns `NaN`', opts, function test( t ) {
109+
tape( 'if provided `+Infinity`, the function returns `NaN`', opts, function test( t ) {
110110
var v = tand( PINF );
111111
t.equal( isnan( v ), true, 'returns expected value' );
112112
t.end();
113113
});
114114

115-
tape( 'if provided `-infinity`, the function returns `NaN`', opts, function test( t ) {
115+
tape( 'if provided `-Infinity`, the function returns `NaN`', opts, function test( t ) {
116116
var v = tand( NINF );
117117
t.equal( isnan( v ), true, 'returns expected value' );
118118
t.end();
@@ -124,7 +124,7 @@ tape( 'if provided `90.0`, the function returns `Infinity`', opts, function test
124124
t.end();
125125
});
126126

127-
tape( 'if provided `180.0`, the function returns `Infinity`', opts, function test( t ) {
127+
tape( 'if provided `180.0`, the function returns `0`', opts, function test( t ) {
128128
var v = tand( 180.0 );
129129
t.equal( v, 0.0, 'returns expected value' );
130130
t.end();

0 commit comments

Comments
 (0)