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 11, 2023
1 parent 122e843 commit 88fa5fd
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 29 deletions.
15 changes: 4 additions & 11 deletions lib/node_modules/@stdlib/math/base/special/cphase/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ limitations under the License.

# phase

> Compute the [argument][complex-number-argument] of a complex number in radians.
> Compute the [argument][complex-number-argument] of a double-precision complex floating-point number in radians.
<section class="intro">

Expand Down Expand Up @@ -61,21 +61,14 @@ var phi = cphase( new Complex128( 5.0, 3.0 ) );

```javascript
var Complex128 = require( '@stdlib/complex/float64' );
var randu = require( '@stdlib/random/base/randu' );
var round = require( '@stdlib/math/base/special/round' );
var real = require( '@stdlib/complex/real' );
var imag = require( '@stdlib/complex/imag' );
var uniform = require( '@stdlib/random/base/uniform' );
var cphase = require( '@stdlib/math/base/special/cphase' );

var re;
var im;
var z;
var i;

for ( i = 0; i < 100; i++ ) {
re = round( randu()*100.0 ) - 50.0;
im = round( randu()*100.0 ) - 50.0;
z = new Complex128( re, im );
z = new Complex128( uniform( -500.0, 500.0 ), uniform( -500.0, 500.0 ) );
console.log( 'arg(%s) = %d', z.toString(), cphase( z ) );
}
```
Expand Down Expand Up @@ -176,7 +169,7 @@ int main( void ) {
y = stdlib_base_cphase( v );
stdlib_reim( v, &re1, &im1 );
stdlib_reim( y, &re2, &im2 );
printf( "cphase(%lf + %lfi) = %lf + %lfi\n", re1, im1, re2, im2 );
printf( "fcphase(%lf + %lfi) = %lf\n", re, im, y );
}
}
```
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

{{alias}}( z )
Computes the argument of a complex number in radians.
Computes the argument of a double-precision complex floating-point number
in radians.

The argument of a complex number, also known as the phase, is the angle of
the radius extending from the origin to the complex number plotted in the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import { Complex128 } from '@stdlib/types/object';

/**
* Computes the argument of a complex number in radians.
* Computes the argument of a double-precision complex floating-point number in radians.
*
* ## Notes
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import cphase = require( './index' );

// TESTS //

// The function returns a number...
// The function returns a double-precision complex floating-point number...
{
cphase( new Complex128( 5.0, 3.0 ) ); // $ExpectType number
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,13 @@
'use strict';

var Complex128 = require( '@stdlib/complex/float64' );
var randu = require( '@stdlib/random/base/randu' );
var round = require( '@stdlib/math/base/special/round' );
var uniform = require( '@stdlib/random/base/uniform' );
var cphase = require( './../lib' );

var re;
var im;
var z;
var i;

for ( i = 0; i < 100; i++ ) {
re = round( randu()*100.0 ) - 50.0;
im = round( randu()*100.0 ) - 50.0;
z = new Complex128( re, im );
z = new Complex128( uniform( -500.0, 500.0 ), uniform( -500.0, 500.0 ) );
console.log( 'arg(%s) = %d', z.toString(), cphase( z ) );
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ extern "C" {
#endif

/**
* Computes the argument of a complex number in radians.
* Computes the argument of a double-precision complex floating-point number in radians.
*/
double stdlib_base_cphase( const stdlib_complex128_t z );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
'use strict';

/**
* Compute the argument of a complex number in radians.
* Compute the argument of a double-precision complex floating-point number in radians.
*
* @module @stdlib/math/base/special/cphase
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,14 @@ var imag = require( '@stdlib/complex/imag' );
// MAIN //

/**
* Computes the argument of a complex number in radians.
* Computes the argument of a double-precision complex floating-point number in radians.
*
* @param {Complex128} z - complex number
* @returns {number} argument
*
* @example
* var Complex128 = require( '@stdlib/complex/float64' );
*
* var phi = cphase( new Complex128( 5.0, 3.0 ) );
* // returns ~0.5404
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var addon = require( './../src/addon.node' );
// MAIN //

/**
* Computes the argument of a complex number in radians.
* Computes the argument of a double-precision complex floating-point number in radians.
*
* @private
* @param {Complex128} z - complex number
Expand Down
4 changes: 2 additions & 2 deletions lib/node_modules/@stdlib/math/base/special/cphase/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <math.h>

/**
* Computes the argument of a complex number in radians.
* Computes the argument of a complex double-precision complex floating-point number in radians.
*
* @param z input value
* @return argument
Expand All @@ -41,5 +41,5 @@ double stdlib_base_cphase( const stdlib_complex128_t z ) {
double im;

stdlib_reim( z, &re, &im );
return atan2( im, re );
return atan2( im, re ); // TODO: replace with stdlib function once available
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,11 @@ var Complex128 = require( '@stdlib/complex/float64' );
* // returns true
*/
function cpolar( out, re, im ) {
out[ 0 ] = cabs( new Complex128( re, im ) );
out[ 1 ] = cphase( new Complex128( re, im ) );
var z;

z = new Complex128( re, im );
out[ 0 ] = cabs( z );
out[ 1 ] = cphase( z );
return out;
}

Expand Down

0 comments on commit 88fa5fd

Please sign in to comment.