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
-**fcns**: list of [ndarray][@stdlib/ndarray/ctor] functions.
133
+
-**types**: one-dimensional list of [ndarray][@stdlib/ndarray/ctor] argument [data types][@stdlib/ndarray/dtypes]. The length of `types` must be the number of [ndarray][@stdlib/ndarray/ctor] functions multiplied by `nin+nout`. If `fcns` is a function, rather than a list, the number of [ndarray][@stdlib/ndarray/ctor] functions is computed as `types.length / (nin+nout)`.
134
+
-**data**: [ndarray][@stdlib/ndarray/ctor] function data (e.g., callbacks). If a list, the length of `data` must equal the number of [ndarray][@stdlib/ndarray/ctor] functions. If `null`, a returned [ndarray][@stdlib/ndarray/ctor] function interface does **not** provide a `data` argument to an invoked [ndarray][@stdlib/ndarray/ctor] function.
135
+
-**nargs**: total number of [ndarray][@stdlib/ndarray/ctor] function interface arguments.
136
+
-**nin**: number of input [ndarrays][@stdlib/ndarray/ctor].
137
+
-**nout**: number of output [ndarrays][@stdlib/ndarray/ctor].
62
138
63
139
</section>
64
140
65
141
<!-- /.usage -->
66
142
67
143
<sectionclass="notes">
68
144
145
+
## Notes
146
+
147
+
- A returned [ndarray][@stdlib/ndarray/ctor] function interface has the following signature:
- The number of [ndarray][@stdlib/ndarray/ctor] function interface parameters is derived from `nargs`, the number of input [ndarrays][@stdlib/ndarray/ctor] is derived from `nin`, and the number of output [ndarrays][@stdlib/ndarray/ctor] is derived from `nout`.
160
+
161
+
- An [ndarray][@stdlib/ndarray/ctor] function (i.e., a value provided for the `fcns` argument) should have the following signature:
162
+
163
+
```text
164
+
f( arrays[, data] )
165
+
```
166
+
167
+
where
168
+
169
+
- **arrays**: array containing input and output [ndarrays][@stdlib/ndarray/ctor].
170
+
- **data**: [ndarray][@stdlib/ndarray/ctor] function data (e.g., a callback).
171
+
172
+
- For convenience, a single [ndarray][@stdlib/ndarray/ctor] function may be provided which will be invoked whenever the [ndarray][@stdlib/ndarray/ctor] argument data types match a sequence of types in `types`. Providing a single [ndarray][@stdlib/ndarray/ctor] function is particularly convenient for the case where, regardless of array data types, traversing arrays remains the same, but the [ndarray][@stdlib/ndarray/ctor] function `data` differs (e.g., callbacks which differ based on the array data types). For example, the following
173
+
174
+
<!-- eslint-disable array-element-newline -->
175
+
176
+
```javascript
177
+
var unary = require( '@stdlib/ndarray-base-unary' );
178
+
179
+
function foo( x ) {
180
+
return x * 10.0;
181
+
}
182
+
183
+
function bar( x ) {
184
+
return x * 5.0;
185
+
}
186
+
187
+
var fcns = [
188
+
unary,
189
+
unary
190
+
];
191
+
var types = [
192
+
'float64', 'float64',
193
+
'float32', 'float32'
194
+
];
195
+
var data = [
196
+
foo,
197
+
bar
198
+
];
199
+
200
+
var fcn = dispatch( fcns, types, data, 2, 1, 1 );
201
+
```
202
+
203
+
is equivalent to
204
+
205
+
<!-- eslint-disable array-element-newline -->
206
+
207
+
```javascript
208
+
var unary = require( '@stdlib/ndarray-base-unary' );
0 commit comments