Skip to content

Commit 486fed2

Browse files
committed
feat: add assign and strided methods
--- 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: na - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - 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 8983ed6 commit 486fed2

File tree

13 files changed

+1197
-73
lines changed

13 files changed

+1197
-73
lines changed

lib/node_modules/@stdlib/complex/float64/base/add/README.md

+55
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,61 @@ var im = imag( v );
5757
// returns 5.0
5858
```
5959

60+
#### add.assign( re1, im1, re2, im2, out, strideOut, offsetOut )
61+
62+
Adds two double-precision complex floating-point numbers and assigns results to a provided output array.
63+
64+
```javascript
65+
var Float64Array = require( '@stdlib/array/float64' );
66+
67+
var out = new Float64Array( 2 );
68+
var v = add.assign( 5.0, 3.0, -2.0, 1.0, out, 1, 0 );
69+
// returns <Float64Array>[ 3.0, 4.0 ]
70+
71+
var bool = ( out === v );
72+
// returns true
73+
```
74+
75+
The function supports the following parameters:
76+
77+
- **re1**: real component of the first complex number.
78+
- **im1**: imaginary component of the first complex number.
79+
- **re2**: real component of the second complex number.
80+
- **im2**: imaginary component of the second complex number.
81+
- **out**: output array.
82+
- **strideOut**: stride length for `out`.
83+
- **offsetOut**: starting index for `out`.
84+
85+
#### add.strided( z1, sz1, oz1, z2, sz2, oz2, out, so, oo )
86+
87+
Adds two double-precision complex floating-point numbers stored in real-valued strided array views and assigns results to a provided strided output array.
88+
89+
```javascript
90+
var Float64Array = require( '@stdlib/array/float64' );
91+
92+
var z1 = new Float64Array( [ 5.0, 3.0 ] );
93+
var z2 = new Float64Array( [ -2.0, 1.0 ] );
94+
var out = new Float64Array( 2 );
95+
96+
var v = add.strided( z1, 1, 0, z2, 1, 0, out, 1, 0 );
97+
// returns <Float64Array>[ 3.0, 4.0 ]
98+
99+
var bool = ( out === v );
100+
// returns true
101+
```
102+
103+
The function supports the following parameters:
104+
105+
- **z1**: first complex number strided array view.
106+
- **sz1**: stride length for `z1`.
107+
- **oz1**: starting index for `z1`.
108+
- **z2**: second complex number strided array view.
109+
- **sz2**: stride length for `z2`.
110+
- **oz2**: starting index for `z2`.
111+
- **out**: output array.
112+
- **so**: stride length for `out`.
113+
- **oo**: starting index for `out`.
114+
60115
</section>
61116

62117
<!-- /.usage -->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
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 uniform = require( '@stdlib/random/array/uniform' );
25+
var isnan = require( '@stdlib/math/base/assert/is-nan' );
26+
var Float64Array = require( '@stdlib/array/float64' );
27+
var pkg = require( './../package.json' ).name;
28+
var add = require( './../lib' );
29+
30+
31+
// VARIABLES //
32+
33+
var options = {
34+
'dtype': 'float64'
35+
};
36+
37+
38+
// MAIN //
39+
40+
bench( pkg+':assign', function benchmark( b ) {
41+
var out;
42+
var re;
43+
var im;
44+
var N;
45+
var i;
46+
var j;
47+
var k;
48+
49+
N = 100;
50+
re = uniform( N, -500.0, 500.0, options );
51+
im = uniform( N, -500.0, 500.0, options );
52+
53+
out = new Float64Array( 2 );
54+
55+
b.tic();
56+
for ( i = 0; i < b.iterations; i++ ) {
57+
j = i % N;
58+
k = ( i+1 ) % N;
59+
out = add.assign( re[ j ], im[ j ], re[ k ], im[ k ], out, 1, 0 );
60+
if ( typeof out !== 'object' ) {
61+
b.fail( 'should return an object' );
62+
}
63+
}
64+
b.toc();
65+
if ( isnan( out[ 0 ] ) || isnan( out[ 1 ] ) ) {
66+
b.fail( 'should not return NaN' );
67+
}
68+
b.pass( 'benchmark finished' );
69+
b.end();
70+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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 uniform = require( '@stdlib/random/array/uniform' );
25+
var isnan = require( '@stdlib/math/base/assert/is-nan' );
26+
var Float64Array = require( '@stdlib/array/float64' );
27+
var pkg = require( './../package.json' ).name;
28+
var add = require( './../lib' );
29+
30+
31+
// VARIABLES //
32+
33+
var options = {
34+
'dtype': 'float64'
35+
};
36+
37+
38+
// MAIN //
39+
40+
bench( pkg+':strided', function benchmark( b ) {
41+
var out;
42+
var z1;
43+
var z2;
44+
var N;
45+
var i;
46+
var j;
47+
48+
N = 50;
49+
z1 = uniform( N*2, -500.0, 500.0, options );
50+
z2 = uniform( N*2, -500.0, 500.0, options );
51+
52+
out = new Float64Array( 2 );
53+
54+
b.tic();
55+
for ( i = 0; i < b.iterations; i++ ) {
56+
j = ( i % N ) * 2;
57+
out = add.strided( z1, 1, j, z2, 1, j, out, 1, 0 );
58+
if ( typeof out !== 'object' ) {
59+
b.fail( 'should return an object' );
60+
}
61+
}
62+
b.toc();
63+
if ( isnan( out[ 0 ] ) || isnan( out[ 1 ] ) ) {
64+
b.fail( 'should not return NaN' );
65+
}
66+
b.pass( 'benchmark finished' );
67+
b.end();
68+
});

lib/node_modules/@stdlib/complex/float64/base/add/docs/repl.txt

+87
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,93 @@
2626
> var im = {{alias:@stdlib/complex/float64/imag}}( out )
2727
6.0
2828

29+
30+
{{alias}}.assign( re1, im1, re2, im2, out, strideOut, offsetOut )
31+
Adds two double-precision complex floating-point numbers and assigns results
32+
to a provided output array.
33+
34+
Parameters
35+
----------
36+
re1: number
37+
Real component of the first complex number.
38+
39+
im1: number
40+
Imaginary component of the first complex number.
41+
42+
re2: number
43+
Real component of the second complex number.
44+
45+
im2: number
46+
Imaginary component of the second complex number.
47+
48+
out: ArrayLikeObject
49+
Output array.
50+
51+
strideOut: integer
52+
Stride length.
53+
54+
offsetOut: integer
55+
Starting index.
56+
57+
Returns
58+
-------
59+
out: ArrayLikeObject
60+
Output array.
61+
62+
Examples
63+
--------
64+
> var out = new {{alias:@stdlib/array/float64}}( 2 );
65+
> {{alias}}.assign( 5.0, 3.0, -2.0, 1.0, out, 1, 0 )
66+
<Float64Array>[ 3.0, 4.0 ]
67+
68+
69+
{{alias}}.strided( z1, sz1, oz1, z2, sz2, oz2, out, so, oo )
70+
Adds two double-precision complex floating-point numbers stored in real-
71+
valued strided array views and assigns results to a provided strided output
72+
array.
73+
74+
Parameters
75+
----------
76+
z1: ArrayLikeObject
77+
First complex number view.
78+
79+
sz1: integer
80+
Stride length for `z1`.
81+
82+
oz1: integer
83+
Starting index for `z1`.
84+
85+
z2: ArrayLikeObject
86+
Second complex number view.
87+
88+
sz2: integer
89+
Stride length for `z2`.
90+
91+
oz2: integer
92+
Starting index for `z2`.
93+
94+
out: ArrayLikeObject
95+
Output array.
96+
97+
so: integer
98+
Stride length for `out`.
99+
100+
oo: integer
101+
Starting index for `out`.
102+
103+
Returns
104+
-------
105+
out: ArrayLikeObject
106+
Output array.
107+
108+
Examples
109+
--------
110+
> var z1 = new {{alias:@stdlib/array/float64}}( [ 5.0, 3.0 ] );
111+
> var z2 = new {{alias:@stdlib/array/float64}}( [ -2.0, 1.0 ] );
112+
> var out = new {{alias:@stdlib/array/float64}}( 2 );
113+
> {{alias}}.strided( z1, 1, 0, z2, 1, 0, out, 1, 0 )
114+
<Float64Array>[ 3.0, 4.0 ]
115+
29116
See Also
30117
--------
31118

0 commit comments

Comments
 (0)