linearSpaced function

Vector<double> linearSpaced(
  1. double start,
  2. double stop, {
  3. int count = 10,
  4. bool includeEndpoint = true,
  5. DataType<double>? dataType,
  6. VectorFormat? format,
})

Generates a Vector with a sequence of count evenly spaced values over an interval between start and stop.

Implementation

Vector<double> linearSpaced(
  double start,
  double stop, {
  int count = 10,
  bool includeEndpoint = true,
  DataType<double>? dataType,
  VectorFormat? format,
}) {
  final factor = 1.0 / (includeEndpoint ? count - 1 : count);
  return Vector.generate(dataType ?? DataType.float, count,
      (i) => start * (1.0 - factor * i) + stop * (factor * i),
      format: format);
}