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
To initialize multidimensional array data, provide a `buffer` argument, which may be a [generic array][@stdlib/array/generic], [typed array][@stdlib/array/typed], [Buffer][@stdlib/buffer/ctor], or [ndarray][@stdlib/ndarray/ctor].
-**buffer**: data source. If provided along with a `buffer` argument, the argument takes precedence.
83
83
84
-
-**dtype**: underlying storage [data type][@stdlib/ndarray/dtypes]. If not specified and a data source is provided, the data type is inferred from the provided data source. If an input data source is not of the same type, this option specifies the data type to which to cast the input data. For non-[`ndarray`][@stdlib/ndarray/ctor] generic array data sources, the function casts generic array data elements to the default data type. In order to prevent this cast, the `dtype` option **must** be explicitly set to `'generic'`. Any time a cast is required, the `copy` option is set to `true`, as memory must be copied from the data source to an output data buffer. Default: `'float64'`.
84
+
-**dtype**: underlying storage [data type][@stdlib/ndarray/dtypes]. If not specified and a data source is provided, the data type is inferred from the provided data source. If an input data source is not of the same type, this option specifies the data type to which to cast the input data. For non-[ndarray][@stdlib/ndarray/ctor] generic array data sources, the function casts generic array data elements to the default data type. In order to prevent this cast, the `dtype` option **must** be explicitly set to `'generic'`. Any time a cast is required, the `copy` option is set to `true`, as memory must be copied from the data source to an output data buffer. Default: `'float64'`.
85
85
86
86
-**order**: specifies the memory layout of the data source as either row-major (C-style) or column-major (Fortran-style). The option may be one of the following values:
87
87
88
-
-`row-major`: the order of the returned array is row-major.
89
-
-`column-major`: the order of the returned array is column-major.
90
-
-`any`: if a data source is column-major and not row-major, the order of the returned array is column-major; otherwise, the order of the returned array is row-major.
91
-
-`same`: the order of the returned array matches the order of an input data source.
88
+
-`'row-major'`: the order of the returned array is row-major.
89
+
-`'column-major'`: the order of the returned array is column-major.
90
+
-`'any'`: if a data source is column-major and not row-major, the order of the returned array is column-major; otherwise, the order of the returned array is row-major.
91
+
-`'same'`: the order of the returned array matches the order of an input data source.
92
92
93
93
Note that specifying an order which differs from the order of a provided data source does **not** entail a conversion from one memory layout to another. In short, this option is descriptive, not prescriptive. Default: `'row-major'`.
94
94
95
95
-**shape**: array shape (dimensions). If a shape is not specified, the function attempts to infer a shape based on a provided data source. For example, if provided a nested array, the function resolves nested array dimensions. If provided a multidimensional array data source, the function uses the array's associated shape. For most use cases, such inference suffices. For the remaining use cases, specifying a shape is necessary. For example, provide a shape to create a multidimensional array view over a linear data buffer, ignoring any existing shape meta data associated with a provided data source.
96
96
97
-
-**flatten**: `boolean` indicating whether to automatically flatten generic array data sources. If an array shape is not specified, the shape is inferred from the dimensions of nested arrays prior to flattening. If a use case requires partial flattening, partially flatten **prior** to invoking this function and set the option value to `false` to prevent further flattening during invocation. Default: `true`.
97
+
-**flatten**: boolean indicating whether to automatically flatten generic array data sources. If an array shape is not specified, the shape is inferred from the dimensions of nested arrays prior to flattening. If a use case requires partial flattening, partially flatten **prior** to invoking this function and set the option value to `false` to prevent further flattening during invocation. Default: `true`.
98
98
99
-
-**copy**: `boolean` indicating whether to (shallow) copy source data to a new data buffer. The function does **not** perform a deep copy. To prevent undesired shared changes in state for generic arrays containing objects, perform a deep copy **prior** to invoking this function. Default: `false`.
99
+
-**copy**: boolean indicating whether to (shallow) copy source data to a new data buffer. The function does **not** perform a deep copy. To prevent undesired shared changes in state for generic arrays containing objects, perform a deep copy **prior** to invoking this function. Default: `false`.
100
100
101
101
-**ndmin**: specifies the minimum number of dimensions. If an array shape has fewer dimensions than required by `ndmin`, the function **prepends** singleton dimensions to the array shape in order to satisfy the dimensions requirement. Default: `0`.
102
102
103
103
-**casting**: specifies the casting rule used to determine acceptable casts. The option may be one of the following values:
104
104
105
-
-`none`: only allow casting between identical types.
106
-
-`equiv`: allow casting between identical and byte swapped types.
107
-
-`safe`: only allow "safe" casts.
108
-
-`mostly-safe`: allow "safe" casts and, for floating-point data types, downcasts.
109
-
-`same-kind`: allow "safe" casts and casts within the same kind (e.g., between signed integers or between floats).
110
-
-`unsafe`: allow casting between all types (including between integers and floats).
105
+
-`'none'`: only allow casting between identical types.
106
+
-`'equiv'`: allow casting between identical and byte swapped types.
107
+
-`'safe'`: only allow "safe" casts.
108
+
-`'mostly-safe'`: allow "safe" casts and, for floating-point data types, downcasts.
109
+
-`'same-kind'`: allow "safe" casts and casts within the same kind (e.g., between signed integers or between floats).
110
+
-`'unsafe'`: allow casting between all types (including between integers and floats).
111
111
112
112
Default: `'safe'`.
113
113
114
114
-**mode**: specifies how to handle indices which exceed array dimensions.
115
115
116
-
-`throw`: specifies that an [`ndarray`][@stdlib/ndarray/ctor] instance should throw an error when an index exceeds array dimensions.
117
-
-`normalize`: specifies that an [`ndarray`][@stdlib/ndarray/ctor] instance should normalize negative indices and throw an error when an index exceeds array dimensions.
118
-
-`wrap`: specifies that an [`ndarray`][@stdlib/ndarray/ctor] instance should wrap around an index exceeding array dimensions using modulo arithmetic.
119
-
-`clamp`: specifies that an [`ndarray`][@stdlib/ndarray/ctor] instance should set an index exceeding array dimensions to either `0` (minimum index) or the maximum index.
116
+
-`'throw'`: specifies that an [ndarray][@stdlib/ndarray/ctor] instance should throw an error when an index exceeds array dimensions.
117
+
-`'normalize'`: specifies that an [ndarray][@stdlib/ndarray/ctor] instance should normalize negative indices and throw an error when an index exceeds array dimensions.
118
+
-`'wrap'`: specifies that an [ndarray][@stdlib/ndarray/ctor] instance should wrap around an index exceeding array dimensions using modulo arithmetic.
119
+
-`'clamp'`: specifies that an [ndarray][@stdlib/ndarray/ctor] instance should set an index exceeding array dimensions to either `0` (minimum index) or the maximum index.
120
120
121
121
Default: `'throw'`.
122
122
123
123
-**submode**: a mode array which specifies for each dimension how to handle subscripts which exceed array dimensions. If provided fewer modes than dimensions, the function recycles modes using modulo arithmetic. Default: `[ options.mode ]`.
124
124
125
-
-**readonly**: `boolean` indicating whether an [`ndarray`][@stdlib/ndarray/ctor] instance should be **read-only**. Default: `false`.
125
+
-**readonly**: boolean indicating whether an [ndarray][@stdlib/ndarray/ctor] instance should be **read-only**. Default: `false`.
126
126
127
-
By default, an [`ndarray`][@stdlib/ndarray/ctor] instance **throws** when provided an index which exceeds array dimensions. To support alternative indexing behavior, set the `mode` option, which will affect all public methods for getting and setting array elements.
127
+
By default, an [ndarray][@stdlib/ndarray/ctor] instance **throws** when provided an index which exceeds array dimensions. To support alternative indexing behavior, set the `mode` option, which will affect all public methods for getting and setting array elements.
128
128
129
129
```javascript
130
130
var opts = {
@@ -189,7 +189,7 @@ var bool = ( v === buf[ 0 ] );
189
189
190
190
## Notes
191
191
192
-
- The number of elements in a data source `buffer`**must** agree with a specified array `shape` (i.e., the function assumes a single-segment contiguous [`ndarray`][@stdlib/ndarray/ctor]). To create arbitrary multidimensional views over linear data buffers, use a [lower-level constructor][@stdlib/ndarray/ctor].
192
+
- The number of elements in a data source `buffer`**must** agree with a specified array shape (i.e., the function assumes a single-segment contiguous [ndarray][@stdlib/ndarray/ctor]). To create arbitrary multidimensional views over linear data buffers, use a [lower-level constructor][@stdlib/ndarray/ctor].
193
193
- The function supports arbitrary casting between data types. Note, however, that casting from a larger data type to a smaller data type (e.g., `int32` to `int8`) and between signed and unsigned types of the same size should be considered **unsafe**.
0 commit comments