@stdlib/strided
Version:
Strided.
156 lines (118 loc) • 4.51 kB
Plain Text
{{alias}}( addon, fallback )
Returns a function which dispatches to a native add-on applying a unary
function to an input strided array.
The returned function has the following signature:
f( N, dtypeX, x, strideX, dtypeY, y, strideY )
where
- N: number of indexed elements.
- dtypeX: `x` data type.
- x: input array.
- strideX: `x` stride length.
- dtypeY: `y` data type.
- y: output array.
- strideY: `y` stride length.
To determine whether to dispatch to the `addon` function, the returned
dispatch function checks whether the provided arrays are typed arrays.
If the provided arrays are typed arrays, the dispatch function invokes the
`addon` function; otherwise, the dispatch function invokes the `fallback`
function.
Parameters
----------
addon: Function
Add-on interface. The function should have the following signature:
f( N, dtypeX, x, strideX, dtypeY, y, strideY )
where
- N: number of indexed elements.
- dtypeX: `x` data type (enumeration constant).
- x: input array.
- strideX: `x` stride length.
- dtypeY: `y` data type (enumeration constant).
- y: output array.
- strideY: `y` stride length.
fallback: Function
Fallback function. The function should have the following signature:
f( N, dtypeX, x, strideX, dtypeY, y, strideY )
where
- N: number of indexed elements.
- dtypeX: `x` data type.
- x: input array.
- strideX: `x` stride length.
- dtypeY: `y` data type.
- y: output array.
- strideY: `y` stride length.
Returns
-------
fcn: Function
Dispatch function.
Examples
--------
> function addon( N, dx, x, sx, dy, y, sy ) {
... // Call into native add-on...
... };
> function fallback( N, dx, x, sx, dy, y, sy ) {
... // Fallback JavaScript implementation...
... };
> var f = {{alias}}( addon, fallback );
> f( 2, 'generic', [ 1, 2 ], 1, 'generic', [ 0, 0 ], 1 );
{{alias}}.ndarray( addon, fallback )
Returns a function which dispatches to a native add-on applying a unary
function to an input strided array using alternative indexing semantics.
The returned function has the following signature:
f( N, dtypeX, x, strideX, offsetX, dtypeY, y, strideY, offsetY )
where
- N: number of indexed elements.
- dtypeX: `x` data type.
- x: input array.
- strideX: `x` stride length.
- offsetX: starting `x` index.
- dtypeY: `y` data type.
- y: output array.
- strideY: `y` stride length.
- offsetY: starting `y` index.
To determine whether to dispatch to the `addon` function, the returned
dispatch function checks whether the provided arrays are typed arrays.
If the provided arrays are typed arrays, the dispatch function invokes the
`addon` function; otherwise, the dispatch function invokes the `fallback`
function.
Parameters
----------
addon: Function
Add-on interface. The function should have the following signature:
f( N, dtypeX, x, strideX, dtypeY, y, strideY )
where
- N: number of indexed elements.
- dtypeX: `x` data type (enumeration constant).
- x: input array.
- strideX: `x` stride length.
- dtypeY: `y` data type (enumeration constant).
- y: output array.
- strideY: `y` stride length.
fallback: Function
Fallback function. The function should have the following signature:
f( N, dtypeX, x, strideX, offsetX, dtypeY, y, strideY, offsetY )
where
- N: number of indexed elements.
- dtypeX: `x` data type.
- x: input array.
- strideX: `x` stride length.
- offsetX: starting `x` index.
- dtypeY: `y` data type.
- y: output array.
- strideY: `y` stride length.
- offsetY: starting `y` index.
Returns
-------
fcn: Function
Dispatch function.
Examples
--------
> function addon( N, dx, x, sx, dy, y, sy ) {
... // Call into native add-on...
... };
> function fallback( N, dx, x, sx, ox, dy, y, sy ) {
... // Fallback JavaScript implementation...
... };
> var f = {{alias}}.ndarray( addon, fallback );
> f( 2, 'generic', [ 1, 2 ], 1, 0, 'generic', [ 0, 0 ], 1, 0 );
See Also
--------