public static double [ ] sequence ( double start , double end , int length ) { // Declare and initialize the return value: double [ ] retval = new double [ length ] ; // Calculate step: double step = ( end - start ) / ( length == 1 ? 1 : length - 1 ) ; // Iterate and fill: for ( int i = 0 ; i < length ; i ++ ) { retval [ i ] = start + ( i * step ) ; } // Done, return; return retval ; }
Generates a sequence of specified length from specified start to specified end .