-
-
Notifications
You must be signed in to change notification settings - Fork 870
feat: add lapack/base/dladiv
#7916
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
Merged
Merged
Changes from 8 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
def6a3c
feat: add lapack/base/dladiv
aayush0325 f54b4ac
docs: add ts files
aayush0325 fb97790
test: add tests
aayush0325 eac69a7
chore: fix test
aayush0325 859b69a
docs: add readme
aayush0325 711c4fc
docs: add repl.txt
aayush0325 014ad62
bench: add missing namespace
kgryte b8ef756
bench: fix description
kgryte ab68e56
docs: update copy
kgryte 925f1c7
docs: update copy
kgryte 721bfc7
style: add missing empty line
kgryte 5cbb261
docs: update copy
kgryte 06f5aa6
docs: update copy
kgryte 476de41
Apply suggestions from code review
kgryte File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,222 @@ | ||
<!-- | ||
|
||
@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. | ||
|
||
--> | ||
|
||
# dladiv | ||
|
||
> Divide two double-precision complex floating-point numbers in real arithmetic. | ||
|
||
<section class="usage"> | ||
|
||
## Usage | ||
|
||
```javascript | ||
var dladiv = require( '@stdlib/lapack/base/dladiv' ); | ||
``` | ||
|
||
#### dladiv( a, b, c, d, P, Q ) | ||
|
||
Divides two double-precision complex floating-point numbers in real arithmetic. | ||
|
||
```javascript | ||
var Float64Array = require( '@stdlib/array/float64' ); | ||
|
||
var P = new Float64Array( 1 ); | ||
var Q = new Float64Array( 1 ); | ||
|
||
dladiv( -13.0, -1.0, -2.0, 1.0, P, Q ); | ||
// P => <Float64Array>[ 5.0 ] | ||
// Q => <Float64Array>[ 3.0 ] | ||
``` | ||
|
||
The function has the following parameters: | ||
|
||
- **a**: real component of numerator. | ||
- **b**: imaginary component of numerator. | ||
- **c**: real component of denominator. | ||
- **d**: imaginary component of denominator. | ||
- **P**: [`Float64Array`][mdn-float64array] containing a single element which is overwritten by the real part of the quotient. | ||
- **Q**: [`Float64Array`][mdn-float64array] containing a single element which is overwritten by the imaginary part of the quotient. | ||
|
||
#### dladiv.ndarray( a, b, c, d, P, offsetP, Q, offsetQ ) | ||
|
||
Divides two double-precision complex floating-point numbers in real arithmetic using alternative indexing semantics. | ||
|
||
```javascript | ||
var Float64Array = require( '@stdlib/array/float64' ); | ||
|
||
var P = new Float64Array( 1 ); | ||
var Q = new Float64Array( 1 ); | ||
|
||
dladiv.ndarray( -13.0, -1.0, -2.0, 1.0, P, 0, Q, 0 ); | ||
// P => <Float64Array>[ 5.0 ] | ||
// Q => <Float64Array>[ 3.0 ] | ||
``` | ||
|
||
The function has the following additional parameters: | ||
|
||
- **a**: real component of numerator. | ||
- **b**: imaginary component of numerator. | ||
- **c**: real component of denominator. | ||
- **d**: imaginary component of denominator. | ||
- **P**: [`Float64Array`][mdn-float64array] containing a single element which is overwritten by the real part of the quotient. | ||
- **offsetP**: index of the element in `P`. | ||
- **Q**: [`Float64Array`][mdn-float64array] containing a single element which is overwritten by the imaginary part of the quotient. | ||
kgryte marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- **offsetQ**: index of the element in `Q`. | ||
|
||
While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting indices. For example, | ||
|
||
```javascript | ||
var Float64Array = require( '@stdlib/array/float64' ); | ||
|
||
var P = new Float64Array( [ 0.0, 0.0, 0.0 ] ); | ||
var Q = new Float64Array( [ 0.0, 0.0, 0.0 ] ); | ||
|
||
dladiv.ndarray( 2.0, 1.0, 3.0, 4.0, P, 1, Q, 2 ); | ||
// P => <Float64Array>[ 0.0, 0.4, 0.0 ] | ||
// Q => <Float64Array>[ 0.0, 0.0, -0.2 ] | ||
``` | ||
|
||
</section> | ||
|
||
<!-- /.usage --> | ||
|
||
<section class="notes"> | ||
|
||
## Notes | ||
|
||
- `dladiv()` corresponds to the [LAPACK][LAPACK] function [`dladiv`][lapack-dladiv]. | ||
|
||
</section> | ||
|
||
<!-- /.notes --> | ||
|
||
<section class="examples"> | ||
|
||
## Examples | ||
|
||
<!-- eslint no-undef: "error" --> | ||
|
||
```javascript | ||
var Float64Array = require( '@stdlib/array/float64' ); | ||
var dladiv = require( '@stdlib/lapack/base/dladiv' ); | ||
|
||
var P = new Float64Array( 1 ); | ||
var Q = new Float64Array( 1 ); | ||
dladiv( 2.0, 1.0, 3.0, 4.0, P, Q ); | ||
console.log( '(2+i)/(3+4i) =', P[ 0 ], '+', Q[ 0 ], 'i' ); | ||
``` | ||
|
||
</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"> | ||
|
||
[mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray | ||
|
||
[lapack-dladiv]: https://www.netlib.org/lapack/explore-html/d5/db7/group__ladiv_gacbc97eb1922a833ffe257e1731bb0aaa.html | ||
|
||
[mdn-float64array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float64Array | ||
|
||
[lapack]: https://www.netlib.org/lapack/explore-html/ | ||
|
||
</section> | ||
|
||
<!-- /.links --> |
72 changes: 72 additions & 0 deletions
72
lib/node_modules/@stdlib/lapack/base/dladiv/benchmark/benchmark.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/** | ||
* @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 uniform = require( '@stdlib/random/array/uniform' ); | ||
var isnan = require( '@stdlib/math/base/assert/is-nan' ); | ||
var Float64Array = require( '@stdlib/array/float64' ); | ||
var pkg = require( './../package.json' ).name; | ||
var dladiv = require( './../lib' ); | ||
|
||
|
||
// VARIABLES // | ||
|
||
var options = { | ||
'dtype': 'float64' | ||
}; | ||
|
||
|
||
// MAIN // | ||
|
||
bench( pkg, function benchmark( b ) { | ||
var re; | ||
var im; | ||
var N; | ||
var P; | ||
var Q; | ||
var i; | ||
var j; | ||
var k; | ||
|
||
N = 100; | ||
re = uniform( N, -500.0, 500.0, options ); | ||
im = uniform( N, -500.0, 500.0, options ); | ||
|
||
P = new Float64Array( 1 ); | ||
Q = new Float64Array( 1 ); | ||
|
||
b.tic(); | ||
for ( i = 0; i < b.iterations; i++ ) { | ||
j = i % N; | ||
k = ( i+1 ) % N; | ||
dladiv( re[ j ], im[ j ], re[ k ], im[ k ], P, Q ); | ||
if ( isnan( P[ 0 ] ) || isnan( Q[ 0 ] ) ) { | ||
b.fail( 'should not return NaN' ); | ||
} | ||
} | ||
b.toc(); | ||
if ( isnan( P[ 0 ] ) || isnan( Q[ 0 ] ) ) { | ||
b.fail( 'should not return NaN' ); | ||
} | ||
b.pass( 'benchmark finished' ); | ||
b.end(); | ||
}); |
72 changes: 72 additions & 0 deletions
72
lib/node_modules/@stdlib/lapack/base/dladiv/benchmark/benchmark.ndarray.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/** | ||
* @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 uniform = require( '@stdlib/random/array/uniform' ); | ||
var isnan = require( '@stdlib/math/base/assert/is-nan' ); | ||
var Float64Array = require( '@stdlib/array/float64' ); | ||
var pkg = require( './../package.json' ).name; | ||
var dladiv = require( './../lib/ndarray.js' ); | ||
|
||
|
||
// VARIABLES // | ||
|
||
var options = { | ||
'dtype': 'float64' | ||
}; | ||
|
||
|
||
// MAIN // | ||
|
||
bench( pkg+':ndarray', function benchmark( b ) { | ||
var re; | ||
var im; | ||
var N; | ||
var P; | ||
var Q; | ||
var i; | ||
var j; | ||
var k; | ||
|
||
N = 100; | ||
re = uniform( N, -500.0, 500.0, options ); | ||
im = uniform( N, -500.0, 500.0, options ); | ||
|
||
P = new Float64Array( 1 ); | ||
Q = new Float64Array( 1 ); | ||
|
||
b.tic(); | ||
for ( i = 0; i < b.iterations; i++ ) { | ||
j = i % N; | ||
k = ( i+1 ) % N; | ||
dladiv( re[ j ], im[ j ], re[ k ], im[ k ], P, 0, Q, 0 ); | ||
if ( isnan( P[ 0 ] ) || isnan( Q[ 0 ] ) ) { | ||
b.fail( 'should not return NaN' ); | ||
} | ||
} | ||
b.toc(); | ||
if ( isnan( P[ 0 ] ) || isnan( Q[ 0 ] ) ) { | ||
b.fail( 'should not return NaN' ); | ||
} | ||
b.pass( 'benchmark finished' ); | ||
b.end(); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.