Skip to content

feat: add lapack/base/dladiv2 #7755

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
181 changes: 181 additions & 0 deletions lib/node_modules/@stdlib/lapack/base/dladiv2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
<!--

@license Apache-2.0

Copyright (c) 2025 The Stdlib Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

-->

# dladiv2

> LAPACK routine to perform complex division in a manner which doesn't cause unnecessary overflow.

<section class="usage">

## Usage

```javascript
var dladiv2 = require( '@stdlib/lapack/base/dladiv2' );
```

#### dladiv2( a, b, c, d, r, t )

Performs complex division `A + iB / C + iD` using real double-precision arithmetic.

```javascript
var out = dladiv2( 3.0, 4.0, 1.0, 2.0, 4.0, 5.0 );
// returns 95.0
```

The function has the following parameters:

- **a**: real part of the dividend complex number.
- **b**: imaginary part of the dividend complex number.
- **c**: real part of the divisor complex number.
- **d**: imaginary part of the divisor complex number.
- **r**: represents the ratio of the smaller-magnitude component to the larger-magnitude component of the denominator complex number `C + iD`.
- **t**: scaling factor.

</section>

<!-- /.usage -->

<section class="notes">

## Notes

- `dladiv2()` corresponds to the [LAPACK][LAPACK] function [`dladiv2`][lapack-dladiv2].

</section>

<!-- /.notes -->

<section class="examples">

## Examples

<!-- eslint no-undef: "error" -->

```javascript
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var logEachMap = require( '@stdlib/console/log-each-map' );
var dladiv2 = require( '@stdlib/lapack/base/dladiv2' );

var opts = {
'dtype': 'float64'
};
var a = discreteUniform( 100, -50, 50, opts );
var b = discreteUniform( 100, -50, 50, opts );
var c = discreteUniform( 100, -50, 50, opts );
var d = discreteUniform( 100, -50, 50, opts );
var r = discreteUniform( 100, -50, 50, opts );
var t = discreteUniform( 100, -50, 50, opts );

logEachMap( 'dladiv2( %d, %d, %d, %d, %d, %d ) = %0.4f', a, b, c, d, r, t, dladiv2 );
```

</section>

<!-- /.examples -->

<!-- C interface documentation. -->

* * *

<section class="c">

## C APIs

<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->

<section class="intro">

</section>

<!-- /.intro -->

<!-- C usage documentation. -->

<section class="usage">

### Usage

```c
TODO
```

#### TODO

TODO.

```c
TODO
```

TODO

```c
TODO
```

</section>

<!-- /.usage -->

<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="notes">

</section>

<!-- /.notes -->

<!-- C API usage examples. -->

<section class="examples">

### Examples

```c
TODO
```

</section>

<!-- /.examples -->

</section>

<!-- /.c -->

<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->

<section class="related">

</section>

<!-- /.related -->

<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="links">

[lapack]: https://www.netlib.org/lapack/explore-html/

[lapack-dladiv2]: https://www.netlib.org/lapack//explore-html/d5/db7/group__ladiv_ga88d53dbc9f14fed11972d11b1458fd1c.html

</section>

<!-- /.links -->
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2025 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

// MODULES //

var bench = require( '@stdlib/bench' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var uniform = require( '@stdlib/random/array/uniform' );
var pkg = require( './../package.json' ).name;
var dladiv2 = require( './../lib' );


// MAIN //

bench( pkg, function benchmark( b ) {
var len;
var B;
var A;
var C;
var D;
var R;
var T;
var z;
var i;

len = 100;
A = uniform( len, -50, 50 );
B = uniform( len, -50, 50 );
C = uniform( len, -50, 50 );
D = uniform( len, -50, 50 );
R = uniform( len, -50, 50 );
T = uniform( len, -50, 50 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
z = dladiv2( A[ i % len ], B[ i % len ], C[ i % len ], D[ i % len ], R[ i % len ], T[ i % len ] ); // eslint-disable-line
if ( isnan( z ) ) {
b.fail( 'should not return NaN' );
}
}
b.toc();
if ( isnan( z ) ) {
b.fail( 'should not return NaN' );
}
b.pass( 'benchmark finished' );
b.end();
});
38 changes: 38 additions & 0 deletions lib/node_modules/@stdlib/lapack/base/dladiv2/docs/repl.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

{{alias}}( a, b, c, d, r, t )
Performs complex division `A + iB / C + iD` using real double-precision
arithmetic.

Parameters
----------
a: number
Real part of the dividend complex number.

b: number
Imaginary part of the dividend complex number.

c: number
Real part of the divisor complex number.

d: number
Imaginary part of the divisor complex number.

r: number
Represents the ratio of the smaller-magnitude component to the
larger-magnitude component of the denominator complex number `C + iD`.

t: number
Scaling factor.

Returns
-------
out: number
A + iB / C + iD.

Examples
--------
> var out = {{alias}}( 3.0, 4.0, 1.0, 2.0, 4.0, 5.0 )
95.0

See Also
--------
41 changes: 41 additions & 0 deletions lib/node_modules/@stdlib/lapack/base/dladiv2/docs/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* @license Apache-2.0
*
* Copyright (c) 2025 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

// TypeScript Version: 4.1

/**
* Performs complex division `A + iB / C + iD` using real double-precision arithmetic.
*
* @param a - real part of the dividend complex number
* @param b - imaginary part of the dividend complex number
* @param c - real part of the divisor complex number
* @param d - imaginary part of the divisor complex number
* @param r - represents the ratio of the smaller-magnitude component to the larger-magnitude component of the denominator complex number `C + iD`
* @param t - scaling factor
* @returns `A + iB / C + iD`
*
* @example
* var out = dladiv2( 3.0, 4.0, 1.0, 2.0, 4.0, 5.0 );
* // returns 95.0
*/
declare function dladiv2( a: number, b: number, c: number, d: number, r: number, t: number ): number;


// EXPORTS //

export = dladiv2;
Loading