Skip to content
Draft
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
222 changes: 222 additions & 0 deletions lib/node_modules/@stdlib/lapack/base/sladiv/README.md
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.

-->

# sladiv

> Divide two single-precision complex floating-point numbers in real arithmetic.

<section class="usage">

## Usage

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

#### sladiv( a, b, c, d, P, Q )

Divides two single-precision complex floating-point numbers in real arithmetic.

```javascript
var Float32Array = require( '@stdlib/array/float32' );

var P = new Float32Array( 1 );
var Q = new Float32Array( 1 );

sladiv( -13.0, -1.0, -2.0, 1.0, P, Q );
// P => <Float32Array>[ 5.0 ]
// Q => <Float32Array>[ 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**: [`Float32Array`][mdn-float32array] containing a single element which is overwritten by the real part of the quotient.
- **Q**: [`Float32Array`][mdn-float32array] containing a single element which is overwritten by the imaginary part of the quotient.

#### sladiv.ndarray( a, b, c, d, P, offsetP, Q, offsetQ )

Divides two single-precision complex floating-point numbers in real arithmetic using alternative indexing semantics.

```javascript
var Float32Array = require( '@stdlib/array/float32' );

var P = new Float32Array( 1 );
var Q = new Float32Array( 1 );

sladiv.ndarray( -13.0, -1.0, -2.0, 1.0, P, 0, Q, 0 );
// P => <Float32Array>[ 5.0 ]
// Q => <Float32Array>[ 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**: [`Float32Array`][mdn-float32array] containing an element which is overwritten by the real part of the quotient.
- **offsetP**: index of the element in `P`.
- **Q**: [`Float32Array`][mdn-float32array] containing an element which is overwritten by the imaginary part of the quotient.
- **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 Float32Array = require( '@stdlib/array/float32' );

var P = new Float32Array( [ 0.0, 0.0, 0.0 ] );
var Q = new Float32Array( [ 0.0, 0.0, 0.0 ] );

sladiv.ndarray( 2.0, 1.0, 3.0, 4.0, P, 1, Q, 2 );
// P => <Float32Array>[ 0.0, 0.4, 0.0 ]
// Q => <Float32Array>[ 0.0, 0.0, -0.2 ]
```

</section>

<!-- /.usage -->

<section class="notes">

## Notes

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

</section>

<!-- /.notes -->

<section class="examples">

## Examples

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

```javascript
var Float32Array = require( '@stdlib/array/float32' );
var sladiv = require( '@stdlib/lapack/base/sladiv' );

var P = new Float32Array( 1 );
var Q = new Float32Array( 1 );
sladiv( 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-sladiv]: https://netlib.org/lapack/explore-html/d5/db7/group__ladiv_gaa0d86a3e395d11f001d7893f826c23b7.html

[mdn-float32array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float32Array

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

</section>

<!-- /.links -->
72 changes: 72 additions & 0 deletions lib/node_modules/@stdlib/lapack/base/sladiv/benchmark/benchmark.js
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 isnanf = require( '@stdlib/math/base/assert/is-nan' );
var Float32Array = require( '@stdlib/array/float32' );
var pkg = require( './../package.json' ).name;
var sladiv = require( './../lib' );


// VARIABLES //

var options = {
'dtype': 'float32'
};


// 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 Float32Array( 1 );
Q = new Float32Array( 1 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
j = i % N;
k = ( i+1 ) % N;
sladiv( re[ j ], im[ j ], re[ k ], im[ k ], P, Q );
if ( isnanf( P[ 0 ] ) || isnanf( Q[ 0 ] ) ) {
b.fail( 'should not return NaN' );
}
}
b.toc();
if ( isnanf( P[ 0 ] ) || isnanf( Q[ 0 ] ) ) {
b.fail( 'should not return NaN' );
}
b.pass( 'benchmark finished' );
b.end();
});
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 isnanf = require( '@stdlib/math/base/assert/is-nan' );
var Float32Array = require( '@stdlib/array/float32' );
var pkg = require( './../package.json' ).name;
var sladiv = require( './../lib/ndarray.js' );


// VARIABLES //

var options = {
'dtype': 'float32'
};


// 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 Float32Array( 1 );
Q = new Float32Array( 1 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
j = i % N;
k = ( i+1 ) % N;
sladiv( re[ j ], im[ j ], re[ k ], im[ k ], P, 0, Q, 0 );
if ( isnanf( P[ 0 ] ) || isnanf( Q[ 0 ] ) ) {
b.fail( 'should not return NaN' );
}
}
b.toc();
if ( isnanf( P[ 0 ] ) || isnanf( Q[ 0 ] ) ) {
b.fail( 'should not return NaN' );
}
b.pass( 'benchmark finished' );
b.end();
});
Loading
Loading