@@ -40,29 +40,15 @@ var includes = require( '@stdlib/ndarray/includes' );
40
40
41
41
Tests whether an [ ` ndarray ` ] [ @stdlib/ndarray/ctor ] contains a specified value along one or more dimensions.
42
42
43
- <!-- eslint-disable max-len -->
44
-
45
43
``` 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' );
60
45
61
46
// 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>
63
49
64
50
// Perform reduction:
65
- var out = includes ( x, 6 .0 );
51
+ var out = includes ( x, 5 .0 );
66
52
// returns <ndarray>
67
53
68
54
var v = out .get ();
@@ -82,106 +68,64 @@ The function accepts the following `options`:
82
68
83
69
By default, the function performs a reduction over all elements in a provided [ ` ndarray ` ] [ @stdlib/ndarray/ctor ] . To reduce specific dimensions, set the ` dims ` option.
84
70
85
- <!-- eslint-disable max-len -->
86
-
87
71
``` javascript
88
- var Float64Array = require ( ' @stdlib/array/float64' );
89
- var ndarray = require ( ' @stdlib/ndarray/ctor' );
72
+ var array = require ( ' @stdlib/ndarray/array' );
90
73
var ndarray2array = require ( ' @stdlib/ndarray/to-array' );
91
74
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
-
104
75
// 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>
106
78
107
79
// Perform reduction:
108
- var out = includes ( x, 6 .0 , {
80
+ var out = includes ( x, 5 .0 , {
109
81
' dims' : [ 1 , 2 ]
110
82
});
111
83
// returns <ndarray>
112
84
113
85
var v = ndarray2array ( out );
114
- // returns [ false, true, false ]
86
+ // returns [ false, false, true ]
115
87
```
116
88
117
89
By 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 ` .
118
90
119
- <!-- eslint-disable max-len -->
120
-
121
91
``` javascript
122
- var Float64Array = require ( ' @stdlib/array/float64' );
123
- var ndarray = require ( ' @stdlib/ndarray/ctor' );
92
+ var array = require ( ' @stdlib/ndarray/array' );
124
93
var ndarray2array = require ( ' @stdlib/ndarray/to-array' );
125
94
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
-
138
95
// 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>
140
98
141
99
// Perform reduction:
142
- var out = includes ( x, 6 .0 , {
100
+ var out = includes ( x, 5 .0 , {
143
101
' dims' : [ 1 , 2 ],
144
102
' keepdims' : true
145
103
});
146
104
// returns <ndarray>
147
105
148
106
var v = ndarray2array ( out );
149
- // returns [ [ [ false ] ], [ [ true ] ], [ [ false ] ] ]
107
+ // returns [ [ [ false ] ], [ [ false ] ], [ [ true ] ] ]
150
108
```
151
109
152
110
#### includes.assign( x, searchElement, out\[ , options] )
153
111
154
112
Tests 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 ] .
155
113
156
- <!-- eslint-disable max-len -->
157
-
158
114
``` javascript
159
- var Float64Array = require ( ' @stdlib/array/float64' );
160
- var ndarray = require ( ' @stdlib/ndarray/ctor' );
115
+ var array = require ( ' @stdlib/ndarray/array' );
161
116
var empty = require ( ' @stdlib/ndarray/empty' );
162
117
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
-
175
118
// 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>
177
121
178
122
// Create an output ndarray:
179
123
var y = empty ( [], {
180
124
' dtype' : ' bool'
181
125
});
182
126
183
127
// Perform reduction:
184
- var out = includes .assign ( x, 6 .0 , y );
128
+ var out = includes .assign ( x, 5 .0 , y );
185
129
// returns <ndarray>
186
130
187
131
var bool = ( out === y );
@@ -204,44 +148,30 @@ The function accepts the following `options`:
204
148
205
149
By default, the function performs a reduction over all elements in a provided [ ` ndarray ` ] [ @stdlib/ndarray/ctor ] . To reduce specific dimensions, set the ` dims ` option.
206
150
207
- <!-- eslint-disable max-len -->
208
-
209
151
``` javascript
210
- var Float64Array = require ( ' @stdlib/array/float64' );
211
- var ndarray = require ( ' @stdlib/ndarray/ctor' );
152
+ var array = require ( ' @stdlib/ndarray/array' );
212
153
var empty = require ( ' @stdlib/ndarray/empty' );
213
154
var ndarray2array = require ( ' @stdlib/ndarray/to-array' );
214
155
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
-
227
156
// 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>
229
159
230
160
// Create an output ndarray:
231
161
var y = empty ( [ 3 ], {
232
162
' dtype' : ' bool'
233
163
});
234
164
235
165
// Perform reduction:
236
- var out = includes .assign ( x, 6 .0 , y, {
166
+ var out = includes .assign ( x, 5 .0 , y, {
237
167
' dims' : [ 1 , 2 ]
238
168
});
239
169
240
170
var bool = ( out === y );
241
171
// returns true
242
172
243
173
var v = ndarray2array ( y );
244
- // returns [ false, true, false ]
174
+ // returns [ false, false, true ]
245
175
```
246
176
247
177
</section >
0 commit comments