Skip to content

Commit ceae67b

Browse files
committed
refactor: add function to initialize array views
--- 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 3864776 commit ceae67b

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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+
// MAIN //
22+
23+
/**
24+
* Initialize ndarray-like objects for representing zero-dimensional sub-array views of the output and ancillary ndarray arguments.
25+
*
26+
* ## Notes
27+
*
28+
* - This function ignores the first ndarray-like object, which is assumed to be the input ndarray.
29+
* - This function mutates the provided output array.
30+
*
31+
* @private
32+
* @param {ArrayLikeObject<Object>} arrays - list of ndarray-like objects
33+
* @param {Array<Object>} out - output array
34+
* @returns {Array<Object>} output array
35+
*/
36+
function initializeViews( arrays, out ) {
37+
var v;
38+
var i;
39+
40+
for ( i = 1; i < arrays.length; i++ ) {
41+
v = arrays[ i ];
42+
out.push({
43+
'dtype': v.dtype,
44+
'data': v.data,
45+
'shape': [],
46+
'strides': [ 0 ],
47+
'offset': v.offset,
48+
'order': v.order
49+
});
50+
}
51+
return out;
52+
}
53+
54+
55+
// EXPORTS //
56+
57+
module.exports = initializeViews;

0 commit comments

Comments
 (0)