#include <stdlib.h>	/* atof */
#include <string.h>	/* strcmp */
#include <math.h>	/* cos, sin */
#include "de.h"
#define q p[0]
#define k p[1]
#define alpha p[2]
#define b p[3]
#define x0 v0[0]
#define y0 v0[1]
#define x1 v1[0]
#define y1 v1[1]
#define ikeda_theta (k-alpha/(1+x0*x0+y0*y0))
void ikeda_init(double p[], double v0[])
{
  q = 1; k = 0.4; alpha = 6; b = 0.9;
  x0 = 0.1;
  y0 = 0.0;
}
void ikeda_options(int argc, char *argv[], double p[], double v0[])
{
  int i;

  for (i=1; i<argc; i++)
    if (strcmp(argv[i], "-q") == 0 && i+1 < argc)
      q = atof(argv[i+1]);
    else if (strcmp(argv[i], "-k") == 0 && i+1 < argc)
      k = atof(argv[i+1]);
    else if (strcmp(argv[i], "-alpha") == 0 && i+1 < argc)
      alpha = atof(argv[i+1]);
    else if (strcmp(argv[i], "-b") == 0 && i+1 < argc)
      b = atof(argv[i+1]);
    else if (strcmp(argv[i], "-x") == 0 && i+1 < argc)
      x0 = atof(argv[i+1]);
    else if (strcmp(argv[i], "-y") == 0 && i+1 < argc)
      y0 = atof(argv[i+1]);
}
void ikeda_map(double p[], double t, double v0[], double v1[])
{
  x1 = q+b*(x0*cos(ikeda_theta)-y0*sin(ikeda_theta));
  y1 =   b*(x0*sin(ikeda_theta)+y0*cos(ikeda_theta));
}
struct de ikeda_de = {
  4, 2, ikeda_init, ikeda_options, ikeda_map,
};
