Skip to content

Commit 362f3e9

Browse files
committed
feat: add kernels upto 10d
--- 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 0aaef8c commit 362f3e9

40 files changed

+6364
-12
lines changed

lib/node_modules/@stdlib/ndarray/base/any-by/lib/0d.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style)
3535
* @param {Function} predicate - predicate function
3636
* @param {*} thisArg - predicate function execution context
37-
* @returns {boolean} boolean indicating whether at least one element pass a test
37+
* @returns {boolean} boolean indicating whether at least one element passes a test
3838
*
3939
* @example
4040
* var Float64Array = require( '@stdlib/array/float64' );

lib/node_modules/@stdlib/ndarray/base/any-by/lib/0d_accessors.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
* @param {Array<Function>} x.accessors - data buffer accessors
3636
* @param {Function} predicate - predicate function
3737
* @param {*} thisArg - predicate function execution context
38-
* @returns {boolean} boolean indicating whether at least one element pass a test
38+
* @returns {boolean} boolean indicating whether at least one element passes a test
3939
*
4040
* @example
4141
* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' );
Lines changed: 218 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,218 @@
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+
/* eslint-disable max-depth */
20+
21+
'use strict';
22+
23+
// MODULES //
24+
25+
var strides2order = require( '@stdlib/ndarray/base/strides2order' );
26+
var zeroTo = require( '@stdlib/array/base/zero-to' );
27+
var reverse = require( '@stdlib/array/base/reverse' );
28+
var take = require( '@stdlib/array/base/take-indexed' );
29+
30+
31+
// MAIN //
32+
33+
/**
34+
* Tests whether at least one element in an ndarray passes a test implemented by a predicate function.
35+
*
36+
* @private
37+
* @param {Object} x - object containing ndarray meta data
38+
* @param {ndarrayLike} x.ref - reference to the original ndarray-like object
39+
* @param {string} x.dtype - data type
40+
* @param {Collection} x.data - data buffer
41+
* @param {NonNegativeIntegerArray} x.shape - dimensions
42+
* @param {IntegerArray} x.strides - stride lengths
43+
* @param {NonNegativeInteger} x.offset - index offset
44+
* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style)
45+
* @param {Function} predicate - predicate function
46+
* @param {*} thisArg - predicate function execution context
47+
* @returns {boolean} boolean indicating whether at least one element passes a test
48+
*
49+
* @example
50+
* var Float64Array = require( '@stdlib/array/float64' );
51+
*
52+
* function predicate( value ) {
53+
* return value > 0.0;
54+
* }
55+
*
56+
* // Create a data buffer:
57+
* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
58+
*
59+
* // Define the shape of the input array:
60+
* var shape = [ 1, 1, 1, 1, 1, 1, 1, 3, 1, 2 ];
61+
*
62+
* // Define the array strides:
63+
* var sx = [ 12, 12, 12, 12, 12, 12, 12, 4, 4, 1 ];
64+
*
65+
* // Define the index offset:
66+
* var ox = 1;
67+
*
68+
* // Create the input ndarray-like object:
69+
* var x = {
70+
* 'ref': null,
71+
* 'dtype': 'float64',
72+
* 'data': xbuf,
73+
* 'shape': shape,
74+
* 'strides': sx,
75+
* 'offset': ox,
76+
* 'order': 'row-major'
77+
* };
78+
*
79+
* // Test elements:
80+
* var out = any10d( x, predicate );
81+
* // returns true
82+
*/
83+
function any10d( x, predicate, thisArg ) { // eslint-disable-line max-statements
84+
var xbuf;
85+
var idx;
86+
var dx0;
87+
var dx1;
88+
var dx2;
89+
var dx3;
90+
var dx4;
91+
var dx5;
92+
var dx6;
93+
var dx7;
94+
var dx8;
95+
var dx9;
96+
var sh;
97+
var S0;
98+
var S1;
99+
var S2;
100+
var S3;
101+
var S4;
102+
var S5;
103+
var S6;
104+
var S7;
105+
var S8;
106+
var S9;
107+
var sx;
108+
var ix;
109+
var i0;
110+
var i1;
111+
var i2;
112+
var i3;
113+
var i4;
114+
var i5;
115+
var i6;
116+
var i7;
117+
var i8;
118+
var i9;
119+
120+
// Note on variable naming convention: S#, dx#, i# where # corresponds to the loop number, with `0` being the innermost loop...
121+
122+
// Extract loop variables for purposes of loop interchange: dimensions and loop offset (pointer) increments...
123+
sh = x.shape;
124+
sx = x.strides;
125+
idx = zeroTo( sh.length );
126+
if ( strides2order( sx ) === 1 ) {
127+
// For row-major ndarrays, the last dimensions have the fastest changing indices...
128+
S0 = sh[ 9 ];
129+
S1 = sh[ 8 ];
130+
S2 = sh[ 7 ];
131+
S3 = sh[ 6 ];
132+
S4 = sh[ 5 ];
133+
S5 = sh[ 4 ];
134+
S6 = sh[ 3 ];
135+
S7 = sh[ 2 ];
136+
S8 = sh[ 1 ];
137+
S9 = sh[ 0 ];
138+
dx0 = sx[ 9 ]; // offset increment for innermost loop
139+
dx1 = sx[ 8 ] - ( S0*sx[9] );
140+
dx2 = sx[ 7 ] - ( S1*sx[8] );
141+
dx3 = sx[ 6 ] - ( S2*sx[7] );
142+
dx4 = sx[ 5 ] - ( S3*sx[6] );
143+
dx5 = sx[ 4 ] - ( S4*sx[5] );
144+
dx6 = sx[ 3 ] - ( S5*sx[4] );
145+
dx7 = sx[ 2 ] - ( S6*sx[3] );
146+
dx8 = sx[ 1 ] - ( S7*sx[2] );
147+
dx9 = sx[ 0 ] - ( S8*sx[1] ); // offset increment for outermost loop
148+
} else { // order === 'column-major'
149+
// For column-major ndarrays, the first dimensions have the fastest changing indices...
150+
S0 = sh[ 0 ];
151+
S1 = sh[ 1 ];
152+
S2 = sh[ 2 ];
153+
S3 = sh[ 3 ];
154+
S4 = sh[ 4 ];
155+
S5 = sh[ 5 ];
156+
S6 = sh[ 6 ];
157+
S7 = sh[ 7 ];
158+
S8 = sh[ 8 ];
159+
S9 = sh[ 9 ];
160+
dx0 = sx[ 0 ]; // offset increment for innermost loop
161+
dx1 = sx[ 1 ] - ( S0*sx[0] );
162+
dx2 = sx[ 2 ] - ( S1*sx[1] );
163+
dx3 = sx[ 3 ] - ( S2*sx[2] );
164+
dx4 = sx[ 4 ] - ( S3*sx[3] );
165+
dx5 = sx[ 5 ] - ( S4*sx[4] );
166+
dx6 = sx[ 6 ] - ( S5*sx[5] );
167+
dx7 = sx[ 7 ] - ( S6*sx[6] );
168+
dx8 = sx[ 8 ] - ( S7*sx[7] );
169+
dx9 = sx[ 9 ] - ( S8*sx[8] ); // offset increment for outermost loop
170+
idx = reverse( idx );
171+
}
172+
// Set a pointer to the first indexed element:
173+
ix = x.offset;
174+
175+
// Cache a reference to the input ndarray buffer:
176+
xbuf = x.data;
177+
178+
// Iterate over the ndarray dimensions...
179+
for ( i9 = 0; i9 < S9; i9++ ) {
180+
for ( i8 = 0; i8 < S8; i8++ ) {
181+
for ( i7 = 0; i7 < S7; i7++ ) {
182+
for ( i6 = 0; i6 < S6; i6++ ) {
183+
for ( i5 = 0; i5 < S5; i5++ ) {
184+
for ( i4 = 0; i4 < S4; i4++ ) {
185+
for ( i3 = 0; i3 < S3; i3++ ) {
186+
for ( i2 = 0; i2 < S2; i2++ ) {
187+
for ( i1 = 0; i1 < S1; i1++ ) {
188+
for ( i0 = 0; i0 < S0; i0++ ) {
189+
if ( predicate.call( thisArg, xbuf[ ix ], take( [ i9, i8, i7, i6, i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len
190+
return true;
191+
}
192+
ix += dx0;
193+
}
194+
ix += dx1;
195+
}
196+
ix += dx2;
197+
}
198+
ix += dx3;
199+
}
200+
ix += dx4;
201+
}
202+
ix += dx5;
203+
}
204+
ix += dx6;
205+
}
206+
ix += dx7;
207+
}
208+
ix += dx8;
209+
}
210+
ix += dx9;
211+
}
212+
return false;
213+
}
214+
215+
216+
// EXPORTS //
217+
218+
module.exports = any10d;

0 commit comments

Comments
 (0)