#include <stdio.h>	/* printf */
#include <stdlib.h>	/* malloc */
#include <string.h>	/* strcmp */
#include "de.h"
extern struct de gm_de, ikeda_de, logistic_de;
struct de *de = &gm_de;
void options(int argc, char *argv[])
{
  int i;

  for (i=1; i<argc; i++)
    if (strcmp(argv[i], "-gm") == 0)
      de = &gm_de;
    else if (strcmp(argv[i], "-ikeda") == 0)
      de = &ikeda_de;
    else if (strcmp(argv[i], "-logistic") == 0)
      de = &logistic_de;
}
int main(int argc, char *argv[])
{
  int i, j;
  double *p, *v0, *v1;

  options(argc, argv);
  p = malloc(sizeof(double)*de->K);
  v0 = malloc(sizeof(double)*de->N);
  v1 = malloc(sizeof(double)*de->N);
  de->init(p, v0);
  de->options(argc, argv, p, v0);
  for (i=0; i<5000; i++) {
    de->map(p, i, v0, v1);
    if (de->N == 1)
      printf("%g\t%g\n", v0[0], v1[0]);
    else {
      for (j=0; j<de->N; j++)
	printf("%g\t", v0[j]);
      printf("\n");
    }
    for (j=0; j<de->N; j++)
      v0[j] = v1[j];
  }
  return 0;
}
