Skip to content
Merged
55 changes: 55 additions & 0 deletions lib/node_modules/@stdlib/complex/float64/base/div/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,61 @@ var v = cdiv( z1, z2 );
// returns <Complex128>[ 5.0, 3.0 ]
```

#### cdiv.assign( re1, im1, re2, im2, out, strideOut, offsetOut )

Divides two double-precision complex floating-point numbers and assigns results to a provided output array.

```javascript
var Float64Array = require( '@stdlib/array/float64' );

var out = new Float64Array( 2 );
var v = cdiv.assign( -13.0, -1.0, -2.0, 1.0, out, 1, 0 );
// returns <Float64Array>[ 5.0, 3.0 ]

var bool = ( out === v );
// returns true
```

The function supports the following parameters:

- **re1**: real component of the first complex number.
- **im1**: imaginary component of the first complex number.
- **re2**: real component of the second complex number.
- **im2**: imaginary component of the second complex number.
- **out**: output array.
- **strideOut**: stride length for `out`.
- **offsetOut**: starting index for `out`.

#### cdiv.strided( z1, sz1, oz1, z2, sz2, oz2, out, so, oo )

Divides two double-precision complex floating-point numbers stored in real-valued strided array views and assigns results to a provided strided output array.

```javascript
var Float64Array = require( '@stdlib/array/float64' );

var z1 = new Float64Array( [ -13.0, -1.0 ] );
var z2 = new Float64Array( [ -2.0, 1.0 ] );
var out = new Float64Array( 2 );

var v = cdiv.strided( z1, 1, 0, z2, 1, 0, out, 1, 0 );
// returns <Float64Array>[ 5.0, 3.0 ]

var bool = ( out === v );
// returns true
```

The function supports the following parameters:

- **z1**: first complex number strided array view.
- **sz1**: stride length for `z1`.
- **oz1**: starting index for `z1`.
- **z2**: second complex number strided array view.
- **sz2**: stride length for `z2`.
- **oz2**: starting index for `z2`.
- **out**: output array.
- **so**: stride length for `out`.
- **oo**: starting index for `out`.

</section>

<!-- /.usage -->
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/**
* @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 cdiv = require( './../lib' );


// VARIABLES //

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


// MAIN //

bench( pkg+':assign', function benchmark( b ) {
var out;
var re;
var im;
var N;
var i;
var j;
var k;

N = 100;
re = uniform( N, -500.0, 500.0, options );
im = uniform( N, -500.0, 500.0, options );

out = new Float64Array( 2 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
j = i % N;
k = ( i+1 ) % N;
out = cdiv.assign( re[ j ], im[ j ], re[ k ], im[ k ], out, 1, 0 );
if ( typeof out !== 'object' ) {
b.fail( 'should return an object' );
}
}
b.toc();
if ( isnan( out[ 0 ] ) || isnan( out[ 1 ] ) ) {
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,68 @@
/**
* @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 cdiv = require( './../lib' );


// VARIABLES //

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


// MAIN //

bench( pkg+':strided', function benchmark( b ) {
var out;
var z1;
var z2;
var N;
var i;
var j;

N = 50;
z1 = uniform( N*2, -500.0, 500.0, options );
z2 = uniform( N*2, -500.0, 500.0, options );

out = new Float64Array( 2 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
j = ( i % N ) * 2;
out = cdiv.strided( z1, 1, j, z2, 1, j, out, 1, 0 );
if ( typeof out !== 'object' ) {
b.fail( 'should return an object' );
}
}
b.toc();
if ( isnan( out[ 0 ] ) || isnan( out[ 1 ] ) ) {
b.fail( 'should not return NaN' );
}
b.pass( 'benchmark finished' );
b.end();
});
88 changes: 87 additions & 1 deletion lib/node_modules/@stdlib/complex/float64/base/div/docs/repl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,92 @@
> var im = {{alias:@stdlib/complex/float64/imag}}( y )
3.0

See Also

{{alias}}.assign( re1, im1, re2, im2, out, strideOut, offsetOut )
Divides two double-precision complex floating-point numbers and assigns
results to a provided output array.

Parameters
----------
re1: number
Real component of the first complex number.

im1: number
Imaginary component of the first complex number.

re2: number
Real component of the second complex number.

im2: number
Imaginary component of the second complex number.

out: ArrayLikeObject
Output array.

strideOut: integer
Stride length.

offsetOut: integer
Starting index.

Returns
-------
out: ArrayLikeObject
Output array.

Examples
--------
> var out = new {{alias:@stdlib/array/float64}}( 2 );
> {{alias}}.assign( -13.0, -1.0, -2.0, 1.0, out, 1, 0 )
<Float64Array>[ 5.0, 3.0 ]


{{alias}}.strided( z1, sz1, oz1, z2, sz2, oz2, out, so, oo )
Divides two double-precision complex floating-point numbers stored in real-
valued strided array views and assigns results to a provided strided output
array.

Parameters
----------
z1: ArrayLikeObject
First complex number view.

sz1: integer
Stride length for `z1`.

oz1: integer
Starting index for `z1`.

z2: ArrayLikeObject
Second complex number view.

sz2: integer
Stride length for `z2`.

oz2: integer
Starting index for `z2`.

out: ArrayLikeObject
Output array.

so: integer
Stride length for `out`.

oo: integer
Starting index for `out`.

Returns
-------
out: ArrayLikeObject
Output array.

Examples
--------
> var z1 = new {{alias:@stdlib/array/float64}}( [ -13.0, -1.0 ] );
> var z2 = new {{alias:@stdlib/array/float64}}( [ -2.0, 1.0 ] );
> var out = new {{alias:@stdlib/array/float64}}( 2 );
> {{alias}}.strided( z1, 1, 0, z2, 1, 0, out, 1, 0 )
<Float64Array>[ 5.0, 3.0 ]

See Also
--------
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,79 @@
/// <reference types="@stdlib/types"/>

import { Complex128 } from '@stdlib/types/complex';
import { Collection, NumericArray } from '@stdlib/types/array';

/**
* Interface for dividing two double-precision complex floating-point numbers.
*/
interface Cdiv {
/**
* Divides two double-precision complex floating-point numbers.
*
* @param z1 - complex number
* @param z2 - complex number
* @returns result
*
* @example
* var Complex128 = require( '@stdlib/complex/float64/ctor' );
*
* var z1 = new Complex128( -13.0, -1.0 );
* var z2 = new Complex128( -2.0, 1.0 );
*
* var out = cdiv( z1, z2 );
* // returns <Complex128>[ 5.0, 3.0 ]
*/
( z1: Complex128, z2: Complex128 ): Complex128;

/**
* Divides two double-precision complex floating-point numbers and assigns results to a provided output array.
*
* @param re1 - real component of the first complex number
* @param im1 - imaginary component of the first complex number
* @param re2 - real component of the second complex number
* @param im2 - imaginary component of the second complex number
* @param out - output array
* @param strideOut - stride length
* @param offsetOut - starting index
* @returns output array
*
* @example
* var Float64Array = require( '@stdlib/array/float64' );
*
* var out = new Float64Array( 2 );
* var v = cdiv.assign( -13.0, -1.0, -2.0, 1.0, out, 1, 0 );
* // returns <Float64Array>[ 5.0, 3.0 ]
*
* var bool = ( out === v );
* // returns true
*/
assign<T extends NumericArray | Collection<number>>( re1: number, im1: number, re2: number, im2: number, out: T, strideOut: number, offsetOut: number ): T;

/**
* Divides two double-precision complex floating-point numbers stored in real-valued strided array views and assigns results to a provided strided output array.
*
* @param z1 - first complex number view
* @param strideZ1 - stride length for `z1`
* @param offsetZ1 - starting index for `z1`
* @param z2 - second complex number view
* @param strideZ2 - stride length for `z2`
* @param offsetZ2 - starting index for `z2`
* @param out - output array
* @param strideOut - stride length for `out`
* @param offsetOut - starting index for `out`
* @returns output array
*
* @example
* var Float64Array = require( '@stdlib/array/float64' );
*
* var z1 = new Float64Array( [ -13.0, -1.0 ] );
* var z2 = new Float64Array( [ -2.0, 1.0 ] );
*
* var out = cdiv.strided( z1, 1, 0, z2, 1, 0, new Float64Array( 2 ), 1, 0 );
* // returns <Float64Array>[ 5.0, 3.0 ]
*/
strided<T extends NumericArray | Collection<number>, U extends NumericArray | Collection<number>, V extends NumericArray | Collection<number>>( z1: T, strideZ1: number, offsetZ1: number, z2: U, strideZ2: number, offsetZ2: number, out: V, strideOut: number, offsetOut: number ): V;
}

/**
* Divides two double-precision complex floating-point numbers.
Expand All @@ -38,7 +111,7 @@ import { Complex128 } from '@stdlib/types/complex';
* var out = cdiv( z1, z2 );
* // returns <Complex128>[ 5.0, 3.0 ]
*/
declare function cdiv( z1: Complex128, z2: Complex128 ): Complex128;
declare var cdiv: Cdiv;


// EXPORTS //
Expand Down
Loading