Skip to content

Commit fab60bb

Browse files
committed
refactor: revert implementation for ndarray
--- 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 73cec23 commit fab60bb

File tree

1 file changed

+29
-8
lines changed
  • lib/node_modules/@stdlib/blas/base/zscal/lib

1 file changed

+29
-8
lines changed

lib/node_modules/@stdlib/blas/base/zscal/lib/ndarray.js

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2025 The Stdlib Authors.
4+
* Copyright (c) 2024 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.
@@ -20,7 +20,10 @@
2020

2121
// MODULES //
2222

23-
var cmul = require( '@stdlib/complex/float64/base/mul' );
23+
var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' );
24+
var cmul = require( '@stdlib/complex/float64/base/mul' ).assign;
25+
var real = require( '@stdlib/complex/float64/real' );
26+
var imag = require( '@stdlib/complex/float64/imag' );
2427

2528

2629
// MAIN //
@@ -31,8 +34,8 @@ var cmul = require( '@stdlib/complex/float64/base/mul' );
3134
* @param {PositiveInteger} N - number of indexed elements
3235
* @param {Complex128} za - constant
3336
* @param {Complex128Array} zx - input array
34-
* @param {integer} strideX - `zx` stride length
35-
* @param {NonNegativeInteger} offsetX - starting index for `zx`
37+
* @param {integer} strideZX - `zx` stride length
38+
* @param {NonNegativeInteger} offsetZX - starting `zx` index
3639
* @returns {Complex128Array} input array
3740
*
3841
* @example
@@ -45,17 +48,35 @@ var cmul = require( '@stdlib/complex/float64/base/mul' );
4548
* zscal( 3, za, zx, 1, 0 );
4649
* // zx => <Complex128Array>[ -2.0, 6.0, -2.0, 14.0, -2.0, 22.0 ]
4750
*/
48-
function zscal( N, za, zx, strideX, offsetX ) {
51+
function zscal( N, za, zx, strideZX, offsetZX ) {
52+
var view;
53+
var re1;
54+
var im1;
55+
var re2;
56+
var im2;
57+
var sx;
4958
var ix;
5059
var i;
5160

5261
if ( N <= 0 ) {
5362
return zx;
5463
}
55-
ix = offsetX;
64+
// Reinterpret the input array as a real-valued array of interleaved real and imaginary components:
65+
view = reinterpret( zx, 0 );
66+
67+
// Adjust the stride and offset:
68+
sx = strideZX * 2;
69+
ix = offsetZX * 2;
70+
71+
// Decompose the input scalar to real and imaginary components:
72+
re1 = real( za );
73+
im1 = imag( za );
74+
5675
for ( i = 0; i < N; i++ ) {
57-
zx.set( cmul( za, zx.get( ix ) ), ix );
58-
ix += strideX;
76+
re2 = view[ ix ];
77+
im2 = view[ ix+1 ];
78+
cmul( re1, im1, re2, im2, view, 1, ix );
79+
ix += sx;
5980
}
6081
return zx;
6182
}

0 commit comments

Comments
 (0)