Skip to content

Commit 3963684

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: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 2970a90 commit 3963684

File tree

3 files changed

+150
-0
lines changed

3 files changed

+150
-0
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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 Complex128 = require( '@stdlib/complex/float64/ctor' );
24+
var real = require( '@stdlib/complex/float64/real' );
25+
var imag = require( '@stdlib/complex/float64/imag' );
26+
var div = require( './main.js' );
27+
28+
29+
// MAIN //
30+
31+
/**
32+
* Divides two double-precision complex floating-point numbers and assigns results to a provided output array.
33+
*
34+
* @param {number} re1 - real component of the first complex number
35+
* @param {number} im1 - imaginary component of the first complex number
36+
* @param {number} re2 - real component of the second complex number
37+
* @param {number} im2 - imaginary component of the second complex number
38+
* @param {Collection} out - output array
39+
* @param {integer} strideOut - stride length
40+
* @param {NonNegativeInteger} offsetOut - starting index
41+
* @returns {Collection} output array
42+
*
43+
* @example
44+
* var Float64Array = require( '@stdlib/array/float64' );
45+
*
46+
* var out = assign( -13.0, -1.0, -2.0, 1.0, new Float64Array( 2 ), 1, 0 );
47+
* // returns <Float64Array>[ 5.0, 3.0 ]
48+
*/
49+
function assign( re1, im1, re2, im2, out, strideOut, offsetOut ) {
50+
var ans;
51+
var c1;
52+
var c2;
53+
54+
c1 = new Complex128( re1, im1 );
55+
c2 = new Complex128( re2, im2 );
56+
57+
ans = div( c1, c2 );
58+
59+
out[ offsetOut ] = real( ans );
60+
out[ offsetOut+strideOut ] = imag( ans );
61+
return out;
62+
}
63+
64+
65+
// EXPORTS //
66+
67+
module.exports = assign;

lib/node_modules/@stdlib/complex/float64/base/div/lib/index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,20 @@
3636

3737
// MODULES //
3838

39+
var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
3940
var main = require( './main.js' );
41+
var assign = require( './assign.js' );
42+
var strided = require( './strided.js' );
43+
44+
45+
// MAIN //
46+
47+
setReadOnly( main, 'assign', assign );
48+
setReadOnly( main, 'strided', strided );
4049

4150

4251
// EXPORTS //
4352

4453
module.exports = main;
54+
55+
// exports: { "assign": "main.assign", "strided": "main.strided" }
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
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 Complex128 = require( '@stdlib/complex/float64/ctor' );
24+
var real = require( '@stdlib/complex/float64/real' );
25+
var imag = require( '@stdlib/complex/float64/imag' );
26+
var div = require( './main.js' );
27+
28+
29+
// MAIN //
30+
31+
/**
32+
* Divides two double-precision complex floating-point numbers stored in real-valued strided array views and assigns results to a provided strided output array.
33+
*
34+
* @param {Float64Array} z1 - first complex number view
35+
* @param {integer} strideZ1 - stride length for `z1`
36+
* @param {NonNegativeInteger} offsetZ1 - starting index for `z1`
37+
* @param {Float64Array} z2 - second complex number view
38+
* @param {integer} strideZ2 - stride length for `z2`
39+
* @param {NonNegativeInteger} offsetZ2 - starting index for `z2`
40+
* @param {Collection} out - output array
41+
* @param {integer} strideOut - stride length for `out`
42+
* @param {NonNegativeInteger} offsetOut - starting index for `out`
43+
* @returns {Collection} output array
44+
*
45+
* @example
46+
* var Float64Array = require( '@stdlib/array/float64' );
47+
*
48+
* var z1 = new Float64Array( [ -13.0, -1.0 ] );
49+
* var z2 = new Float64Array( [ -2.0, 1.0 ] );
50+
*
51+
* var out = strided( z1, 1, 0, z2, 1, 0, new Float64Array( 2 ), 1, 0 );
52+
* // returns <Float64Array>[ 5.0, 3.0 ]
53+
*/
54+
function strided( z1, strideZ1, offsetZ1, z2, strideZ2, offsetZ2, out, strideOut, offsetOut ) { // eslint-disable-line max-len
55+
var ans;
56+
var c1;
57+
var c2;
58+
59+
c1 = new Complex128( z1[ offsetZ1 ], z1[ offsetZ1+strideZ1 ] );
60+
c2 = new Complex128( z2[ offsetZ2 ], z2[ offsetZ2+strideZ2 ] );
61+
ans = div( c1, c2 );
62+
63+
out[ offsetOut ] = real( ans );
64+
out[ offsetOut+strideOut ] = imag( ans );
65+
66+
return out;
67+
}
68+
69+
70+
// EXPORTS //
71+
72+
module.exports = strided;

0 commit comments

Comments
 (0)