Skip to content

Commit 6ad3152

Browse files
kgrytesaurabhraghuvanshii
authored andcommitted
feat: add strided API
--- 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 0fa6ac9 commit 6ad3152

File tree

10 files changed

+616
-10
lines changed

10 files changed

+616
-10
lines changed

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

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ var im = imag( v );
5858
// returns -1.0
5959
```
6060

61+
The function supports the following parameters:
62+
63+
- **z1**: first [complex number][@stdlib/complex/float64/ctor].
64+
- **z2**: second [complex number][@stdlib/complex/float64/ctor].
65+
6166
#### mul.assign( re1, im1, re2, im2, out, strideOut, offsetOut )
6267

6368
Multiplies two double-precision complex floating-point numbers and assigns results to a provided output array.
@@ -73,6 +78,46 @@ var bool = ( out === v );
7378
// returns true
7479
```
7580

81+
The function supports the following parameters:
82+
83+
- **re1**: real component of the first complex number.
84+
- **im1**: imaginary component of the first complex number.
85+
- **re2**: real component of the second complex number.
86+
- **im2**: imaginary component of the second complex number.
87+
- **out**: output array.
88+
- **strideOut**: stride length for `out`.
89+
- **offsetOut**: starting index for `out`.
90+
91+
#### mul.strided( z1, sz1, oz1, z2, sz2, oz2, out, so, oo )
92+
93+
Multiplies two double-precision complex floating-point numbers stored in real-valued strided array views and assigns results to a provided strided output array.
94+
95+
```javascript
96+
var Float64Array = require( '@stdlib/array/float64' );
97+
98+
var z1 = new Float64Array( [ 5.0, 3.0 ] );
99+
var z2 = new Float64Array( [ -2.0, 1.0 ] );
100+
var out = new Float64Array( 2 );
101+
102+
var v = mul.strided( z1, 1, 0, z2, 1, 0, out, 1, 0 );
103+
// returns <Float64Array>[ -13.0, -1.0 ]
104+
105+
var bool = ( out === v );
106+
// returns true
107+
```
108+
109+
The function supports the following parameters:
110+
111+
- **z1**: first complex number strided array view.
112+
- **sz1**: stride length for `z1`.
113+
- **oz1**: starting index for `z1`.
114+
- **z2**: second complex number strided array view.
115+
- **sz2**: stride length for `z2`.
116+
- **oz2**: starting index for `z2`.
117+
- **out**: output array.
118+
- **so**: stride length for `out`.
119+
- **oo**: starting index for `out`.
120+
76121
</section>
77122

78123
<!-- /.usage -->
@@ -239,6 +284,8 @@ int main( void ) {
239284

240285
<section class="links">
241286

287+
[@stdlib/complex/float64/ctor]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/ctor
288+
242289
<!-- <related-links> -->
243290

244291
[@stdlib/complex/float64/base/add]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/base/add

lib/node_modules/@stdlib/complex/float64/base/mul/benchmark/benchmark.assign.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ var pkg = require( './../package.json' ).name;
2828
var mul = require( './../lib' );
2929

3030

31+
// VARIABLES //
32+
33+
var options = {
34+
'dtype': 'float64'
35+
};
36+
37+
3138
// MAIN //
3239

3340
bench( pkg+':assign', function benchmark( b ) {
@@ -40,8 +47,8 @@ bench( pkg+':assign', function benchmark( b ) {
4047
var k;
4148

4249
N = 100;
43-
re = uniform( N, -500.0, 500.0 );
44-
im = uniform( N, -500.0, 500.0 );
50+
re = uniform( N, -500.0, 500.0, options );
51+
im = uniform( N, -500.0, 500.0, options );
4552

4653
out = new Float64Array( 2 );
4754

Lines changed: 68 additions & 0 deletions
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 mul = 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 = mul.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/mul/docs/repl.txt

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,54 @@
6767
> {{alias}}.assign( 5.0, 3.0, -2.0, 1.0, out, 1, 0 )
6868
<Float64Array>[ -13.0, -1.0 ]
6969

70+
71+
{{alias}}.strided( z1, sz1, oz1, z2, sz2, oz2, out, so, oo )
72+
Multiplies two double-precision complex floating-point numbers stored in
73+
real-valued strided array views and assigns results to a provided strided
74+
output array.
75+
76+
Parameters
77+
----------
78+
z1: ArrayLikeObject
79+
First complex number view.
80+
81+
sz1: integer
82+
Stride length for `z1`.
83+
84+
oz1: integer
85+
Starting index for `z1`.
86+
87+
z2: ArrayLikeObject
88+
Second complex number view.
89+
90+
sz2: integer
91+
Stride length for `z2`.
92+
93+
oz2: integer
94+
Starting index for `z2`.
95+
96+
out: ArrayLikeObject
97+
Output array.
98+
99+
so: integer
100+
Stride length for `out`.
101+
102+
oo: integer
103+
Starting index for `out`.
104+
105+
Returns
106+
-------
107+
out: ArrayLikeObject
108+
Output array.
109+
110+
Examples
111+
--------
112+
> var z1 = new {{alias:@stdlib/array/float64}}( [ 5.0, 3.0 ] );
113+
> var z2 = new {{alias:@stdlib/array/float64}}( [ -2.0, 1.0 ] );
114+
> var out = new {{alias:@stdlib/array/float64}}( 2 );
115+
> {{alias}}.strided( z1, 1, 0, z2, 1, 0, out, 1, 0 )
116+
<Float64Array>[ -13.0, -1.0 ]
117+
70118
See Also
71119
--------
72120

lib/node_modules/@stdlib/complex/float64/base/mul/docs/types/index.d.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,31 @@ interface Mul {
7979
* // returns true
8080
*/
8181
assign<T extends NumericArray | Collection<number>>( re1: number, im1: number, re2: number, im2: number, out: T, strideOut: number, offsetOut: number ): T;
82+
83+
/**
84+
* Multiplies two double-precision complex floating-point numbers stored in real-valued strided array views and assigns results to a provided strided output array.
85+
*
86+
* @param z1 - first complex number view
87+
* @param strideZ1 - stride length for `z1`
88+
* @param offsetZ1 - starting index for `z1`
89+
* @param z2 - second complex number view
90+
* @param strideZ2 - stride length for `z2`
91+
* @param offsetZ2 - starting index for `z2`
92+
* @param out - output array
93+
* @param strideOut - stride length for `out`
94+
* @param offsetOut - starting index for `out`
95+
* @returns output array
96+
*
97+
* @example
98+
* var Float64Array = require( '@stdlib/array/float64' );
99+
*
100+
* var z1 = new Float64Array( [ 5.0, 3.0 ] );
101+
* var z2 = new Float64Array( [ -2.0, 1.0 ] );
102+
*
103+
* var out = mul.strided( z1, 1, 0, z2, 1, 0, new Float64Array( 2 ), 1, 0 );
104+
* // returns <Float64Array>[ -13.0, -1.0 ]
105+
*/
106+
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;
82107
}
83108

84109
/**
@@ -117,6 +142,15 @@ interface Mul {
117142
*
118143
* var bool = ( out === v );
119144
* // returns true
145+
*
146+
* @example
147+
* var Float64Array = require( '@stdlib/array/float64' );
148+
*
149+
* var z1 = new Float64Array( [ 5.0, 3.0 ] );
150+
* var z2 = new Float64Array( [ -2.0, 1.0 ] );
151+
*
152+
* var out = mul.strided( z1, 1, 0, z2, 1, 0, new Float64Array( 2 ), 1, 0 );
153+
* // returns <Float64Array>[ -13.0, -1.0 ]
120154
*/
121155
declare var mul: Mul;
122156

0 commit comments

Comments
 (0)