Skip to content
Draft
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
33 changes: 6 additions & 27 deletions lib/node_modules/@stdlib/math/base/special/rempio2f/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@ var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
var incrspace = require( '@stdlib/array/base/incrspace' );
var linspace = require( '@stdlib/array/base/linspace' );
var randu = require( '@stdlib/random/base/randu' );
var absf = require( '@stdlib/math/base/special/absf' );
var pow = require( '@stdlib/math/base/special/pow' );
var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' );
var EPS = require( '@stdlib/constants/float32/eps' );
var isAlmostSameValue = require( '@stdlib/number/float32/base/assert/is-almost-same-value' );
var PINF = require( '@stdlib/constants/float32/pinf' );
var NINF = require( '@stdlib/constants/float32/ninf' );
var PIO2 = require( '@stdlib/constants/float32/half-pi' );
Expand Down Expand Up @@ -68,8 +67,6 @@ tape( 'the function returns `0` and sets `y[0]` to `NaN` if provided positive or
});

tape( 'the function returns `n` and stores `r` as a double-precision floating point number in `y` such that `x - nπ/2 = r` (positive)', function test( t ) {
var delta;
var tol;
var x;
var y;
var z;
Expand All @@ -85,16 +82,12 @@ tape( 'the function returns `n` and stores `r` as a double-precision floating po
t.strictEqual( isNumber( y[ 0 ] ), true, 'returns expected value' );

z = float64ToFloat32( ( PIO2*n ) + ( y[0] ) );
delta = absf( z - x );
tol = EPS * absf( x );
t.ok( delta <= tol, 'within tolerance. x: '+x+'. n: '+n+'. y: '+y+'. z: '+z+'. delta: '+delta+'. tol: '+tol+'.' );
t.strictEqual( isAlmostSameValue( z, x, 1 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the function returns `n` and stores `r` as a double-precision floating point number in `y` such that `x - nπ/2 = r` (tiny positive)', function test( t ) {
var delta;
var tol;
var x;
var y;
var z;
Expand All @@ -110,16 +103,12 @@ tape( 'the function returns `n` and stores `r` as a double-precision floating po
t.strictEqual( isNumber( y[0] ), true, 'returns expected value' );

z = float64ToFloat32( ( PIO2*n ) + ( y[0] ) );
delta = absf( z - x );
tol = EPS * absf( x );
t.ok( delta <= tol, 'within tolerance. x: '+x+'. n: '+n+'. y: '+y+'. z: '+z+'. delta: '+delta+'. tol: '+tol+'.' );
t.strictEqual( z, x, 'returns expected value' );
}
t.end();
});

tape( 'the function returns `n` and stores `r` as a double-precision floating point number in `y` such that `x - nπ/2 = r` (negative)', function test( t ) {
var delta;
var tol;
var x;
var y;
var z;
Expand All @@ -135,16 +124,12 @@ tape( 'the function returns `n` and stores `r` as a double-precision floating po
t.strictEqual( isNumber( y[0] ), true, 'returns expected value' );

z = float64ToFloat32( ( PIO2*n ) + ( y[0] ) );
delta = absf( z - x );
tol = EPS * absf( x );
t.ok( delta <= tol, 'within tolerance. x: '+x+'. n: '+n+'. y: '+y+'. z: '+z+'. delta: '+delta+'. tol: '+tol+'.' );
t.strictEqual( isAlmostSameValue( z, x, 1 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the function returns `n` and stores `r` as a double-precision floating point number in `y` such that `x - nπ/2 = r` (tiny negative)', function test( t ) {
var delta;
var tol;
var x;
var y;
var z;
Expand All @@ -160,16 +145,12 @@ tape( 'the function returns `n` and stores `r` as a double-precision floating po
t.strictEqual( isNumber( y[0] ), true, 'returns expected value' );

z = float64ToFloat32( ( PIO2*n ) + ( y[0] ) );
delta = absf( z - x );
tol = EPS * absf( x );
t.ok( delta <= tol, 'within tolerance. x: '+x+'. n: '+n+'. y: '+y+'. z: '+z+'. delta: '+delta+'. tol: '+tol+'.' );
t.strictEqual( z, x, 'returns expected value' );
}
t.end();
});

tape( 'the function returns `n` and stores `r` as a double-precision floating point number in `y` such that `x - nπ/2 = r` (multiples of π/4)', function test( t ) {
var delta;
var tol;
var x;
var y;
var z;
Expand All @@ -186,9 +167,7 @@ tape( 'the function returns `n` and stores `r` as a double-precision floating po
t.strictEqual( isNumber( y[0] ), true, 'returns expected value' );

z = float64ToFloat32( ( PIO2*n ) + ( y[0] ) );
delta = absf( z - x[i] );
tol = EPS * absf( x[i] );
t.ok( delta <= tol, 'within tolerance. x: '+x+'. n: '+n+'. y: '+y+'. z: '+z+'. delta: '+delta+'. tol: '+tol+'.' );
t.strictEqual( isAlmostSameValue( z, x[ i ], 1 ), true, 'returns expected value' );
}
t.end();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@ var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
var incrspace = require( '@stdlib/array/base/incrspace' );
var linspace = require( '@stdlib/array/base/linspace' );
var randu = require( '@stdlib/random/base/randu' );
var absf = require( '@stdlib/math/base/special/absf' );
var pow = require( '@stdlib/math/base/special/pow' );
var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' );
var EPS = require( '@stdlib/constants/float32/eps' );
var isAlmostSameValue = require( '@stdlib/number/float32/base/assert/is-almost-same-value' );
var PINF = require( '@stdlib/constants/float32/pinf' );
var NINF = require( '@stdlib/constants/float32/ninf' );
var PIO2 = require( '@stdlib/constants/float32/half-pi' );
Expand Down Expand Up @@ -78,8 +77,6 @@ tape( 'the function returns `0` and sets `y[0]` to `NaN` if provided positive or
});

tape( 'the function returns `n` and stores `r` as a double-precision floating point number in `y` such that `x - nπ/2 = r` (positive)', opts, function test( t ) {
var delta;
var tol;
var x;
var y;
var z;
Expand All @@ -95,16 +92,12 @@ tape( 'the function returns `n` and stores `r` as a double-precision floating po
t.strictEqual( isNumber( y[ 0 ] ), true, 'returns expected value' );

z = float64ToFloat32( ( PIO2*n ) + ( y[0] ) );
delta = absf( z - x );
tol = EPS * absf( x );
t.ok( delta <= tol, 'within tolerance. x: '+x+'. n: '+n+'. y: '+y+'. z: '+z+'. delta: '+delta+'. tol: '+tol+'.' );
t.strictEqual( isAlmostSameValue( z, x, 1 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the function returns `n` and stores `r` as a double-precision floating point number in `y` such that `x - nπ/2 = r` (tiny positive)', opts, function test( t ) {
var delta;
var tol;
var x;
var y;
var z;
Expand All @@ -120,16 +113,12 @@ tape( 'the function returns `n` and stores `r` as a double-precision floating po
t.strictEqual( isNumber( y[0] ), true, 'returns expected value' );

z = float64ToFloat32( ( PIO2*n ) + ( y[0] ) );
delta = absf( z - x );
tol = EPS * absf( x );
t.ok( delta <= tol, 'within tolerance. x: '+x+'. n: '+n+'. y: '+y+'. z: '+z+'. delta: '+delta+'. tol: '+tol+'.' );
t.strictEqual( z, x, 'returns expected value' );
}
t.end();
});

tape( 'the function returns `n` and stores `r` as a double-precision floating point number in `y` such that `x - nπ/2 = r` (negative)', opts, function test( t ) {
var delta;
var tol;
var x;
var y;
var z;
Expand All @@ -145,16 +134,12 @@ tape( 'the function returns `n` and stores `r` as a double-precision floating po
t.strictEqual( isNumber( y[0] ), true, 'returns expected value' );

z = float64ToFloat32( ( PIO2*n ) + ( y[0] ) );
delta = absf( z - x );
tol = EPS * absf( x );
t.ok( delta <= tol, 'within tolerance. x: '+x+'. n: '+n+'. y: '+y+'. z: '+z+'. delta: '+delta+'. tol: '+tol+'.' );
t.strictEqual( isAlmostSameValue( z, x, 1 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the function returns `n` and stores `r` as a double-precision floating point number in `y` such that `x - nπ/2 = r` (tiny negative)', opts, function test( t ) {
var delta;
var tol;
var x;
var y;
var z;
Expand All @@ -170,16 +155,12 @@ tape( 'the function returns `n` and stores `r` as a double-precision floating po
t.strictEqual( isNumber( y[0] ), true, 'returns expected value' );

z = float64ToFloat32( ( PIO2*n ) + ( y[0] ) );
delta = absf( z - x );
tol = EPS * absf( x );
t.ok( delta <= tol, 'within tolerance. x: '+x+'. n: '+n+'. y: '+y+'. z: '+z+'. delta: '+delta+'. tol: '+tol+'.' );
t.strictEqual( z, x, 'returns expected value' );
}
t.end();
});

tape( 'the function returns `n` and stores `r` as a double-precision floating point number in `y` such that `x - nπ/2 = r` (multiples of π/4)', opts, function test( t ) {
var delta;
var tol;
var x;
var y;
var z;
Expand All @@ -196,9 +177,7 @@ tape( 'the function returns `n` and stores `r` as a double-precision floating po
t.strictEqual( isNumber( y[0] ), true, 'returns expected value' );

z = float64ToFloat32( ( PIO2*n ) + ( y[0] ) );
delta = absf( z - x[i] );
tol = EPS * absf( x[i] );
t.ok( delta <= tol, 'within tolerance. x: '+x+'. n: '+n+'. y: '+y+'. z: '+z+'. delta: '+delta+'. tol: '+tol+'.' );
t.strictEqual( isAlmostSameValue( z, x[ i ], 1 ), true, 'returns expected value' );
}
t.end();
});
Expand Down