code: private static double[] calculateParameters( final double[][] elevationValues ) {
          int rows = elevationValues.length;
          int cols = elevationValues[0].length;
          int pointsNum = rows * cols;
  
          final double[][] xyMatrix = new double[pointsNum][6];
          final double[] valueArray = new double[pointsNum];
  
          // TODO check on resolution
          int index = 0;
          for( int y = 0; y < rows; y++ ) {
              for( int x = 0; x < cols; x++ ) {
                  xyMatrix[index][0] = x * x; // x^2
                  xyMatrix[index][1] = y * y; // y^2
                  xyMatrix[index][2] = x * y; // xy
                  xyMatrix[index][3] = x; // x
                  xyMatrix[index][4] = y; // y
                  xyMatrix[index][5] = 1;
                  valueArray[index] = elevationValues[y][x];
                  index++;
              }
          }
  
          RealMatrix A = MatrixUtils.createRealMatrix(xyMatrix);
          RealVector z = MatrixUtils.createRealVector(valueArray);
  
          DecompositionSolver solver = new RRQRDecomposition(A).getSolver();
          RealVector solution = solver.solve(z);
  
          // start values for a, b, c, d, e, f, all set to 0.0
          final double[] parameters = solution.toArray();
          return parameters;
      }
docs: Calculates the parameters of a bivariate quadratic equation.
  
  @param elevationValues the window of points to use.
  @return the parameters of the bivariate quadratic equation as [a, b, c, d, e, f]