Skip to content

refactor: use constant packages, remove stdint #2355

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
#ifndef STDLIB_MATH_BASE_SPECIAL_COS_H
#define STDLIB_MATH_BASE_SPECIAL_COS_H

#include <stdint.h>

/*
* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler.
*/
Expand Down
12 changes: 4 additions & 8 deletions lib/node_modules/@stdlib/math/base/special/cos/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,25 +38,21 @@
var kernelCos = require( '@stdlib/math/base/special/kernel-cos' );
var kernelSin = require( '@stdlib/math/base/special/kernel-sin' );
var rempio2 = require( '@stdlib/math/base/special/rempio2' );
var ABS_MASK = require( '@stdlib/constants/float64/high-word-abs-mask' );
var EXPONENT_MASK = require( '@stdlib/constants/float64/high-word-exponent-mask' );


// VARIABLES //

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

Check warning on line 48 in lib/node_modules/@stdlib/math/base/special/cos/lib/main.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Unexpected 'warning' comment: 'WARNING: not thread safe'

// High word absolute value mask: 0x7fffffff => 01111111111111111111111111111111
var HIGH_WORD_ABS_MASK = 0x7fffffff|0; // asm type annotation

// High word of π/4: 0x3fe921fb => 00111111111010010010000111111011
var HIGH_WORD_PIO4 = 0x3fe921fb|0; // asm type annotation

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

// High word exponent mask: 0x7ff00000 => 01111111111100000000000000000000
var HIGH_WORD_EXPONENT_MASK = 0x7ff00000|0; // asm type annotation


// MAIN //

Expand Down Expand Up @@ -102,7 +98,7 @@
var n;

ix = getHighWord( x );
ix &= HIGH_WORD_ABS_MASK;
ix &= ABS_MASK;

// Case: |x| ~< pi/4
if ( ix <= HIGH_WORD_PIO4 ) {
Expand All @@ -113,7 +109,7 @@
return kernelCos( x, 0.0 );
}
// Case: cos(Inf or NaN) is NaN */
if ( ix >= HIGH_WORD_EXPONENT_MASK ) {
if ( ix >= EXPONENT_MASK ) {
return NaN;
}
// Case: Argument reduction needed...
Expand Down
6 changes: 6 additions & 0 deletions lib/node_modules/@stdlib/math/base/special/cos/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
"dependencies": [
"@stdlib/math/base/napi/unary",
"@stdlib/number/float64/base/get-high-word",
"@stdlib/constants/float64/high-word-abs-mask",
"@stdlib/constants/float64/high-word-exponent-mask",
"@stdlib/math/base/special/kernel-cos",
"@stdlib/math/base/special/kernel-sin",
"@stdlib/math/base/special/rempio2"
Expand All @@ -55,6 +57,8 @@
"libpath": [],
"dependencies": [
"@stdlib/number/float64/base/get-high-word",
"@stdlib/constants/float64/high-word-abs-mask",
"@stdlib/constants/float64/high-word-exponent-mask",
"@stdlib/math/base/special/kernel-cos",
"@stdlib/math/base/special/kernel-sin",
"@stdlib/math/base/special/rempio2"
Expand All @@ -72,6 +76,8 @@
"libpath": [],
"dependencies": [
"@stdlib/number/float64/base/get-high-word",
"@stdlib/constants/float64/high-word-abs-mask",
"@stdlib/constants/float64/high-word-exponent-mask",
"@stdlib/math/base/special/kernel-cos",
"@stdlib/math/base/special/kernel-sin",
"@stdlib/math/base/special/rempio2"
Expand Down
12 changes: 4 additions & 8 deletions lib/node_modules/@stdlib/math/base/special/cos/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,19 @@

#include "stdlib/math/base/special/cos.h"
#include "stdlib/number/float64/base/get_high_word.h"
#include "stdlib/constants/float64/high_word_abs_mask.h"
#include "stdlib/constants/float64/high_word_exponent_mask.h"
#include "stdlib/math/base/special/kernel_cos.h"
#include "stdlib/math/base/special/kernel_sin.h"
#include "stdlib/math/base/special/rempio2.h"
#include <stdint.h>

// High word absolute value mask: 0x7fffffff => 01111111111111111111111111111111
static const int32_t HIGH_WORD_ABS_MASK = 0x7fffffff;

// High word of π/4: 0x3fe921fb => 00111111111010010010000111111011
static const int32_t HIGH_WORD_PIO4 = 0x3fe921fb;

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

// High word exponent mask: 0x7ff00000 => 01111111111100000000000000000000
static const int32_t HIGH_WORD_EXPONENT_MASK = 0x7ff00000;

/**
* Computes the cosine of a number.
*
Expand Down Expand Up @@ -82,7 +78,7 @@ double stdlib_base_cos( const double x ) {

stdlib_base_float64_get_high_word( x, &uix );
ix = (int32_t)uix;
ix &= HIGH_WORD_ABS_MASK;
ix &= STDLIB_CONSTANT_FLOAT64_HIGH_WORD_ABS_MASK;

// Case: |x| ~< π/4
if ( ix <= HIGH_WORD_PIO4 ) {
Expand All @@ -93,7 +89,7 @@ double stdlib_base_cos( const double x ) {
return stdlib_base_kernel_cos( x, 0.0 );
}
// Case: cos(Inf or NaN) is NaN */
if ( ix >= HIGH_WORD_EXPONENT_MASK ) {
if ( ix >= STDLIB_CONSTANT_FLOAT64_HIGH_WORD_EXPONENT_MASK ) {
return 0.0 / 0.0; // NaN
}
// Case: Argument reduction needed...
Expand Down
Loading