{{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 Array shape. strides: ArrayLikeObject 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' ) // 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 [ 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 Information about 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 --------