-
-
Notifications
You must be signed in to change notification settings - Fork 804
/
Copy pathrepl.txt
141 lines (112 loc) · 4.46 KB
/
repl.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
{{alias}}( arrays, shape, strides, fcn, clbk[, thisArg] )
Applies a unary function to each element retrieved from a strided input
array according to a callback function and assigns results to a strided
output array.
The shape and stride parameters determine which elements in the strided
input and output arrays are accessed at runtime.
Indexing is relative to the first index. To introduce an offset, use typed
array views.
The callback function is provided four arguments:
- value: array element.
- idx: iteration index.
- indices: strided indices (offset + idx*stride).
- arrays: input and output arrays.
If the callback function does not return any value (or equivalently,
explicitly returns `undefined`), the value is ignored.
Parameters
----------
arrays: ArrayLikeObject<ArrayLikeObject>
Array-like object containing one strided input array and one strided
output array.
shape: ArrayLikeObject<integer>
Array-like object containing a single element, the number of indexed
elements.
strides: ArrayLikeObject<integer>
Array-like object containing the stride lengths for the strided input
and output arrays.
fcn: Function
Unary function to apply to callback return values.
clbk: Function
Callback function.
thisArg: any (optional)
Callback execution context.
Examples
--------
// Standard usage:
> var x = [ 1.0, -2.0, 3.0, -4.0 ];
> var y = [ 0.0, 0.0, 0.0, 0.0 ];
> var sh = [ x.length ];
> var st = [ 1, 1 ];
> function clbk( v ) { return v * 2.0; };
> {{alias}}( [ x, y ], sh, st, {{alias:@stdlib/math/base/special/abs}}, clbk );
> y
[ 2.0, 4.0, 6.0, 8.0 ]
// Using shape and stride parameters:
> y = [ 0.0, 0.0, 0.0, 0.0 ];
> sh = [ 2 ];
> st = [ 2, -1 ];
> {{alias}}( [ x, y ], sh, st, {{alias:@stdlib/math/base/special/abs}}, clbk );
> y
[ 6.0, 2.0, 0.0, 0.0 ]
// Using view offsets:
> var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, -4.0 ] );
> var y0 = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 0.0, 0.0 ] );
> var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 );
> var y1 = new {{alias:@stdlib/array/float64}}( y0.buffer, y0.BYTES_PER_ELEMENT*2 );
> sh = [ 2 ];
> st = [ -2, 1 ];
> {{alias}}( [ x1, y1 ], sh, st, {{alias:@stdlib/math/base/special/abs}}, clbk );
> y1
<Float64Array>[ 8.0, 4.0 ]
> y0
<Float64Array>[ 0.0, 0.0, 8.0, 4.0 ]
{{alias}}.ndarray( arrays, shape, strides, offsets, fcn, clbk[, thisArg] )
Applies a unary function to each element retrieved from a strided input
array according to a callback function and assigns results to a strided
output array using alternative indexing semantics.
While typed array views mandate a view offset based on the underlying
buffer, the offsest parameters support indexing semantics
based on starting indices.
Parameters
----------
arrays: ArrayLikeObject<ArrayLikeObject>
Array-like object containing one strided input array and one strided
output array.
shape: ArrayLikeObject<integer>
Array-like object containing a single element, the number of indexed
elements.
strides: ArrayLikeObject<integer>
Array-like object containing the stride lengths for the strided input
and output arrays.
offsets: ArrayLikeObject<integer>
Array-like object containing the starting indices (i.e., index offsets)
for the strided input and output arrays.
fcn: Function
Unary function to apply to callback return values.
clbk: Function
Callback function.
thisArg: any (optional)
Callback execution context.
Examples
--------
// Standard usage:
> var x = [ 1.0, -2.0, 3.0, -4.0 ];
> var y = [ 0.0, 0.0, 0.0, 0.0 ];
> var sh = [ x.length ];
> var st = [ 1, 1 ];
> var o = [ 0, 0 ];
> function clbk( v ) { return v * 2.0; };
> {{alias}}.ndarray( [ x, y ], sh, st, o, {{alias:@stdlib/math/base/special/abs}}, clbk );
> y
[ 2.0, 4.0, 6.0, 8.0 ]
// Advanced indexing:
> x = [ 1.0, -2.0, 3.0, -4.0 ];
> y = [ 0.0, 0.0, 0.0, 0.0 ];
> sh = [ 2 ];
> st = [ 2, -1 ];
> o = [ 1, y.length-1 ];
> {{alias}}.ndarray( [ x, y ], sh, st, o, {{alias:@stdlib/math/base/special/abs}}, clbk );
> y
[ 0.0, 0.0, 8.0, 4.0 ]
See Also
--------