Skip to content

Commit 57eb7c9

Browse files
committed
chore: apply suggestions from reviewa
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 9e4dbbb commit 57eb7c9

File tree

3 files changed

+23
-25
lines changed

3 files changed

+23
-25
lines changed

lib/node_modules/@stdlib/math/base/special/cinvf/README.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,20 +76,18 @@ var im = imagf( v );
7676
<!-- eslint no-undef: "error" -->
7777

7878
```javascript
79-
var Complex64 = require( '@stdlib/complex/float32/ctor' );
79+
var Complex64 = require( '@stdlib/complex/float64/ctor' );
8080
var uniform = require( '@stdlib/random/base/uniform' );
81+
var filledarrayBy = require( '@stdlib/array/filled-by' );
82+
var logEachMap = require( '@stdlib/console/log-each-map' );
8183
var cinvf = require( '@stdlib/math/base/special/cinvf' );
8284

83-
var z1;
84-
var z2;
85-
var i;
86-
87-
for ( i = 0; i < 100; i++ ) {
88-
z1 = new Complex64( uniform( -50.0, 50.0 ), uniform( -50.0, 50.0 ) );
89-
z2 = cinvf( z1 );
90-
91-
console.log( '1.0 / (%s) = %s', z1.toString(), z2.toString() );
85+
function clbk() {
86+
return new Complex64( uniform( -50.0, 50.0 ), uniform( -50.0, 50.0 ) );
9287
}
88+
var arr = filledarrayBy( 100, 'complex64', clbk );
89+
90+
logEachMap( '1.0 / (%s) = %s', arr, cinvf );
9391
```
9492

9593
</section>

lib/node_modules/@stdlib/math/base/special/cinvf/examples/index.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,13 @@
2020

2121
var Complex64 = require( '@stdlib/complex/float64/ctor' );
2222
var uniform = require( '@stdlib/random/base/uniform' );
23+
var filledarrayBy = require( '@stdlib/array/filled-by' );
24+
var logEachMap = require( '@stdlib/console/log-each-map' );
2325
var cinvf = require( './../lib' );
2426

25-
var z1;
26-
var z2;
27-
var i;
28-
29-
for ( i = 0; i < 100; i++ ) {
30-
z1 = new Complex64( uniform( -50.0, 50.0 ), uniform( -50.0, 50.0 ) );
31-
z2 = cinvf( z1 );
32-
33-
console.log( '1.0 / (%s) = %s', z1.toString(), z2.toString() );
27+
function clbk() {
28+
return new Complex64( uniform( -50.0, 50.0 ), uniform( -50.0, 50.0 ) );
3429
}
30+
var arr = filledarrayBy( 100, 'complex64', clbk );
31+
32+
logEachMap( '1.0 / (%s) = %s', arr, cinvf );

lib/node_modules/@stdlib/math/base/special/cinvf/lib/main.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ var imagf = require( '@stdlib/complex/float32/imag' );
3333

3434
// VARIABLES //
3535

36+
var ONE = f32( 1.0 );
37+
var HALF = f32( 0.5 );
3638
var LARGE_THRESHOLD = f32( FLOAT32_BIGGEST * f32( 0.5 ) );
3739
var SMALL_THRESHOLD = f32( FLOAT32_SMALLEST * f32( f32(2.0)/EPS ) );
3840
var RECIP_EPS_SQR = f32( f32(2.0) / f32(EPS*EPS) );
@@ -75,24 +77,24 @@ function cinvf( z ) {
7577
re = realf( z );
7678
im = imagf( z );
7779
ab = maxf( absf(re), absf(im) );
78-
s = f32( 1.0 );
80+
s = ONE;
7981
if ( ab >= LARGE_THRESHOLD ) {
80-
re = f32( re * f32( 0.5 ) );
81-
im = f32( im * f32( 0.5 ) );
82-
s = f32( s * f32( 0.5 ) );
82+
re = f32( re * HALF );
83+
im = f32( im * HALF );
84+
s = f32( s * HALF );
8385
} else if ( ab <= SMALL_THRESHOLD ) {
8486
re = f32( re * RECIP_EPS_SQR );
8587
im = f32( im * RECIP_EPS_SQR );
8688
s = f32( s * RECIP_EPS_SQR );
8789
}
8890
if ( absf( im ) <= absf( re ) ) {
8991
r = f32( im / re );
90-
t = f32( f32( 1.0 ) / f32( re + f32(im*r) ) );
92+
t = f32( ONE / f32( re + f32(im*r) ) );
9193
re = t;
9294
im = f32( -r * t );
9395
} else {
9496
r = f32( re / im );
95-
t = f32( f32( 1.0 ) / f32( im + f32(re*r) ) );
97+
t = f32( ONE / f32( im + f32(re*r) ) );
9698
re = f32( r * t );
9799
im = -t;
98100
}

0 commit comments

Comments
 (0)