Skip to content

Commit 9a0599e

Browse files
committed
Auto-generated commit
1 parent aabd3d7 commit 9a0599e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+7883
-0
lines changed

CHANGELOG.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,6 +1039,50 @@ A total of 2 issues were closed in this release:
10391039

10401040
<!-- /.package -->
10411041

1042+
<section class="package" id="ndarray-base-unary-reduce-strided1d-dispatch-unreleased">
1043+
1044+
#### [@stdlib/ndarray/base/unary-reduce-strided1d-dispatch](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/unary-reduce-strided1d-dispatch)
1045+
1046+
<details>
1047+
1048+
<section class="features">
1049+
1050+
##### Features
1051+
1052+
- [`a374c5a`](https://github.com/stdlib-js/stdlib/commit/a374c5a0a41ce15ea957d6fa92d0a6b7fe6baa1f) - add `ndarray/base/unary-reduce-strided1d-dispatch`
1053+
1054+
</section>
1055+
1056+
<!-- /.features -->
1057+
1058+
</details>
1059+
1060+
</section>
1061+
1062+
<!-- /.package -->
1063+
1064+
<section class="package" id="ndarray-base-unary-reduce-strided1d-dispatch-factory-unreleased">
1065+
1066+
#### [@stdlib/ndarray/base/unary-reduce-strided1d-dispatch-factory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/unary-reduce-strided1d-dispatch-factory)
1067+
1068+
<details>
1069+
1070+
<section class="features">
1071+
1072+
##### Features
1073+
1074+
- [`9c1e5c9`](https://github.com/stdlib-js/stdlib/commit/9c1e5c9b5b87643d31668a7a0b9c009413fa4c05) - add `ndarray/base/unary-reduce-strided1d-dispatch-factory`
1075+
1076+
</section>
1077+
1078+
<!-- /.features -->
1079+
1080+
</details>
1081+
1082+
</section>
1083+
1084+
<!-- /.package -->
1085+
10421086
<section class="package" id="ndarray-base-unary-reduce-subarray-unreleased">
10431087

10441088
#### [@stdlib/ndarray/base/unary-reduce-subarray](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/unary-reduce-subarray)
@@ -1110,6 +1154,50 @@ A total of 2 issues were closed in this release:
11101154

11111155
<!-- /.package -->
11121156

1157+
<section class="package" id="ndarray-base-unary-strided1d-dispatch-unreleased">
1158+
1159+
#### [@stdlib/ndarray/base/unary-strided1d-dispatch](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/unary-strided1d-dispatch)
1160+
1161+
<details>
1162+
1163+
<section class="features">
1164+
1165+
##### Features
1166+
1167+
- [`3036ccc`](https://github.com/stdlib-js/stdlib/commit/3036cccd1db41f0093555d2b7c890bdbd6f07cdf) - add `ndarray/base/unary-strided1d-dispatch`
1168+
1169+
</section>
1170+
1171+
<!-- /.features -->
1172+
1173+
</details>
1174+
1175+
</section>
1176+
1177+
<!-- /.package -->
1178+
1179+
<section class="package" id="ndarray-base-unary-strided1d-dispatch-factory-unreleased">
1180+
1181+
#### [@stdlib/ndarray/base/unary-strided1d-dispatch-factory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/unary-strided1d-dispatch-factory)
1182+
1183+
<details>
1184+
1185+
<section class="features">
1186+
1187+
##### Features
1188+
1189+
- [`db7d60b`](https://github.com/stdlib-js/stdlib/commit/db7d60b388d19ab8a4b537ec3445f3181ef270b7) - add `ndarray/base/unary-strided1d-dispatch-factory`
1190+
1191+
</section>
1192+
1193+
<!-- /.features -->
1194+
1195+
</details>
1196+
1197+
</section>
1198+
1199+
<!-- /.package -->
1200+
11131201
<section class="package" id="ndarray-ctor-unreleased">
11141202

11151203
#### [@stdlib/ndarray/ctor](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/ctor)
@@ -1631,6 +1719,10 @@ A total of 14 people contributed to this release. Thank you to the following con
16311719

16321720
<details>
16331721

1722+
- [`db7d60b`](https://github.com/stdlib-js/stdlib/commit/db7d60b388d19ab8a4b537ec3445f3181ef270b7) - **feat:** add `ndarray/base/unary-strided1d-dispatch-factory` _(by Athan Reines)_
1723+
- [`3036ccc`](https://github.com/stdlib-js/stdlib/commit/3036cccd1db41f0093555d2b7c890bdbd6f07cdf) - **feat:** add `ndarray/base/unary-strided1d-dispatch` _(by Athan Reines)_
1724+
- [`9c1e5c9`](https://github.com/stdlib-js/stdlib/commit/9c1e5c9b5b87643d31668a7a0b9c009413fa4c05) - **feat:** add `ndarray/base/unary-reduce-strided1d-dispatch-factory` _(by Athan Reines)_
1725+
- [`a374c5a`](https://github.com/stdlib-js/stdlib/commit/a374c5a0a41ce15ea957d6fa92d0a6b7fe6baa1f) - **feat:** add `ndarray/base/unary-reduce-strided1d-dispatch` _(by Athan Reines)_
16341726
- [`3be1d66`](https://github.com/stdlib-js/stdlib/commit/3be1d666a8dffa16c58b4ab1b4186e0f7b1b15f9) - **chore:** address commit comments for commit `a1e8f03` [(#6784)](https://github.com/stdlib-js/stdlib/pull/6784) _(by devshree-bhati, stdlib-bot)_
16351727
- [`e00f861`](https://github.com/stdlib-js/stdlib/commit/e00f86162891392508f20d212cf2b3b01f111203) - **refactor:** ensure iteration happens according to memory layout of input ndarray _(by Athan Reines)_
16361728
- [`0216d98`](https://github.com/stdlib-js/stdlib/commit/0216d98429db599b577ac3b5dd89bc6b72902e1c) - **fix:** verify that input and output ndarrays have same number of dimensions _(by Athan Reines)_
Lines changed: 262 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,262 @@
1+
<!--
2+
3+
@license Apache-2.0
4+
5+
Copyright (c) 2025 The Stdlib Authors.
6+
7+
Licensed under the Apache License, Version 2.0 (the "License");
8+
you may not use this file except in compliance with the License.
9+
You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
19+
-->
20+
21+
# unaryStrided1dDispatchFactory
22+
23+
> Create a function for performing a reduction on an input ndarray.
24+
25+
<section class="usage">
26+
27+
## Usage
28+
29+
<!-- eslint-disable id-length -->
30+
31+
```javascript
32+
var unaryStrided1dDispatchFactory = require( '@stdlib/ndarray/base/unary-reduce-strided1d-dispatch-factory' );
33+
```
34+
35+
#### unaryStrided1dDispatchFactory( table, idtypes, odtypes, policy )
36+
37+
Returns a function for performing a reduction on an input ndarray.
38+
39+
<!-- eslint-disable id-length -->
40+
41+
```javascript
42+
var base = require( '@stdlib/stats/base/ndarray/max' );
43+
44+
var table = {
45+
'default': base
46+
};
47+
48+
var dtypes = [ 'float64', 'float32', 'generic' ];
49+
var policy = 'same';
50+
51+
var unary = unaryStrided1dDispatchFactory( table, [ dtypes ], dtypes, policy );
52+
```
53+
54+
- **table**: strided reduction function dispatch table. Must have a `'default'` property and a corresponding strided reduction function. May have additional properties corresponding to specific data types and associated specialized strided reduction functions.
55+
- **idtypes**: list containing lists of supported input data types for each input ndarray argument.
56+
- **odtypes**: list of supported input data types.
57+
- **policy**: output data type policy.
58+
59+
#### unary( x\[, ...args]\[, options] )
60+
61+
Performs a reduction on a provided input ndarray.
62+
63+
<!-- eslint-disable id-length -->
64+
65+
```javascript
66+
var ndarray = require( '@stdlib/ndarray/base/ctor' );
67+
var base = require( '@stdlib/stats/base/ndarray/max' );
68+
69+
var table = {
70+
'default': base
71+
};
72+
73+
var dtypes = [ 'float64', 'float32', 'generic' ];
74+
var policy = 'same';
75+
76+
var unary = unaryStrided1dDispatchFactory( table, [ dtypes ], dtypes, policy );
77+
78+
var xbuf = [ -1.0, 2.0, -3.0 ];
79+
var x = new ndarray( 'generic', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' );
80+
81+
var y = unary( x );
82+
// returns <ndarray>
83+
84+
var v = y.get();
85+
// returns 2.0
86+
```
87+
88+
The function has the following parameters:
89+
90+
- **x**: input ndarray.
91+
- **...args**: additional input ndarray arguments (_optional_).
92+
- **options**: function options (_optional_).
93+
94+
The function accepts the following options:
95+
96+
- **dims**: list of dimensions over which to perform a reduction.
97+
- **dtype**: output ndarray data type. Setting this option, overrides the output data type policy.
98+
- **keepdims**: boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions. Default: `false`.
99+
100+
By default, the function returns an ndarray having a data type determined by the output data type policy. To override the default behavior, set the `dtype` option.
101+
102+
<!-- eslint-disable id-length -->
103+
104+
```javascript
105+
var ndarray = require( '@stdlib/ndarray/base/ctor' );
106+
var base = require( '@stdlib/stats/base/ndarray/max' );
107+
var getDType = require( '@stdlib/ndarray/dtype' );
108+
109+
var table = {
110+
'default': base
111+
};
112+
113+
var dtypes = [ 'float64', 'float32', 'generic' ];
114+
var policy = 'same';
115+
116+
var unary = unaryStrided1dDispatchFactory( table, [ dtypes ], dtypes, policy );
117+
118+
var xbuf = [ -1.0, 2.0, -3.0 ];
119+
var x = new ndarray( 'generic', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' );
120+
121+
var y = unary( x, {
122+
'dtype': 'float64'
123+
});
124+
// returns <ndarray>
125+
126+
var dt = getDType( y );
127+
// returns 'float64'
128+
```
129+
130+
#### unary.assign( x\[, ...args], out\[, options] )
131+
132+
Performs a reduction on a provided input ndarray and assigns results to a provided output ndarray.
133+
134+
<!-- eslint-disable id-length -->
135+
136+
```javascript
137+
var base = require( '@stdlib/stats/base/ndarray/max' );
138+
var dtypes = require( '@stdlib/ndarray/dtypes' );
139+
var ndarray = require( '@stdlib/ndarray/base/ctor' );
140+
141+
var idt = dtypes( 'real_and_generic' );
142+
var odt = idt;
143+
var policy = 'same';
144+
145+
var table = {
146+
'default': base
147+
};
148+
var unary = unaryStrided1dDispatchFactory( table, [ idt ], odt, policy );
149+
150+
var xbuf = [ -1.0, 2.0, -3.0 ];
151+
var x = new ndarray( 'generic', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' );
152+
153+
var ybuf = [ 0.0 ];
154+
var y = new ndarray( 'generic', ybuf, [], [ 0 ], 0, 'row-major' );
155+
156+
var out = unary.assign( x, y );
157+
// returns <ndarray>
158+
159+
var v = out.get();
160+
// returns 2.0
161+
162+
var bool = ( out === y );
163+
// returns true
164+
```
165+
166+
The method has the following parameters:
167+
168+
- **x**: input ndarray.
169+
- **args**: additional input ndarray arguments (_optional_).
170+
- **out**: output ndarray.
171+
- **options**: function options (_optional_).
172+
173+
The function accepts the following options:
174+
175+
- **dims**: list of dimensions over which to perform a reduction.
176+
177+
</section>
178+
179+
<!-- /.usage -->
180+
181+
<section class="notes">
182+
183+
## Notes
184+
185+
- The output data type policy only applies to the function returned by `factory`. For the `assign` method, the output ndarray is allowed to have any data type.
186+
187+
</section>
188+
189+
<!-- /.notes -->
190+
191+
<section class="examples">
192+
193+
## Examples
194+
195+
<!-- eslint-disable id-length, max-len -->
196+
197+
<!-- eslint no-undef: "error" -->
198+
199+
```javascript
200+
var base = require( '@stdlib/stats/base/ndarray/max' );
201+
var uniform = require( '@stdlib/random/array/uniform' );
202+
var dtypes = require( '@stdlib/ndarray/dtypes' );
203+
var dtype = require( '@stdlib/ndarray/dtype' );
204+
var ndarray2array = require( '@stdlib/ndarray/to-array' );
205+
var ndarray = require( '@stdlib/ndarray/ctor' );
206+
var unaryStrided1dDispatchFactory = require( '@stdlib/ndarray/base/unary-reduce-strided1d-dispatch-factory' );
207+
208+
// Define the supported input and output data types:
209+
var idt = dtypes( 'real_and_generic' );
210+
var odt = dtypes( 'real_and_generic' );
211+
212+
// Define the policy mapping an input data type to an output data type:
213+
var policy = 'same';
214+
215+
// Define a dispatch table:
216+
var table = {
217+
'default': base
218+
};
219+
220+
// Create an interface for performing a reduction:
221+
var max = unaryStrided1dDispatchFactory( table, [ idt ], odt, policy );
222+
223+
// Generate an array of random numbers:
224+
var xbuf = uniform( 100, -1.0, 1.0, {
225+
'dtype': 'generic'
226+
});
227+
228+
// Wrap in an ndarray:
229+
var x = new ndarray( 'generic', xbuf, [ 10, 10 ], [ 10, 1 ], 0, 'row-major' );
230+
231+
// Perform a reduction:
232+
var y = max( x, {
233+
'dims': [ 0 ]
234+
});
235+
236+
// Resolve the output array data type:
237+
var dt = dtype( y );
238+
console.log( dt );
239+
240+
// Print the results:
241+
console.log( ndarray2array( y ) );
242+
```
243+
244+
</section>
245+
246+
<!-- /.examples -->
247+
248+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
249+
250+
<section class="related">
251+
252+
</section>
253+
254+
<!-- /.related -->
255+
256+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
257+
258+
<section class="links">
259+
260+
</section>
261+
262+
<!-- /.links -->

0 commit comments

Comments
 (0)