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: vector/ctor/README.md
+42-7
Original file line number
Diff line number
Diff line change
@@ -186,6 +186,41 @@ var dt6 = getDType( arr6 );
186
186
// returns 'int16'
187
187
```
188
188
189
+
#### vector.factory( dtype\[, options] )
190
+
191
+
Returns a function for creating a one-dimensional [ndarray][@stdlib/ndarray/ctor].
192
+
193
+
```javascript
194
+
var getDType =require( '@stdlib/ndarray/dtype' );
195
+
var numel =require( '@stdlib/ndarray/numel' );
196
+
197
+
var Float32Vector =vector.factory( 'float32' );
198
+
199
+
var arr =newFloat32Vector( [ 1, 2, 3 ] );
200
+
// returns <ndarray>
201
+
202
+
var dt =getDType( arr );
203
+
// returns 'float32'
204
+
205
+
var len =numel( arr );
206
+
// returns 3
207
+
```
208
+
209
+
The function supports the following parameters:
210
+
211
+
-**dtype**: [data type][@stdlib/ndarray/dtypes].
212
+
-**options**: function options (_optional_).
213
+
214
+
The function accepts the following options:
215
+
216
+
-**order**: specifies whether the default memory layout for a returned [ndarray][@stdlib/ndarray/ctor] should be `'row-major'` (C-style) or `'column-major'` (Fortran-style). Default: `'row-major'`.
217
+
-**mode**: specifies the default behavior when handling indices which exceed array dimensions (see [`ndarray`][@stdlib/ndarray/ctor]). Default: `'throw'`.
218
+
-**readonly**: boolean indicating whether to return a **read-only**[ndarray][@stdlib/ndarray/ctor] by default. Default: `false`.
219
+
220
+
The function returned by the `factory` method supports the same arguments and options as `vector` above, except for the `dtype` argument, as the returned function always returns a one-dimensional [ndarray][@stdlib/ndarray/ctor] having the same [data type][@stdlib/ndarray/dtypes].
221
+
222
+
When providing options to the returned function, the provided option values override the defaults established during function creation.
223
+
189
224
</section>
190
225
191
226
<!-- /.usage -->
@@ -211,7 +246,7 @@ var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
211
246
var cartesianProduct =require( '@stdlib/array/cartesian-product' );
212
247
var unzip =require( '@stdlib/utils/unzip' );
213
248
var dtypes =require( '@stdlib/ndarray/dtypes' );
214
-
vargetShape=require( '@stdlib/ndarray/shape' );
249
+
varsum=require( '@stdlib/blas/ext/sum' );
215
250
var logEachMap =require( '@stdlib/console/log-each-map' );
216
251
var vector =require( '@stdlib/ndarray/vector/ctor' );
0 commit comments