|
21 | 21 | /* tslint:disable:max-line-length */ |
22 | 22 | /* tslint:disable:max-file-line-count */ |
23 | 23 |
|
| 24 | +import arraylike2object = require( '@stdlib/array/base/arraylike2object' ); |
| 25 | +import copy = require( '@stdlib/array/base/copy' ); |
24 | 26 | import filled = require( '@stdlib/array/base/filled' ); |
| 27 | +import filledBy = require( '@stdlib/array/base/filled-by' ); |
| 28 | +import incrspace = require( '@stdlib/array/base/incrspace' ); |
| 29 | +import linspace = require( '@stdlib/array/base/linspace' ); |
| 30 | +import logspace = require( '@stdlib/array/base/logspace' ); |
| 31 | +import ones = require( '@stdlib/array/base/ones' ); |
| 32 | +import unitspace = require( '@stdlib/array/base/unitspace' ); |
| 33 | +import zeros = require( '@stdlib/array/base/zeros' ); |
25 | 34 |
|
26 | 35 | /** |
27 | | -* Interface describing the `array` namespace. |
| 36 | +* Interface describing the `base` namespace. |
28 | 37 | */ |
29 | 38 | interface Namespace { |
30 | 39 | /** |
31 | | - * Automatically generated. |
| 40 | + * Converts a one-dimensional array-like object to an object likely to have the same "shape". |
| 41 | + * |
| 42 | + * ## Notes |
| 43 | + * |
| 44 | + * - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". |
| 45 | + * |
| 46 | + * @param x - input array |
| 47 | + * @returns object containing array data |
| 48 | + * |
| 49 | + * @example |
| 50 | + * var x = [ 1, 2, 3, 4, 5, 6 ]; |
| 51 | + * |
| 52 | + * var obj = ns.arraylike2object( x ); |
| 53 | + * // returns {...} |
| 54 | + */ |
| 55 | + arraylike2object: typeof arraylike2object; |
| 56 | + |
| 57 | + /** |
| 58 | + * Copies the elements of an array-like object to a new "generic" array. |
| 59 | + * |
| 60 | + * @param x - array length |
| 61 | + * @returns output array |
| 62 | + * |
| 63 | + * @example |
| 64 | + * var x = [ 1, 2, 3 ]; |
| 65 | + * |
| 66 | + * var out = ns.copy( x ); |
| 67 | + * // returns [ 1, 2, 3 ] |
| 68 | + */ |
| 69 | + copy: typeof copy; |
| 70 | + |
| 71 | + /** |
| 72 | + * Returns a filled "generic" array. |
| 73 | + * |
| 74 | + * @param value - fill value |
| 75 | + * @param len - array length |
| 76 | + * @returns output array |
| 77 | + * |
| 78 | + * @example |
| 79 | + * var out = ns.filled( 0.0, 3 ); |
| 80 | + * // returns [ 0.0, 0.0, 0.0 ] |
| 81 | + * |
| 82 | + * @example |
| 83 | + * var out = ns.filled( 'beep', 3 ); |
| 84 | + * // returns [ 'beep', 'beep', 'beep' ] |
32 | 85 | */ |
33 | 86 | filled: typeof filled; |
| 87 | + |
| 88 | + /** |
| 89 | + * Returns a filled "generic" array according to a provided callback function. |
| 90 | + * |
| 91 | + * @param len - array length |
| 92 | + * @param clbk - callback function |
| 93 | + * @param thisArg - callback function execution context |
| 94 | + * @returns output array |
| 95 | + * |
| 96 | + * @example |
| 97 | + * var constantFunction = require( `@stdlib/utils/constant-function` ); |
| 98 | + * |
| 99 | + * var arr = ns.filledBy( 5, constantFunction( 1.0 ) ); |
| 100 | + * // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] |
| 101 | + */ |
| 102 | + filledBy: typeof filledBy; |
| 103 | + |
| 104 | + /** |
| 105 | + * Generates a linearly spaced numeric array according to a provided increment. |
| 106 | + * |
| 107 | + * @param x1 - first array value |
| 108 | + * @param x2 - array element bound |
| 109 | + * @param increment - increment |
| 110 | + * @returns linearly spaced numeric array |
| 111 | + * |
| 112 | + * @example |
| 113 | + * var arr = ns.incrspace( 0, 11, 2 ); |
| 114 | + * // returns [ 0, 2, 4, 6, 8, 10 ] |
| 115 | + */ |
| 116 | + incrspace: typeof incrspace; |
| 117 | + |
| 118 | + /** |
| 119 | + * Generates a linearly spaced numeric array. |
| 120 | + * |
| 121 | + * @param x1 - first array value |
| 122 | + * @param x2 - last array value |
| 123 | + * @param len - length of output array |
| 124 | + * @returns linearly spaced numeric array |
| 125 | + * |
| 126 | + * @example |
| 127 | + * var arr = ns.linspace( 0, 100, 6 ); |
| 128 | + * // returns [ 0, 20, 40, 60, 80, 100 ] |
| 129 | + */ |
| 130 | + linspace: typeof linspace; |
| 131 | + |
| 132 | + /** |
| 133 | + * Generates a logarithmically spaced numeric array. |
| 134 | + * |
| 135 | + * @param a - exponent of start value |
| 136 | + * @param b - exponent of end value |
| 137 | + * @param len - length of output array |
| 138 | + * @returns logarithmically spaced numeric array |
| 139 | + * |
| 140 | + * @example |
| 141 | + * var arr = ns.logspace( 0, 2, 6 ); |
| 142 | + * // returns [ 1, ~2.5, ~6.31, ~15.85, ~39.81, 100 ] |
| 143 | + */ |
| 144 | + logspace: typeof logspace; |
| 145 | + |
| 146 | + /** |
| 147 | + * Returns a "generic" array filled with ones. |
| 148 | + * |
| 149 | + * @param len - array length |
| 150 | + * @returns output array |
| 151 | + * |
| 152 | + * @example |
| 153 | + * var out = ns.ones( 3 ); |
| 154 | + * // returns [ 1.0, 1.0, 1.0 ] |
| 155 | + */ |
| 156 | + ones: typeof ones; |
| 157 | + |
| 158 | + /** |
| 159 | + * Generates a linearly spaced numeric array whose elements increment by 1. |
| 160 | + * |
| 161 | + * @param x1 - first array value |
| 162 | + * @param x2 - array element bound |
| 163 | + * @returns linearly spaced numeric array |
| 164 | + * |
| 165 | + * @example |
| 166 | + * var arr = ns.unitspace( 0, 6 ); |
| 167 | + * // returns [ 0, 1, 2, 3, 4, 5 ] |
| 168 | + */ |
| 169 | + unitspace: typeof unitspace; |
| 170 | + |
| 171 | + /** |
| 172 | + * Returns a zero-filled "generic" array. |
| 173 | + * |
| 174 | + * @param len - array length |
| 175 | + * @returns output array |
| 176 | + * |
| 177 | + * @example |
| 178 | + * var out = ns.zeros( 3 ); |
| 179 | + * // returns [ 0.0, 0.0, 0.0 ] |
| 180 | + */ |
| 181 | + zeros: typeof zeros; |
34 | 182 | } |
35 | 183 |
|
36 | 184 | /** |
37 | | -* Arrays. |
| 185 | +* Base (i.e., lower-level) array utilities. |
38 | 186 | */ |
39 | 187 | declare var ns: Namespace; |
40 | 188 |
|
|
0 commit comments