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
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

var ABS_MASK = require( '@stdlib/constants/float32/abs-mask' );
var EXPONENT_MASK = require( '@stdlib/constants/float32/exponent-mask' );
var roundf = require( '@stdlib/math/base/special/roundf' );
var round = require( '@stdlib/math/base/special/round-nearest-even' );
var fromWordf = require( '@stdlib/number/float32/base/from-word' );
var toWordf = require( '@stdlib/number/float32/base/to-word' );
var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' );
Expand Down Expand Up @@ -108,7 +108,7 @@ function rempio2f( x, y ) {

// Case: |x| ~< 2^28*π/2 (medium size)
if ( ix < MEDIUM ) {
n = roundf( float64ToFloat32( x * INVPIO2 ) );
n = round( x * INVPIO2 );
r = x - ( n * PIO2_1 );
w = n * PIO2_1T;
y[ 0 ] = r - w;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"@stdlib/napi/argv-float64array",
"@stdlib/napi/create-double",
"@stdlib/napi/export",
"@stdlib/math/base/special/roundf",
"@stdlib/math/base/special/round-nearest-even",
"@stdlib/math/base/special/floor",
"@stdlib/math/base/special/ldexp",
"@stdlib/number/float32/base/from-word",
Expand All @@ -61,7 +61,7 @@
"libraries": [],
"libpath": [],
"dependencies": [
"@stdlib/math/base/special/roundf",
"@stdlib/math/base/special/round-nearest-even",
"@stdlib/math/base/special/floor",
"@stdlib/math/base/special/ldexp",
"@stdlib/number/float32/base/from-word",
Expand All @@ -81,7 +81,7 @@
"libraries": [],
"libpath": [],
"dependencies": [
"@stdlib/math/base/special/roundf",
"@stdlib/math/base/special/round-nearest-even",
"@stdlib/math/base/special/floor",
"@stdlib/math/base/special/ldexp",
"@stdlib/number/float32/base/from-word",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
*/

#include "stdlib/math/base/special/rempio2f.h"
#include "stdlib/math/base/special/roundf.h"
#include "stdlib/math/base/special/round_nearest_even.h"
#include "stdlib/math/base/special/floor.h"
#include "stdlib/math/base/special/ldexp.h"
#include "stdlib/number/float32/base/from_word.h"
Expand Down Expand Up @@ -413,7 +413,7 @@ int32_t stdlib_base_rempio2f( const float x, double *rem ) {

// Case: |x| ~< 2^28*π/2 (medium size)
if ( ix < MEDIUM ) {
n = stdlib_base_roundf( x * INVPIO2 );
n = stdlib_base_round_nearest_even( x * INVPIO2 );
r = x - ( n * PIO2_1 );
w = n * PIO2_1T;
*rem = r - w;
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,20 @@ gen( x, "medium_negative.json" );
x = Float32.( range( 0.0, stop = 256.0*pi, length = 4000 ) );
gen( x, "medium_positive.json" );

# Positive medium-large values:
x = Float32.( range( 2.0^23*(pi/2.0), stop = 2.0^28*(pi/2.0), length = 4000 ) );
gen( x, "medium_large_positive.json" );

# Negative medium-large values:
x = Float32.( range( -2.0^28*(pi/2.0), stop = -2.0^23*(pi/2.0), length = 4000 ) );
gen( x, "medium_large_negative.json" );

# Negative large values:
x = Float32.( range( -2.0^20*(pi/2.0), stop = -2.0^60*(pi/2.0), length = 4000 ) );
x = Float32.( range( -2.0^28*(pi/2.0), stop = -2.0^60*(pi/2.0), length = 4000 ) );
gen( x, "large_negative.json" );

# Positive large values:
x = Float32.( range( 2.0^20*(pi/2.0), stop = 2.0^60*(pi/2.0), length = 4000 ) );
x = Float32.( range( 2.0^28*(pi/2.0), stop = 2.0^60*(pi/2.0), length = 4000 ) );
gen( x, "large_positive.json" );

# Negative huge values:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ var sincosf = require( './../lib/assign.js' );

var mediumNegative = require( './fixtures/julia/medium_negative.json' );
var mediumPositive = require( './fixtures/julia/medium_positive.json' );
var mediumLargeNegative = require( './fixtures/julia/medium_large_negative.json' );
var mediumLargePositive = require( './fixtures/julia/medium_large_positive.json' );
var largeNegative = require( './fixtures/julia/large_negative.json' );
var largePositive = require( './fixtures/julia/large_positive.json' );
var hugeNegative = require( './fixtures/julia/huge_negative.json' );
Expand Down Expand Up @@ -97,6 +99,56 @@ tape( 'the function computes the sine and cosine (medium positive values)', func
t.end();
});

tape( 'the function computes the sine and cosine (medium-large negative values)', function test( t ) {
var cosine;
var sine;
var x;
var y;
var i;
var z;

z = [ 0.0, 0.0 ];
x = mediumLargeNegative.x;
sine = mediumLargeNegative.sine;
cosine = mediumLargeNegative.cosine;

for ( i = 0; i < x.length; i++ ) {
x[ i ] = f32( x[ i ] );
y = sincosf( x[ i ], z, 1, 0 );
sine[ i ] = f32( sine[ i ] );
cosine[ i ] = f32( cosine[ i ] );
t.strictEqual( y, z, 'returns output array' );
t.strictEqual( y[ 0 ], sine[ i ], 'returns expected value' );
t.strictEqual( y[ 1 ], cosine[ i ], 'returns expected value' );
}
t.end();
});

tape( 'the function computes the sine and cosine (medium-large positive values)', function test( t ) {
var cosine;
var sine;
var x;
var y;
var i;
var z;

z = [ 0.0, 0.0 ];
x = mediumLargePositive.x;
sine = mediumLargePositive.sine;
cosine = mediumLargePositive.cosine;

for ( i = 0; i < x.length; i++ ) {
x[ i ] = f32( x[ i ] );
y = sincosf( x[ i ], z, 1, 0 );
sine[ i ] = f32( sine[ i ] );
cosine[ i ] = f32( cosine[ i ] );
t.strictEqual( y, z, 'returns output array' );
t.strictEqual( y[ 0 ], sine[ i ], 'returns expected value' );
t.strictEqual( y[ 1 ], cosine[ i ], 'returns expected value' );
}
t.end();
});

tape( 'the function computes the sine and cosine (large negative values)', function test( t ) {
var cosine;
var sine;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ var sincosf = require( './../lib/main.js' );

var mediumNegative = require( './fixtures/julia/medium_negative.json' );
var mediumPositive = require( './fixtures/julia/medium_positive.json' );
var mediumLargeNegative = require( './fixtures/julia/medium_large_negative.json' );
var mediumLargePositive = require( './fixtures/julia/medium_large_positive.json' );
var largeNegative = require( './fixtures/julia/large_negative.json' );
var largePositive = require( './fixtures/julia/large_positive.json' );
var hugeNegative = require( './fixtures/julia/huge_negative.json' );
Expand Down Expand Up @@ -90,6 +92,50 @@ tape( 'the function computes the sine and cosine (medium positive values)', func
t.end();
});

tape( 'the function computes the sine and cosine (medium-large negative values)', function test( t ) {
var cosine;
var sine;
var x;
var y;
var i;

x = mediumLargeNegative.x;
sine = mediumLargeNegative.sine;
cosine = mediumLargeNegative.cosine;

for ( i = 0; i < x.length; i++ ) {
x[ i ] = f32( x[ i ] );
y = sincosf( x[ i ] );
sine[ i ] = f32( sine[ i ] );
cosine[ i ] = f32( cosine[ i ] );
t.strictEqual( y[ 0 ], sine[ i ], 'returns expected value' );
t.strictEqual( y[ 1 ], cosine[ i ], 'returns expected value' );
}
t.end();
});

tape( 'the function computes the sine and cosine (medium-large positive values)', function test( t ) {
var cosine;
var sine;
var x;
var y;
var i;

x = mediumLargePositive.x;
sine = mediumLargePositive.sine;
cosine = mediumLargePositive.cosine;

for ( i = 0; i < x.length; i++ ) {
x[ i ] = f32( x[ i ] );
y = sincosf( x[ i ] );
sine[ i ] = f32( sine[ i ] );
cosine[ i ] = f32( cosine[ i ] );
t.strictEqual( y[ 0 ], sine[ i ], 'returns expected value' );
t.strictEqual( y[ 1 ], cosine[ i ], 'returns expected value' );
}
t.end();
});

tape( 'the function computes the sine and cosine (large negative values)', function test( t ) {
var cosine;
var sine;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ var opts = {

var mediumNegative = require( './fixtures/julia/medium_negative.json' );
var mediumPositive = require( './fixtures/julia/medium_positive.json' );
var mediumLargeNegative = require( './fixtures/julia/medium_large_negative.json' );
var mediumLargePositive = require( './fixtures/julia/medium_large_positive.json' );
var largeNegative = require( './fixtures/julia/large_negative.json' );
var largePositive = require( './fixtures/julia/large_positive.json' );
var hugeNegative = require( './fixtures/julia/huge_negative.json' );
Expand Down Expand Up @@ -99,6 +101,50 @@ tape( 'the function computes the sine and cosine (medium positive values)', opts
t.end();
});

tape( 'the function computes the sine and cosine (medium-large negative values)', opts, function test( t ) {
var cosine;
var sine;
var x;
var y;
var i;

x = mediumLargeNegative.x;
sine = mediumLargeNegative.sine;
cosine = mediumLargeNegative.cosine;

for ( i = 0; i < x.length; i++ ) {
x[ i ] = f32( x[ i ] );
y = sincosf( x[ i ] );
sine[ i ] = f32( sine[ i ] );
cosine[ i ] = f32( cosine[ i ] );
t.strictEqual( y[ 0 ], sine[ i ], 'returns expected value' );
t.strictEqual( y[ 1 ], cosine[ i ], 'returns expected value' );
}
t.end();
});

tape( 'the function computes the sine and cosine (medium-large positive values)', opts, function test( t ) {
var cosine;
var sine;
var x;
var y;
var i;

x = mediumLargePositive.x;
sine = mediumLargePositive.sine;
cosine = mediumLargePositive.cosine;

for ( i = 0; i < x.length; i++ ) {
x[ i ] = f32( x[ i ] );
y = sincosf( x[ i ] );
sine[ i ] = f32( sine[ i ] );
cosine[ i ] = f32( cosine[ i ] );
t.strictEqual( y[ 0 ], sine[ i ], 'returns expected value' );
t.strictEqual( y[ 1 ], cosine[ i ], 'returns expected value' );
}
t.end();
});

tape( 'the function computes the sine and cosine (large negative values)', opts, function test( t ) {
var cosine;
var sine;
Expand Down