Skip to content

Commit

Permalink
fix: add review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
steff456 committed Jul 18, 2023
1 parent 28ef98c commit b692d3b
Show file tree
Hide file tree
Showing 10 changed files with 124 additions and 123 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand All @@ -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' );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -43,7 +43,7 @@ var opts = {

bench( pkg+'::native', opts, function benchmark( b ) {
var values;
var out;
var y;
var z;
var i;

Expand All @@ -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' );
Expand Down
6 changes: 3 additions & 3 deletions lib/node_modules/@stdlib/math/base/special/ccis/docs/repl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) )
<Complex128>
> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand All @@ -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 );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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
8 changes: 4 additions & 4 deletions lib/node_modules/@stdlib/math/base/special/ccis/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand Down Expand Up @@ -79,16 +79,16 @@ 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 );
tmp *= e;
out[ 1 ] *= e;
}
out[ 0 ] = out[ 1 ];
out[ 1 ] = tmp;
return new Complex128( out[ 0 ], out[ 1 ] );
return new Complex128( out[ 0 ], tmp );
}


Expand Down
154 changes: 77 additions & 77 deletions lib/node_modules/@stdlib/math/base/special/ccis/manifest.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
]
}
29 changes: 14 additions & 15 deletions lib/node_modules/@stdlib/math/base/special/ccis/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
12 changes: 6 additions & 6 deletions lib/node_modules/@stdlib/math/base/special/ccis/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 ) );
Expand All @@ -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 ) );
Expand All @@ -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 ) );
Expand Down
Loading

0 comments on commit b692d3b

Please sign in to comment.