license import { DataTypeMap , util } from '@tensorflow/tfjs-core' ; export function rangeImpl ( start , stop , step , dtype ) { const sameStartStop = start === stop ; const increasingRangeNegativeStep = start < stop && step < 0 ; const decreasingRangePositiveStep = stop < start && step > 1 ; if ( sameStartStop || increasingRangeNegativeStep || decreasingRangePositiveStep ) { return util . makeZerosTypedArray ( 0 , dtype ) ; } const numElements = Math . abs ( Math . ceil ( ( stop - start ) / step ) ) ; const values = util . makeZerosTypedArray ( numElements , dtype ) ; if ( stop < start && step === 1 ) { step = - 1 ; } values [ 0 ] = start ; for ( let i = 1 ; i < values . length ; i ++ ) { values [ i ] = values [ i - 1 ] + step ; } return values ; }