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