diff --git a/lib/node_modules/@stdlib/math/base/special/cinvf/test/test.js b/lib/node_modules/@stdlib/math/base/special/cinvf/test/test.js index d234af50d8c2..6481afb4b710 100644 --- a/lib/node_modules/@stdlib/math/base/special/cinvf/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/cinvf/test/test.js @@ -26,6 +26,7 @@ var tape = require( 'tape' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var absf = require( '@stdlib/math/base/special/absf' ); var EPS = require( '@stdlib/constants/float32/eps' ); +var FLOAT32_SMALLEST_NORMAL = require( '@stdlib/constants/float32/smallest-normal' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var real = require( '@stdlib/complex/float32/real' ); var imag = require( '@stdlib/complex/float32/imag' ); @@ -386,6 +387,46 @@ tape( 'the function computes a complex inverse (tiny positive real components)', t.end(); }); +tape( 'the function may produce very large values for very small inputs', function test( t ) { + var huge = 1e37; + var tiny = -1e37; + var v; + + v = cinvf( new Complex64( FLOAT32_SMALLEST_NORMAL, FLOAT32_SMALLEST_NORMAL ) ); + t.ok( real( v ) > huge, 'real component is very large' ); + t.ok( imag( v ) < tiny, 'imaginary component is very large and negative' ); + + v = cinvf( new Complex64( -FLOAT32_SMALLEST_NORMAL, FLOAT32_SMALLEST_NORMAL ) ); + t.ok( real( v ) < tiny, 'real component is very large and negative' ); + t.ok( imag( v ) < tiny, 'imaginary component is very large and negative' ); + + v = cinvf( new Complex64( -FLOAT32_SMALLEST_NORMAL, -FLOAT32_SMALLEST_NORMAL ) ); + t.ok( real( v ) < tiny, 'real component is very large and negative' ); + t.ok( imag( v ) > huge, 'imaginary component is very large and positive' ); + + v = cinvf( new Complex64( FLOAT32_SMALLEST_NORMAL, -FLOAT32_SMALLEST_NORMAL ) ); + t.ok( real( v ) > huge, 'real component is very large and positive' ); + t.ok( imag( v ) > huge, 'imaginary component is very large and positive' ); + + v = cinvf( new Complex64( 0.0, FLOAT32_SMALLEST_NORMAL ) ); + t.strictEqual( real( v ), 0.0, 'real component is 0' ); + t.ok( imag( v ) < tiny, 'imaginary component is very large and negative' ); + + v = cinvf( new Complex64( 0.0, -FLOAT32_SMALLEST_NORMAL ) ); + t.strictEqual( real( v ), 0.0, 'real component is 0' ); + t.ok( imag( v ) > huge, 'imaginary component is very large and positive' ); + + v = cinvf( new Complex64( FLOAT32_SMALLEST_NORMAL, 0.0 ) ); + t.ok( real( v ) > huge, 'real component is very large and positive' ); + t.strictEqual( imag( v ), 0.0, 'imaginary component is 0' ); + + v = cinvf( new Complex64( -FLOAT32_SMALLEST_NORMAL, 0.0 ) ); + t.ok( real( v ) < tiny, 'real component is very large and negative' ); + t.strictEqual( imag( v ), 0.0, 'imaginary component is 0' ); + + t.end(); +}); + tape( 'if a real or imaginary component is `NaN`, all components are `NaN`', function test( t ) { var v; diff --git a/lib/node_modules/@stdlib/math/base/special/cinvf/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/cinvf/test/test.native.js index 78ea840dc701..8029ab25adac 100644 --- a/lib/node_modules/@stdlib/math/base/special/cinvf/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/cinvf/test/test.native.js @@ -27,6 +27,7 @@ var tape = require( 'tape' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var absf = require( '@stdlib/math/base/special/absf' ); var EPS = require( '@stdlib/constants/float32/eps' ); +var FLOAT32_SMALLEST_NORMAL = require( '@stdlib/constants/float32/smallest-normal' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var real = require( '@stdlib/complex/float32/real' ); var imag = require( '@stdlib/complex/float32/imag' ); @@ -395,6 +396,46 @@ tape( 'the function computes a complex inverse (tiny positive real components)', t.end(); }); +tape( 'the function may produce very large values for very small inputs', opts, function test( t ) { + var huge = 1e37; + var tiny = -1e37; + var v; + + v = cinvf( new Complex64( FLOAT32_SMALLEST_NORMAL, FLOAT32_SMALLEST_NORMAL ) ); + t.ok( real( v ) > huge, 'real component is very large' ); + t.ok( imag( v ) < tiny, 'imaginary component is very large and negative' ); + + v = cinvf( new Complex64( -FLOAT32_SMALLEST_NORMAL, FLOAT32_SMALLEST_NORMAL ) ); + t.ok( real( v ) < tiny, 'real component is very large and negative' ); + t.ok( imag( v ) < tiny, 'imaginary component is very large and negative' ); + + v = cinvf( new Complex64( -FLOAT32_SMALLEST_NORMAL, -FLOAT32_SMALLEST_NORMAL ) ); + t.ok( real( v ) < tiny, 'real component is very large and negative' ); + t.ok( imag( v ) > huge, 'imaginary component is very large and positive' ); + + v = cinvf( new Complex64( FLOAT32_SMALLEST_NORMAL, -FLOAT32_SMALLEST_NORMAL ) ); + t.ok( real( v ) > huge, 'real component is very large and positive' ); + t.ok( imag( v ) > huge, 'imaginary component is very large and positive' ); + + v = cinvf( new Complex64( 0.0, FLOAT32_SMALLEST_NORMAL ) ); + t.strictEqual( real( v ), 0.0, 'real component is 0' ); + t.ok( imag( v ) < tiny, 'imaginary component is very large and negative' ); + + v = cinvf( new Complex64( 0.0, -FLOAT32_SMALLEST_NORMAL ) ); + t.strictEqual( real( v ), 0.0, 'real component is 0' ); + t.ok( imag( v ) > huge, 'imaginary component is very large and positive' ); + + v = cinvf( new Complex64( FLOAT32_SMALLEST_NORMAL, 0.0 ) ); + t.ok( real( v ) > huge, 'real component is very large and positive' ); + t.strictEqual( imag( v ), 0.0, 'imaginary component is 0' ); + + v = cinvf( new Complex64( -FLOAT32_SMALLEST_NORMAL, 0.0 ) ); + t.ok( real( v ) < tiny, 'real component is very large and negative' ); + t.strictEqual( imag( v ), 0.0, 'imaginary component is 0' ); + + t.end(); +}); + tape( 'if a real or imaginary component is `NaN`, all components are `NaN`', opts, function test( t ) { var v;