//***********************************************************************************
/** Class to return nf'th iterate of map function.<br>
* To be subclassed by specific functions, which must provide:
* <UL><LI> a method iterate(double[] x) to return the new values of {x,y}.
* <LI> an int variable nParameters giving the number of map parameters (1 or 2)
* <LI> the initialization of a[nParamters] and aDefault[nParameters]</UL>
* Optional parameters are:<UL>
* <LI> double xminDefault, xmaxDefault, yminDefault, ymaxDefault giving the
* default plot range
* <LI> String title giving the name of the function to use as a graph title
* <LI> boolean showWinding set to true if winding number to be displayed
* </UL>.
*/

public class Map2DFunction {

/** number of map parameters (1,2 or 3) */
      public int nParameters;
/** array giving map paramters */      
      double[] a;
/** array giving default values of map parameters */      
      public double[] aDefault;      
/** the name of the function to use as a graph title */
      public String title = "Function";
// Axes ranges
/** the default value of xmin */
      public double xminDefault=0.;
/** the default value of xmax */
      public double xmaxDefault=1.;
/** the default value of ymin */
      public double yminDefault=0.; 
/** the default value of ymax */
      public double ymaxDefault=1.;
/** winding number for circle map  */      
      public int winding; 
/** set to zero in transients so winding number not updated  */
      public int windingAdd=1;  
/** number of iterations contributing to winding */      
      public int total=0;
/** true if winding number to be shown */
      public boolean showWinding=false;                      
                       
      
//***********************************************************************************
/** Sets the map paramters 
* @param paramters the array of input paramters
*/
//***********************************************************************************      
      public void setParameters(double[] parameters) {
            for(int i=0; i<nParameters;i++) a[i]=parameters[i];
      }

//***********************************************************************************      
/** iterates the tangent space of the map function
* @param x input value and returns updated values
* x[0] and x[1] contain the new values of X and Y
* @param t value of tangent vector (updated by iteration)
*/
//***********************************************************************************
      public void iterateTangent(double[] x, double[] t) {               
      }      

//***********************************************************************************      
/** iterates the map function
* @param x input value of map point
* x[0] and x[1] contain the new values of X and Y
* x[2] and x[3] contain the previous values
*/
//***********************************************************************************
      public void iterate(double[] x) {                       
      }   

//***********************************************************************************
/** Returns the number of parameters defining the map
* @return number of parameters
*/
//***********************************************************************************
     public int getNParameters() {
            return nParameters;
     }      
 
//**********************************************************************
/**
* Shifts x to 0<x<1
* @param x input value
* @return value shifted to between 0 and 1
*/
//**********************************************************************      
      double mod(double x) {
         while (x>1.) {
            winding=winding+windingAdd;
            x=x-1.;
         }   
         while (x<0.) {
            winding=winding-windingAdd;
            x=x+1.;
         }
         total=total+windingAdd;
         return x;
      }
    
//***********************************************************************************               
}
