# include "data.h"

int print_vectors (int argc, char **argv) {

  Vector **vec;
  int i, j;

  if (argc < 2) {
    gprint (GP_ERR, "USAGE: print_vectors (vector)[,vector,...]\n");
    return (FALSE);
  }

  int Nvec = argc - 1;
  ALLOCATE (vec, Vector *, Nvec);
  for (i = 1; i < argc; i++) {
    vec[i-1] = SelectVector (argv[i], OLDVECTOR, FALSE);
    if (!vec[i-1]) {
      gprint (GP_ERR, "unknown vector %s\n", argv[i]);
      free (vec);
      return FALSE;
    }
  }

  int MaxLen = 0;
  for (i = 0; i < Nvec; i++) {
    MaxLen = MAX (MaxLen, vec[i][0].Nelements);
  }

  for (j = 0; j < MaxLen; j++) {
    for (i = 0; i < Nvec; i++) {
      if (j >= vec[i][0].Nelements) {
	gprint (GP_LOG, "NaN ");
      } else {
	if (vec[i][0].type == OPIHI_FLT) {
	  gprint (GP_LOG, "%f ", vec[i][0].elements.Flt[j]);
	} else {
	  gprint (GP_LOG, "%d ", vec[i][0].elements.Int[j]);
	}
      }
    }
    gprint (GP_LOG, "\n");
  }
  free (vec);

  return (TRUE);
}

