public static boolean isMonotonic(double[] x){
        boolean monoFlag = true;
        int n = x.length;
        double gap1 = x[1] - x[0];
        double gap0 = gap1;
        if(gap1==0.0){
            monoFlag = false;
        }
        else{
            for(int i=2; i<n; i++){
                gap1 = x[i] - x[i-1];
                if(gap1==0.0){
                    monoFlag = false;
                }
                else{
                    if(Fmath.sign(gap1)!=Fmath.sign(gap0))monoFlag = false;
                }
                if(!monoFlag)break;
            }
        }

        return monoFlag;
    }