You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
var floor =require( '@stdlib/math/base/special/floor' );
105
101
106
102
functionaccessor( v ) {
107
103
return v *2.0;
@@ -112,16 +108,15 @@ var x0 = new Float64Array( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] );
112
108
113
109
// Create an offset view...
114
110
var x1 =newFloat64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
115
-
varN=floor( x0.length/2 );
116
111
117
112
// Access every other element...
118
-
var v =maxBy( N, x1, 2, accessor );
113
+
var v =maxBy( 3, x1, 2, accessor );
119
114
// returns -4.0
120
115
```
121
116
122
-
#### maxBy.ndarray( N, x, stride, offset, clbk\[, thisArg] )
117
+
#### maxBy.ndarray( N, x, strideX, offsetX, clbk\[, thisArg] )
123
118
124
-
Calculates the maximum value of strided array`x` via a callback function and using alternative indexing semantics.
119
+
Computes the maximum value of a strided array via a callback function and using alternative indexing semantics.
125
120
126
121
```javascript
127
122
functionaccessor( v ) {
@@ -136,9 +131,9 @@ var v = maxBy.ndarray( x.length, x, 1, 0, accessor );
136
131
137
132
The function has the following additional parameters:
138
133
139
-
-**offset**: starting index.
134
+
-**offsetX**: starting index.
140
135
141
-
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 access only the last three elements of `x`
136
+
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 access only the last three elements of `x`
142
137
143
138
```javascript
144
139
functionaccessor( v ) {
@@ -162,6 +157,7 @@ var v = maxBy.ndarray( 3, x, 1, x.length-3, accessor );
162
157
- If `N <= 0`, both functions return `NaN`.
163
158
- A provided callback function should return a numeric value.
164
159
- If a provided callback function does not return any value (or equivalently, explicitly returns `undefined`), the value is **ignored**.
160
+
- 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]).
165
161
- When possible, prefer using [`dmax`][@stdlib/stats/strided/dmax], [`smax`][@stdlib/stats/strided/smax], and/or [`max`][@stdlib/stats/base/max], as, depending on the environment, these interfaces are likely to be significantly more performant.
166
162
167
163
</section>
@@ -175,15 +171,16 @@ var v = maxBy.ndarray( 3, x, 1, x.length-3, accessor );
175
171
<!-- eslint no-undef: "error" -->
176
172
177
173
```javascript
178
-
var discreteUniform =require( '@stdlib/random/base/discrete-uniform' ).factory;
179
-
var filledarrayBy =require( '@stdlib/array/filled-by' );
174
+
var discreteUniform =require( '@stdlib/random/array/discrete-uniform' );
180
175
var maxBy =require( '@stdlib/stats/base/max-by' );
181
176
182
177
functionaccessor( v ) {
183
178
return v *2.0;
184
179
}
185
180
186
-
var x =filledarrayBy( 10, 'float64', discreteUniform( -50, 50 ) );
0 commit comments