|
3 | 3 | Adds a constant to each element in a single-precision floating-point strided
|
4 | 4 | array.
|
5 | 5 |
|
6 |
| - The `N` and `stride` parameters determine which elements in `x` are accessed |
7 |
| - at runtime. |
| 6 | + The `N` and stride parameters determine which elements in the strided array |
| 7 | + are accessed at runtime. |
8 | 8 |
|
9 | 9 | Indexing is relative to the first index. To introduce an offset, use typed
|
10 | 10 | array views.
|
11 | 11 |
|
12 |
| - If `N <= 0`, the function returns `x` unchanged. |
| 12 | + If `N <= 0`, the function returns the strided array unchanged. |
13 | 13 |
|
14 | 14 | Parameters
|
15 | 15 | ----------
|
|
23 | 23 | Input array.
|
24 | 24 |
|
25 | 25 | stride: integer
|
26 |
| - Index increment for `x`. |
| 26 | + Index increment. |
27 | 27 |
|
28 | 28 | Returns
|
29 | 29 | -------
|
30 | 30 | x: Float32Array
|
31 |
| - Input array `x`. |
| 31 | + Input array. |
32 | 32 |
|
33 | 33 | Examples
|
34 | 34 | --------
|
35 | 35 | // Standard Usage:
|
36 | 36 | > var x = new {{alias:@stdlib/array/float32}}( [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, -3.0 ] );
|
37 |
| - > var alpha = 5.0; |
38 |
| - > {{alias}}( x.length, alpha, x, 1 ) |
| 37 | + > {{alias}}( x.length, 5.0, x, 1 ) |
39 | 38 | <Float32Array>[ 3.0, 6.0, 8.0, 0.0, 9.0, 4.0, 2.0 ]
|
40 | 39 |
|
41 | 40 | // Using `N` and `stride` parameters:
|
42 | 41 | > x = new {{alias:@stdlib/array/float32}}( [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, -3.0 ] );
|
43 |
| - > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); |
44 |
| - > alpha = 5.0; |
45 |
| - > var stride = 2; |
46 |
| - > {{alias}}( N, alpha, x, stride ) |
| 42 | + > {{alias}}( 3, 5.0, x, 2 ) |
47 | 43 | <Float32Array>[ 3.0, 1.0, 8.0, -5.0, 9.0, -1.0, -3.0 ]
|
48 | 44 |
|
49 | 45 | // Using view offsets:
|
50 | 46 | > var x0 = new {{alias:@stdlib/array/float32}}( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] );
|
51 | 47 | > var x1 = new {{alias:@stdlib/array/float32}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 );
|
52 |
| - > N = {{alias:@stdlib/math/base/special/floor}}( x0.length / 2 ); |
53 |
| - > alpha = 5.0; |
54 |
| - > stride = 2; |
55 |
| - > {{alias}}( N, alpha, x1, stride ) |
| 48 | + > {{alias}}( 3, 5.0, x1, 2 ) |
56 | 49 | <Float32Array>[ 3.0, 3.0, 1.0, 5.0, -1.0 ]
|
57 | 50 | > x0
|
58 | 51 | <Float32Array>[ 1.0, 3.0, 3.0, 1.0, 5.0, -1.0 ]
|
59 | 52 |
|
| 53 | + |
60 | 54 | {{alias}}.ndarray( N, alpha, x, stride, offset )
|
61 | 55 | Adds a constant to each element in a single-precision floating-point strided
|
62 | 56 | array using alternative indexing semantics.
|
|
77 | 71 | Input array.
|
78 | 72 |
|
79 | 73 | stride: integer
|
80 |
| - Index increment for `x`. |
| 74 | + Index increment. |
81 | 75 |
|
82 | 76 | offset: integer
|
83 |
| - Starting index of `x`. |
| 77 | + Starting index. |
84 | 78 |
|
85 | 79 | Returns
|
86 | 80 | -------
|
87 | 81 | x: Float32Array
|
88 |
| - Input array `x`. |
| 82 | + Input array. |
89 | 83 |
|
90 | 84 | Examples
|
91 | 85 | --------
|
92 | 86 | // Standard Usage:
|
93 | 87 | > var x = new {{alias:@stdlib/array/float32}}( [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, -3.0 ] );
|
94 |
| - > var alpha = 5.0; |
95 |
| - > {{alias}}.ndarray( x.length, alpha, x, 1, 0 ) |
| 88 | + > {{alias}}.ndarray( x.length, 5.0, x, 1, 0 ) |
96 | 89 | <Float32Array>[ 3.0, 6.0, 8.0, 0.0, 9.0, 4.0, 2.0 ]
|
97 | 90 |
|
98 | 91 | // Using an index offset:
|
99 | 92 | > x = new {{alias:@stdlib/array/float32}}( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] );
|
100 |
| - > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); |
101 |
| - > alpha = 5.0; |
102 |
| - > var stride = 2; |
103 |
| - > {{alias}}.ndarray( N, alpha, x, stride, 1 ) |
| 93 | + > {{alias}}.ndarray( 3, 5.0, x, 2, 1 ) |
104 | 94 | <Float32Array>[ 1.0, 3.0, 3.0, 1.0, 5.0, -1.0 ]
|
105 | 95 |
|
106 | 96 | See Also
|
|
0 commit comments