2222
2323import { Collection , AccessorArrayLike } from '@stdlib/types/array' ;
2424
25+ /**
26+ * Input array.
27+ */
28+ type InputArray < T > = Collection < T > | AccessorArrayLike < T > ;
29+
2530/**
2631* Interface describing `gzeroTo`.
2732*/
2833interface Routine {
29- /**
30- * Fills a strided array with linearly spaced numeric elements which increment by `1` starting from zero.
31- *
32- * @param N - number of indexed elements
33- * @param x - input array
34- * @param strideX - stride length
35- * @returns input array
36- *
37- * @example
38- * var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' );
39- *
40- * var x = [ 0.0, 0.0, 0.0, 0.0 ];
41- *
42- * gzeroTo( x.length, toAccessorArray( x ), 1 );
43- * // x => [ 0.0, 1.0, 2.0, 3.0 ]
44- */
45- < T = unknown > ( N : number , x : AccessorArrayLike < T > , strideX : number ) : AccessorArrayLike < T > ;
46-
4734 /**
4835 * Fills a strided array with linearly spaced numeric elements which increment by `1` starting from zero.
4936 *
@@ -58,26 +45,7 @@ interface Routine {
5845 * gzeroTo( x.length, x, 1 );
5946 * // x => [ 0.0, 1.0, 2.0, 3.0 ]
6047 */
61- < T = unknown > ( N : number , x : Collection < T > , strideX : number ) : Collection < T > ;
62-
63- /**
64- * Fills a strided array with linearly spaced numeric elements which increment by `1` starting from zero using alternative indexing semantics.
65- *
66- * @param N - number of indexed elements
67- * @param x - input array
68- * @param strideX - stride length
69- * @param offsetX - starting index
70- * @returns input array
71- *
72- * @example
73- * var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' );
74- *
75- * var x = [ 0.0, 0.0, 0.0, 0.0 ];
76- *
77- * gzeroTo.ndarray( x.length, toAccessorArray( x ), 1, 0 );
78- * // x => [ 0.0, 1.0, 2.0, 3.0 ]
79- */
80- ndarray < T = unknown > ( N : number , x : AccessorArrayLike < T > , strideX : number , offsetX : number ) : AccessorArrayLike < T > ;
48+ < T = unknown , U extends InputArray < T > = InputArray < T > > ( N : number , x : U , strideX : number ) : U ;
8149
8250 /**
8351 * Fills a strided array with linearly spaced numeric elements which increment by `1` starting from zero using alternative indexing semantics.
@@ -94,7 +62,7 @@ interface Routine {
9462 * gzeroTo.ndarray( x.length, x, 1, 0 );
9563 * // x => [ 0.0, 1.0, 2.0, 3.0 ]
9664 */
97- ndarray < T = unknown > ( N : number , x : Collection < T > , strideX : number , offsetX : number ) : Collection < T > ;
65+ ndarray < T = unknown , U extends InputArray < T > = InputArray < T > > ( N : number , x : U , strideX : number , offsetX : number ) : U ;
9866}
9967
10068/**
0 commit comments