# include "data.h"

int create (int argc, char **argv) {
  
  int i;
  float start, end, delta;
  Vector *vec;
  
  if ((argc != 5) && (argc != 4)) {
    gprint (GP_ERR, "USAGE: create vector start end [delta]\n");
    return (FALSE);
  }

  if ((vec = SelectVector (argv[1], ANYVECTOR, TRUE)) == NULL) return (FALSE);

  start = atof (argv[2]);
  end   = atof (argv[3]);
  delta = 1;
  if (argc == 5) delta = atof (argv[4]);
  if ((start == end) || (delta == 0)) {
    gprint (GP_ERR, "error in value: %f to %f, %f\n", start, end, delta);
    return (FALSE);
  }
  delta = fabs (delta);
  if (end - start < 0) {
    delta = -1.0 * delta;
  }

  vec[0].Nelements = (end - start) / delta;
  REALLOCATE (vec[0].elements, float, vec[0].Nelements);

  for (i = 0; i < vec[0].Nelements; i++) {
    vec[0].elements[i] = start + i*delta;
  }

  return (TRUE);
}
