-
-
Notifications
You must be signed in to change notification settings - Fork 804
/
Copy pathrepl.txt
445 lines (347 loc) · 9.69 KB
/
repl.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
{{alias}}( dtype, buffer, shape, strides, offset, order )
Returns an ndarray.
Parameters
----------
dtype: string
Underlying data type.
buffer: ArrayLikeObject|TypedArray|Buffer
Data buffer. A data buffer must be an array-like object (i.e., have a
`length` property). For data buffers which are not indexed collections
(i.e., collections which cannot support direct index access, such as
`buffer[ index ]`; e.g., Complex64Array, Complex128Array, etc), a data
buffer should provide `#.get( idx )` and `#.set( v[, idx] )` methods.
Note that, for `set` methods, the value to set should be the first
argument, followed by the linear index, similar to the native typed
array `set` method.
shape: ArrayLikeObject<integer>
Array shape.
strides: ArrayLikeObject<integer>
Array strides.
offset: integer
Index offset.
order: string
Specifies whether an array is row-major (C-style) or column-major
(Fortran-style).
Returns
-------
ndarray: ndarray
ndarray instance.
Examples
--------
// Create a new instance...
> var b = [ 1, 2, 3, 4 ]; // underlying data buffer
> var d = [ 2, 2 ]; // shape
> var s = [ 2, 1 ]; // strides
> var o = 0; // index offset
> var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' )
<ndarray>
// Get an element using subscripts:
> var v = arr.get( 1, 1 )
4
// Get an element using a linear index:
> v = arr.iget( 3 )
4
// Set an element using subscripts:
> arr.set( 1, 1, 40 );
> arr.get( 1, 1 )
40
// Set an element using a linear index:
> arr.iset( 3, 99 );
> arr.get( 1, 1 )
99
{{alias}}.prototype.byteLength
Size (in bytes) of the array (if known).
Returns
-------
size: integer|null
Size (in bytes) of the array.
Examples
--------
> var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] );
> var d = [ 2, 2 ];
> var s = [ 2, 1 ];
> var o = 0;
> var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' );
> var sz = arr.byteLength
32
{{alias}}.prototype.BYTES_PER_ELEMENT
Size (in bytes) of each array element (if known).
Returns
-------
size: integer|null
Size (in bytes) of each array element.
Examples
--------
> var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] );
> var d = [ 2, 2 ];
> var s = [ 2, 1 ];
> var o = 0;
> var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' );
> var sz = arr.BYTES_PER_ELEMENT
8
{{alias}}.prototype.data
Pointer to the underlying data buffer.
Returns
-------
buf: ArrayLikeObject|TypedArray|Buffer
Underlying data buffer.
Examples
--------
> var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] );
> var d = [ 2, 2 ];
> var s = [ 2, 1 ];
> var o = 0;
> var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' );
> var buf = arr.data
<Float64Array>[ 1.0, 2.0, 3.0, 4.0 ]
{{alias}}.prototype.dtype
Underlying data type.
Returns
-------
dtype: string
Underlying data type.
Examples
--------
> var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] );
> var d = [ 2, 2 ];
> var s = [ 2, 1 ];
> var o = 0;
> var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' );
> var dt = arr.dtype
'float64'
{{alias}}.prototype.flags
Meta information, such as information concerning the memory layout of the
array.
Returns
-------
flags: Object
Info object.
Examples
--------
> var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] );
> var d = [ 2, 2 ];
> var s = [ 2, 1 ];
> var o = 0;
> var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' );
> var fl = arr.flags
{...}
{{alias}}.prototype.length
Length of the array (i.e., number of elements).
Returns
-------
len: integer
Array length.
Examples
--------
> var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] );
> var d = [ 2, 2 ];
> var s = [ 2, 1 ];
> var o = 0;
> var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' );
> var len = arr.length
4
{{alias}}.prototype.ndims
Number of dimensions.
Returns
-------
ndims: integer
Number of dimensions.
Examples
--------
> var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] );
> var d = [ 2, 2 ];
> var s = [ 2, 1 ];
> var o = 0;
> var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' );
> var n = arr.ndims
2
{{alias}}.prototype.offset
Index offset which specifies the buffer index at which to start iterating
over array elements.
Returns
-------
offset: integer
Index offset.
Examples
--------
> var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] );
> var d = [ 2, 2 ];
> var s = [ 2, 1 ];
> var o = 0;
> var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' );
> var v = arr.offset
0
{{alias}}.prototype.order: string
Array order.
The array order is either row-major (C-style) or column-major (Fortran-
style).
Returns
-------
order: string
Array order.
Examples
--------
> var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] );
> var d = [ 2, 2 ];
> var s = [ 2, 1 ];
> var o = 0;
> var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' );
> var ord = arr.order
'row-major'
{{alias}}.prototype.shape
Array shape.
Returns
-------
shape: Array
Array shape.
Examples
--------
> var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] );
> var d = [ 2, 2 ];
> var s = [ 2, 1 ];
> var o = 0;
> var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' );
> var sh = arr.shape
[ 2, 2 ]
{{alias}}.prototype.strides
Index strides which specify how to access data along corresponding array
dimensions.
Returns
-------
strides: Array
Index strides.
Examples
--------
> var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] );
> var d = [ 2, 2 ];
> var s = [ 2, 1 ];
> var o = 0;
> var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' );
> var st = arr.strides
[ 2, 1 ]
{{alias}}.prototype.get( ...idx )
Returns an array element specified according to provided subscripts.
The number of provided subscripts should equal the number of dimensions.
For zero-dimensional arrays, no indices should be provided.
Parameters
----------
idx: ...integer
Subscripts.
Returns
-------
out: any
Array element.
Examples
--------
> var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] );
> var d = [ 2, 2 ];
> var s = [ 2, 1 ];
> var o = 0;
> var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' );
> var v = arr.get( 1, 1 )
4.0
{{alias}}.prototype.iget( idx )
Returns an array element located at a specified linear index.
For zero-dimensional arrays, the input argument is ignored and, for clarity,
should not be provided.
Parameters
----------
idx: integer
Linear index.
Returns
-------
out: any
Array element.
Examples
--------
> var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] );
> var d = [ 2, 2 ];
> var s = [ 2, 1 ];
> var o = 0;
> var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' );
> var v = arr.iget( 3 )
4.0
{{alias}}.prototype.set( ...idx, v )
Sets an array element specified according to provided subscripts.
The number of provided subscripts should equal the number of dimensions.
For zero-dimensional arrays, no indices should be provided.
Parameters
----------
idx: ...integer
Subscripts.
v: any
Value to set.
Returns
-------
out: ndarray
ndarray instance.
Examples
--------
> var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] );
> var d = [ 2, 2 ];
> var s = [ 2, 1 ];
> var o = 0;
> var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' );
> arr.set( 1, 1, -4.0 );
> arr.get( 1, 1 )
-4.0
{{alias}}.prototype.iset( idx, v )
Sets an array element located at a specified linear index.
For zero-dimensional arrays, the first, and only, argument should be the
value to set.
Parameters
----------
idx: integer
Linear index.
v: any
Value to set.
Returns
-------
out: ndarray
ndarray instance.
Examples
--------
> var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] );
> var d = [ 2, 2 ];
> var s = [ 2, 1 ];
> var o = 0;
> var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' );
> arr.iset( 3, -4.0 );
> arr.iget( 3 )
-4.0
{{alias}}.prototype.toString()
Serializes an ndarray as a string.
This method does **not** serialize data outside of the buffer region defined
by the array configuration.
Returns
-------
str: string
Serialized ndarray string.
Examples
--------
> var b = [ 1, 2, 3, 4 ];
> var d = [ 2, 2 ];
> var s = [ 2, 1 ];
> var o = 0;
> var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' );
> arr.toString()
'...'
{{alias}}.prototype.toJSON()
Serializes an ndarray as a JSON object.
This method does **not** serialize data outside of the buffer region defined
by the array configuration.
Returns
-------
obj: Object
JSON object.
Examples
--------
> var b = [ 1, 2, 3, 4 ];
> var d = [ 2, 2 ];
> var s = [ 2, 1 ];
> var o = 0;
> var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' );
> arr.toJSON()
{...}
See Also
--------