@@ -40,29 +40,15 @@ var includes = require( '@stdlib/ndarray/includes' );
4040
4141Tests whether an [ ` ndarray ` ] [ @stdlib/ndarray/ctor ] contains a specified value along one or more dimensions.
4242
43- <!-- eslint-disable max-len -->
44-
4543``` javascript
46- var Float64Array = require ( ' @stdlib/array/float64' );
47- var ndarray = require ( ' @stdlib/ndarray/ctor' );
48-
49- // Create a data buffer:
50- 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 ] );
51-
52- // Define the shape of the input array:
53- var sh = [ 3 , 1 , 2 ];
54-
55- // Define the array strides:
56- var sx = [ 4 , 4 , 1 ];
57-
58- // Define the index offset:
59- var ox = 1 ;
44+ var array = require ( ' @stdlib/ndarray/array' );
6045
6146// Create an input ndarray:
62- var x = new ndarray ( ' float64' , xbuf, sh, sx, ox, ' row-major' );
47+ var x = array ( [ [ [ 1.0 , 2.0 ] ], [ [ 3.0 , 4.0 ] ], [ [ 5.0 , 6.0 ] ] ] );
48+ // returns <ndarray>
6349
6450// Perform reduction:
65- var out = includes ( x, 6 .0 );
51+ var out = includes ( x, 5 .0 );
6652// returns <ndarray>
6753
6854var v = out .get ();
@@ -82,106 +68,64 @@ The function accepts the following `options`:
8268
8369By default, the function performs a reduction over all elements in a provided [ ` ndarray ` ] [ @stdlib/ndarray/ctor ] . To reduce specific dimensions, set the ` dims ` option.
8470
85- <!-- eslint-disable max-len -->
86-
8771``` javascript
88- var Float64Array = require ( ' @stdlib/array/float64' );
89- var ndarray = require ( ' @stdlib/ndarray/ctor' );
72+ var array = require ( ' @stdlib/ndarray/array' );
9073var ndarray2array = require ( ' @stdlib/ndarray/to-array' );
9174
92- // Create a data buffer:
93- 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 ] );
94-
95- // Define the shape of the input array:
96- var sh = [ 3 , 1 , 2 ];
97-
98- // Define the array strides:
99- var sx = [ 4 , 4 , 1 ];
100-
101- // Define the index offset:
102- var ox = 1 ;
103-
10475// Create an input ndarray:
105- var x = new ndarray ( ' float64' , xbuf, sh, sx, ox, ' row-major' );
76+ var x = array ( [ [ [ 1.0 , 2.0 ] ], [ [ 3.0 , 4.0 ] ], [ [ 5.0 , 6.0 ] ] ] );
77+ // returns <ndarray>
10678
10779// Perform reduction:
108- var out = includes ( x, 6 .0 , {
80+ var out = includes ( x, 5 .0 , {
10981 ' dims' : [ 1 , 2 ]
11082});
11183// returns <ndarray>
11284
11385var v = ndarray2array ( out );
114- // returns [ false, true, false ]
86+ // returns [ false, false, true ]
11587```
11688
11789By 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 ` .
11890
119- <!-- eslint-disable max-len -->
120-
12191``` javascript
122- var Float64Array = require ( ' @stdlib/array/float64' );
123- var ndarray = require ( ' @stdlib/ndarray/ctor' );
92+ var array = require ( ' @stdlib/ndarray/array' );
12493var ndarray2array = require ( ' @stdlib/ndarray/to-array' );
12594
126- // Create a data buffer:
127- 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 ] );
128-
129- // Define the shape of the input array:
130- var sh = [ 3 , 1 , 2 ];
131-
132- // Define the array strides:
133- var sx = [ 4 , 4 , 1 ];
134-
135- // Define the index offset:
136- var ox = 1 ;
137-
13895// Create an input ndarray:
139- var x = new ndarray ( ' float64' , xbuf, sh, sx, ox, ' row-major' );
96+ var x = array ( [ [ [ 1.0 , 2.0 ] ], [ [ 3.0 , 4.0 ] ], [ [ 5.0 , 6.0 ] ] ] );
97+ // returns <ndarray>
14098
14199// Perform reduction:
142- var out = includes ( x, 6 .0 , {
100+ var out = includes ( x, 5 .0 , {
143101 ' dims' : [ 1 , 2 ],
144102 ' keepdims' : true
145103});
146104// returns <ndarray>
147105
148106var v = ndarray2array ( out );
149- // returns [ [ [ false ] ], [ [ true ] ], [ [ false ] ] ]
107+ // returns [ [ [ false ] ], [ [ false ] ], [ [ true ] ] ]
150108```
151109
152110#### includes.assign( x, searchElement, out\[ , options] )
153111
154112Tests 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 ] .
155113
156- <!-- eslint-disable max-len -->
157-
158114``` javascript
159- var Float64Array = require ( ' @stdlib/array/float64' );
160- var ndarray = require ( ' @stdlib/ndarray/ctor' );
115+ var array = require ( ' @stdlib/ndarray/array' );
161116var empty = require ( ' @stdlib/ndarray/empty' );
162117
163- // Create a data buffer:
164- 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 ] );
165-
166- // Define the shape of the input array:
167- var sh = [ 3 , 1 , 2 ];
168-
169- // Define the array strides:
170- var sx = [ 4 , 4 , 1 ];
171-
172- // Define the index offset:
173- var ox = 1 ;
174-
175118// Create an input ndarray:
176- var x = new ndarray ( ' float64' , xbuf, sh, sx, ox, ' row-major' );
119+ var x = array ( [ [ [ 1.0 , 2.0 ] ], [ [ 3.0 , 4.0 ] ], [ [ 5.0 , 6.0 ] ] ] );
120+ // returns <ndarray>
177121
178122// Create an output ndarray:
179123var y = empty ( [], {
180124 ' dtype' : ' bool'
181125});
182126
183127// Perform reduction:
184- var out = includes .assign ( x, 6 .0 , y );
128+ var out = includes .assign ( x, 5 .0 , y );
185129// returns <ndarray>
186130
187131var bool = ( out === y );
@@ -204,44 +148,30 @@ The function accepts the following `options`:
204148
205149By default, the function performs a reduction over all elements in a provided [ ` ndarray ` ] [ @stdlib/ndarray/ctor ] . To reduce specific dimensions, set the ` dims ` option.
206150
207- <!-- eslint-disable max-len -->
208-
209151``` javascript
210- var Float64Array = require ( ' @stdlib/array/float64' );
211- var ndarray = require ( ' @stdlib/ndarray/ctor' );
152+ var array = require ( ' @stdlib/ndarray/array' );
212153var empty = require ( ' @stdlib/ndarray/empty' );
213154var ndarray2array = require ( ' @stdlib/ndarray/to-array' );
214155
215- // Create a data buffer:
216- 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 ] );
217-
218- // Define the shape of the input array:
219- var sh = [ 3 , 1 , 2 ];
220-
221- // Define the array strides:
222- var sx = [ 4 , 4 , 1 ];
223-
224- // Define the index offset:
225- var ox = 1 ;
226-
227156// Create an input ndarray:
228- var x = new ndarray ( ' float64' , xbuf, sh, sx, ox, ' row-major' );
157+ var x = array ( [ [ [ 1.0 , 2.0 ] ], [ [ 3.0 , 4.0 ] ], [ [ 5.0 , 6.0 ] ] ] );
158+ // returns <ndarray>
229159
230160// Create an output ndarray:
231161var y = empty ( [ 3 ], {
232162 ' dtype' : ' bool'
233163});
234164
235165// Perform reduction:
236- var out = includes .assign ( x, 6 .0 , y, {
166+ var out = includes .assign ( x, 5 .0 , y, {
237167 ' dims' : [ 1 , 2 ]
238168});
239169
240170var bool = ( out === y );
241171// returns true
242172
243173var v = ndarray2array ( y );
244- // returns [ false, true, false ]
174+ // returns [ false, false, true ]
245175```
246176
247177</section >
0 commit comments