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.
113
+
-**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)`.
114
+
-**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.
115
+
-**nargs**: total number of [ndarray][@stdlib/ndarray/ctor] function interface arguments.
116
+
-**nin**: number of input [ndarrays][@stdlib/ndarray/ctor].
117
+
-**nout**: number of output [ndarrays][@stdlib/ndarray/ctor].
42
118
43
119
</section>
44
120
45
121
<!-- /.usage -->
46
122
47
123
<sectionclass="notes">
48
124
125
+
## Notes
126
+
127
+
- 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`.
140
+
141
+
- An [ndarray][@stdlib/ndarray/ctor] function (i.e., a value provided for the `fcns` argument) should have the following signature:
142
+
143
+
```text
144
+
f( arrays[, data] )
145
+
```
146
+
147
+
where
148
+
149
+
- **arrays**: array containing input and output [ndarrays][@stdlib/ndarray/ctor].
150
+
- **data**: [ndarray][@stdlib/ndarray/ctor] function data (e.g., a callback).
151
+
152
+
- 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
153
+
154
+
<!-- eslint-disable array-element-newline -->
155
+
156
+
```javascript
157
+
var unary = require( '@stdlib/ndarray/base/unary' );
158
+
159
+
function foo( x ) {
160
+
return x * 10.0;
161
+
}
162
+
163
+
function bar( x ) {
164
+
return x * 5.0;
165
+
}
166
+
167
+
var fcns = [
168
+
unary,
169
+
unary
170
+
];
171
+
var types = [
172
+
'float64', 'float64',
173
+
'float32', 'float32'
174
+
];
175
+
var data = [
176
+
foo,
177
+
bar
178
+
];
179
+
180
+
var fcn = dispatch( fcns, types, data, 2, 1, 1 );
181
+
```
182
+
183
+
is equivalent to
184
+
185
+
<!-- eslint-disable array-element-newline -->
186
+
187
+
```javascript
188
+
var unary = require( '@stdlib/ndarray/base/unary' );
0 commit comments