|
20 | 20 |
|
21 | 21 | /// <reference types="@stdlib/types"/>
|
22 | 22 |
|
23 |
| -import { Complex128Array, Complex64Array, DataType } from '@stdlib/types/array'; |
24 |
| - |
25 |
| -/** |
26 |
| -* Creates an array filled with ones and having a specified length. |
27 |
| -* |
28 |
| -* @param length - array length |
29 |
| -* @param dtype - data type |
30 |
| -* @returns filled array |
31 |
| -* |
32 |
| -* @example |
33 |
| -* var arr = ones( 2, 'float64' ); |
34 |
| -* // returns <Float64Array>[ 1.0, 1.0 ] |
35 |
| -*/ |
36 |
| -declare function ones( length: number, dtype: 'float64' ): Float64Array; |
37 |
| - |
38 |
| -/** |
39 |
| -* Creates an array filled with ones and having a specified length. |
40 |
| -* |
41 |
| -* @param length - array length |
42 |
| -* @param dtype - data type |
43 |
| -* @returns filled array |
44 |
| -* |
45 |
| -* @example |
46 |
| -* var arr = ones( 2, 'float32' ); |
47 |
| -* // returns <Float32Array>[ 1.0, 1.0 ] |
48 |
| -*/ |
49 |
| -declare function ones( length: number, dtype: 'float32' ): Float32Array; |
50 |
| - |
51 |
| -/** |
52 |
| -* Creates an array filled with ones and having a specified length. |
53 |
| -* |
54 |
| -* ## Notes |
55 |
| -* |
56 |
| -* - Each entry has a real component equal to `1` and an imaginary component equal to `0`. |
57 |
| -* |
58 |
| -* @param length - array length |
59 |
| -* @param dtype - data type |
60 |
| -* @returns filled array |
61 |
| -* |
62 |
| -* @example |
63 |
| -* var arr = ones( 2, 'complex128' ); |
64 |
| -* // returns <Complex128Array> |
65 |
| -*/ |
66 |
| -declare function ones( length: number, dtype: 'complex128' ): Complex128Array; |
67 |
| - |
68 |
| -/** |
69 |
| -* Creates an array filled with ones and having a specified length. |
70 |
| -* |
71 |
| -* ## Notes |
72 |
| -* |
73 |
| -* - Each entry has a real component equal to `1` and an imaginary component equal to `0`. |
74 |
| -* |
75 |
| -* @param length - array length |
76 |
| -* @param dtype - data type |
77 |
| -* @returns filled array |
78 |
| -* |
79 |
| -* @example |
80 |
| -* var arr = ones( 2, 'complex64' ); |
81 |
| -* // returns <Complex64Array> |
82 |
| -*/ |
83 |
| -declare function ones( length: number, dtype: 'complex64' ): Complex64Array; |
84 |
| - |
85 |
| -/** |
86 |
| -* Creates an array filled with ones and having a specified length. |
87 |
| -* |
88 |
| -* @param length - array length |
89 |
| -* @param dtype - data type |
90 |
| -* @returns filled array |
91 |
| -* |
92 |
| -* @example |
93 |
| -* var arr = ones( 2, 'int32' ); |
94 |
| -* // returns <Int32Array>[ 1, 1 ] |
95 |
| -*/ |
96 |
| -declare function ones( length: number, dtype: 'int32' ): Int32Array; |
97 |
| - |
98 |
| -/** |
99 |
| -* Creates an array filled with ones and having a specified length. |
100 |
| -* |
101 |
| -* @param length - array length |
102 |
| -* @param dtype - data type |
103 |
| -* @returns filled array |
104 |
| -* |
105 |
| -* @example |
106 |
| -* var arr = ones( 2, 'int16' ); |
107 |
| -* // returns <Int16Array>[ 1, 1 ] |
108 |
| -*/ |
109 |
| -declare function ones( length: number, dtype: 'int16' ): Int16Array; |
110 |
| - |
111 |
| -/** |
112 |
| -* Creates an array filled with ones and having a specified length. |
113 |
| -* |
114 |
| -* @param length - array length |
115 |
| -* @param dtype - data type |
116 |
| -* @returns filled array |
117 |
| -* |
118 |
| -* @example |
119 |
| -* var arr = ones( 2, 'int8' ); |
120 |
| -* // returns <Int8Array>[ 1, 1 ] |
121 |
| -*/ |
122 |
| -declare function ones( length: number, dtype: 'int8' ): Int8Array; |
123 |
| - |
124 |
| -/** |
125 |
| -* Creates an array filled with ones and having a specified length. |
126 |
| -* |
127 |
| -* @param length - array length |
128 |
| -* @param dtype - data type |
129 |
| -* @returns filled array |
130 |
| -* |
131 |
| -* @example |
132 |
| -* var arr = ones( 2, 'uint32' ); |
133 |
| -* // returns <Uint32Array>[ 1, 1 ] |
134 |
| -*/ |
135 |
| -declare function ones( length: number, dtype: 'uint32' ): Uint32Array; |
136 |
| - |
137 |
| -/** |
138 |
| -* Creates an array filled with ones and having a specified length. |
139 |
| -* |
140 |
| -* @param length - array length |
141 |
| -* @param dtype - data type |
142 |
| -* @returns filled array |
143 |
| -* |
144 |
| -* @example |
145 |
| -* var arr = ones( 2, 'uint16' ); |
146 |
| -* // returns <Uint16Array>[ 1, 1 ] |
147 |
| -*/ |
148 |
| -declare function ones( length: number, dtype: 'uint16' ): Uint16Array; |
149 |
| - |
150 |
| -/** |
151 |
| -* Creates an array filled with ones and having a specified length. |
152 |
| -* |
153 |
| -* @param length - array length |
154 |
| -* @param dtype - data type |
155 |
| -* @returns filled array |
156 |
| -* |
157 |
| -* @example |
158 |
| -* var arr = ones( 2, 'uint8' ); |
159 |
| -* // returns <Uint8Array>[ 1, 1 ] |
160 |
| -*/ |
161 |
| -declare function ones( length: number, dtype: 'uint8' ): Uint8Array; |
162 |
| - |
163 |
| -/** |
164 |
| -* Creates an array filled with ones and having a specified length. |
165 |
| -* |
166 |
| -* @param length - array length |
167 |
| -* @param dtype - data type |
168 |
| -* @returns filled array |
169 |
| -* |
170 |
| -* @example |
171 |
| -* var arr = ones( 2, 'uint8c' ); |
172 |
| -* // returns <Uint8ClampedArray>[ 1, 1 ] |
173 |
| -*/ |
174 |
| -declare function ones( length: number, dtype: 'uint8c' ): Uint8ClampedArray; |
175 |
| - |
176 |
| -/** |
177 |
| -* Creates an array filled with ones and having a specified length. |
178 |
| -* |
179 |
| -* @param length - array length |
180 |
| -* @param dtype - data type |
181 |
| -* @returns filled array |
182 |
| -* |
183 |
| -* @example |
184 |
| -* var arr = ones( 2, 'generic' ); |
185 |
| -* // returns [ 1, 1 ] |
186 |
| -*/ |
187 |
| -declare function ones( length: number, dtype: 'generic' ): Array<number>; |
| 23 | +import { NumericAndGenericDataTypeMap } from '@stdlib/types/array'; |
188 | 24 |
|
189 | 25 | /**
|
190 | 26 | * Creates an array filled with ones and having a specified length.
|
@@ -216,7 +52,7 @@ declare function ones( length: number, dtype: 'generic' ): Array<number>;
|
216 | 52 | * var arr = ones( 2, 'float32' );
|
217 | 53 | * // returns <Float32Array>[ 1.0, 1.0 ]
|
218 | 54 | */
|
219 |
| -declare function ones( length: number, dtype?: DataType ): Float64Array; |
| 55 | +declare function ones<T extends keyof NumericAndGenericDataTypeMap<number> = 'float64'>( length: number, dtype?: T ): NumericAndGenericDataTypeMap<number>[T]; |
220 | 56 |
|
221 | 57 |
|
222 | 58 | // EXPORTS //
|
|
0 commit comments