Skip to content

Commit 924df6a

Browse files
committed
Auto-generated commit
1 parent 80d77e3 commit 924df6a

18 files changed

+320
-159
lines changed

CHANGELOG.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,25 @@
44
55
<section class="release" id="unreleased">
66

7-
## Unreleased (2025-01-18)
7+
## Unreleased (2025-02-02)
8+
9+
<section class="features">
10+
11+
### Features
12+
13+
- [`7793d43`](https://github.com/stdlib-js/stdlib/commit/7793d4347d1e97f221b05522e724dd26ebb96ca7) - add support for accessor arrays and refactor `stats/base/max` [(#5008)](https://github.com/stdlib-js/stdlib/pull/5008)
14+
15+
</section>
16+
17+
<!-- /.features -->
818

919
<section class="commits">
1020

1121
### Commits
1222

1323
<details>
1424

25+
- [`7793d43`](https://github.com/stdlib-js/stdlib/commit/7793d4347d1e97f221b05522e724dd26ebb96ca7) - **feat:** add support for accessor arrays and refactor `stats/base/max` [(#5008)](https://github.com/stdlib-js/stdlib/pull/5008) _(by Aayush Khanna)_
1526
- [`e0799e5`](https://github.com/stdlib-js/stdlib/commit/e0799e5da799e74ff3369f652f4380aeb8dfe7fc) - **refactor:** update paths _(by Athan Reines)_
1627

1728
</details>
@@ -24,8 +35,9 @@
2435

2536
### Contributors
2637

27-
A total of 1 person contributed to this release. Thank you to this contributor:
38+
A total of 2 people contributed to this release. Thank you to the following contributors:
2839

40+
- Aayush Khanna
2941
- Athan Reines
3042

3143
</section>

CONTRIBUTORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Daniel Killenberger <daniel.killenberger@gmail.com>
2727
Daniel Yu <40680511+Daniel777y@users.noreply.github.com>
2828
Debashis Maharana <debashismaharana7854@gmail.com>
2929
Desh Deepak Kant <118960904+DeshDeepakKant@users.noreply.github.com>
30+
Dev Goel <135586571+corsairier@users.noreply.github.com>
3031
Dhruv Arvind Singh <154677013+DhruvArvindSingh@users.noreply.github.com>
3132
Divyansh Seth <59174836+sethdivyansh@users.noreply.github.com>
3233
Dominic Lim <46486515+domlimm@users.noreply.github.com>

README.md

Lines changed: 18 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -69,33 +69,29 @@ To view installation and usage instructions specific to each branch build, be su
6969
var max = require( '@stdlib/stats-base-max' );
7070
```
7171

72-
#### max( N, x, stride )
72+
#### max( N, x, strideX )
7373

7474
Computes the maximum value of a strided array `x`.
7575

7676
```javascript
7777
var x = [ 1.0, -2.0, 2.0 ];
78-
var N = x.length;
7978

80-
var v = max( N, x, 1 );
79+
var v = max( x.length, x, 1 );
8180
// returns 2.0
8281
```
8382

8483
The function has the following parameters:
8584

8685
- **N**: number of indexed elements.
8786
- **x**: input [`Array`][mdn-array] or [`typed array`][mdn-typed-array].
88-
- **stride**: index increment for `x`.
87+
- **strideX**: stride length for `x`.
8988

90-
The `N` and `stride` parameters determine which elements in `x` are accessed at runtime. For example, to compute the maximum value of every other element in `x`,
89+
The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to compute the maximum value of every other element in `x`,
9190

9291
```javascript
93-
var floor = require( '@stdlib/math-base-special-floor' );
94-
9592
var x = [ 1.0, 2.0, 2.0, -7.0, -2.0, 3.0, 4.0, 2.0 ];
96-
var N = floor( x.length / 2 );
9793

98-
var v = max( N, x, 2 );
94+
var v = max( 4, x, 2 );
9995
// returns 4.0
10096
```
10197

@@ -105,42 +101,35 @@ Note that indexing is relative to the first index. To introduce an offset, use [
105101

106102
```javascript
107103
var Float64Array = require( '@stdlib/array-float64' );
108-
var floor = require( '@stdlib/math-base-special-floor' );
109104

110105
var x0 = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] );
111106
var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
112107

113-
var N = floor( x0.length / 2 );
114-
115-
var v = max( N, x1, 2 );
108+
var v = max( 4, x1, 2 );
116109
// returns 4.0
117110
```
118111

119-
#### max.ndarray( N, x, stride, offset )
112+
#### max.ndarray( N, x, strideX, offsetX )
120113

121114
Computes the maximum value of a strided array using alternative indexing semantics.
122115

123116
```javascript
124117
var x = [ 1.0, -2.0, 2.0 ];
125-
var N = x.length;
126118

127-
var v = max.ndarray( N, x, 1, 0 );
119+
var v = max.ndarray( x.length, x, 1, 0 );
128120
// returns 2.0
129121
```
130122

131123
The function has the following additional parameters:
132124

133-
- **offset**: starting index for `x`.
125+
- **offsetX**: starting index for `x`.
134126

135-
While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, the `offset` parameter supports indexing semantics based on a starting index. For example, to calculate the maximum value for every other value in `x` starting from the second value
127+
While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting index. For example, to calculate the maximum value for every other element in `x` starting from the second element
136128

137129
```javascript
138-
var floor = require( '@stdlib/math-base-special-floor' );
139-
140130
var x = [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ];
141-
var N = floor( x.length / 2 );
142131

143-
var v = max.ndarray( N, x, 2, 1 );
132+
var v = max.ndarray( 4, x, 2, 1 );
144133
// returns 4.0
145134
```
146135

@@ -153,6 +142,7 @@ var v = max.ndarray( N, x, 2, 1 );
153142
## Notes
154143

155144
- If `N <= 0`, both functions return `NaN`.
145+
- Both functions support array-like objects having getter and setter accessors for array element access (e.g., [`@stdlib/array-base/accessor`][@stdlib/array/base/accessor]).
156146
- Depending on the environment, the typed versions ([`dmax`][@stdlib/stats/strided/dmax], [`smax`][@stdlib/stats/base/smax], etc.) are likely to be significantly more performant.
157147

158148
</section>
@@ -166,18 +156,12 @@ var v = max.ndarray( N, x, 2, 1 );
166156
<!-- eslint no-undef: "error" -->
167157

168158
```javascript
169-
var randu = require( '@stdlib/random-base-randu' );
170-
var round = require( '@stdlib/math-base-special-round' );
171-
var Float64Array = require( '@stdlib/array-float64' );
159+
var discreteUniform = require( '@stdlib/random-array-discrete-uniform' );
172160
var max = require( '@stdlib/stats-base-max' );
173161

174-
var x;
175-
var i;
176-
177-
x = new Float64Array( 10 );
178-
for ( i = 0; i < x.length; i++ ) {
179-
x[ i ] = round( (randu()*100.0) - 50.0 );
180-
}
162+
var x = discreteUniform( 10, -50, 50, {
163+
'dtype': 'float64'
164+
});
181165
console.log( x );
182166

183167
var v = max( x.length, x, 1 );
@@ -281,6 +265,8 @@ Copyright &copy; 2016-2025. The Stdlib [Authors][stdlib-authors].
281265

282266
[mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray
283267

268+
[@stdlib/array/base/accessor]: https://github.com/stdlib-js/array-base-accessor
269+
284270
<!-- <related-links> -->
285271

286272
[@stdlib/stats/strided/dmax]: https://github.com/stdlib-js/stats-strided-dmax

benchmark/benchmark.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,18 @@
2121
// MODULES //
2222

2323
var bench = require( '@stdlib/bench-harness' );
24-
var randu = require( '@stdlib/random-base-randu' );
24+
var uniform = require( '@stdlib/random-array-uniform' );
2525
var isnan = require( '@stdlib/math-base-assert-is-nan' );
2626
var pow = require( '@stdlib/math-base-special-pow' );
2727
var pkg = require( './../package.json' ).name;
28-
var max = require( './../lib/max.js' );
28+
var max = require( './../lib/main.js' );
29+
30+
31+
// VARIABLES //
32+
33+
var options = {
34+
'dtype': 'generic'
35+
};
2936

3037

3138
// FUNCTIONS //
@@ -38,13 +45,7 @@ var max = require( './../lib/max.js' );
3845
* @returns {Function} benchmark function
3946
*/
4047
function createBenchmark( len ) {
41-
var x;
42-
var i;
43-
44-
x = [];
45-
for ( i = 0; i < len; i++ ) {
46-
x.push( ( randu()*20.0 ) - 10.0 );
47-
}
48+
var x = uniform( len, -100, 100, options );
4849
return benchmark;
4950

5051
function benchmark( b ) {

benchmark/benchmark.ndarray.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,20 @@
2121
// MODULES //
2222

2323
var bench = require( '@stdlib/bench-harness' );
24-
var randu = require( '@stdlib/random-base-randu' );
2524
var isnan = require( '@stdlib/math-base-assert-is-nan' );
25+
var uniform = require( '@stdlib/random-array-uniform' );
2626
var pow = require( '@stdlib/math-base-special-pow' );
2727
var pkg = require( './../package.json' ).name;
2828
var max = require( './../lib/ndarray.js' );
2929

3030

31+
// VARIABLES //
32+
33+
var options = {
34+
'dtype': 'generic'
35+
};
36+
37+
3138
// FUNCTIONS //
3239

3340
/**
@@ -38,13 +45,7 @@ var max = require( './../lib/ndarray.js' );
3845
* @returns {Function} benchmark function
3946
*/
4047
function createBenchmark( len ) {
41-
var x;
42-
var i;
43-
44-
x = [];
45-
for ( i = 0; i < len; i++ ) {
46-
x.push( ( randu()*20.0 ) - 10.0 );
47-
}
48+
var x = uniform( len, -100, 100, options );
4849
return benchmark;
4950

5051
function benchmark( b ) {

dist/index.js

Lines changed: 8 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)