public PolyCubicSplineFast(Object xArrays, Object fOfX){

    	    this.fOfX = Fmath.copyObject(fOfX);
    	    this.xArrays = Fmath.copyObject(xArrays);

    	    // Calculate fOfX array dimension number
    	    Object internalArrays = Fmath.copyObject(fOfX);
    	    this.nDimensions = 1;
            while(!((internalArrays  =  Array.get(internalArrays, 0)) instanceof Double))this.nDimensions++;

            // Repack xArrays as 2 dimensional array if entered a single dimensioned array for a simple cubic spline
            if(this.xArrays instanceof double[] && this.nDimensions == 1){
                double[][] xArraysTemp = new double[1][];
                xArraysTemp[0] = (double[])this.xArrays;
                this.xArrays = (Object)xArraysTemp;
            }
            else{
               if(!(this.xArrays instanceof double[][]))throw new IllegalArgumentException("xArrays should be a two dimensional array of doubles");
            }

            // x -arrays and their limits
            this.xArray = (double[][])this.xArrays;

            // Select interpolation method
            switch(this.nDimensions){
                case 0: throw new IllegalArgumentException("data array must have at least one dimension");
                case 1:     // If fOfX is one dimensional perform simple cubic spline
                            CubicSplineFast cs = new CubicSplineFast(this.xArray[0], (double[])this.fOfX);
                            this.method = (Object)cs;
                            break;
                case 2:     // If fOfX is two dimensional perform bicubic spline
                            BiCubicSplineFast bcs = new BiCubicSplineFast(this.xArray[0], this.xArray[1], (double[][])this.fOfX);
                            this.method = (Object)bcs;
                            break;
                default:    // If fOfX is greater than four dimensional, recursively call PolyCubicSplineFast
                            //  with, as arguments, the n1 fOfX sub-arrays, each of (number of dimensions - 1) dimensions,
                            //  where n1 is the number of x1 variables.
                            Object obj = fOfX;
                            this.dimOne = Array.getLength(obj);
                            this.csArray = new double [dimOne];
                            double[][] newXarrays= new double[this.nDimensions-1][];
                            for(int i=0; i<this.nDimensions-1; i++){
                                newXarrays[i] = xArray[i+1];
                            }

                            this.pcs = new PolyCubicSplineFast[dimOne];
                            for(int i=0; i<dimOne; i++){
                                Object objT = (Object)Array.get(obj, i);
                                this.pcs[i] = new PolyCubicSplineFast(newXarrays, objT);
                            }
            }
        }