Skip to content
  • Sponsor stdlib-js/stdlib

  • Notifications You must be signed in to change notification settings
  • Fork 805

Commit ced30b0

Browse files
authoredJun 10, 2024··
refactor: use constant packages and remove unused include
PR-URL: #2355 Ref: #2352 Reviewed-by: Athan Reines <kgryte@gmail.com>
1 parent 343da6f commit ced30b0

File tree

4 files changed

+14
-18
lines changed

4 files changed

+14
-18
lines changed
 

‎lib/node_modules/@stdlib/math/base/special/cos/include/stdlib/math/base/special/cos.h

-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
#ifndef STDLIB_MATH_BASE_SPECIAL_COS_H
2323
#define STDLIB_MATH_BASE_SPECIAL_COS_H
2424

25-
#include <stdint.h>
26-
2725
/*
2826
* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler.
2927
*/

‎lib/node_modules/@stdlib/math/base/special/cos/lib/main.js

+4-8
Original file line numberDiff line numberDiff line change
@@ -38,25 +38,21 @@ var getHighWord = require( '@stdlib/number/float64/base/get-high-word' );
3838
var kernelCos = require( '@stdlib/math/base/special/kernel-cos' );
3939
var kernelSin = require( '@stdlib/math/base/special/kernel-sin' );
4040
var rempio2 = require( '@stdlib/math/base/special/rempio2' );
41+
var ABS_MASK = require( '@stdlib/constants/float64/high-word-abs-mask' );
42+
var EXPONENT_MASK = require( '@stdlib/constants/float64/high-word-exponent-mask' );
4143

4244

4345
// VARIABLES //
4446

4547
// Scratch array for storing temporary values:
4648
var buffer = [ 0.0, 0.0 ]; // WARNING: not thread safe
4749

48-
// High word absolute value mask: 0x7fffffff => 01111111111111111111111111111111
49-
var HIGH_WORD_ABS_MASK = 0x7fffffff|0; // asm type annotation
50-
5150
// High word of π/4: 0x3fe921fb => 00111111111010010010000111111011
5251
var HIGH_WORD_PIO4 = 0x3fe921fb|0; // asm type annotation
5352

5453
// High word of 2^-27: 0x3e400000 => 00111110010000000000000000000000
5554
var HIGH_WORD_TWO_NEG_27 = 0x3e400000|0; // asm type annotation
5655

57-
// High word exponent mask: 0x7ff00000 => 01111111111100000000000000000000
58-
var HIGH_WORD_EXPONENT_MASK = 0x7ff00000|0; // asm type annotation
59-
6056

6157
// MAIN //
6258

@@ -102,7 +98,7 @@ function cos( x ) {
10298
var n;
10399

104100
ix = getHighWord( x );
105-
ix &= HIGH_WORD_ABS_MASK;
101+
ix &= ABS_MASK;
106102

107103
// Case: |x| ~< pi/4
108104
if ( ix <= HIGH_WORD_PIO4 ) {
@@ -113,7 +109,7 @@ function cos( x ) {
113109
return kernelCos( x, 0.0 );
114110
}
115111
// Case: cos(Inf or NaN) is NaN */
116-
if ( ix >= HIGH_WORD_EXPONENT_MASK ) {
112+
if ( ix >= EXPONENT_MASK ) {
117113
return NaN;
118114
}
119115
// Case: Argument reduction needed...

‎lib/node_modules/@stdlib/math/base/special/cos/manifest.json

+6
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
"dependencies": [
3939
"@stdlib/math/base/napi/unary",
4040
"@stdlib/number/float64/base/get-high-word",
41+
"@stdlib/constants/float64/high-word-abs-mask",
42+
"@stdlib/constants/float64/high-word-exponent-mask",
4143
"@stdlib/math/base/special/kernel-cos",
4244
"@stdlib/math/base/special/kernel-sin",
4345
"@stdlib/math/base/special/rempio2"
@@ -55,6 +57,8 @@
5557
"libpath": [],
5658
"dependencies": [
5759
"@stdlib/number/float64/base/get-high-word",
60+
"@stdlib/constants/float64/high-word-abs-mask",
61+
"@stdlib/constants/float64/high-word-exponent-mask",
5862
"@stdlib/math/base/special/kernel-cos",
5963
"@stdlib/math/base/special/kernel-sin",
6064
"@stdlib/math/base/special/rempio2"
@@ -72,6 +76,8 @@
7276
"libpath": [],
7377
"dependencies": [
7478
"@stdlib/number/float64/base/get-high-word",
79+
"@stdlib/constants/float64/high-word-abs-mask",
80+
"@stdlib/constants/float64/high-word-exponent-mask",
7581
"@stdlib/math/base/special/kernel-cos",
7682
"@stdlib/math/base/special/kernel-sin",
7783
"@stdlib/math/base/special/rempio2"

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

+4-8
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,19 @@
3232

3333
#include "stdlib/math/base/special/cos.h"
3434
#include "stdlib/number/float64/base/get_high_word.h"
35+
#include "stdlib/constants/float64/high_word_abs_mask.h"
36+
#include "stdlib/constants/float64/high_word_exponent_mask.h"
3537
#include "stdlib/math/base/special/kernel_cos.h"
3638
#include "stdlib/math/base/special/kernel_sin.h"
3739
#include "stdlib/math/base/special/rempio2.h"
3840
#include <stdint.h>
3941

40-
// High word absolute value mask: 0x7fffffff => 01111111111111111111111111111111
41-
static const int32_t HIGH_WORD_ABS_MASK = 0x7fffffff;
42-
4342
// High word of π/4: 0x3fe921fb => 00111111111010010010000111111011
4443
static const int32_t HIGH_WORD_PIO4 = 0x3fe921fb;
4544

4645
// High word of 2^-27: 0x3e400000 => 00111110010000000000000000000000
4746
static const int32_t HIGH_WORD_TWO_NEG_27 = 0x3e400000;
4847

49-
// High word exponent mask: 0x7ff00000 => 01111111111100000000000000000000
50-
static const int32_t HIGH_WORD_EXPONENT_MASK = 0x7ff00000;
51-
5248
/**
5349
* Computes the cosine of a number.
5450
*
@@ -82,7 +78,7 @@ double stdlib_base_cos( const double x ) {
8278

8379
stdlib_base_float64_get_high_word( x, &uix );
8480
ix = (int32_t)uix;
85-
ix &= HIGH_WORD_ABS_MASK;
81+
ix &= STDLIB_CONSTANT_FLOAT64_HIGH_WORD_ABS_MASK;
8682

8783
// Case: |x| ~< π/4
8884
if ( ix <= HIGH_WORD_PIO4 ) {
@@ -93,7 +89,7 @@ double stdlib_base_cos( const double x ) {
9389
return stdlib_base_kernel_cos( x, 0.0 );
9490
}
9591
// Case: cos(Inf or NaN) is NaN */
96-
if ( ix >= HIGH_WORD_EXPONENT_MASK ) {
92+
if ( ix >= STDLIB_CONSTANT_FLOAT64_HIGH_WORD_EXPONENT_MASK ) {
9793
return 0.0 / 0.0; // NaN
9894
}
9995
// Case: Argument reduction needed...

0 commit comments

Comments
 (0)