Skip to content

Commit 710d35e

Browse files
committed
feat: add lapack/base/dladiv2
--- 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: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - 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: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed ---
1 parent 2970a90 commit 710d35e

File tree

10 files changed

+670
-0
lines changed

10 files changed

+670
-0
lines changed
Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
<!--
2+
3+
@license Apache-2.0
4+
5+
Copyright (c) 2025 The Stdlib Authors.
6+
7+
Licensed under the Apache License, Version 2.0 (the "License");
8+
you may not use this file except in compliance with the License.
9+
You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
19+
-->
20+
21+
# dladiv2
22+
23+
> LAPACK routine to perform complex division in a manner which doesn't cause unnecessary overflow.
24+
25+
<section class="usage">
26+
27+
## Usage
28+
29+
```javascript
30+
var dladiv2 = require( '@stdlib/lapack/base/dladiv2' );
31+
```
32+
33+
#### dladiv2( a, b, c, d, r, t )
34+
35+
Performs complex division `A + iB / C + iD` using real double-precision arithmetic.
36+
37+
```javascript
38+
var out = dladiv2( 3.0, 4.0, 1.0, 2.0, 4.0, 5.0 );
39+
// returns 95.0
40+
```
41+
42+
The function has the following parameters:
43+
44+
- **a**: real part of the dividend complex number.
45+
- **b**: imaginary part of the dividend complex number.
46+
- **c**: real part of the divisor complex number.
47+
- **d**: imaginary part of the divisor complex number.
48+
- **r**: represents the ratio of the smaller-magnitude component to the larger-magnitude component of the denominator complex number `C + iD`.
49+
- **t**: scaling factor.
50+
51+
</section>
52+
53+
<!-- /.usage -->
54+
55+
<section class="notes">
56+
57+
## Notes
58+
59+
- `dladiv2()` corresponds to the [LAPACK][LAPACK] function [`dladiv2`][lapack-dladiv2].
60+
61+
</section>
62+
63+
<!-- /.notes -->
64+
65+
<section class="examples">
66+
67+
## Examples
68+
69+
<!-- eslint no-undef: "error" -->
70+
71+
```javascript
72+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
73+
var logEachMap = require( '@stdlib/console/log-each-map' );
74+
var dladiv2 = require( '@stdlib/lapack/base/dladiv2' );
75+
76+
var opts = {
77+
'dtype': 'float64'
78+
};
79+
var a = discreteUniform( 100, -50, 50, opts );
80+
var b = discreteUniform( 100, -50, 50, opts );
81+
var c = discreteUniform( 100, -50, 50, opts );
82+
var d = discreteUniform( 100, -50, 50, opts );
83+
var r = discreteUniform( 100, -50, 50, opts );
84+
var t = discreteUniform( 100, -50, 50, opts );
85+
86+
logEachMap( 'dladiv2( %d, %d, %d, %d, %d, %d ) = %0.4f', a, b, c, d, r, t, dladiv2 );
87+
```
88+
89+
</section>
90+
91+
<!-- /.examples -->
92+
93+
<!-- C interface documentation. -->
94+
95+
* * *
96+
97+
<section class="c">
98+
99+
## C APIs
100+
101+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
102+
103+
<section class="intro">
104+
105+
</section>
106+
107+
<!-- /.intro -->
108+
109+
<!-- C usage documentation. -->
110+
111+
<section class="usage">
112+
113+
### Usage
114+
115+
```c
116+
TODO
117+
```
118+
119+
#### TODO
120+
121+
TODO.
122+
123+
```c
124+
TODO
125+
```
126+
127+
TODO
128+
129+
```c
130+
TODO
131+
```
132+
133+
</section>
134+
135+
<!-- /.usage -->
136+
137+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
138+
139+
<section class="notes">
140+
141+
</section>
142+
143+
<!-- /.notes -->
144+
145+
<!-- C API usage examples. -->
146+
147+
<section class="examples">
148+
149+
### Examples
150+
151+
```c
152+
TODO
153+
```
154+
155+
</section>
156+
157+
<!-- /.examples -->
158+
159+
</section>
160+
161+
<!-- /.c -->
162+
163+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
164+
165+
<section class="related">
166+
167+
</section>
168+
169+
<!-- /.related -->
170+
171+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
172+
173+
<section class="links">
174+
175+
[lapack]: https://www.netlib.org/lapack/explore-html/
176+
177+
[lapack-dladiv2]: https://www.netlib.org/lapack//explore-html/d5/db7/group__ladiv_ga88d53dbc9f14fed11972d11b1458fd1c.html
178+
179+
</section>
180+
181+
<!-- /.links -->
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var bench = require( '@stdlib/bench' );
24+
var isnan = require( '@stdlib/math/base/assert/is-nan' );
25+
var uniform = require( '@stdlib/random/array/uniform' );
26+
var pkg = require( './../package.json' ).name;
27+
var dladiv2 = require( './../lib' );
28+
29+
30+
// MAIN //
31+
32+
bench( pkg, function benchmark( b ) {
33+
var len;
34+
var B;
35+
var A;
36+
var C;
37+
var D;
38+
var R;
39+
var T;
40+
var z;
41+
var i;
42+
43+
len = 100;
44+
A = uniform( len, -50, 50 );
45+
B = uniform( len, -50, 50 );
46+
C = uniform( len, -50, 50 );
47+
D = uniform( len, -50, 50 );
48+
R = uniform( len, -50, 50 );
49+
T = uniform( len, -50, 50 );
50+
51+
b.tic();
52+
for ( i = 0; i < b.iterations; i++ ) {
53+
z = dladiv2( A[ i % len ], B[ i % len ], C[ i % len ], D[ i % len ], R[ i % len ], T[ i % len ] ); // eslint-disable-line
54+
if ( isnan( z ) ) {
55+
b.fail( 'should not return NaN' );
56+
}
57+
}
58+
b.toc();
59+
if ( isnan( z ) ) {
60+
b.fail( 'should not return NaN' );
61+
}
62+
b.pass( 'benchmark finished' );
63+
b.end();
64+
});
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
2+
{{alias}}( a, b, c, d, r, t )
3+
Performs complex division `A + iB / C + iD` using real double-precision
4+
arithmetic.
5+
6+
Parameters
7+
----------
8+
a: number
9+
Real part of the dividend complex number.
10+
11+
b: number
12+
Imaginary part of the dividend complex number.
13+
14+
c: number
15+
Real part of the divisor complex number.
16+
17+
d: number
18+
Imaginary part of the divisor complex number.
19+
20+
r: number
21+
Represents the ratio of the smaller-magnitude component to the
22+
larger-magnitude component of the denominator complex number `C + iD`.
23+
24+
t: number
25+
Scaling factor.
26+
27+
Returns
28+
-------
29+
out: number
30+
A + iB / C + iD.
31+
32+
Examples
33+
--------
34+
> var out = {{alias}}( 3.0, 4.0, 1.0, 2.0, 4.0, 5.0 )
35+
95.0
36+
37+
See Also
38+
--------
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
// TypeScript Version: 4.1
20+
21+
/**
22+
* Performs complex division `A + iB / C + iD` using real double-precision arithmetic.
23+
*
24+
* @param a - real part of the dividend complex number
25+
* @param b - imaginary part of the dividend complex number
26+
* @param c - real part of the divisor complex number
27+
* @param d - imaginary part of the divisor complex number
28+
* @param r - represents the ratio of the smaller-magnitude component to the larger-magnitude component of the denominator complex number `C + iD`
29+
* @param t - scaling factor
30+
* @returns `A + iB / C + iD`
31+
*
32+
* @example
33+
* var out = dladiv2( 3.0, 4.0, 1.0, 2.0, 4.0, 5.0 );
34+
* // returns 95.0
35+
*/
36+
declare function dladiv2( a: number, b: number, c: number, d: number, r: number, t: number ): number;
37+
38+
39+
// EXPORTS //
40+
41+
export = dladiv2;

0 commit comments

Comments
 (0)