Skip to content

Commit aad6304

Browse files
committed
chore: cleaning up
--- 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: na - 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: passed - task: lint_license_headers status: passed ---
1 parent d34d482 commit aad6304

File tree

5 files changed

+59
-73
lines changed

5 files changed

+59
-73
lines changed

lib/node_modules/@stdlib/complex/float64/base/div/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ int main( void ) {
269269

270270
## See Also
271271

272-
- <span class="package-name">[`@stdlib/complex/float64/base/cdiv`][@stdlib/complex/float64/base/cdiv]</span><span class="delimiter">: </span><span class="description">cdiv two double-precision complex floating-point numbers.</span>
272+
- <span class="package-name">[`@stdlib/complex/float64/base/add`][@stdlib/complex/float64/base/add]</span><span class="delimiter">: </span><span class="description">add two double-precision complex floating-point numbers.</span>
273273
- <span class="package-name">[`@stdlib/complex/float64/base/mul`][@stdlib/complex/float64/base/mul]</span><span class="delimiter">: </span><span class="description">multiply two double-precision complex floating-point numbers.</span>
274274
- <span class="package-name">[`@stdlib/complex/float64/base/sub`][@stdlib/complex/float64/base/sub]</span><span class="delimiter">: </span><span class="description">subtract two double-precision complex floating-point numbers.</span>
275275

@@ -291,7 +291,7 @@ int main( void ) {
291291

292292
<!-- <related-links> -->
293293

294-
[@stdlib/complex/float64/base/cdiv]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/base/cdiv
294+
[@stdlib/complex/float64/base/add]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/base/add
295295

296296
[@stdlib/complex/float64/base/mul]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/base/mul
297297

lib/node_modules/@stdlib/complex/float64/base/div/docs/types/test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ import cdiv = require( './index' );
6666
cdiv( z, z, z ); // $ExpectError
6767
}
6868

69-
7069
// Attached to the main export is an `assign` method which returns a collection...
7170
{
7271
cdiv.assign( 1.0, 1.0, 1.0, 1.0, new Float64Array( 2 ), 1, 0 ); // $ExpectType Float64Array

lib/node_modules/@stdlib/complex/float64/base/div/lib/assign.js

Lines changed: 51 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,19 @@
2020

2121
// MODULES //
2222

23-
var Complex128 = require( '@stdlib/complex/float64/ctor' );
24-
var real = require( '@stdlib/complex/float64/real' );
25-
var imag = require( '@stdlib/complex/float64/imag' );
26-
var div = require( './main.js' );
23+
var abs = require( '@stdlib/math/base/special/abs' );
24+
var max = require( '@stdlib/math/base/special/max' );
25+
var FLOAT64_BIGGEST = require( '@stdlib/constants/float64/max' );
26+
var FLOAT64_SMALLEST = require( '@stdlib/constants/float64/smallest-normal' );
27+
var EPS = require( '@stdlib/constants/float64/eps' );
28+
var robustInternal = require( './robust_internal.js' );
29+
30+
31+
// VARIABLES //
32+
33+
var LARGE_THRESHOLD = FLOAT64_BIGGEST * 0.5;
34+
var SMALL_THRESHOLD = FLOAT64_SMALLEST * ( 2.0 / EPS );
35+
var RECIP_EPS_SQR = 2.0 / ( EPS * EPS );
2736

2837

2938
// MAIN //
@@ -47,17 +56,47 @@ var div = require( './main.js' );
4756
* // returns <Float64Array>[ 5.0, 3.0 ]
4857
*/
4958
function assign( re1, im1, re2, im2, out, strideOut, offsetOut ) {
50-
var ans;
51-
var c1;
52-
var c2;
59+
var res;
60+
var ab;
61+
var cd;
62+
var s;
63+
64+
ab = max( abs(re1), abs(im1) );
65+
cd = max( abs(re2), abs(im2) );
66+
s = 1.0;
67+
68+
if ( ab >= LARGE_THRESHOLD ) {
69+
re1 *= 0.5;
70+
im1 *= 0.5;
71+
s *= 2.0;
72+
} else if ( ab <= SMALL_THRESHOLD ) {
73+
re1 *= RECIP_EPS_SQR;
74+
im1 *= RECIP_EPS_SQR;
75+
s /= RECIP_EPS_SQR;
76+
}
77+
if ( cd >= LARGE_THRESHOLD ) {
78+
re2 *= 0.5;
79+
im2 *= 0.5;
80+
s *= 0.5;
81+
} else if ( cd <= SMALL_THRESHOLD ) {
82+
re2 *= RECIP_EPS_SQR;
83+
im2 *= RECIP_EPS_SQR;
84+
s *= RECIP_EPS_SQR;
85+
}
86+
87+
if ( abs( im2 ) <= abs( re2 ) ) {
88+
res = robustInternal( re1, im1, re2, im2 );
89+
} else {
90+
res = robustInternal( im1, re1, im2, re2 );
91+
res[ 1 ] *= -1.0;
92+
}
5393

54-
c1 = new Complex128( re1, im1 );
55-
c2 = new Complex128( re2, im2 );
94+
res[ 0 ] *= s;
95+
res[ 1 ] *= s;
5696

57-
ans = div( c1, c2 );
97+
out[ offsetOut ] = res[ 0 ];
98+
out[ offsetOut+strideOut ] = res[ 1 ];
5899

59-
out[ offsetOut ] = real( ans );
60-
out[ offsetOut+strideOut ] = imag( ans );
61100
return out;
62101
}
63102

lib/node_modules/@stdlib/complex/float64/base/div/lib/main.js

Lines changed: 4 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,16 @@
2020

2121
// MODULES //
2222

23-
var abs = require( '@stdlib/math/base/special/abs' );
24-
var max = require( '@stdlib/math/base/special/max' );
25-
var FLOAT64_BIGGEST = require( '@stdlib/constants/float64/max' );
26-
var FLOAT64_SMALLEST = require( '@stdlib/constants/float64/smallest-normal' );
27-
var EPS = require( '@stdlib/constants/float64/eps' );
2823
var real = require( '@stdlib/complex/float64/real' );
2924
var imag = require( '@stdlib/complex/float64/imag' );
25+
var Float64Array = require( '@stdlib/array/float64' );
3026
var Complex128 = require( '@stdlib/complex/float64/ctor' );
31-
var robustInternal = require( './robust_internal.js' );
27+
var assign = require( './assign.js' );
3228

3329

3430
// VARIABLES //
3531

36-
var LARGE_THRESHOLD = FLOAT64_BIGGEST * 0.5;
37-
var SMALL_THRESHOLD = FLOAT64_SMALLEST * ( 2.0 / EPS );
38-
var RECIP_EPS_SQR = 2.0 / ( EPS * EPS );
32+
var out = new Float64Array( 2 );
3933

4034

4135
// MAIN //
@@ -65,46 +59,14 @@ function cdiv( z1, z2 ) {
6559
var re2;
6660
var im1;
6761
var im2;
68-
var out;
69-
var ab;
70-
var cd;
71-
var s;
7262

7363
re1 = real( z1 );
7464
re2 = real( z2 );
7565
im1 = imag( z1 );
7666
im2 = imag( z2 );
7767

78-
ab = max( abs(re1), abs(im1) );
79-
cd = max( abs(re2), abs(im2) );
80-
s = 1.0;
68+
out = assign( re1, im1, re2, im2, out, 1, 0 );
8169

82-
if ( ab >= LARGE_THRESHOLD ) {
83-
re1 *= 0.5;
84-
im1 *= 0.5;
85-
s *= 2.0;
86-
} else if ( ab <= SMALL_THRESHOLD ) {
87-
re1 *= RECIP_EPS_SQR;
88-
im1 *= RECIP_EPS_SQR;
89-
s /= RECIP_EPS_SQR;
90-
}
91-
if ( cd >= LARGE_THRESHOLD ) {
92-
re2 *= 0.5;
93-
im2 *= 0.5;
94-
s *= 0.5;
95-
} else if ( cd <= SMALL_THRESHOLD ) {
96-
re2 *= RECIP_EPS_SQR;
97-
im2 *= RECIP_EPS_SQR;
98-
s *= RECIP_EPS_SQR;
99-
}
100-
if ( abs( im2 ) <= abs( re2 ) ) {
101-
out = robustInternal( re1, im1, re2, im2 );
102-
} else {
103-
out = robustInternal( im1, re1, im2, re2 );
104-
out[ 1 ] *= -1.0;
105-
}
106-
out[ 0 ] *= s;
107-
out[ 1 ] *= s;
10870
return new Complex128( out[ 0 ], out[ 1 ] );
10971
}
11072

lib/node_modules/@stdlib/complex/float64/base/div/lib/strided.js

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@
2020

2121
// MODULES //
2222

23-
var Complex128 = require( '@stdlib/complex/float64/ctor' );
24-
var real = require( '@stdlib/complex/float64/real' );
25-
var imag = require( '@stdlib/complex/float64/imag' );
26-
var div = require( './main.js' );
23+
var assign = require( './assign.js' );
2724

2825

2926
// MAIN //
@@ -52,18 +49,7 @@ var div = require( './main.js' );
5249
* // returns <Float64Array>[ 5.0, 3.0 ]
5350
*/
5451
function strided( z1, strideZ1, offsetZ1, z2, strideZ2, offsetZ2, out, strideOut, offsetOut ) { // eslint-disable-line max-len
55-
var ans;
56-
var c1;
57-
var c2;
58-
59-
c1 = new Complex128( z1[ offsetZ1 ], z1[ offsetZ1+strideZ1 ] );
60-
c2 = new Complex128( z2[ offsetZ2 ], z2[ offsetZ2+strideZ2 ] );
61-
ans = div( c1, c2 );
62-
63-
out[ offsetOut ] = real( ans );
64-
out[ offsetOut+strideOut ] = imag( ans );
65-
66-
return out;
52+
return assign( z1[ offsetZ1 ], z1[ offsetZ1+strideZ1 ], z2[ offsetZ2 ], z2[ offsetZ2+strideZ2 ], out, strideOut, offsetOut ); // eslint-disable-line max-len
6753
}
6854

6955

0 commit comments

Comments
 (0)