import java.util.*;

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

public class SinaiFunction extends Map2DFunction {
      double X,Y;

      SinaiFunction() {      

            nParameters=1;    
            a = new double[nParameters];    
            aDefault = new double[nParameters];
            aDefault[0]=0.1;     
            title = "Sinai Map";
            xminDefault=0.0;
            xmaxDefault=1.0;
            yminDefault=0.; 
            ymaxDefault=1.;
            showWinding=false;
      }      
                       
      
//***********************************************************************************      
/** iterates the map function
* @param x input value
* @return iterated value
*/
//***********************************************************************************
      public void iterate(double[] x) {                       

            X = x[0];
            Y = x[1];

            x[0] = mod(X+Y+a[0]*Math.cos(2*Math.PI*Y)); 
            x[1] = mod(X+2*Y);
            
            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
* @param t value of tangent vector (updated by iteration)
*/
//***********************************************************************************
      public void iterateTangent(double[] x, double[] t) {
            X = t[0];
            Y = t[1];
            t[0] = X+Y-a[0]*2*Math.PI*Math.sin(2*Math.PI*x[1])*Y;
            t[1] = X+2*Y; 
      }              

//***********************************************************************************               
}
