From b692d3b9e365156e0378973ad8f41c62671e8a9c Mon Sep 17 00:00:00 2001 From: Stephannie Jimenez Date: Tue, 18 Jul 2023 17:14:59 -0500 Subject: [PATCH] fix: add review changes --- .../base/special/ccis/benchmark/benchmark.js | 6 +- .../ccis/benchmark/benchmark.native.js | 12 +- .../math/base/special/ccis/docs/repl.txt | 6 +- .../math/base/special/ccis/docs/types/test.ts | 4 +- .../include/stdlib/math/base/special/ccis.h | 6 +- .../math/base/special/ccis/lib/main.js | 8 +- .../math/base/special/ccis/manifest.json | 154 +++++++++--------- .../@stdlib/math/base/special/ccis/src/main.c | 29 ++-- .../math/base/special/ccis/test/test.js | 12 +- .../base/special/ccis/test/test.native.js | 10 +- 10 files changed, 124 insertions(+), 123 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/ccis/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/ccis/benchmark/benchmark.js index 88195181cb5..ff972e84908 100644 --- a/lib/node_modules/@stdlib/math/base/special/ccis/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/ccis/benchmark/benchmark.js @@ -23,6 +23,8 @@ var bench = require( '@stdlib/bench' ); var uniform = require( '@stdlib/random/base/uniform' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var real = require( '@stdlib/complex/real' ); +var imag = require( '@stdlib/complex/imag' ); var Complex128 = require( '@stdlib/complex/float64' ); var pkg = require( './../package.json' ).name; var ccis = require( './../lib' ); @@ -43,12 +45,12 @@ bench( pkg, function benchmark( b ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { y = ccis( values[ i%values.length ] ); - if ( isnan( y ) ) { + if ( isnan( real( y ) ) ) { b.fail( 'should not return NaN' ); } } b.toc(); - if ( isnan( y ) ) { + if ( isnan( imag( y ) ) ) { b.fail( 'should not return NaN' ); } b.pass( 'benchmark finished' ); diff --git a/lib/node_modules/@stdlib/math/base/special/ccis/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/ccis/benchmark/benchmark.native.js index 418b8265913..0dc08d0beb2 100644 --- a/lib/node_modules/@stdlib/math/base/special/ccis/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/math/base/special/ccis/benchmark/benchmark.native.js @@ -24,9 +24,9 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); var uniform = require( '@stdlib/random/base/uniform' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var Complex128 = require( '@stdlib/complex/float64' ); var real = require( '@stdlib/complex/real' ); var imag = require( '@stdlib/complex/imag' ); +var Complex128 = require( '@stdlib/complex/float64' ); var tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; @@ -43,7 +43,7 @@ var opts = { bench( pkg+'::native', opts, function benchmark( b ) { var values; - var out; + var y; var z; var i; @@ -55,13 +55,13 @@ bench( pkg+'::native', opts, function benchmark( b ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { z = values[ i%values.length ]; - out = ccis( z ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); + y = ccis( z ); + if ( isnan( real( y ) ) ) { + b.fail( 'should not return NaN' ); } } b.toc(); - if ( isnan( real( out ) ) || isnan( imag( out ) ) ) { + if ( isnan( imag( y ) ) ) { b.fail( 'should not return NaN' ); } b.pass( 'benchmark finished' ); diff --git a/lib/node_modules/@stdlib/math/base/special/ccis/docs/repl.txt b/lib/node_modules/@stdlib/math/base/special/ccis/docs/repl.txt index a7136da2713..6d407160fc1 100644 --- a/lib/node_modules/@stdlib/math/base/special/ccis/docs/repl.txt +++ b/lib/node_modules/@stdlib/math/base/special/ccis/docs/repl.txt @@ -21,11 +21,11 @@ 1.0 > var im = {{alias:@stdlib/complex/imag}}( y ) 0.0 - > var out = {{alias}}( new {{alias:@stdlib/complex/float64}}( 1.0, 0.0 ) ) + > y = {{alias}}( new {{alias:@stdlib/complex/float64}}( 1.0, 0.0 ) ) - > re = {{alias:@stdlib/complex/real}}( out ) + > re = {{alias:@stdlib/complex/real}}( y ) ~0.540 - > im = {{alias:@stdlib/complex/imag}}( out ) + > im = {{alias:@stdlib/complex/imag}}( y ) ~0.841 See Also diff --git a/lib/node_modules/@stdlib/math/base/special/ccis/docs/types/test.ts b/lib/node_modules/@stdlib/math/base/special/ccis/docs/types/test.ts index aa009fca62f..77fcd66cfc6 100644 --- a/lib/node_modules/@stdlib/math/base/special/ccis/docs/types/test.ts +++ b/lib/node_modules/@stdlib/math/base/special/ccis/docs/types/test.ts @@ -22,7 +22,7 @@ import ccis = require( './index' ); // TESTS // -// The function returns a double-precision complex floating-point number. +// The function returns a double-precision complex floating-point number... { const z = new Complex128( 1.0, 1.0 ); @@ -41,7 +41,7 @@ import ccis = require( './index' ); ccis( ( x: number ): number => x ); // $ExpectError } -// The compiler throws an error if the function is provided insufficient arguments... +// The compiler throws an error if the function is provided an unsupported number of arguments... { const z = new Complex128( 1.0, 1.0 ); diff --git a/lib/node_modules/@stdlib/math/base/special/ccis/include/stdlib/math/base/special/ccis.h b/lib/node_modules/@stdlib/math/base/special/ccis/include/stdlib/math/base/special/ccis.h index b61a50cc7b5..d0a946cbb2e 100644 --- a/lib/node_modules/@stdlib/math/base/special/ccis/include/stdlib/math/base/special/ccis.h +++ b/lib/node_modules/@stdlib/math/base/special/ccis/include/stdlib/math/base/special/ccis.h @@ -16,8 +16,8 @@ * limitations under the License. */ -#ifndef STDLIB_MATH_BASE_OPS_CCIS_H -#define STDLIB_MATH_BASE_OPS_CCIS_H +#ifndef STDLIB_MATH_BASE_SPECIAL_CCIS_H +#define STDLIB_MATH_BASE_SPECIAL_CCIS_H #include "stdlib/complex/float64.h" @@ -37,4 +37,4 @@ stdlib_complex128_t stdlib_base_ccis( const stdlib_complex128_t z ); } #endif -#endif // !STDLIB_MATH_BASE_OPS_CCIS_H +#endif // !STDLIB_MATH_BASE_SPECIAL_CCIS_H diff --git a/lib/node_modules/@stdlib/math/base/special/ccis/lib/main.js b/lib/node_modules/@stdlib/math/base/special/ccis/lib/main.js index 011fff3aaaa..130200dad97 100644 --- a/lib/node_modules/@stdlib/math/base/special/ccis/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/ccis/lib/main.js @@ -20,7 +20,7 @@ // MODULES // -var sincos = require( '@stdlib/math/base/special/sincos' ); +var sincos = require( '@stdlib/math/base/special/sincos' ).assign; var exp = require( '@stdlib/math/base/special/exp' ); var Complex128 = require( '@stdlib/complex/float64' ); var real = require( '@stdlib/complex/real' ); @@ -79,7 +79,8 @@ function ccis( z ) { re = real( z ); im = imag( z ); - out = sincos( re ); + out = [ 0.0, 0.0 ]; + sincos( re, out, 1, 0 ); tmp = out[ 0 ]; if ( im !== 0.0 ) { e = exp( -im ); @@ -87,8 +88,7 @@ function ccis( z ) { out[ 1 ] *= e; } out[ 0 ] = out[ 1 ]; - out[ 1 ] = tmp; - return new Complex128( out[ 0 ], out[ 1 ] ); + return new Complex128( out[ 0 ], tmp ); } diff --git a/lib/node_modules/@stdlib/math/base/special/ccis/manifest.json b/lib/node_modules/@stdlib/math/base/special/ccis/manifest.json index 51828ebe4dd..40172d7d058 100644 --- a/lib/node_modules/@stdlib/math/base/special/ccis/manifest.json +++ b/lib/node_modules/@stdlib/math/base/special/ccis/manifest.json @@ -1,78 +1,78 @@ { - "options": { - "task": "build" - }, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "task": "build", - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [ - "@stdlib/math/base/napi/unary", - "@stdlib/complex/float64", - "@stdlib/complex/reim", - "@stdlib/math/base/special/exp" - ] - }, - { - "task": "benchmark", - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [ - "@stdlib/complex/float64", - "@stdlib/complex/reim", - "@stdlib/math/base/special/exp" - ] - }, - { - "task": "examples", - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [ - "@stdlib/complex/float64", - "@stdlib/complex/reim", - "@stdlib/math/base/special/exp" - ] - } - ] - } + "options": { + "task": "build" + }, + "fields": [ + { + "field": "src", + "resolve": true, + "relative": true + }, + { + "field": "include", + "resolve": true, + "relative": true + }, + { + "field": "libraries", + "resolve": false, + "relative": false + }, + { + "field": "libpath", + "resolve": true, + "relative": false + } + ], + "confs": [ + { + "task": "build", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/napi/unary", + "@stdlib/complex/float64", + "@stdlib/complex/reim", + "@stdlib/math/base/special/exp" + ] + }, + { + "task": "benchmark", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/complex/float64", + "@stdlib/complex/reim", + "@stdlib/math/base/special/exp" + ] + }, + { + "task": "examples", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/complex/float64", + "@stdlib/complex/reim", + "@stdlib/math/base/special/exp" + ] + } + ] +} diff --git a/lib/node_modules/@stdlib/math/base/special/ccis/src/main.c b/lib/node_modules/@stdlib/math/base/special/ccis/src/main.c index 82dc1324682..03ef7450a64 100644 --- a/lib/node_modules/@stdlib/math/base/special/ccis/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/ccis/src/main.c @@ -60,24 +60,23 @@ * // returns ~0.841 */ stdlib_complex128_t stdlib_base_ccis( const stdlib_complex128_t z ) { - double tmp; + double tmp; double re; double im; - double y; - double x; - double e; + double y; + double x; + double e; stdlib_reim( z, &re, &im ); - y = sin( re ); //TODO: use stdlib function once available - x = cos( re ); //TODO: use stdlib function once available - tmp = y; - if( im != 0.0 ){ - e = stdlib_base_exp( -im ); - tmp *= e; - x *= e; - } - y = x; - x = tmp; - return stdlib_complex128( y, x ); + y = sin( re ); //TODO: use stdlib function once available + x = cos( re ); //TODO: use stdlib function once available + tmp = y; + if( im != 0.0 ){ + e = stdlib_base_exp( -im ); + tmp *= e; + x *= e; + } + y = x; + return stdlib_complex128( y, tmp ); } diff --git a/lib/node_modules/@stdlib/math/base/special/ccis/test/test.js b/lib/node_modules/@stdlib/math/base/special/ccis/test/test.js index 3977ead19af..b11232c2010 100644 --- a/lib/node_modules/@stdlib/math/base/special/ccis/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/ccis/test/test.js @@ -46,7 +46,7 @@ tape( 'main export is a function', function test( t ) { t.end(); }); -tape( 'the function works without output array specified', function test( t ) { +tape( 'the function evaluates the cis function for a double-precision complex floating-point number', function test( t ) { var v; var z; @@ -59,7 +59,7 @@ tape( 'the function works without output array specified', function test( t ) { t.end(); }); -tape( 'the function computes ccis(z) for pure real z', function test( t ) { +tape( 'the function computes cis(z) for pure real z', function test( t ) { var delta; var cisre; var cisim; @@ -97,7 +97,7 @@ tape( 'the function computes ccis(z) for pure real z', function test( t ) { t.end(); }); -tape( 'the function computes ccis(z) for complex z', function test( t ) { +tape( 'the function computes cis(z) for complex z', function test( t ) { var delta; var cisre; var cisim; @@ -135,7 +135,7 @@ tape( 'the function computes ccis(z) for complex z', function test( t ) { t.end(); }); -tape( 'if real component is `+Infinity`, the function returns `[NaN, NaN]`', function test( t ) { +tape( 'if real component is `+Infinity`, all components are `NaN`', function test( t ) { var v; v = ccis( new Complex128( PINF, 0.0 ) ); @@ -144,7 +144,7 @@ tape( 'if real component is `+Infinity`, the function returns `[NaN, NaN]`', fun t.end(); }); -tape( 'if real component is `-Infinity`, the function returns `[NaN, NaN]`', function test( t ) { +tape( 'if real component is `-Infinity`, all components are `NaN`', function test( t ) { var v; v = ccis( new Complex128( NINF, 0.0 ) ); @@ -153,7 +153,7 @@ tape( 'if real component is `-Infinity`, the function returns `[NaN, NaN]`', fun t.end(); }); -tape( 'if imaginary component is `+Infinity`, the function returns `[0.0, 0.0]`', function test( t ) { +tape( 'if imaginary component is `+Infinity`, all components are zero', function test( t ) { var v; v = ccis( new Complex128( 1.0, PINF ) ); diff --git a/lib/node_modules/@stdlib/math/base/special/ccis/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/ccis/test/test.native.js index 45ecad35292..a7dd2d94338 100644 --- a/lib/node_modules/@stdlib/math/base/special/ccis/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/ccis/test/test.native.js @@ -68,7 +68,7 @@ tape( 'the function works without output array specified', opts, function test( t.end(); }); -tape( 'the function computes ccis(z) for pure real z', opts, function test( t ) { +tape( 'the function computes cis(z) for pure real z', opts, function test( t ) { var delta; var cisre; var cisim; @@ -106,7 +106,7 @@ tape( 'the function computes ccis(z) for pure real z', opts, function test( t ) t.end(); }); -tape( 'the function computes ccis(z) for complex z', opts, function test( t ) { +tape( 'the function computes cis(z) for complex z', opts, function test( t ) { var delta; var cisre; var cisim; @@ -144,7 +144,7 @@ tape( 'the function computes ccis(z) for complex z', opts, function test( t ) { t.end(); }); -tape( 'if real component is `+Infinity`, the function returns `[NaN, NaN]`', opts, function test( t ) { +tape( 'if real component is `+Infinity`, all components are `NaN`', opts, function test( t ) { var v; v = ccis( new Complex128( PINF, 0.0 ) ); @@ -153,7 +153,7 @@ tape( 'if real component is `+Infinity`, the function returns `[NaN, NaN]`', opt t.end(); }); -tape( 'if real component is `-Infinity`, the function returns `[NaN, NaN]`', opts, function test( t ) { +tape( 'if real component is `-Infinity`, all components are `NaN`', opts, function test( t ) { var v; v = ccis( new Complex128( NINF, 0.0 ) ); @@ -162,7 +162,7 @@ tape( 'if real component is `-Infinity`, the function returns `[NaN, NaN]`', opt t.end(); }); -tape( 'if imaginary component is `+Infinity`, the function returns `[0.0, 0.0]`', opts, function test( t ) { +tape( 'if imaginary component is `+Infinity`, all components are zeros', opts, function test( t ) { var v; v = ccis( new Complex128( 1.0, PINF ) );