|
1 | 1 |
|
2 |
| -{{alias}}( start, stop[, length] ) |
3 |
| - Generates a linearly spaced numeric array. |
| 2 | +{{alias}}( start, stop, length[, options] ) |
| 3 | + Generates a linearly spaced array over a specified interval. |
4 | 4 |
|
5 |
| - If a `length` is not provided, the default output array length is `100`. |
| 5 | + If the specified length is zero, the function returns an empty array. |
6 | 6 |
|
7 |
| - The output array is guaranteed to include the `start` and `stop` values. |
| 7 | + If the specified length is one, the function returns an array containing |
| 8 | + `stop`, but not `start`, when `endpoint` is true; otherwise, the function |
| 9 | + returns an array containing `start`, but not `stop`. |
| 10 | + |
| 11 | + For real-valued `start` and `stop`, if `start` is less than `stop`, the |
| 12 | + output array will contain ascending values, and, if `start` is greater than |
| 13 | + `stop`, the output array will contain descending values. |
| 14 | + |
| 15 | + When the output array length is greater than one and `endpoint` is true, the |
| 16 | + output array is guaranteed to include the `start` and `stop` values. Beware, |
| 17 | + however, that values between `start` and `stop` are subject to floating- |
| 18 | + point rounding errors. |
| 19 | + |
| 20 | + If both `start` and `stop` are real-valued, the output array data type may |
| 21 | + be any floating-point data type or 'generic'. However, if either `start` or |
| 22 | + `stop` are complex numbers, the output array type must be a complex |
| 23 | + floating-point data type or 'generic'. |
| 24 | + |
| 25 | + When writing to a complex floating-point output array, real-valued `start` |
| 26 | + and `stop` values are treated as complex numbers having a real component |
| 27 | + equaling the provided value and having an imaginary component equaling zero. |
| 28 | + |
| 29 | + When generating linearly spaced complex floating-point numbers, the real and |
| 30 | + imaginary components are generated separately. |
8 | 31 |
|
9 | 32 | Parameters
|
10 | 33 | ----------
|
11 |
| - start: number |
12 |
| - First array value. |
| 34 | + start: number|ComplexLike |
| 35 | + Start of interval. |
| 36 | + |
| 37 | + stop: number|ComplexLike |
| 38 | + End of interval. |
| 39 | + |
| 40 | + length: integer |
| 41 | + Length of output array. |
13 | 42 |
|
14 |
| - stop: number |
15 |
| - Last array value. |
| 43 | + options: Object (optional) |
| 44 | + Options. |
16 | 45 |
|
17 |
| - length: integer (optional) |
18 |
| - Length of output array. Default: `100`. |
| 46 | + options.dtype: string (optional) |
| 47 | + Output array data type. Must be a floating-point data type or 'generic'. |
| 48 | + If both `start` and `stop` are the same type (either 'float64', |
| 49 | + 'complex64', or 'complex128'), the default output array data type is |
| 50 | + the same type as the input values (either 'float64', 'complex64', or |
| 51 | + 'complex128', respectively). Otherwise, the default output array data |
| 52 | + type is 'complex128'. |
| 53 | + |
| 54 | + options.endpoint: boolean (optional) |
| 55 | + Boolean indicating whether to include the `stop` value in the output |
| 56 | + array. If false, the function generates `length + 1` linearly spaced |
| 57 | + values over the interval `[start, stop]` and only writes `length` values |
| 58 | + to the output array, thus excluding `stop` from the output array. |
| 59 | + Accordingly, for a fixed `length`, the spacing between adjacent values |
| 60 | + in the output array changes depending on the value of `endpoint`. |
| 61 | + Default: true. |
19 | 62 |
|
20 | 63 | Returns
|
21 | 64 | -------
|
22 | 65 | arr: Array
|
23 |
| - Linearly spaced numeric array. |
| 66 | + Linearly spaced array. |
| 67 | + |
| 68 | + Examples |
| 69 | + -------- |
| 70 | + > var arr = {{alias}}( 0.0, 100.0, 6 ) |
| 71 | + <Float64Array>[ 0.0, 20.0, 40.0, 60.0, 80.0, 100.0 ] |
| 72 | + > arr = {{alias}}( 0.0, 100.0, 5, { 'endpoint': false } ) |
| 73 | + <Float64Array>[ 0.0, 20.0, 40.0, 60.0, 80.0 ] |
| 74 | + > arr = {{alias}}( 0.0, 100.0, 6, { 'dtype': 'generic' } ) |
| 75 | + [ 0.0, 20.0, 40.0, 60.0, 80.0, 100.0 ] |
| 76 | + |
| 77 | + |
| 78 | +{{alias}}.assign( start, stop, out[, options] ) |
| 79 | + Generates a linearly spaced sequence over a specified interval and assigns |
| 80 | + the results to a provided output array. |
| 81 | + |
| 82 | + If the provided output array is empty, the function returns the provided |
| 83 | + output array unchanged. |
| 84 | + |
| 85 | + If the provided output array contains a single element, the function writes |
| 86 | + the `stop` value, but not `start`, when `endpoint` is true; otherwise, the |
| 87 | + function writes the `start` value, but not `stop`. |
| 88 | + |
| 89 | + Parameters |
| 90 | + ---------- |
| 91 | + start: number|ComplexLike |
| 92 | + Start of interval. |
| 93 | + |
| 94 | + stop: number|ComplexLike |
| 95 | + End of interval. |
| 96 | + |
| 97 | + out: ArrayLikeObject |
| 98 | + Output array. |
| 99 | + |
| 100 | + options: Object (optional) |
| 101 | + Options. |
| 102 | + |
| 103 | + options.endpoint: boolean (optional) |
| 104 | + Boolean indicating whether to include the `stop` value in the output |
| 105 | + array. If false, the function generates `N+1` linearly spaced values |
| 106 | + (where `N` is the length of the provided output array) over the interval |
| 107 | + `[start, stop]` and only writes `N` values to the output array, thus |
| 108 | + excluding `stop` from the output array. Accordingly, for a fixed `N`, |
| 109 | + the spacing between adjacent values in the output array changes |
| 110 | + depending on the value of `endpoint`. Default: true. |
| 111 | + |
| 112 | + Returns |
| 113 | + ------- |
| 114 | + out: ArrayLikeObject |
| 115 | + Output array. |
24 | 116 |
|
25 | 117 | Examples
|
26 | 118 | --------
|
27 |
| - > var arr = {{alias}}( 0, 100, 6 ) |
| 119 | + > var arr = [ 0, 0, 0, 0, 0, 0 ]; |
| 120 | + > var out = {{alias}}.assign( 0, 100, arr ) |
28 | 121 | [ 0, 20, 40, 60, 80, 100 ]
|
| 122 | + > var bool = ( arr === out ) |
| 123 | + true |
| 124 | + > arr = [ 0, 0, 0, 0, 0 ]; |
| 125 | + > out = {{alias}}.assign( 0, 100, arr, { 'endpoint': false } ) |
| 126 | + [ 0, 20, 40, 60, 80 ] |
29 | 127 |
|
30 | 128 | See Also
|
31 | 129 | --------
|
|
0 commit comments