@@ -73,29 +73,15 @@ var includes = require( '@stdlib/ndarray-includes' );
7373
7474Tests whether an [ ` ndarray ` ] [ @stdlib/ndarray/ctor ] contains a specified value along one or more dimensions.
7575
76- <!-- eslint-disable max-len -->
77-
7876``` javascript
79- var Float64Array = require ( ' @stdlib/array-float64' );
80- var ndarray = require ( ' @stdlib/ndarray-ctor' );
81-
82- // Create a data buffer:
83- 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 ] );
84-
85- // Define the shape of the input array:
86- var sh = [ 3 , 1 , 2 ];
87-
88- // Define the array strides:
89- var sx = [ 4 , 4 , 1 ];
90-
91- // Define the index offset:
92- var ox = 1 ;
77+ var array = require ( ' @stdlib/ndarray-array' );
9378
9479// Create an input ndarray:
95- var x = new ndarray ( ' float64' , xbuf, sh, sx, ox, ' row-major' );
80+ var x = array ( [ [ [ 1.0 , 2.0 ] ], [ [ 3.0 , 4.0 ] ], [ [ 5.0 , 6.0 ] ] ] );
81+ // returns <ndarray>
9682
9783// Perform reduction:
98- var out = includes ( x, 6 .0 );
84+ var out = includes ( x, 5 .0 );
9985// returns <ndarray>
10086
10187var v = out .get ();
@@ -115,106 +101,64 @@ The function accepts the following `options`:
115101
116102By default, the function performs a reduction over all elements in a provided [ ` ndarray ` ] [ @stdlib/ndarray/ctor ] . To reduce specific dimensions, set the ` dims ` option.
117103
118- <!-- eslint-disable max-len -->
119-
120104``` javascript
121- var Float64Array = require ( ' @stdlib/array-float64' );
122- var ndarray = require ( ' @stdlib/ndarray-ctor' );
105+ var array = require ( ' @stdlib/ndarray-array' );
123106var ndarray2array = require ( ' @stdlib/ndarray-to-array' );
124107
125- // Create a data buffer:
126- 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 ] );
127-
128- // Define the shape of the input array:
129- var sh = [ 3 , 1 , 2 ];
130-
131- // Define the array strides:
132- var sx = [ 4 , 4 , 1 ];
133-
134- // Define the index offset:
135- var ox = 1 ;
136-
137108// Create an input ndarray:
138- var x = new ndarray ( ' float64' , xbuf, sh, sx, ox, ' row-major' );
109+ var x = array ( [ [ [ 1.0 , 2.0 ] ], [ [ 3.0 , 4.0 ] ], [ [ 5.0 , 6.0 ]
4B12
] ] );
110+ // returns <ndarray>
139111
140112// Perform reduction:
141- var out = includes ( x, 6 .0 , {
113+ var out = includes ( x, 5 .0 , {
142114 ' dims' : [ 1 , 2 ]
143115});
144116// returns <ndarray>
145117
146118var v = ndarray2array ( out );
147- // returns [ false, true, false ]
119+ // returns [ false, false, true ]
148120```
149121
150122By default, the function returns an [ ` ndarray ` ] [ @stdlib/ndarray/ctor ] having a shape matching only the non-reduced dimensions of the input [ ` ndarray ` ] [ @stdlib/ndarray/ctor ] (i.e., the reduced dimensions are dropped). To include the reduced dimensions as singleton dimensions in the output [ ` ndarray ` ] [ @stdlib/ndarray/ctor ] , set the ` keepdims ` option to ` true ` .
151123
152- <!-- eslint-disable max-len -->
153-
154124``` javascript
155- var Float64Array = require ( ' @stdlib/array-float64' );
156- var ndarray = require ( ' @stdlib/ndarray-ctor' );
125+ var array = require ( ' @stdlib/ndarray-array' );
157126var ndarray2array = require ( ' @stdlib/ndarray-to-array' );
158127
159- // Create a data buffer:
160- 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 ] );
161-
162- // Define the shape of the input array:
163- var sh = [ 3 , 1 , 2 ];
164-
165- // Define the array strides:
166- var sx = [ 4 , 4 , 1 ];
167-
168- // Define the index offset:
169- var ox = 1 ;
170-
171128// Create an input ndarray:
172- var x = new ndarray ( ' float64' , xbuf, sh, sx, ox, ' row-major' );
129+ var x = array ( [ [ [ 1.0 , 2.0 ] ], [ [ 3.0 , 4.0 ] ], [ [ 5.0 , 6.0 ] ] ] );
130+ // returns <ndarray>
173131
174132// Perform reduction:
175- var out = includes ( x, 6 .0 , {
133+ var out = includes ( x, 5 .0 , {
176134 ' dims' : [ 1 , 2 ],
177135 ' keepdims' : true
178136});
179137// returns <ndarray>
180138
181139var v = ndarray2array ( out );
182- // returns [ [ [ false ] ], [ [ true ] ], [ [ false ] ] ]
140+ // returns [ [ [ false ] ], [ [ false ] ], [ [ true ] ] ]
183141```
184142
185143#### includes.assign( x, searchElement, out\[ , options] )
186144
187145Tests whether an [ ` ndarray ` ] [ @stdlib/ndarray/ctor ] contains a specified value along one or more dimensions and assigns results to a provided output [ ` ndarray ` ] [ @stdlib/ndarray/ctor ] .
188146
189- <!-- eslint-disable max-len -->
190-
191147``` javascript
192- var Float64Array = require ( ' @stdlib/array-float64' );
193- var ndarray = require ( ' @stdlib/ndarray-ctor' );
148+ var array = require ( ' @stdlib/ndarray-array' );
194149var empty = require ( ' @stdlib/ndarray-empty' );
195150
196- // Create a data buffer:
197- 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 ] );
198-
199- // Define the shape of the input array:
200- var sh = [ 3 , 1 , 2 ];
201-
202- // Define the array strides:
203- var sx = [ 4 , 4 , 1 ];
204-
205- // Define the index offset:
206- var ox = 1 ;
207-
208151// Create an input ndarray:
209- var x = new ndarray ( ' float64' , xbuf, sh, sx, ox, ' row-major' );
152+ var x = array ( [ [ [ 1.0 , 2.0 ] ], [ [ 3.0 , 4.0 ] ], [ [ 5.0 , 6.0 ] ] ] );
153+ // returns <ndarray>
210154
211155// Create an output ndarray:
212156var y = empty ( [], {
213157 ' dtype' : ' bool'
214158});
215159
216160// Perform reduction:
217- var out = includes .assign ( x, 6 .0 , y );
161+ var out = includes .assign ( x, 5 .0 , y );
218162// returns <ndarray>
219163
220164var bool = ( out === y );
@@ -237,44 +181,30 @@ The function accepts the following `options`:
237181
238182By default, the function performs a reduction over all elements in a provided [ ` ndarray ` ] [ @stdlib/ndarray/ctor ] . To reduce specific dimensions, set the ` dims ` option.
239183
240- <!-- eslint-disable max-len -->
241-
242184``` javascript
243- var Float64Array = require ( ' @stdlib/array-float64' );
244- var ndarray = require ( ' @stdlib/ndarray-ctor' );
185+ var array = require ( ' @stdlib/ndarray-array' );
245186var empty = require ( ' @stdlib/ndarray-empty' );
246187var ndarray2array = require ( ' @stdlib/ndarray-to-array' );
247188
248- // Create a data buffer:
249- 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 ] );
250-
251- // Define the shape of the input array:
252- var sh = [ 3 , 1 , 2 ];
253-
254- // Define the array strides:
255- var sx = [ 4 , 4 , 1 ];
256-
257- // Define the index offset:
258- var ox = 1 ;
259-
260189// Create an input ndarray:
261- var x = new ndarray ( ' float64' , xbuf, sh, sx, ox, ' row-major' );
190+ var x = array ( [ [ [ 1.0 , 2.0 ] ], [ [ 3.0 , 4.0 ] ], [ [ 5.0 , 6.0 ] ] ] );
191+ // returns <ndarray>
262192
263193// Create an output ndarray:<
5AE0
/span>
264194var y = empty ( [ 3 ], {
265195 ' dtype' : ' bool'
266196});
267197
268198// Perform reduction:
269- var out = includes .assign ( x, 6 .0 , y, {
199+ var out = includes .assign ( x, 5 .0 , y, {
270200 ' dims' : [ 1 , 2 ]
271201});
272202
273203var bool = ( out === y );
274204// returns true
275205
276206var v = ndarray2array ( y );
277- // returns [ false, true, false ]
207+ // returns [ false, false, true ]
278208```
279209
280210</section >
0 commit comments