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
Copy file name to clipboardExpand all lines: lib/node_modules/@stdlib/stats/mskmax/README.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -51,7 +51,7 @@ var v = y.get();
51
51
The function has the following parameters:
52
52
53
53
-**x**: input [ndarray][@stdlib/ndarray/ctor]. Must have a real-valued or "generic" [data type][@stdlib/ndarray/dtypes].
54
-
-**mask**: mask [ndarray][@stdlib/ndarray/ctor]. Must have the same shape as`x`. If a mask element is `0`, the corresponding element in `x` is considered valid. If a mask element is non-zero, the corresponding element in `x` is ignored.
54
+
-**mask**: mask [ndarray][@stdlib/ndarray/ctor]. Must be [broadcast-compatible][@stdlib/ndarray/base/broadcast-shapes] with`x`. If a mask element is `0`, the corresponding element in `x` is considered valid. If a mask element is non-zero, the corresponding element in `x` is ignored.
55
55
-**options**: function options (_optional_).
56
56
57
57
The function accepts the following options:
@@ -201,7 +201,7 @@ var bool = ( out === y );
201
201
The method has the following parameters:
202
202
203
203
-**x**: input [ndarray][@stdlib/ndarray/ctor]. Must have a real-valued or generic [data type][@stdlib/ndarray/dtypes].
204
-
-**mask**: mask [ndarray][@stdlib/ndarray/ctor]. Must have the same shape as`x`. If a mask element is `0`, the corresponding element in `x` is considered valid. If a mask element is non-zero, the corresponding element in `x` is ignored.
204
+
-**mask**: mask [ndarray][@stdlib/ndarray/ctor]. Must be [broadcast-compatible][@stdlib/ndarray/base/broadcast-shapes] with`x`. If a mask element is `0`, the corresponding element in `x` is considered valid. If a mask element is non-zero, the corresponding element in `x` is ignored.
* Base implementation for computing the maximum value along one or more ndarray dimensions according to a mask.
58
+
*
59
+
* @name base
60
+
* @type {Function}
61
+
* @param {ndarray} x - input ndarray
62
+
* @param {ndarray} mask - mask ndarray
63
+
* @param {Options} [options] - function options
64
+
* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction
65
+
* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions
66
+
* @param {string} [options.dtype] - output ndarray data type
67
+
* @throws {TypeError} first argument must be an ndarray-like object
68
+
* @throws {TypeError} second argument must be an ndarray-like object
69
+
* @throws {TypeError} options argument must be an object
70
+
* @throws {RangeError} dimension indices must not exceed input ndarray bounds
71
+
* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions
thrownewTypeError(format('invalid argument. First argument must be an ndarray-like object. Value: `%s`.',x));
87
+
}
88
+
if(!isNdarrayLike(mask)){
89
+
thrownewTypeError(format('invalid argument. Second argument must be an ndarray-like object. Value: `%s`.',mask));
90
+
}
91
+
arrs=maybeBroadcastArrays([x,mask]);
92
+
if(arguments.length>2){
93
+
returnbase(arrs[0],arrs[1],arguments[2]);
94
+
}
95
+
returnbase(arrs[0],arrs[1]);
96
+
}
97
+
98
+
/**
99
+
* Computes the maximum value along one or more ndarray dimensions according to a mask and assigns the results to a provided output ndarray.
100
+
*
101
+
* @name assign
102
+
* @memberof mskmax
103
+
* @type {Function}
104
+
* @param {ndarray} x - input ndarray
105
+
* @param {ndarray} mask - mask ndarray
106
+
* @param {ndarray} out - output ndarray
107
+
* @param {Options} [options] - function options
108
+
* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction
109
+
* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions
110
+
* @throws {TypeError} first argument must be an ndarray-like object
111
+
* @throws {TypeError} second argument must be an ndarray-like object
112
+
* @throws {TypeError} third argument must be an ndarray-like object
113
+
* @throws {TypeError} options argument must be an object
114
+
* @throws {RangeError} dimension indices must not exceed input ndarray bounds
115
+
* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions
116
+
* @throws {Error} must provide valid options
117
+
* @returns {ndarray} output ndarray
118
+
*
119
+
* @example
120
+
* var Float64Array = require( '@stdlib/array/float64' );
121
+
* var Uint8Array = require( '@stdlib/array/uint8' );
122
+
* var ndarray = require( '@stdlib/ndarray/ctor' );
123
+
*
124
+
* // Create a data buffer:
125
+
* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
126
+
*
127
+
* // Create a mask buffer:
128
+
* var mbuf = new Uint8Array( [ 0, 0, 0, 1, 0, 1 ] );
129
+
*
130
+
* // Create an output buffer:
131
+
* var obuf = new Float64Array( [ 0.0 ] );
132
+
*
133
+
* // Define the shape of the input array:
134
+
* var sh = [ 3, 2 ];
135
+
*
136
+
* // Define the array strides:
137
+
* var sx = [ 2, 1 ];
138
+
* var sm = [ 2, 1 ];
139
+
*
140
+
* // Define the index offset:
141
+
* var ox = 0;
142
+
* var om = 0;
143
+
*
144
+
* // Create the input ndarray:
145
+
* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );
146
+
*
147
+
* // Create the mask ndarray:
148
+
* var mask = new ndarray( 'uint8', mbuf, sh, sm, om, 'row-major' ); // cspell:disable-line
149
+
*
150
+
* // Create the output ndarray:
151
+
* var out = new ndarray( 'float64', obuf, [], [ 0 ], 0, 'row-major' );
152
+
*
153
+
* // Perform reduction:
154
+
* var res = mskmax.assign( x, mask, out );
155
+
* // returns <ndarray>
156
+
*
157
+
* var v = res.get();
158
+
* // returns 5.0
159
+
*/
160
+
functionassign(x,mask,out){
161
+
vararrs;
162
+
if(!isNdarrayLike(x)){
163
+
thrownewTypeError(format('invalid argument. First argument must be an ndarray-like object. Value: `%s`.',x));
164
+
}
165
+
if(!isNdarrayLike(mask)){
166
+
thrownewTypeError(format('invalid argument. Second argument must be an ndarray-like object. Value: `%s`.',mask));
167
+
}
168
+
if(!isNdarrayLike(out)){
169
+
thrownewTypeError(format('invalid argument. Third argument must be an ndarray-like object. Value: `%s`.',out));
0 commit comments