import java.util.*;

//***********************************************************************************
/** Class to return iterate of Standard map function.<br>
*/
//***********************************************************************************

public class StandardFunction extends Map2DFunction {
      double X,Y;

      StandardFunction() {      

            nParameters=1;    
            a = new double[nParameters];    
            aDefault = new double[nParameters];
            aDefault[0]=0.97;
//            aDefault[1]=1.0; 
            title = "Standard Map";
            xminDefault=0.0;
            xmaxDefault=1.0;
            yminDefault=-3.14159; 
            ymaxDefault=3.14159;
            winding=0;
            total=0;
            showWinding=true;            
      }      
                       
      
//***********************************************************************************      
/** iterates the map function
* @param x input value
* @return iterated value
*/
//***********************************************************************************
      public void iterate(double[] x) {                       

          X = x[0];
          Y = x[1];
//          x[1] = a[1]*Y+a[0]*Math.sin(2*Math.PI*X);
          x[1] = Y+a[0]*Math.sin(2*Math.PI*X);

          x[0] = mod(X+x[1]/(2*Math.PI));
          
          x[2]=X;
          x[3]=Y;
      }      

//***********************************************************************************      
/** iterates the tangent space to the map
* @param x input value and returns updated values
* x[0] and x[1] contain the new values of X and Y
* x[2] and x[3] contain the previous values
* @param t value of tangent vector (updated by iteration)
*/
//***********************************************************************************
      public void iterateTangent(double[] x, double[] t) {
            X = t[0];
            Y = t[1];
//            t[1] = a[1]*Y+2*Math.PI*a[0]*Math.cos(2*Math.PI*x[0])*X;
            t[1] = Y+2*Math.PI*a[0]*Math.cos(2*Math.PI*x[0])*X;
            t[0] = X+t[1]/(2*Math.PI); 
      }      
//***********************************************************************************               
}
