Skip to content
Open
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
10 changes: 10 additions & 0 deletions lib/node_modules/@stdlib/math/base/assert/is-odd/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
// MODULES //

var isEven = require( '@stdlib/math/base/assert/is-even' );
var MAX_SAFE_INTEGER = require( '@stdlib/constants/float64/max-safe-integer' );
var PINF = require( '@stdlib/constants/float64/pinf' );
var NINF = require( '@stdlib/constants/float64/ninf' );


// MAIN //
Expand Down Expand Up @@ -48,6 +51,13 @@ var isEven = require( '@stdlib/math/base/assert/is-even' );
* // returns false
*/
function isOdd( x ) {
// Every finite value whose magnitude exceeds the maximum safe integer is even, but `x-1` and `x+1` would round to an even value...
if ( x > MAX_SAFE_INTEGER ) {
return ( x === PINF );
}
if ( x < -MAX_SAFE_INTEGER ) {
return ( x === NINF );
}
// Check sign to prevent overflow...
if ( x > 0.0 ) {
return isEven( x-1.0 );
Expand Down
15 changes: 12 additions & 3 deletions lib/node_modules/@stdlib/math/base/assert/is-odd/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@
"@stdlib/napi/export",
"@stdlib/napi/argv",
"@stdlib/napi/argv-double",
"@stdlib/napi/create-int32"
"@stdlib/napi/create-int32",
"@stdlib/constants/float64/max-safe-integer",
"@stdlib/constants/float64/pinf",
"@stdlib/constants/float64/ninf"
]
},
{
Expand All @@ -58,7 +61,10 @@
],
"libpath": [],
"dependencies": [
"@stdlib/math/base/assert/is-even"
"@stdlib/math/base/assert/is-even",
"@stdlib/constants/float64/max-safe-integer",
"@stdlib/constants/float64/pinf",
"@stdlib/constants/float64/ninf"
]
},
{
Expand All @@ -72,7 +78,10 @@
"libraries": [],
"libpath": [],
"dependencies": [
"@stdlib/math/base/assert/is-even"
"@stdlib/math/base/assert/is-even",
"@stdlib/constants/float64/max-safe-integer",
"@stdlib/constants/float64/pinf",
"@stdlib/constants/float64/ninf"
]
}
]
Expand Down
10 changes: 10 additions & 0 deletions lib/node_modules/@stdlib/math/base/assert/is-odd/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@

#include "stdlib/math/base/assert/is_odd.h"
#include "stdlib/math/base/assert/is_even.h"
#include "stdlib/constants/float64/max_safe_integer.h"
#include "stdlib/constants/float64/pinf.h"
#include "stdlib/constants/float64/ninf.h"
#include <stdbool.h>

/**
Expand All @@ -33,6 +36,13 @@
* // returns true
*/
bool stdlib_base_is_odd( const double x ) {
// Every finite value whose magnitude exceeds the maximum safe integer is even, but `x-1` and `x+1` would round to an even value...
if ( x > STDLIB_CONSTANT_FLOAT64_MAX_SAFE_INTEGER ) {
return ( x == STDLIB_CONSTANT_FLOAT64_PINF );
}
if ( x < -STDLIB_CONSTANT_FLOAT64_MAX_SAFE_INTEGER ) {
return ( x == STDLIB_CONSTANT_FLOAT64_NINF );
}
// Check sign to prevent overflow...
if ( x > 0.0 ) {
return stdlib_base_is_even( x - 1.0 );
Expand Down
22 changes: 22 additions & 0 deletions lib/node_modules/@stdlib/math/base/assert/is-odd/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,28 @@ tape( 'the function returns `true` if provided an odd number', function test( t
t.end();
});

tape( 'the function returns `false` if provided a value whose magnitude exceeds the maximum safe integer', function test( t ) {
var values;
var v;
var i;

values = [
9007199254740992.0,
9007199254740994.0,
1.152921504606847e18,
1.0e300,
1.7976931348623157e308
];
for ( i = 0; i < values.length; i++ ) {
v = values[ i ];
t.strictEqual( isOdd( v ), false, 'returns expected value when provided '+v );
t.strictEqual( isOdd( -v ), false, 'returns expected value when provided '+(-v) );
}
t.strictEqual( isOdd( 9007199254740991.0 ), true, 'returns expected value' );
t.strictEqual( isOdd( -9007199254740991.0 ), true, 'returns expected value' );
t.end();
});

tape( 'the function returns `false` if provided `+-0`', function test( t ) {
t.strictEqual( isOdd( +0.0 ), false, 'returns expected value' );
t.strictEqual( isOdd( -0.0 ), false, 'returns expected value' );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,28 @@ tape( 'the function returns `true` if provided an odd number', opts, function te
t.end();
});

tape( 'the function returns `false` if provided a value whose magnitude exceeds the maximum safe integer', opts, function test( t ) {
var values;
var v;
var i;

values = [
9007199254740992.0,
9007199254740994.0,
1.152921504606847e18,
1.0e300,
1.7976931348623157e308
];
for ( i = 0; i < values.length; i++ ) {
v = values[ i ];
t.strictEqual( isOdd( v ), false, 'returns expected value when provided '+v );
t.strictEqual( isOdd( -v ), false, 'returns expected value when provided '+(-v) );
}
t.strictEqual( isOdd( 9007199254740991.0 ), true, 'returns expected value' );
t.strictEqual( isOdd( -9007199254740991.0 ), true, 'returns expected value' );
t.end();
});

tape( 'the function returns `false` if provided `+-0`', opts, function test( t ) {
t.strictEqual( isOdd( +0.0 ), false, 'returns expected value' );
t.strictEqual( isOdd( -0.0 ), false, 'returns expected value' );
Expand Down
13 changes: 12 additions & 1 deletion lib/node_modules/@stdlib/math/base/assert/is-oddf/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@

var isEvenf = require( '@stdlib/math/base/assert/is-evenf' );
var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' );
var MAX_SAFE_INTEGER = require( '@stdlib/constants/float32/max-safe-integer' );
var PINF = require( '@stdlib/constants/float32/pinf' );
var NINF = require( '@stdlib/constants/float32/ninf' );


// MAIN //
Expand Down Expand Up @@ -49,8 +52,16 @@ var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' );
* // returns false
*/
function isOddf( x ) {
// Check sign to prevent overflow...
x = float64ToFloat32( x );

// Every finite value whose magnitude exceeds the maximum safe integer is even, but `x-1` and `x+1` would round to an even value...
if ( x > MAX_SAFE_INTEGER ) {
return ( x === PINF );
}
if ( x < -MAX_SAFE_INTEGER ) {
return ( x === NINF );
}
// Check sign to prevent overflow...
if ( x > 0.0 ) {
return isEvenf( float64ToFloat32( x - 1.0 ) );
}
Expand Down
15 changes: 12 additions & 3 deletions lib/node_modules/@stdlib/math/base/assert/is-oddf/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@
"@stdlib/napi/argv-float",
"@stdlib/napi/create-int32",
"@stdlib/napi/export",
"@stdlib/math/base/assert/is-evenf"
"@stdlib/math/base/assert/is-evenf",
"@stdlib/constants/float32/max-safe-integer",
"@stdlib/constants/float32/pinf",
"@stdlib/constants/float32/ninf"
]
},
{
Expand All @@ -54,7 +57,10 @@
"libraries": [],
"libpath": [],
"dependencies": [
"@stdlib/math/base/assert/is-evenf"
"@stdlib/math/base/assert/is-evenf",
"@stdlib/constants/float32/max-safe-integer",
"@stdlib/constants/float32/pinf",
"@stdlib/constants/float32/ninf"
]
},
{
Expand All @@ -68,7 +74,10 @@
"libraries": [],
"libpath": [],
"dependencies": [
"@stdlib/math/base/assert/is-evenf"
"@stdlib/math/base/assert/is-evenf",
"@stdlib/constants/float32/max-safe-integer",
"@stdlib/constants/float32/pinf",
"@stdlib/constants/float32/ninf"
]
}
]
Expand Down
10 changes: 10 additions & 0 deletions lib/node_modules/@stdlib/math/base/assert/is-oddf/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@

#include "stdlib/math/base/assert/is_oddf.h"
#include "stdlib/math/base/assert/is_evenf.h"
#include "stdlib/constants/float32/max_safe_integer.h"
#include "stdlib/constants/float32/pinf.h"
#include "stdlib/constants/float32/ninf.h"
#include <stdbool.h>

/**
Expand All @@ -33,6 +36,13 @@
* // returns true
*/
bool stdlib_base_is_oddf( const float x ) {
// Every finite value whose magnitude exceeds the maximum safe integer is even, but `x-1` and `x+1` would round to an even value...
if ( x > STDLIB_CONSTANT_FLOAT32_MAX_SAFE_INTEGER ) {
return ( x == STDLIB_CONSTANT_FLOAT32_PINF );
}
if ( x < -STDLIB_CONSTANT_FLOAT32_MAX_SAFE_INTEGER ) {
return ( x == STDLIB_CONSTANT_FLOAT32_NINF );
}
// Check sign to prevent overflow...
if ( x > 0.0f ) {
return stdlib_base_is_evenf( x - 1.0f );
Expand Down
22 changes: 22 additions & 0 deletions lib/node_modules/@stdlib/math/base/assert/is-oddf/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,28 @@ tape( 'the function returns `true` if provided an odd number', function test( t
t.end();
});

tape( 'the function returns `false` if provided a value whose magnitude exceeds the maximum safe integer', function test( t ) {
var values;
var v;
var i;

values = [
16777216.0,
16777218.0,
1073741824.0,
1.0e30,
3.4028234663852886e38
];
for ( i = 0; i < values.length; i++ ) {
v = values[ i ];
t.strictEqual( isOddf( v ), false, 'returns expected value when provided '+v );
t.strictEqual( isOddf( -v ), false, 'returns expected value when provided '+(-v) );
}
t.strictEqual( isOddf( 16777215.0 ), true, 'returns expected value' );
t.strictEqual( isOddf( -16777215.0 ), true, 'returns expected value' );
t.end();
});

tape( 'the function returns `false` if provided `+-0`', function test( t ) {
t.strictEqual( isOddf( +0.0 ), false, 'returns expected value' );
t.strictEqual( isOddf( -0.0 ), false, 'returns expected value' );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,28 @@ tape( 'the function returns `true` if provided an odd number', opts, function te
t.end();
});

tape( 'the function returns `false` if provided a value whose magnitude exceeds the maximum safe integer', opts, function test( t ) {
var values;
var v;
var i;

values = [
16777216.0,
16777218.0,
1073741824.0,
1.0e30,
3.4028234663852886e38
];
for ( i = 0; i < values.length; i++ ) {
v = values[ i ];
t.strictEqual( isOddf( v ), false, 'returns expected value when provided '+v );
t.strictEqual( isOddf( -v ), false, 'returns expected value when provided '+(-v) );
}
t.strictEqual( isOddf( 16777215.0 ), true, 'returns expected value' );
t.strictEqual( isOddf( -16777215.0 ), true, 'returns expected value' );
t.end();
});

tape( 'the function returns `false` if provided `+-0`', opts, function test( t ) {
t.strictEqual( isOddf( +0.0 ), false, 'returns expected value' );
t.strictEqual( isOddf( -0.0 ), false, 'returns expected value' );
Expand Down
9 changes: 4 additions & 5 deletions lib/node_modules/@stdlib/math/base/special/pow/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
var isInteger = require( '@stdlib/math/base/assert/is-integer' );
var sqrt = require( '@stdlib/math/base/special/sqrt' );
var abs = require( '@stdlib/math/base/special/abs' );
var toWords = require( '@stdlib/number/float64/base/to-words' );

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

View workflow job for this annotation

GitHub Actions / Lint Changed Files

only the `assign` property of the required module is used; require the property directly
var setLowWord = require( '@stdlib/number/float64/base/set-low-word' );
var uint32ToInt32 = require( '@stdlib/number/uint32/base/to-int32' );
var NINF = require( '@stdlib/constants/float64/ninf' );
Expand Down Expand Up @@ -82,7 +82,7 @@
var HUGE = 1.0e300;
var TINY = 1.0e-300;

// -(1024-log2(ovfl+.5ulp))

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

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Unknown word: "ovfl"
var OVT = 8.0085662595372944372e-17;

// High/low words workspace:
Expand Down Expand Up @@ -262,11 +262,10 @@
if ( x === 1.0 ) {
return 1.0;
}
if (
x === -1.0 &&
isOdd( y )
) {
return -1.0;
if ( x === -1.0 ) {
if ( isInteger( y ) ) {
return ( isOdd( y ) ) ? -1.0 : 1.0;
}
}
if ( isInfinite( x ) ) {
if ( x === NINF ) {
Expand Down
9 changes: 4 additions & 5 deletions lib/node_modules/@stdlib/math/base/special/pow/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -618,11 +618,10 @@ double stdlib_base_pow( const double x, const double y ) {
if ( xc == 1.0 ) {
return 1.0;
}
if (
xc == -1.0 &&
stdlib_base_is_odd( y )
) {
return -1.0;
if ( xc == -1.0 ) {
if ( stdlib_base_is_integer( y ) ) {
return ( stdlib_base_is_odd( y ) ) ? -1.0 : 1.0;
}
}
if ( stdlib_base_is_infinite( xc ) ) {
if ( xc == STDLIB_CONSTANT_FLOAT64_NINF ) {
Expand Down
20 changes: 20 additions & 0 deletions lib/node_modules/@stdlib/math/base/special/pow/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,26 @@ tape( '`-1` raised to any odd integer is `-1`', function test( t ) {
t.end();
});

tape( '`-1` raised to any even integer is `1`', function test( t ) {
var values;
var i;

values = [
-1.0e300,
-3.6893488147419103e19,
-9007199254740994.0,
-2.0,
2.0,
9007199254740994.0,
3.6893488147419103e19,
1.0e300
];
for ( i = 0; i < values.length; i++ ) {
t.strictEqual( pow( -1.0, values[ i ] ), 1.0, 'returns expected value' );
}
t.end();
});

tape( '`+-0` raised to `-infinity` is `+infinity`', function test( t ) {
var v;

Expand Down
20 changes: 20 additions & 0 deletions lib/node_modules/@stdlib/math/base/special/pow/test/test.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,26 @@ tape( '`-1` raised to any odd integer is `-1`', opts, function test( t ) {
t.end();
});

tape( '`-1` raised to any even integer is `1`', opts, function test( t ) {
var values;
var i;

values = [
-1.0e300,
-3.6893488147419103e19,
-9007199254740994.0,
-2.0,
2.0,
9007199254740994.0,
3.6893488147419103e19,
1.0e300
];
for ( i = 0; i < values.length; i++ ) {
t.strictEqual( pow( -1.0, values[ i ] ), 1.0, 'returns expected value' );
}
t.end();
});

tape( '`+-0` raised to `-infinity` is `+infinity`', opts, function test( t ) {
var v;

Expand Down
Loading